From cdf411e82d7e437e5de138492b6e75e5513686ee Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Wed, 30 Nov 2022 20:46:05 +0200 Subject: [PATCH] opusenc: Reverse channel order in template caps We want to make it so that we prefer a higher, not lower, number of channels. Otherwise, this pipeline would convert from 2 to 1 channels: gst-launch-1.0 audiotestsrc ! audio/x-raw,channels=2 ! opusenc ! queue ! opusdec ! queue ! opusenc ! fakesink Part-of: --- subprojects/gst-plugins-base/ext/opus/gstopusenc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-base/ext/opus/gstopusenc.c b/subprojects/gst-plugins-base/ext/opus/gstopusenc.c index 6f1fc2b..5476106 100644 --- a/subprojects/gst-plugins-base/ext/opus/gstopusenc.c +++ b/subprojects/gst-plugins-base/ext/opus/gstopusenc.c @@ -857,17 +857,8 @@ gst_opus_enc_get_sink_template_caps (void) g_value_unset (&rate_array); g_value_unset (&v); - /* Mono */ - s = gst_structure_copy (s1); - gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL); - gst_caps_append_structure (caps, s); - - s = gst_structure_copy (s2); - gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL); - gst_caps_append_structure (caps, s); - /* Stereo and further */ - for (i = 2; i <= 8; i++) { + for (i = 8; i >= 2; i--) { guint64 channel_mask = 0; const GstAudioChannelPosition *pos = gst_opus_channel_positions[i - 1]; @@ -898,6 +889,14 @@ gst_opus_enc_get_sink_template_caps (void) gst_caps_append_structure (caps, s); } + /* Mono */ + s = gst_structure_copy (s1); + gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL); + gst_caps_append_structure (caps, s); + + s = gst_structure_copy (s2); + gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL); + gst_caps_append_structure (caps, s); gst_structure_free (s1); gst_structure_free (s2); -- 2.7.4