audioringbuffer: parse channels field from compressed audio caps
authorJosep Torra <n770galaxy@gmail.com>
Tue, 8 Apr 2014 10:46:21 +0000 (12:46 +0200)
committerJosep Torra <n770galaxy@gmail.com>
Tue, 8 Apr 2014 10:54:04 +0000 (12:54 +0200)
Also parse channels as an optional field in the caps for compressed
audio formats.

gst-libs/gst/audio/gstaudioringbuffer.c

index ba56846..c0b060f 100644 (file)
@@ -242,6 +242,7 @@ gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
     if (!(gst_structure_get_int (structure, "rate", &info.rate)))
       goto parse_error;
 
+    gst_structure_get_int (structure, "channels", &info.channels);
     spec->type = GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3;
     info.bpf = 4;
   } else if (g_str_equal (mimetype, "audio/x-eac3")) {
@@ -249,6 +250,7 @@ gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
     if (!(gst_structure_get_int (structure, "rate", &info.rate)))
       goto parse_error;
 
+    gst_structure_get_int (structure, "channels", &info.channels);
     spec->type = GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3;
     info.bpf = 16;
   } else if (g_str_equal (mimetype, "audio/x-dts")) {
@@ -256,6 +258,7 @@ gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
     if (!(gst_structure_get_int (structure, "rate", &info.rate)))
       goto parse_error;
 
+    gst_structure_get_int (structure, "channels", &info.channels);
     spec->type = GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS;
     info.bpf = 4;
   } else if (g_str_equal (mimetype, "audio/mpeg") &&
@@ -266,6 +269,7 @@ gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
     if (!(gst_structure_get_int (structure, "rate", &info.rate)))
       goto parse_error;
 
+    gst_structure_get_int (structure, "channels", &info.channels);
     spec->type = GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG;
     info.bpf = 4;
   } else if (g_str_equal (mimetype, "audio/mpeg") &&
@@ -276,6 +280,8 @@ gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec * spec, GstCaps * caps)
     /* MPEG-2 AAC or MPEG-4 AAC */
     if (!(gst_structure_get_int (structure, "rate", &info.rate)))
       goto parse_error;
+
+    gst_structure_get_int (structure, "channels", &info.channels);
     spec->type = (i == 2) ? GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC :
         GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC;
     info.bpf = 4;