]> git.sesse.net Git - vlc/blobdiff - modules/demux/real.c
Use a different FOURCC for Speex from RTP (refs #1291),
[vlc] / modules / demux / real.c
index 441d93174063ccb56554eb9ea8031f2c52d98cff..885c8da6a3e982e6fd7aa9bce82a0b81137252f4 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * real.c: Real demuxer.
  *****************************************************************************
- * Copyright (C) 2004, 2006 the VideoLAN team
+ * Copyright (C) 2004, 2006-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -26,8 +26,6 @@
  *****************************************************************************/
 #include <vlc/vlc.h>
 
-#include <stdio.h>
-#include <stdlib.h>                                      /* malloc(), free() */
 
 #include <vlc_demux.h>
 #include <vlc_charset.h>
@@ -113,10 +111,10 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
 
     if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return VLC_EGENERIC;
-    if( strncmp( (char *)p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
+    if( memcmp( p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
 
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
@@ -507,16 +505,18 @@ static int Demux( demux_t *p_demux )
             }
         }
         else if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) ||
-                 tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') )
+                 tk->fmt.i_codec == VLC_FOURCC( 'a', 't', 'r', 'c') ||
+                 tk->fmt.i_codec == VLC_FOURCC( '2', '8', '_', '8') )
         {
             uint8_t *p_buf = p_sys->buffer;
-            int y = tk->i_subpacket / (tk->i_frame_size /tk->i_subpacket_size);
+            int y = tk->i_subpacket / ( tk->i_frame_size /tk->i_subpacket_size);
             int i_index, i;
 
             /* Sanity check */
             if( i_flags & 2 ) y = tk->i_subpacket = 0;
 
-            if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) )
+            if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) ||
+                tk->fmt.i_codec == VLC_FOURCC( 'a', 't', 'r', 'c' ) )
             for( i = 0; i < tk->i_frame_size / tk->i_subpacket_size; i++ )
             {
                 block_t *p_block = block_New( p_demux, tk->i_subpacket_size );
@@ -531,7 +531,7 @@ static int Demux( demux_t *p_demux )
                 tk->i_subpacket++;
             }
 
-            if( tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') )
+            if( tk->fmt.i_codec == VLC_FOURCC( '2', '8', '_', '8' ) )
             for( i = 0; i < tk->i_subpacket_h / 2; i++ )
             {
                 block_t *p_block = block_New( p_demux, tk->i_coded_frame_size);
@@ -651,7 +651,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            
             /* the commented following lines are fen's implementation, which doesn't seem to
              * work for one reason or another -- FK */
             /*if( p_sys->i_mux_rate > 0 )
@@ -663,7 +663,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             {
                 /* our stored duration is in ms, so... */
                 *pi64 = (int64_t)1000 * p_sys->i_our_duration;
-                
                 return VLC_SUCCESS;
             }
             *pi64 = 0;
@@ -673,7 +673,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         {
             vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
 
-            /* the core will crash if we provide NULL strings, so check 
+            /* the core will crash if we provide NULL strings, so check
              * every string first */
             if( p_sys->psz_title )
                 vlc_meta_SetTitle( p_meta, p_sys->psz_title );
@@ -752,10 +752,10 @@ static int HeaderRead( demux_t *p_demux )
             msg_Dbg( p_demux, "    - index offset=%d", GetDWBE(&header[28]) );
             msg_Dbg( p_demux, "    - data offset=%d", GetDWBE(&header[32]) );
             msg_Dbg( p_demux, "    - num streams=%d", GetWBE(&header[36]) );
-            
             /* set the duration for export in control */
             p_sys->i_our_duration = (int)GetDWBE(&header[20]);
-            
             i_flags = GetWBE(&header[38]);
             msg_Dbg( p_demux, "    - flags=0x%x %s%s%s",
                      i_flags,
@@ -768,7 +768,7 @@ static int HeaderRead( demux_t *p_demux )
         {
             int i_len;
             char *psz;
-            
             /* FIXME FIXME: should convert from whatever the character
              * encoding of the input meta data is to UTF-8. */
 
@@ -849,7 +849,7 @@ static int HeaderRead( demux_t *p_demux )
             msg_Dbg( p_demux, "    - start time=%d", GetDWBE(&header[18]) );
             msg_Dbg( p_demux, "    - preroll=%d", GetDWBE(&header[22]) );
             msg_Dbg( p_demux, "    - duration=%d", GetDWBE(&header[26]) );
-            
             i_skip -= 30;
 
             stream_Read( p_demux->s, header, 1 );
@@ -925,12 +925,12 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
     demux_sys_t *p_sys = p_demux->p_sys;
     es_format_t fmt;
     real_track_t *tk;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
 
     msg_Dbg( p_demux, "    - specific data len=%d", i_len );
     if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;
 
-    if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )
+    if( ( i_len >= 8 ) && !memcmp( &p_peek[4], "VIDO", 4 ) )
     {
         es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],
                         p_peek[10], p_peek[11] ) );
@@ -1059,6 +1059,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
             break;
 
         case VLC_FOURCC('c','o','o','k'):
+        case VLC_FOURCC('a','t','r','c'):
             fmt.audio.i_blockalign = i_subpacket_size;
             if( !(fmt.i_extra = GetDWBE( p_peek )) ) break;
             fmt.p_extra = malloc( fmt.i_extra );