]> git.sesse.net Git - vlc/commitdiff
Do not access input object from decoders.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 6 Dec 2008 17:59:49 +0000 (18:59 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 9 Dec 2008 20:13:02 +0000 (21:13 +0100)
modules/codec/faad.c
modules/codec/kate.c
modules/codec/speex.c
modules/codec/theora.c
modules/codec/vorbis.c

index 521b272e3b42c34c449c0294e270bca1dc7cef5f..fd5636efbf8a4109d8510952f420aa0c2835c5fe 100644 (file)
@@ -365,27 +365,19 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             = pi_channels_guessed[frame.channels];
 
         /* Adjust stream info when dealing with SBR/PS */
-        if( (p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps) &&
-            p_dec->p_parent->i_object_type == VLC_OBJECT_INPUT )
+        if( p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps )
         {
-            input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
-            char *psz_cat;
             const char *psz_ext = (frame.sbr && frame.ps) ? "SBR+PS" :
                                     frame.sbr ? "SBR" : "PS";
 
             msg_Dbg( p_dec, "AAC %s (channels: %u, samplerate: %lu)",
                     psz_ext, frame.channels, frame.samplerate );
 
-            if( asprintf( &psz_cat, _("Stream %d"), p_dec->fmt_in.i_id ) != -1 )
-            {
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("AAC extension"), "%s", psz_ext );
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("Channels"), "%d", frame.channels );
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("Sample rate"), _("%d Hz"), frame.samplerate );
-                free( psz_cat );
-            }
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, _("AAC extension"), psz_ext );
+
             p_sys->b_sbr = frame.sbr; p_sys->b_ps = frame.ps;
         }
 
index ced41c9cc1396b37a968705befca78d73248703e..2f2be9e4ae43800be54cd22a2e69b4c001327634 100644 (file)
@@ -702,16 +702,13 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
 }
 
 /*****************************************************************************
- * ParseKateComments: FIXME should be done in demuxer
+ * ParseKateComments:
  *****************************************************************************/
 static void ParseKateComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
-
     while ( i < p_dec->p_sys->kc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->kc.user_comments[i] );
@@ -723,8 +720,11 @@ static void ParseKateComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Kate comment"),
-                           psz_name, "%s", psz_value );
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
         }
         free( psz_comment );
         i++;
index c67379d09497e97c1b51ed7d56588e66de6d7995..547448c588b62e081a157970dcfbdcf9af293e62 100644 (file)
@@ -812,7 +812,7 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
 }
 
 /*****************************************************************************
- * ParseSpeexComments: FIXME should be done in demuxer
+ * ParseSpeexComments:
  *****************************************************************************/
 #define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \
                            ((buf[base+2]<<16)&0xff0000)| \
@@ -821,40 +821,31 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
 
 static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     decoder_sys_t *p_sys = p_dec->p_sys;
-
-    char *p_buf = (char *)p_oggpacket->packet;
     const SpeexMode *p_mode;
-    int i_len;
-
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
 
     assert( p_sys->p_header->mode < SPEEX_NB_MODES );
 
     p_mode = speex_mode_list[p_sys->p_header->mode];
     assert( p_mode != NULL );
 
-    input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), _("Mode"),
-                   "%s%s", p_mode->modeName,
-                   p_sys->p_header->vbr ? " VBR" : "" );
-
-    if( p_oggpacket->bytes < 8 )
+    if( !p_dec->p_description )
     {
-        msg_Err( p_dec, "invalid/corrupted comments" );
-        return;
+        p_dec->p_description = vlc_meta_New();
+        if( !p_dec->p_description )
+            return;
     }
 
-    i_len = readint( p_buf, 0 ); p_buf += 4;
-    if( i_len > p_oggpacket->bytes - 4 )
+    /* */
+    char *psz_mode;
+    if( asprintf( &psz_mode, "%s%s", p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ) >= 0 )
     {
-        msg_Err( p_dec, "invalid/corrupted comments" );
-        return;
+        vlc_meta_AddExtra( p_dec->p_description, _("Mode"), psz_mode );
+        free( psz_mode );
     }
 
-    input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), p_buf, "" );
-
     /* TODO: finish comments parsing */
+    VLC_UNUSED( p_oggpacket );
 }
 
 /*****************************************************************************
index 2380b234af1601c832f9377c1ea20a32b0460514..5817bf0eeb4f54f394213d0d68fb2ba0ea857125 100644 (file)
@@ -506,16 +506,13 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
 }
 
 /*****************************************************************************
- * ParseTheoraComments: FIXME should be done in demuxer
+ * ParseTheoraComments:
  *****************************************************************************/
 static void ParseTheoraComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
-
     while ( i < p_dec->p_sys->tc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->tc.user_comments[i] );
@@ -527,8 +524,11 @@ static void ParseTheoraComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Theora comment"),
-                           psz_name, "%s", psz_value );
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
         }
         free( psz_comment );
         i++;
index f7a90783b943abb28b7d3fe4ca7ee17e11f38f83..4d079dc8efdd0d6fe45fc2731d599c605427e0c4 100644 (file)
@@ -605,16 +605,9 @@ static block_t *SendPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
  *****************************************************************************/
 static void ParseVorbisComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
-    input_item_t *p_item;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT )
-        return;
-
-    p_item = input_GetItem( p_input );
-
     while( i < p_dec->p_sys->vc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->vc.user_comments[i] );
@@ -626,33 +619,12 @@ static void ParseVorbisComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"),
-                           psz_name, "%s", psz_value );
-/*TODO: dot he test at the beginning and save time !! */
-#ifndef HAVE_TAGLIB
-            if( psz_value && ( *psz_value != '\0' ) )
-            {
-                if( !strcasecmp( psz_name, "artist" ) )
-                    input_item_SetArtist( p_item, psz_value );
-                else if( !strcasecmp( psz_name, "title" ) )
-                {
-                    input_item_SetTitle( p_item, psz_value );
-                    p_item->psz_name = strdup( psz_value );
-                }
-                else if( !strcasecmp( psz_name, "album" ) )
-                {
-                    input_item_SetAlbum( p_item, psz_value );
-                }
-                else if( !strcasecmp( psz_name, "musicbrainz_trackid" ) )
-                    input_item_SetTrackID( p_item, psz_value );
-#if 0 //not used
-                else if( !strcasecmp( psz_name, "musicbrainz_artistid" ) )
-                    vlc_meta_SetArtistID( p_item, psz_value );
-                else if( !strcasecmp( psz_name, "musicbrainz_albumid" ) )
-                    input_item_SetAlbumID( p_item, psz_value );
-#endif
-            }
-#endif
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
+
             if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_GAIN" ) ||
                      !strcasecmp( psz_name, "RG_RADIO" ) )
             {