/***************************************************************************** * Import_M3U: main import function *****************************************************************************/ int Import_M3U( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_PEEK( p_peek, 8 ); char *(*pf_dup) (const char *); if( POKE( p_peek, "RTSPtext", 8 ) /* QuickTime */ || demux_IsPathExtension( p_demux, ".m3u8" ) || demux_IsForced( p_demux, "m3u8" ) ) pf_dup = strdup; /* UTF-8 */ else if( POKE( p_peek, "#EXTM3U", 7 ) || demux_IsPathExtension( p_demux, ".m3u" ) || demux_IsPathExtension( p_demux, ".vlc" ) || demux_IsForced( p_demux, "m3u" ) || ContainsURL( p_demux ) ) pf_dup = FromLocaleDup; /* locale character set (?) */ else return VLC_EGENERIC; STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); p_demux->p_sys->pf_dup = pf_dup; return VLC_SUCCESS; }
int Import_WPL( vlc_object_t* p_this ) { demux_t* p_demux = (demux_t*)p_this; CHECK_FILE(); if( !demux_IsPathExtension( p_demux, ".wpl" ) && !demux_IsPathExtension( p_demux, ".zpl" ) ) return VLC_EGENERIC; DEMUX_INIT_COMMON(); demux_sys_t* p_sys = p_demux->p_sys; uint8_t *p_peek; ssize_t i_peek = stream_Peek( p_demux->s, (const uint8_t **) &p_peek, 2048 ); if( unlikely( i_peek <= 0 ) ) { Close_WPL( p_this ); return VLC_EGENERIC; } stream_t *p_probestream = stream_MemoryNew( p_demux->s, p_peek, i_peek, true ); if( unlikely( !p_probestream ) ) { Close_WPL( p_this ); return VLC_EGENERIC; } p_sys->p_reader = xml_ReaderCreate( p_this, p_probestream ); if ( !p_sys->p_reader ) { msg_Err( p_demux, "Failed to create an XML reader" ); Close_WPL( p_this ); stream_Delete( p_probestream ); return VLC_EGENERIC; } const int i_flags = p_sys->p_reader->i_flags; p_sys->p_reader->i_flags |= OBJECT_FLAGS_QUIET; const char* psz_name; int type = xml_ReaderNextNode( p_sys->p_reader, &psz_name ); p_sys->p_reader->i_flags = i_flags; if ( type != XML_READER_STARTELEM || strcasecmp( psz_name, "smil" ) ) { msg_Err( p_demux, "Invalid WPL playlist. Root element should have been <smil>" ); Close_WPL( p_this ); stream_Delete( p_probestream ); return VLC_EGENERIC; } p_sys->p_reader = xml_ReaderReset( p_sys->p_reader, p_demux->s ); stream_Delete( p_probestream ); msg_Dbg( p_demux, "Found valid WPL playlist" ); return VLC_SUCCESS; }
/** * Import_RAM: main import function * @param p_this: this demux object * @return VLC_SUCCESS if everything is okay */ int Import_RAM( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; if(! demux_IsPathExtension( p_demux, ".ram" ) || demux_IsPathExtension( p_demux, ".rm" ) ) return VLC_EGENERIC; STANDARD_DEMUX_INIT_MSG( "found valid RAM playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); return VLC_SUCCESS; }
/***************************************************************************** * Import_M3U: main import function *****************************************************************************/ int Import_M3U( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; char *(*pf_dup) (const char *) = GuessEncoding; int offset = 0; CHECK_FILE(); if( vlc_stream_Peek( p_demux->s, &p_peek, 3 ) == 3 && !memcmp( p_peek, "\xef\xbb\xbf", 3) ) { pf_dup = CheckUnicode; /* UTF-8 Byte Order Mark */ offset = 3; } if( demux_IsPathExtension( p_demux, ".m3u8" ) || demux_IsForced( p_demux, "m3u8" ) || CheckContentType( p_demux->s, "application/vnd.apple.mpegurl" ) ) pf_dup = CheckUnicode; /* UTF-8 file type */ else if( demux_IsPathExtension( p_demux, ".m3u" ) || demux_IsPathExtension( p_demux, ".vlc" ) || demux_IsForced( p_demux, "m3u" ) || ContainsURL( p_demux ) || CheckContentType( p_demux->s, "audio/x-mpegurl") ) ; /* Guess encoding */ else { if( vlc_stream_Peek( p_demux->s, &p_peek, 8 + offset ) < (8 + offset) ) return VLC_EGENERIC; p_peek += offset; if( !strncasecmp( (const char *)p_peek, "RTSPtext", 8 ) ) /* QuickTime */ pf_dup = CheckUnicode; /* UTF-8 */ else if( !memcmp( p_peek, "#EXTM3U", 7 ) ) ; /* Guess encoding */ else return VLC_EGENERIC; } vlc_stream_Seek( p_demux->s, offset ); STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); p_demux->p_sys->pf_dup = pf_dup; return VLC_SUCCESS; }
/***************************************************************************** * Open: check file and initializes structures *****************************************************************************/ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; /* Identify cdg file by extension, as there is no simple way to * detect it */ if( !demux_IsPathExtension( p_demux, ".cdg" ) && !demux_IsForced( p_demux, "cdg" ) ) return VLC_EGENERIC; /* CDG file size has to be multiple of CDG_FRAME_SIZE (it works even * if size is unknown ie 0) */ // if( (stream_Size( p_demux->s ) % CDG_FRAME_SIZE) != 0 ) // { // msg_Err( p_demux, "Reject CDG file based on its size" ); // return VLC_EGENERIC; // } p_demux->pf_demux = Demux; p_demux->pf_control = Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); /* */ es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_CDG ); p_sys->fmt.video.i_width = 300-2*6; p_sys->fmt.video.i_height = 216-2*12 ; p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); /* There is CDG_FRAME_RATE frames per second */ date_Init( &p_sys->pts, CDG_FRAME_RATE, 1 ); date_Set( &p_sys->pts, 1 ); return VLC_SUCCESS; }
/***************************************************************************** * Import_DVB: main import function *****************************************************************************/ int Import_DVB( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; int i_peek; bool b_valid = false; if( !demux_IsPathExtension( p_demux, ".conf" ) && !p_demux->b_force ) return VLC_EGENERIC; /* Check if this really is a channels file */ if( (i_peek = stream_Peek( p_demux->s, &p_peek, 1024 )) > 0 ) { char psz_line[1024+1]; int i; for( i = 0; i < i_peek; i++ ) { if( p_peek[i] == '\n' ) break; psz_line[i] = p_peek[i]; } psz_line[i] = 0; if( ParseLine( psz_line, 0, 0, 0 ) ) b_valid = true; } if( !b_valid ) return VLC_EGENERIC; msg_Dbg( p_demux, "found valid DVB conf playlist file"); p_demux->pf_control = Control; p_demux->pf_demux = Demux; return VLC_SUCCESS; }
/** Detect dvb-utils zap channels.conf format */ int Import_DVB(vlc_object_t *p_this) { demux_t *demux = (demux_t *)p_this; CHECK_FILE(); if (!demux_IsPathExtension(demux, ".conf" ) && !demux->b_force ) return VLC_EGENERIC; /* Check if this really is a channels file */ const uint8_t *peek; int len = stream_Peek(demux->s, &peek, 1023); if (len <= 0) return VLC_EGENERIC; const uint8_t *eol = memchr(peek, '\n', len); if (eol == NULL) return VLC_EGENERIC; len = eol - peek; char line[len + 1]; memcpy(line, peek, len); line[len] = '\0'; input_item_t *item = ParseLine(line); if (item == NULL) return VLC_EGENERIC; vlc_gc_decref(item); msg_Dbg(demux, "found valid channels.conf file"); demux->pf_control = Control; demux->pf_demux = Demux; return VLC_SUCCESS; }
int Import_ASX( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; if( demux_IsPathExtension( p_demux, ".asx" ) || demux_IsPathExtension( p_demux, ".wax" ) || demux_IsPathExtension( p_demux, ".wvx" ) || ( ( CheckContentType( p_demux->s, "video/x-ms-asf" ) || CheckContentType( p_demux->s, "audio/x-ms-wax" ) ) && PeekASX( p_demux ) ) || demux_IsForced( p_demux, "asx-open" ) ) { STANDARD_DEMUX_INIT_MSG( "found valid ASX playlist" ); return VLC_SUCCESS; } else return VLC_EGENERIC; }
/***************************************************************************** * Import_B4S: main import function *****************************************************************************/ int Import_B4S( vlc_object_t *p_this ) { demux_t *demux = (demux_t *)p_this; if( !demux_IsPathExtension( demux, ".b4s" ) && !demux_IsForced( demux, "b4s-open" ) ) return VLC_EGENERIC; demux->pf_demux = Demux; demux->pf_control = Control; return VLC_SUCCESS; }
/***************************************************************************** * Import_QTL: main import function *****************************************************************************/ int Import_QTL( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; if( !demux_IsPathExtension( p_demux, ".qtl" ) ) return VLC_EGENERIC; p_demux->pf_demux = Demux; p_demux->pf_control = Control; msg_Dbg( p_demux, "using QuickTime Media Link reader" ); return VLC_SUCCESS; }
/** * Import_RAM: main import function * @param p_this: this demux object * @return VLC_SUCCESS if everything is okay */ int Import_RAM( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_FILE(); if(! demux_IsPathExtension( p_demux, ".ram" ) || demux_IsPathExtension( p_demux, ".rm" ) ) return VLC_EGENERIC; /* Many Real Media Files are misdetected */ if( vlc_stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( !memcmp( p_peek, ".ra", 3 ) || !memcmp( p_peek, ".RMF", 4 ) ) { return VLC_EGENERIC; } STANDARD_DEMUX_INIT_MSG( "found valid RAM playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); return VLC_SUCCESS; }
/***************************************************************************** * Import_WPL: main import function *****************************************************************************/ int Import_WPL( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_PEEK( p_peek, 8 ); if(! ( demux_IsPathExtension( p_demux, ".wpl" ) || demux_IsForced( p_demux, "wpl" ))) return VLC_EGENERIC; STANDARD_DEMUX_INIT_MSG( "found valid WPL playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); return VLC_SUCCESS; }
int Import_ASX( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; CHECK_FILE(); if( demux_IsPathExtension( p_demux, ".asx" ) || demux_IsPathExtension( p_demux, ".wax" ) || demux_IsPathExtension( p_demux, ".wvx" ) || ( ( CheckContentType( p_demux->s, "video/x-ms-asf" ) || CheckContentType( p_demux->s, "audio/x-ms-wax" ) ) && PeekASX( p_demux ) ) || demux_IsForced( p_demux, "asx-open" ) ) { msg_Dbg( p_demux, "found valid ASX playlist" ); } else return VLC_EGENERIC; p_demux->pf_control = Control; p_demux->pf_demux = Demux; return VLC_SUCCESS; }
/** * Import_RAM: main import function * @param p_this: this demux object * @return VLC_SUCCESS if everything is okay */ int Import_RAM( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_FILE(); if(! demux_IsPathExtension( p_demux, ".ram" ) || demux_IsPathExtension( p_demux, ".rm" ) ) return VLC_EGENERIC; /* Many Real Media Files are misdetected */ if( vlc_stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( !memcmp( p_peek, ".ra", 3 ) || !memcmp( p_peek, ".RMF", 4 ) ) { return VLC_EGENERIC; } msg_Dbg( p_demux, "found valid RAM playlist" ); p_demux->pf_demux = Demux; p_demux->pf_control = Control; return VLC_SUCCESS; }
/***************************************************************************** * Import_PLS: main import function *****************************************************************************/ int Import_PLS( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_PEEK( p_peek, 10 ); if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) || demux_IsPathExtension( p_demux, ".pls" ) || demux_IsForced( p_demux, "pls" ) ) { ; } else return VLC_EGENERIC; STANDARD_DEMUX_INIT_MSG( "found valid PLS playlist file"); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); return VLC_SUCCESS; }
/***************************************************************************** * Import_PLS: main import function *****************************************************************************/ int Import_PLS( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; CHECK_FILE(); CHECK_PEEK( p_peek, 10 ); if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) || demux_IsPathExtension( p_demux, ".pls" ) || demux_IsForced( p_demux, "pls" ) ) { ; } else return VLC_EGENERIC; msg_Dbg( p_demux, "found valid PLS playlist file"); p_demux->pf_demux = Demux; p_demux->pf_control = Control; return VLC_SUCCESS; }
/***************************************************************************** * Open: check file and initializes structures *****************************************************************************/ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; int i_size; bool b_matched = false; float f_fps; p_sys = malloc( sizeof( demux_sys_t ) ); if( unlikely(p_sys == NULL) ) return VLC_ENOMEM; p_demux->pf_control = Control; p_demux->p_sys = p_sys; p_sys->p_es = NULL; p_sys->i_time = 0; p_sys->i_level = 0; p_sys->psz_separator = NULL; p_sys->i_frame_size_estimate = 15 * 1024; b_matched = CheckMimeHeader( p_demux, &i_size); if( b_matched ) { p_demux->pf_demux = MimeDemux; stream_Read( p_demux->s, NULL, i_size ); } else if( 0 == i_size ) { /* 0xffd8 identify a JPEG SOI */ if( p_sys->p_peek[0] == 0xFF && p_sys->p_peek[1] == 0xD8 ) { msg_Dbg( p_demux, "JPEG SOI marker detected" ); p_demux->pf_demux = MjpgDemux; p_sys->i_level++; } else { goto error; } } else { goto error; } f_fps = var_CreateGetFloat( p_demux, "mjpeg-fps" ); p_sys->i_frame_length = 0; /* Check for jpeg file extension */ p_sys->b_still = false; p_sys->i_still_end = 0; if( demux_IsPathExtension( p_demux, ".jpeg" ) || demux_IsPathExtension( p_demux, ".jpg" ) ) { p_sys->b_still = true; if( f_fps ) { p_sys->i_still_length = 1000000.0 / f_fps; } else { /* Defaults to 1fps */ p_sys->i_still_length = 1000000; } } else if ( f_fps ) { p_sys->i_frame_length = 1000000.0 / f_fps; } es_format_Init( &p_sys->fmt, VIDEO_ES, 0 ); p_sys->fmt.i_codec = VLC_CODEC_MJPG; p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); return VLC_SUCCESS; error: free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * Open: check file and initializes structures *****************************************************************************/ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; int i_size; bool b_matched = false; if( IsMxpeg( p_demux->s ) && !p_demux->b_force ) // let avformat handle this case return VLC_EGENERIC; demux_sys_t *p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) ); // sunqueen modify if( unlikely(p_sys == NULL) ) return VLC_ENOMEM; p_demux->pf_control = Control; p_demux->p_sys = p_sys; p_sys->p_es = NULL; p_sys->i_time = VLC_TS_0; p_sys->i_level = 0; p_sys->psz_separator = NULL; p_sys->i_frame_size_estimate = 15 * 1024; char *content_type = stream_ContentType( p_demux->s ); if ( content_type ) { //FIXME: this is not fully match to RFC char* boundary = strstr( content_type, "boundary=" ); if( boundary ) { boundary += strlen( "boundary=" ); size_t len = strlen( boundary ); if( len > 2 && boundary[0] == '"' && boundary[len-1] == '"' ) { boundary[len-1] = '\0'; boundary++; } p_sys->psz_separator = strdup( boundary ); if( !p_sys->psz_separator ) { free( content_type ); goto error; } } free( content_type ); } b_matched = CheckMimeHeader( p_demux, &i_size); if( b_matched ) { p_demux->pf_demux = MimeDemux; stream_Read( p_demux->s, NULL, i_size ); } else if( i_size == 0 ) { /* 0xffd8 identify a JPEG SOI */ if( p_sys->p_peek[0] == 0xFF && p_sys->p_peek[1] == 0xD8 ) { msg_Dbg( p_demux, "JPEG SOI marker detected" ); p_demux->pf_demux = MjpgDemux; p_sys->i_level++; } else { goto error; } } else { goto error; } /* Frame rate */ float f_fps = var_InheritFloat( p_demux, "mjpeg-fps" ); p_sys->i_still_end = 0; if( demux_IsPathExtension( p_demux, ".jpeg" ) || demux_IsPathExtension( p_demux, ".jpg" ) ) { /* Plain JPEG file = single still picture */ p_sys->b_still = true; if( f_fps == 0.f ) /* Defaults to 1fps */ f_fps = 1.f; } else p_sys->b_still = false; p_sys->i_frame_length = f_fps ? (CLOCK_FREQ / f_fps) : 0; es_format_Init( &p_sys->fmt, VIDEO_ES, 0 ); p_sys->fmt.i_codec = VLC_CODEC_MJPG; p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); return VLC_SUCCESS; error: free( p_sys->psz_separator ); free( p_sys ); return VLC_EGENERIC; }