taglib: Supports in ogg/vorbis base64 encoded embedded album art with COVERARTMIME...
[vlc.git] / modules / demux / ogg.c
index fb4d4e6..4082522 100644 (file)
@@ -103,6 +103,10 @@ struct demux_sys_t
 
     /* bitrate */
     int     i_bitrate;
+
+    /* attachments */
+    int                i_attachments;
+    input_attachment_t **attachments;
 };
 
 /* OggDS headers for the new header format (used in ogm files) */
@@ -221,7 +225,8 @@ static int Open( vlc_object_t * p_this )
                     p_demux_meta->p_meta );
             vlc_meta_Delete( p_demux_meta->p_meta );
             module_Unneed( p_demux, p_meta );
-            TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+            p_sys->i_attachments = p_demux_meta->i_attachments;
+            p_sys->attachments = p_demux_meta->attachments;
         }
         vlc_object_release( p_input );
         free( p_demux->p_private );
@@ -246,6 +251,11 @@ static void Close( vlc_object_t *p_this )
 
     Ogg_EndOfStream( p_demux );
 
+    int i;
+    for( i = 0; i < p_sys->i_attachments; i++ )
+        free( p_sys->attachments[i] );
+    TAB_CLEAN( p_sys->i_attachments, p_sys->attachments);
+
     free( p_sys );
 }
 
@@ -391,6 +401,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     demux_sys_t *p_sys  = p_demux->p_sys;
     int64_t *pi64;
     int i;
+    input_attachment_t ***ppp_attach;
+    int *pi_int;
 
     switch( i_query )
     {
@@ -415,6 +427,20 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             ogg_sync_reset( &p_sys->oy );
 
+        case DEMUX_GET_ATTACHMENTS:
+            ppp_attach =
+                (input_attachment_t***)va_arg( args, input_attachment_t*** );
+            pi_int = (int*)va_arg( args, int * );
+
+            if( p_sys->i_attachments <= 0 )
+                return VLC_EGENERIC;
+
+            *pi_int = p_sys->i_attachments;
+            *ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachments );
+            for( i = 0; i < p_sys->i_attachments; i++ )
+                (*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] );
+            return VLC_SUCCESS;
+
         default:
             return demux2_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
                                            1, i_query, args );