<br>ืิฯาฮษห, 11 ำลฮิัยาั 2012ว. ะฯฬฺุฯืมิลฬุ Sergey Radionov ะษำมฬ:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
modules/demux/mjpeg.c | 53 ++++++++++++++++++++++++-------------------------<br>
1 files changed, 26 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c<br>
index a057db3..b6c7445 100644<br>
--- a/modules/demux/mjpeg.c<br>
+++ b/modules/demux/mjpeg.c<br>
@@ -193,33 +193,8 @@ static bool CheckMimeHeader( demux_t *p_demux, int *p_header_size )<br>
if( strncmp( (char *)p_sys->p_peek, "--", 2 ) != 0<br>
&& strncmp( (char *)p_sys->p_peek, "\r\n--", 4 ) != 0 )<br>
{<br>
- /* Some broken stream may lack the first boundary */<br>
- if ( p_sys->psz_separator == NULL )<br>
- {<br>
- msg_Warn( p_demux, "Malformed stream. Trying to work around");<br>
- char *content_type = stream_ContentType( p_demux->s );<br>
- if ( content_type == NULL )<br>
- return false;<br>
- const char* boundary = strstr( content_type, "boundary=--" );<br>
- if ( boundary != NULL )<br>
- {<br>
- p_sys->psz_separator = strdup( boundary + strlen( "boundary=--" ) );<br>
- msg_Dbg( p_demux, "Video boundary extracted from Content-Type: %s", p_sys->psz_separator );<br>
- free( content_type );<br>
- /* Skip to HTTP header parsing as there's no boundary to extract<br>
- * from the stream */<br>
- }<br>
- else<br>
- {<br>
- free( content_type );<br>
- return false;<br>
- }<br>
- }<br>
- else<br>
- {<br>
- *p_header_size = 0;<br>
- return false;<br>
- }<br>
+ *p_header_size = 0;<br>
+ return false;<br>
}<br>
else<br>
{<br>
@@ -351,6 +326,22 @@ static int Open( vlc_object_t * p_this )<br>
goto error;<br>
}<br>
<br>
+ char *content_type = stream_ContentType( p_demux->s );<br>
+ if ( content_type )<br>
+ {<br>
+ //FIXME: this is not fully match to RFC<br>
+ char* boundary = strstr( content_type, "boundary=" );<br>
+ if( boundary )<br>
+ {<br>
+ p_sys->psz_separator = strdup( boundary + strlen("boundary=") );<br>
+ if( !p_sys->psz_separator ) {<br>
+ free( content_type );<br>
+ goto error;<br>
+ }<br>
+ }<br>
+ free( content_type );<br>
+ }<br>
+<br>
b_matched = CheckMimeHeader( p_demux, &i_size);<br>
if( b_matched )<br>
{<br>
@@ -409,6 +400,7 @@ static int Open( vlc_object_t * p_this )<br>
return VLC_SUCCESS;<br>
<br>
error:<br>
+ free( p_sys->psz_separator );<br>
free( p_sys );<br>
return VLC_EGENERIC;<br>
}<br>
@@ -532,6 +524,13 @@ static int MimeDemux( demux_t *p_demux )<br>
{<br>
break;<br>
}<br>
+ //sometimes in Content-Type the boundary is defined something like "--video boundary--"<br>
+ else if( !strncmp( p_sys->psz_separator, "--", 2 ) &&<br>
+ !strncmp( p_sys->psz_separator, (char *)(p_sys->p_peek + i),<br>
+ strlen( p_sys->psz_separator ) ) )<br>
+ {<br>
+ break;<br>
+ }<br>
<br>
i++;<br>
i_size++;<br>
--<br>
1.7.7.1.msysgit.0<br>
<br>
</blockquote><div><br></div><div>Any comments please?<span></span></div>