]> git.sesse.net Git - vlc/blobdiff - modules/demux/mpeg/mpga.c
Extra Data code factorisation: This shouldn't destroy old support, but please repport...
[vlc] / modules / demux / mpeg / mpga.c
index 82d76756d0426c01122083817c79a86ee04845a5..c40ae1cf8f525bd77bdb5a2abea269e5acb3824d 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include "vlc_codec.h"
-#include "vlc_meta.h"
+#include <vlc_demux.h>
+#include <vlc_codec.h>
+#include <vlc_input.h>
 
 #define MPGA_PACKET_SIZE 1024
 
@@ -59,7 +58,6 @@ static int Control( demux_t *, int, va_list );
 struct demux_sys_t
 {
     es_out_id_t *p_es;
-    vlc_meta_t  *meta;
 
     vlc_bool_t  b_start;
     decoder_t   *p_packetizer;
@@ -121,18 +119,11 @@ static int Open( vlc_object_t * p_this )
     vlc_bool_t   b_forced = VLC_FALSE;
 
     uint32_t     header;
-    uint8_t     *p_peek;
-    module_t    *p_id3;
+    const uint8_t     *p_peek;
     block_t     *p_block_in, *p_block_out;
 
-    if( p_demux->psz_path )
-    {
-        int  i_len = strlen( p_demux->psz_path );
-        if( i_len > 4 && !strcasecmp( &p_demux->psz_path[i_len - 4], ".mp3" ) )
-        {
-            b_forced = VLC_TRUE;
-        }
-    }
+    if( demux2_IsPathExtension( p_demux, ".mp3" ) )
+        b_forced = VLC_TRUE;
 
     if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
 
@@ -157,11 +148,10 @@ static int Open( vlc_object_t * p_this )
         if( !b_ok && !p_demux->b_force ) return VLC_EGENERIC;
     }
 
-    STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
+    DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
     memset( p_sys, 0, sizeof( demux_sys_t ) );
     p_sys->p_es = 0;
     p_sys->b_start = VLC_TRUE;
-    p_sys->meta = 0;
 
     /* Load the mpeg audio packetizer */
     INIT_APACKETIZER( p_sys->p_packetizer, 'm', 'p', 'g', 'a' );
@@ -172,7 +162,7 @@ static int Open( vlc_object_t * p_this )
     if( HeaderCheck( header ) )
     {
         int i_xing, i_skip;
-        uint8_t *p_xing;
+        const uint8_t *p_xing;
 
         if( ( i_xing = stream_Peek( p_demux->s, &p_xing, 1024 ) ) < 21 )
             return VLC_SUCCESS; /* No header */
@@ -245,9 +235,6 @@ static int Open( vlc_object_t * p_this )
     else
         p_sys->b_initial_sync_failed = VLC_FALSE;
 
-    p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
-    p_sys->p_es = es_out_Add( p_demux->out,
-                              &p_sys->p_packetizer->fmt_out);
     p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
 
     if( p_sys->i_xing_bytes && p_sys->i_xing_frames &&
@@ -261,14 +248,10 @@ static int Open( vlc_object_t * p_this )
     p_sys->p_block_in = p_block_in;
     p_sys->p_block_out = p_block_out;
 
-    /* Parse possible id3 header */
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
-    {
-        p_sys->meta = (vlc_meta_t *)p_demux->p_private;
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-    }
-
+    /* */
+    p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
+    p_sys->p_es = es_out_Add( p_demux->out,
+                              &p_sys->p_packetizer->fmt_out);
     return VLC_SUCCESS;
 }
 
@@ -338,7 +321,6 @@ static void Close( vlc_object_t * p_this )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     DESTROY_PACKETIZER( p_sys->p_packetizer );
-    if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
     if( p_sys->p_block_out ) block_Release( p_sys->p_block_out );
 
     free( p_sys );
@@ -351,14 +333,14 @@ 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;
-    vlc_meta_t *p_meta;
+    vlc_bool_t *pb_bool;
     int i_ret;
 
     switch( i_query )
     {
-        case DEMUX_GET_META:
-            p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t* );
-            vlc_meta_Merge( p_meta, p_sys->meta );
+        case DEMUX_HAS_UNSUPPORTED_META:
+            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
+            *pb_bool = VLC_TRUE;
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME: