[vlc-devel] [PATCH] added handling of wrong MIME boundary separator to mjpeg demux

Rémi Denis-Courmont remi at remlab.net
Fri Sep 14 10:23:28 CEST 2012


Applying: added handling of wrong MIME boundary separator to mjpeg demux
error: patch failed: modules/demux/mjpeg.c:351
error: modules/demux/mjpeg.c: patch does not apply
Patch failed at 0001 added handling of wrong MIME boundary separator to mjpeg 
demux

Le mardi 11 septembre 2012 17:38:52, Sergey Radionov a écrit :
> ---
>  modules/demux/mjpeg.c |   53
> ++++++++++++++++++++++++------------------------- 1 files changed, 26
> insertions(+), 27 deletions(-)
> 
> diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
> index a057db3..b6c7445 100644
> --- a/modules/demux/mjpeg.c
> +++ b/modules/demux/mjpeg.c
> @@ -193,33 +193,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
>      {
> @@ -351,6 +326,22 @@ static int Open( vlc_object_t * p_this )
>          goto error;
>      }
> 
> +    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 )
>      {
> @@ -409,6 +400,7 @@ static int Open( vlc_object_t * p_this )
>      return VLC_SUCCESS;
> 
>  error:
> +    free( p_sys->psz_separator );
>      free( p_sys );
>      return VLC_EGENERIC;
>  }
> @@ -532,6 +524,13 @@ static int MimeDemux( demux_t *p_demux )
>          {
>              break;
>          }
> +        //sometimes in Content-Type the boundary is defined something like
> "--video boundary--" +        else if( !strncmp( p_sys->psz_separator,
> "--", 2 ) &&
> +                 !strncmp( p_sys->psz_separator, (char *)(p_sys->p_peek +
> i), +                 strlen( p_sys->psz_separator ) ) )
> +        {
> +            break;
> +        }
> 
>          i++;
>          i_size++;

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list