[vlc-commits] wpl/ttml: use similar logic that subtitle_helper has for xml probing
Ilkka Ollakka
git at videolan.org
Sat Oct 3 17:11:58 CEST 2015
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Oct 3 15:17:30 2015 +0300| [7ce48b0dd1bb160572a3b81e07d12379693c0a98] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ce48b0dd1bb160572a3b81e07d12379693c0a98
---
modules/demux/playlist/wpl.c | 19 +++++++++++++++++++
modules/demux/ttml.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/modules/demux/playlist/wpl.c b/modules/demux/playlist/wpl.c
index 121ffd2..302317b 100644
--- a/modules/demux/playlist/wpl.c
+++ b/modules/demux/playlist/wpl.c
@@ -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" );
diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index 5f4661c..f6e849c 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -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 );
More information about the vlc-commits
mailing list