* hb_stream_open *********************************************************************** * **********************************************************************/
| 828 | * |
| 829 | **********************************************************************/ |
| 830 | hb_stream_t * |
| 831 | hb_stream_open(hb_handle_t *h, const char *path, hb_title_t *title, int scan) |
| 832 | { |
| 833 | if (title == NULL) |
| 834 | { |
| 835 | hb_log("hb_stream_open: title is null"); |
| 836 | return NULL; |
| 837 | } |
| 838 | |
| 839 | FILE *f = hb_fopen(path, "rb"); |
| 840 | if ( f == NULL ) |
| 841 | { |
| 842 | hb_log( "hb_stream_open: open %s failed", path ); |
| 843 | return NULL; |
| 844 | } |
| 845 | |
| 846 | hb_stream_t *d = calloc( sizeof( hb_stream_t ), 1 ); |
| 847 | if ( d == NULL ) |
| 848 | { |
| 849 | fclose( f ); |
| 850 | hb_log( "hb_stream_open: can't allocate space for %s stream state", path ); |
| 851 | return NULL; |
| 852 | } |
| 853 | |
| 854 | if (!(title->flags & HBTF_NO_IDR)) |
| 855 | { |
| 856 | d->has_IDRs = 1; |
| 857 | } |
| 858 | |
| 859 | /* |
| 860 | * If it's something we can deal with (MPEG2 PS or TS) return a stream |
| 861 | * reference structure & null otherwise. |
| 862 | */ |
| 863 | d->h = h; |
| 864 | d->file_handle = f; |
| 865 | d->title = title; |
| 866 | d->scan = scan; |
| 867 | d->path = strdup( path ); |
| 868 | if (d->path != NULL ) |
| 869 | { |
| 870 | if (hb_stream_get_type( d ) != 0) |
| 871 | { |
| 872 | if( !scan ) |
| 873 | { |
| 874 | prune_streams( d ); |
| 875 | } |
| 876 | // reset to beginning of file and reset some stream |
| 877 | // state information |
| 878 | hb_stream_seek( d, 0. ); |
| 879 | return d; |
| 880 | } |
| 881 | fclose( d->file_handle ); |
| 882 | d->file_handle = NULL; |
| 883 | if ( ffmpeg_open( d, title, scan ) ) |
| 884 | { |
| 885 | return d; |
| 886 | } |
| 887 | } |
no test coverage detected