gst/matroska/matroska-mux.c: The "signed" field in audio caps is of boolean type...
authorTim-Philipp Müller <tim@centricular.net>
Sun, 24 Dec 2006 11:24:59 +0000 (11:24 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Sun, 24 Dec 2006 11:24:59 +0000 (11:24 +0000)
Original commit message from CVS:
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_audio_pad_setcaps):
The "signed" field in audio caps is of boolean type, trying to use
gst_structure_get_int() to extract it will fail. Fixing this makes
matroskamux accept raw audio input (#387121) (use at your own risk
though, due to the matroska spec being not entirely useful in this
respect).
Also fix up raw audio structures in template caps so that they
represent what our setcaps function will actually accept, so that
converters know what to convert to.
Finally, don't fail if there isn't an "endianness" field in 8-bit
PCM caps.

ChangeLog
gst/matroska/matroska-mux.c

index c5f011d..43a8467 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-12-24  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/matroska/matroska-mux.c:
+       (gst_matroska_mux_audio_pad_setcaps):
+         The "signed" field in audio caps is of boolean type, trying to use
+         gst_structure_get_int() to extract it will fail. Fixing this makes
+         matroskamux accept raw audio input (#387121) (use at your own risk
+         though, due to the matroska spec being not entirely useful in this
+         respect).
+         Also fix up raw audio structures in template caps so that they
+         represent what our setcaps function will actually accept, so that
+         converters know what to convert to.
+         Finally, don't fail if there isn't an "endianness" field in 8-bit
+         PCM caps.
+
 2006-12-22  Stefan Kost  <ensonic@users.sf.net>
 
        * tests/check/elements/audiopanorama.c: (cleanup_panorama):
index a275410..cdb5e32 100644 (file)
@@ -105,10 +105,15 @@ static GstStaticPadTemplate audiosink_templ =
         "audio/x-vorbis, "
         COMMON_AUDIO_CAPS "; "
         "audio/x-raw-int, "
-        "width = (int) { 8, 16, 24 }, "
-        "depth = (int) { 8, 16, 24 }, "
+        "width = (int) 8, "
+        "depth = (int) 8, "
+        "signed = (boolean) false, "
+        COMMON_AUDIO_CAPS ";"
+        "audio/x-raw-int, "
+        "width = (int) 16, "
+        "depth = (int) 16, "
         "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, "
-        "signed = (boolean) { true, false }, "
+        "signed = (boolean) true, "
         COMMON_AUDIO_CAPS ";"
         "audio/x-tta, "
         "width = (int) { 8, 16, 24 }, "
@@ -984,15 +989,29 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
     gint endianness, width, depth;
     gboolean signedness;
 
-    if (!gst_structure_get_int (structure, "endianness", &endianness) ||
-        !gst_structure_get_int (structure, "width", &width) ||
+    if (!gst_structure_get_int (structure, "width", &width) ||
         !gst_structure_get_int (structure, "depth", &depth) ||
-        !gst_structure_get_int (structure, "signed", &signedness))
+        !gst_structure_get_boolean (structure, "signed", &signedness)) {
+      GST_DEBUG_OBJECT (mux, "broken caps, width/depth/signed field missing");
       return FALSE;
+    }
 
-    if (width != depth ||
-        (width == 8 && signedness) || (width == 16 && !signedness))
+    if (depth > 8 &&
+        !gst_structure_get_int (structure, "endianness", &endianness)) {
+      GST_DEBUG_OBJECT (mux, "broken caps, no endianness specified");
       return FALSE;
+    }
+
+    if (width != depth) {
+      GST_DEBUG_OBJECT (mux, "width must be same as depth!");
+      return FALSE;
+    }
+
+    /* where is this spec'ed out? (tpm) */
+    if ((width == 8 && signedness) || (width == 16 && !signedness)) {
+      GST_DEBUG_OBJECT (mux, "8-bit PCM must be unsigned, 16-bit PCM signed");
+      return FALSE;
+    }
 
     audiocontext->bitdepth = depth;
     if (endianness == G_BIG_ENDIAN)