opusheader: Put number of channels and sample rate into the caps
authorSebastian Dröge <sebastian@centricular.com>
Mon, 23 Mar 2015 10:56:09 +0000 (11:56 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 23 Mar 2015 10:56:09 +0000 (11:56 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=746617

ext/opus/gstopusheader.c

index d190cc227b076310fef858f08ed662cc8bb6a25e..53969602b4559a13fbdb26f6f172f7ba5957071d 100644 (file)
@@ -157,6 +157,7 @@ gst_opus_header_create_caps_from_headers (GstCaps ** caps, GSList ** headers,
     GstBuffer * buf1, GstBuffer * buf2)
 {
   int n_streams, family;
+  gint channels, rate;
   gboolean multistream;
   GstMapInfo map;
   guint8 *data;
@@ -168,6 +169,9 @@ gst_opus_header_create_caps_from_headers (GstCaps ** caps, GSList ** headers,
   gst_buffer_map (buf1, &map, GST_MAP_READ);
   data = map.data;
 
+  channels = data[9];
+  rate = GST_READ_UINT32_LE (data + 12);
+
   /* work out the number of streams */
   family = data[18];
   if (family == 0) {
@@ -183,12 +187,16 @@ gst_opus_header_create_caps_from_headers (GstCaps ** caps, GSList ** headers,
     }
   }
 
+  /* TODO: should probably also put the channel mapping into the caps too once
+   * we actually support multi channel, and pre-skip and other fields */
+
   gst_buffer_unmap (buf1, &map);
 
   /* mark and put on caps */
   multistream = n_streams > 1;
   *caps = gst_caps_new_simple ("audio/x-opus",
-      "multistream", G_TYPE_BOOLEAN, multistream, NULL);
+      "multistream", G_TYPE_BOOLEAN, multistream,
+      "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
   *caps = _gst_caps_set_buffer_array (*caps, "streamheader", buf1, buf2, NULL);
 
   *headers = g_slist_prepend (*headers, gst_buffer_ref (buf2));