]> git.sesse.net Git - vlc/blobdiff - modules/demux/tta.c
taglib: Supports in ogg/vorbis base64 encoded embedded album art with COVERARTMIME...
[vlc] / modules / demux / tta.c
index be9e37df27b015c749a2cd4f24884ee5ac7b4080..8a226c200029007af1c90f2a7bb16f9230b705ee 100644 (file)
@@ -25,7 +25,7 @@
  * Preamble
  *****************************************************************************/
 #include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_demux.h>
 #include <vlc_codec.h>
 #include <math.h>
 
@@ -79,7 +79,7 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
     es_format_t fmt;
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
     uint8_t     p_header[22];
     uint8_t     *p_seektable;
     int         i_seektable_size = 0, i;
@@ -105,7 +105,7 @@ static int Open( vlc_object_t * p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
-    
+
     /* Read the metadata */
     es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'T', 'T', 'A', '1' ) );
     fmt.audio.i_channels = GetWLE( &p_header[6] );
@@ -115,7 +115,7 @@ static int Open( vlc_object_t * p_this )
     p_sys->i_datalength = GetDWLE( &p_header[14] );
     p_sys->i_framelength = TTA_FRAMETIME * fmt.audio.i_rate;
 
-    p_sys->i_totalframes = p_sys->i_datalength / p_sys->i_framelength + 
+    p_sys->i_totalframes = p_sys->i_datalength / p_sys->i_framelength +
                           ((p_sys->i_datalength % p_sys->i_framelength) ? 1 : 0);
     p_sys->i_currentframe = 0;
 
@@ -132,21 +132,30 @@ static int Open( vlc_object_t * p_this )
     /* Store the header and Seektable for avcodec */
     fmt.i_extra = 22 + (p_sys->i_totalframes * 4) + 4;
     fmt.p_extra = malloc( fmt.i_extra );
-    memcpy( fmt.p_extra, p_header, 22 );
-    memcpy( fmt.p_extra+22, p_seektable, fmt.i_extra -22 );
+    memcpy( (uint8_t*)fmt.p_extra, p_header, 22 );
+    memcpy( (uint8_t*)fmt.p_extra+22, p_seektable, fmt.i_extra -22 );
 
     p_sys->p_es = es_out_Add( p_demux->out, &fmt );
     free( p_seektable );
     p_sys->i_start = stream_Tell( p_demux->s );
-    
+
 #if 0
     /* Parse possible id3 header */
+    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+    if( !p_demux->p_private )
+        return VLC_ENOMEM;
     if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
     {
-        p_sys->p_meta = (vlc_meta_t *)p_demux->p_private;
+        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+        p_sys->p_meta = p_demux_meta->p_meta;
         p_demux->p_private = NULL;
         module_Unneed( p_demux, p_id3 );
+        int i;
+        for( i = 0; i < p_demux_meta->i_attachments; i++ )
+            free( p_demux_meta->attachments[i] );
+        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
     }
+    free( p_demux->p_private );
 
     if( !p_sys->p_meta )
         p_sys->p_meta = vlc_meta_New();
@@ -198,7 +207,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     demux_sys_t *p_sys = p_demux->p_sys;
     double   f, *pf;
     int64_t i64, *pi64;
-    vlc_meta_t *p_meta;
 
     switch( i_query )
     {
@@ -232,7 +240,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
-         
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
             *pi64 = I64C(1000000) * p_sys->i_totalframes * TTA_FRAMETIME;
@@ -242,7 +250,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             *pi64 = I64C(1000000) * p_sys->i_currentframe * TTA_FRAMETIME;
             return VLC_SUCCESS;
-            
         default:
             return VLC_EGENERIC;
     }