MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_stream_open

Function hb_stream_open

libhb/stream.c:830–899  ·  view source on GitHub ↗

* hb_stream_open *********************************************************************** * **********************************************************************/

Source from the content-addressed store, hash-verified

828 *
829 **********************************************************************/
830hb_stream_t *
831hb_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 }

Callers 5

hb_batch_title_scanFunction · 0.85
hb_reader_openFunction · 0.85
ScanFuncFunction · 0.85
DecodePreviewsFunction · 0.85

Calls 6

hb_logFunction · 0.85
hb_fopenFunction · 0.85
hb_stream_get_typeFunction · 0.85
prune_streamsFunction · 0.85
hb_stream_seekFunction · 0.85
ffmpeg_openFunction · 0.85

Tested by

no test coverage detected