summaryrefslogtreecommitdiff
path: root/ext/sbc
diff options
context:
space:
mode:
authorAurélien Zanelli <aurelien.zanelli@parrot.com>2014-03-11 10:32:46 +0100
committerSebastian Dröge <sebastian@centricular.com>2014-03-12 09:06:33 +0100
commitda601be78f011f22fcedc0c5691ddf32a5eef63a (patch)
tree22e720e9893b769a3953c410b6c42c913e669534 /ext/sbc
parent4d17166b0355cad49ab8fda059a390db3eee6ad6 (diff)
downloadgstreamer-plugins-bad-da601be78f011f22fcedc0c5691ddf32a5eef63a.tar.gz
sbcenc: Allow user to set channel-mode
Don't return error when channel-mode is already set, just check that it is coherent with number of channels. https://bugzilla.gnome.org/show_bug.cgi?id=726098
Diffstat (limited to 'ext/sbc')
-rw-r--r--ext/sbc/gstsbcenc.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/sbc/gstsbcenc.c b/ext/sbc/gstsbcenc.c
index d456190a5..6ef56b49e 100644
--- a/ext/sbc/gstsbcenc.c
+++ b/ext/sbc/gstsbcenc.c
@@ -118,21 +118,10 @@ gst_sbc_enc_set_format (GstAudioEncoder * audio_enc, GstAudioInfo * info)
GST_DEBUG_OBJECT (enc, "fixating caps %" GST_PTR_FORMAT, output_caps);
output_caps = gst_caps_truncate (output_caps);
s = gst_caps_get_structure (output_caps, 0);
- if (enc->channels == 1) {
- if (!gst_structure_fixate_field_string (s, "channel-mode", "mono")) {
- GST_DEBUG_OBJECT (enc, "Failed to fixate channel-mode to mono");
- gst_caps_unref (output_caps);
- return FALSE;
- }
- } else {
- if (!gst_structure_fixate_field_string (s, "channel-mode", "joint") &&
- !gst_structure_fixate_field_string (s, "channel-mode", "stereo") &&
- !gst_structure_fixate_field_string (s, "channel-mode", "dual")) {
- GST_DEBUG_OBJECT (enc, "Failed to fixate channel-mode for 2 channels");
- gst_caps_unref (output_caps);
- return FALSE;
- }
- }
+ if (enc->channels == 1)
+ gst_structure_fixate_field_string (s, "channel-mode", "mono");
+ else
+ gst_structure_fixate_field_string (s, "channel-mode", "joint");
gst_structure_fixate_field_nearest_int (s, "bitpool", 64);
gst_structure_fixate_field_nearest_int (s, "blocks", 16);
@@ -154,6 +143,25 @@ gst_sbc_enc_set_format (GstAudioEncoder * audio_enc, GstAudioInfo * info)
allocation_method = gst_structure_get_string (s, "allocation-method");
channel_mode = gst_structure_get_string (s, "channel-mode");
+ /* We want channel-mode and channels coherent */
+ if (enc->channels == 1) {
+ if (g_strcmp0 (channel_mode, "mono") != 0) {
+ GST_ERROR_OBJECT (enc, "Can't have channel-mode '%s' for 1 channel",
+ channel_mode);
+ gst_caps_unref (output_caps);
+ return FALSE;
+ }
+ } else {
+ if (g_strcmp0 (channel_mode, "joint") != 0 &&
+ g_strcmp0 (channel_mode, "stereo") != 0 &&
+ g_strcmp0 (channel_mode, "dual") != 0) {
+ GST_ERROR_OBJECT (enc, "Can't have channel-mode '%s' for 2 channels",
+ channel_mode);
+ gst_caps_unref (output_caps);
+ return FALSE;
+ }
+ }
+
/* we want to be handed all available samples in handle_frame, but always
* enough to encode a frame */
sampleframes_per_frame = enc->blocks * enc->subbands;