]> git.sesse.net Git - vlc/blobdiff - modules/demux/mjpeg.c
playlist demux: no need to strdup the string here.
[vlc] / modules / demux / mjpeg.c
index fff153f4bca26e411b6b86fad50767669a571707..406ac6e7a3a47775a0295f8227bde62bdf8a332e 100644 (file)
@@ -147,9 +147,9 @@ static char* GetLine( demux_t *p_demux, int *p_pos )
             {
                 return NULL;
             }
+            p_buf = p_sys->p_peek + *p_pos;
+            i_size = p_sys->i_data_peeked - *p_pos;
         }
-        p_buf = p_sys->p_peek + *p_pos;
-        i_size = p_sys->i_data_peeked - *p_pos;
     }
     *p_pos += ( i + 1 );
     if( i > 0 && '\r' == p_buf[i - 1] )
@@ -185,18 +185,19 @@ static bool CheckMimeHeader( demux_t *p_demux, int *p_header_size )
         *p_header_size = -1;
         return false;
     }
-    if( p_sys->i_data_peeked < 3)
+    if( p_sys->i_data_peeked < 5)
     {
         msg_Err( p_demux, "data shortage" );
         *p_header_size = -2;
         return false;
     }
-    if( strncmp( (char *)p_sys->p_peek, "--", 2 ) )
+    if( strncmp( (char *)p_sys->p_peek, "--", 2 ) != 0
+        && strncmp( (char *)p_sys->p_peek, "\r\n--", 4 ) != 0 )
     {
         *p_header_size = 0;
         return false;
     }
-    i_pos = 2;
+    i_pos = *p_sys->p_peek == '-' ? 2 : 4;
     psz_line = GetLine( p_demux, &i_pos );
     if( NULL == psz_line )
     {
@@ -301,7 +302,7 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
     int         i_size;
-    int         b_matched = false;
+    bool        b_matched = false;
     vlc_value_t val;
 
     p_demux->pf_control = Control;
@@ -366,7 +367,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     es_format_Init( &p_sys->fmt, VIDEO_ES, 0 );
-    p_sys->fmt.i_codec = VLC_FOURCC('m','j','p','g');
+    p_sys->fmt.i_codec = VLC_CODEC_MJPG;
 
     p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
     return VLC_SUCCESS;