matroskamux: Only accept raw aac
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 11 Jan 2010 15:07:29 +0000 (12:07 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 11 Jan 2010 15:32:29 +0000 (12:32 -0300)
makes matroskamux reject aac streams that are not
in raw format (stream-format=none)

Fixes #598350

gst/matroska/matroska-mux.c

index e59faab..fa45637 100644 (file)
@@ -136,6 +136,7 @@ static GstStaticPadTemplate audiosink_templ =
     GST_STATIC_CAPS ("audio/mpeg, "
         "mpegversion = (int) 1, "
         "layer = (int) [ 1, 3 ], "
+        "stream-format = (string) { none }, "
         COMMON_AUDIO_CAPS "; "
         "audio/mpeg, "
         "mpegversion = (int) { 2, 4 }, "
@@ -1426,6 +1427,7 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
   GstStructure *structure;
   const GValue *codec_data = NULL;
   const GstBuffer *buf = NULL;
+  const gchar *stream_format = NULL;
 
   mux = GST_MATROSKA_MUX (GST_PAD_PARENT (pad));
 
@@ -1504,20 +1506,30 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
         break;
       }
       case 2:
-        if (buf) {
-          context->codec_id =
-              g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2 "%s",
-              aac_codec_data_to_codec_id (buf));
+      case 4:
+        stream_format = gst_structure_get_string (structure, "stream-format");
+        /* check this is raw aac */
+        if (stream_format) {
+          if (strcmp (stream_format, "none") != 0) {
+            GST_WARNING_OBJECT (mux, "AAC stream-format must be 'none', not %s",
+                stream_format);
+          }
         } else {
-          GST_DEBUG_OBJECT (mux, "no AAC codec_data; not packetized");
-          return FALSE;
+          GST_WARNING_OBJECT (mux, "AAC stream-format not specified, "
+              "assuming 'none'");
         }
-        break;
-      case 4:
+
         if (buf) {
-          context->codec_id =
-              g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4 "%s",
-              aac_codec_data_to_codec_id (buf));
+          if (mpegversion == 2)
+            context->codec_id =
+                g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2 "%s",
+                aac_codec_data_to_codec_id (buf));
+          else if (mpegversion == 4)
+            context->codec_id =
+                g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4 "%s",
+                aac_codec_data_to_codec_id (buf));
+          else
+            g_assert_not_reached ();
         } else {
           GST_DEBUG_OBJECT (mux, "no AAC codec_data; not packetized");
           return FALSE;