[vlc-commits] mjpeg: move content-type checks to probe phase
Sergey Radionov
git at videolan.org
Sun Sep 30 13:07:03 CEST 2012
vlc | branch: master | Sergey Radionov <rsatom at gmail.com> | Sun Sep 30 14:06:22 2012 +0300| [a5a93926b55bed6f970423ee4bb8f8da9b54ac6f] | committer: Rémi Denis-Courmont
mjpeg: move content-type checks to probe phase
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a5a93926b55bed6f970423ee4bb8f8da9b54ac6f
---
modules/demux/mjpeg.c | 47 ++++++++++++++++++++---------------------------
1 file changed, 20 insertions(+), 27 deletions(-)
diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index cf9d659..6b9dd3d 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -189,33 +189,8 @@ static bool CheckMimeHeader( demux_t *p_demux, int *p_header_size )
if( strncmp( (char *)p_sys->p_peek, "--", 2 ) != 0
&& strncmp( (char *)p_sys->p_peek, "\r\n--", 4 ) != 0 )
{
- /* Some broken stream may lack the first boundary */
- if ( p_sys->psz_separator == NULL )
- {
- msg_Warn( p_demux, "Malformed stream. Trying to work around");
- char *content_type = stream_ContentType( p_demux->s );
- if ( content_type == NULL )
- return false;
- const char* boundary = strstr( content_type, "boundary=--" );
- if ( boundary != NULL )
- {
- p_sys->psz_separator = strdup( boundary + strlen( "boundary=--" ) );
- msg_Dbg( p_demux, "Video boundary extracted from Content-Type: %s", p_sys->psz_separator );
- free( content_type );
- /* Skip to HTTP header parsing as there's no boundary to extract
- * from the stream */
- }
- else
- {
- free( content_type );
- return false;
- }
- }
- else
- {
- *p_header_size = 0;
- return false;
- }
+ *p_header_size = 0;
+ return false;
}
else
{
@@ -340,6 +315,23 @@ static int Open( vlc_object_t * p_this )
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 )
+ {
+ p_sys->psz_separator = strdup( boundary + strlen("boundary=") );
+ if( !p_sys->psz_separator )
+ {
+ free( content_type );
+ goto error;
+ }
+ }
+ free( content_type );
+ }
+
b_matched = CheckMimeHeader( p_demux, &i_size);
if( b_matched )
{
@@ -389,6 +381,7 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
error:
+ free( p_sys->psz_separator );
free( p_sys );
return VLC_EGENERIC;
}
More information about the vlc-commits
mailing list