]> git.sesse.net Git - vlc/blobdiff - modules/demux/rawaud.c
AVFormat Demuxer : Set fourcc based on source container.
[vlc] / modules / demux / rawaud.c
index c3ff27bc71c987865535e745f0b05e81afe36f91..b5a270b05384cdc403c7e85b02af5f968cc70da7 100644 (file)
@@ -50,7 +50,7 @@ static void Close( vlc_object_t * );
 #define FOURCC_LONGTEXT N_( \
     "FOURCC code of the raw input format. This is a four character string." )
 
-#define LANG_TEXT N_("Forces the audio language.")
+#define LANG_TEXT N_("Forces the audio language")
 #define LANG_LONGTEXT N_("Forces the audio language for the output mux. Three letter ISO639 code. Default is 'eng'. ")
 
 #ifdef WORDS_BIGENDIAN
@@ -113,49 +113,43 @@ static int Open( vlc_object_t * p_this )
     es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
 
     char *psz_fourcc = var_CreateGetString( p_demux, "rawaud-fourcc" );
+    p_sys->fmt.i_codec = vlc_fourcc_GetCodecFromString( AUDIO_ES, psz_fourcc );
+    free( psz_fourcc );
 
-    if( ( psz_fourcc == NULL ?  0 : strlen( psz_fourcc ) ) != 4  )
+    if( !p_sys->fmt.i_codec )
     {
         msg_Err( p_demux, "rawaud-fourcc must be a 4 character string");
-        free( psz_fourcc );
         es_format_Clean( &p_sys->fmt );
         free( p_sys );
         return VLC_EGENERIC;
     }
 
-    p_sys->fmt.i_codec = VLC_FOURCC( psz_fourcc[0], psz_fourcc[1],
-                                     psz_fourcc[2], psz_fourcc[3] );
-
-    free( psz_fourcc );
     // get the bits per sample ratio based on codec
     switch( p_sys->fmt.i_codec )
     {
 
-        case VLC_FOURCC( 'f', 'l', '6', '4' ):
+        case VLC_CODEC_FL64:
             p_sys->fmt.audio.i_bitspersample = 64;
             break;
 
-        case VLC_FOURCC( 'f', 'l', '3', '2' ):
-        case VLC_FOURCC( 's', '3', '2', 'l' ):
-        case VLC_FOURCC( 's', '3', '2', 'b' ):
-        case VLC_FOURCC( 'i', 'n', '3', '2' ):
+        case VLC_CODEC_FL32:
+        case VLC_CODEC_S32L:
+        case VLC_CODEC_S32B:
             p_sys->fmt.audio.i_bitspersample = 32;
             break;
 
-        case VLC_FOURCC( 's', '2', '4', 'l' ):
-        case VLC_FOURCC( 's', '2', '4', 'b' ):
-        case VLC_FOURCC( 'i', 'n', '2', '4' ):
-        case VLC_FOURCC( '4', '2', 'n', 'i' ):
+        case VLC_CODEC_S24L:
+        case VLC_CODEC_S24B:
             p_sys->fmt.audio.i_bitspersample = 24;
             break;
 
-        case VLC_FOURCC( 's', '1', '6', 'l' ):
-        case VLC_FOURCC( 's', '1', '6', 'b' ):
+        case VLC_CODEC_S16L:
+        case VLC_CODEC_S16B:
             p_sys->fmt.audio.i_bitspersample = 16;
             break;
 
-        case VLC_FOURCC( 's', '8', ' ', ' ' ):
-        case VLC_FOURCC( 'u', '8', ' ', ' ' ):
+        case VLC_CODEC_S8:
+        case VLC_CODEC_U8:
             p_sys->fmt.audio.i_bitspersample = 8;
             break;
 
@@ -207,7 +201,7 @@ static int Open( vlc_object_t * p_this )
 
     /* initialize timing */
     date_Init( &p_sys->pts, p_sys->fmt.audio.i_rate, 1 );
-    date_Set( &p_sys->pts, 1 );
+    date_Set( &p_sys->pts, 0 );
 
     /* calculate 50ms frame size/time */
     p_sys->i_frame_samples = __MAX( p_sys->fmt.audio.i_rate / 20, 1 );
@@ -248,10 +242,13 @@ static int Demux( demux_t *p_demux )
     }
 
     p_block->i_dts =
-    p_block->i_pts = date_Increment( &p_sys->pts, p_sys->i_frame_samples );
+    p_block->i_pts = VLC_TS_0 + date_Get( &p_sys->pts );
 
     es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
     es_out_Send( p_demux->out, p_sys->p_es, p_block );
+
+    date_Increment( &p_sys->pts, p_sys->i_frame_samples );
+
     return 1;
 }