Commit 7ce48b0d authored by Ilkka Ollakka's avatar Ilkka Ollakka

wpl/ttml: use similar logic that subtitle_helper has for xml probing

Xml reader reads stream so we need to handle that so later on probing
don't fubar. This seemed to hit for srt probing atleast as currently it
doesn't anymore explicitly seek to 0.
parent 70f2ac5f
......@@ -186,6 +186,22 @@ int Import_WPL( vlc_object_t* p_this )
Close_WPL( p_this );
return VLC_EGENERIC;
}
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_ReaderReset( p_sys->p_reader, p_probestream );
const char* psz_name;
int type = xml_ReaderNextNode( p_sys->p_reader, &psz_name );
......@@ -193,8 +209,11 @@ int Import_WPL( vlc_object_t* p_this )
{
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" );
......
......@@ -455,17 +455,42 @@ static int Open( vlc_object_t* p_this )
if ( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
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( p_demux );
return VLC_EGENERIC;
}
stream_t *p_probestream = stream_MemoryNew( p_demux->s, p_peek, i_peek, true );
if( unlikely( !p_probestream ) )
{
Close( p_demux );
return VLC_EGENERIC;
}
p_sys->p_xml = xml_Create( p_demux );
if ( !p_sys->p_xml )
{
Close( p_demux );
stream_Delete( p_probestream );
return VLC_EGENERIC;
}
p_sys->p_reader = xml_ReaderCreate( p_sys->p_xml, p_demux->s );
if ( !p_sys->p_reader )
{
Close( p_demux );
stream_Delete( p_probestream );
return VLC_EGENERIC;
}
p_sys->p_reader = xml_ReaderReset( p_sys->p_reader, p_probestream );
if ( !p_sys->p_reader )
{
Close( p_demux );
stream_Delete( p_probestream );
return VLC_EGENERIC;
}
......@@ -474,8 +499,19 @@ static int Open( vlc_object_t* p_this )
if ( i_type != XML_READER_STARTELEM || ( strcmp( psz_name, "tt" ) && strcmp( psz_name, "tt:tt" ) ) )
{
Close( p_demux );
stream_Delete( p_probestream );
return VLC_EGENERIC;
}
p_sys->p_reader = xml_ReaderReset( p_sys->p_reader, p_demux->s );
if ( !p_sys->p_reader )
{
Close( p_demux );
stream_Delete( p_probestream );
return VLC_EGENERIC;
}
stream_Delete( p_probestream );
if ( ReadTTML( p_demux ) != VLC_SUCCESS )
{
Close( p_demux );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment