opusheader: Put number of channels and sample rate into the caps

https://bugzilla.gnome.org/show_bug.cgi?id=746617
This commit is contained in:
Sebastian Dröge 2015-03-23 11:56:09 +01:00
parent fcce2fe059
commit e252b13dd0

View 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));