diff options
author | Thiago Santos <thiagoss@osg.samsung.com> | 2016-05-02 14:21:55 -0300 |
---|---|---|
committer | Thiago Santos <thiagoss@osg.samsung.com> | 2016-05-03 07:43:15 -0300 |
commit | 7ac32601c8a185292748b75ff2f4004cb2b8fa1b (patch) | |
tree | 1663792b7b4d124ec6a91ae5909b597b8b6ee83c | |
parent | 8587548767e07d679d8ad261e8d8acb9155b0a33 (diff) | |
download | gstreamer-plugins-base-7ac32601c8a185292748b75ff2f4004cb2b8fa1b.tar.gz |
opusdec: intersect with the filter before returning on getcaps
So upstream gets a smaller set to decide upon as it is what it requested
with the filter
https://bugzilla.gnome.org/show_bug.cgi?id=765684
-rw-r--r-- | ext/opus/gstopusdec.c | 23 | ||||
-rw-r--r-- | tests/check/elements/opus.c | 14 |
2 files changed, 29 insertions, 8 deletions
diff --git a/ext/opus/gstopusdec.c b/ext/opus/gstopusdec.c index 8cab0fee9..5fdfd5573 100644 --- a/ext/opus/gstopusdec.c +++ b/ext/opus/gstopusdec.c @@ -904,20 +904,27 @@ gst_opus_dec_caps_extend_rate_options (GstCaps * caps) GstCaps * gst_opus_dec_getcaps (GstAudioDecoder * dec, GstCaps * filter) { - GstCaps *caps; + GstCaps *caps, *proxy_filter = NULL, *ret; if (filter) { - filter = gst_caps_copy (filter); - gst_opus_dec_caps_extend_channels_options (filter); - gst_opus_dec_caps_extend_rate_options (filter); + proxy_filter = gst_caps_copy (filter); + gst_opus_dec_caps_extend_channels_options (proxy_filter); + gst_opus_dec_caps_extend_rate_options (proxy_filter); } - caps = gst_audio_decoder_proxy_getcaps (dec, NULL, filter); - if (filter) - gst_caps_unref (filter); + caps = gst_audio_decoder_proxy_getcaps (dec, NULL, proxy_filter); + if (proxy_filter) + gst_caps_unref (proxy_filter); if (caps) { caps = gst_caps_make_writable (caps); gst_opus_dec_caps_extend_channels_options (caps); gst_opus_dec_caps_extend_rate_options (caps); } - return caps; + + if (filter) { + ret = gst_caps_intersect (caps, filter); + gst_caps_unref (caps); + } else { + ret = caps; + } + return ret; } diff --git a/tests/check/elements/opus.c b/tests/check/elements/opus.c index 0fe1041c3..5b04bb211 100644 --- a/tests/check/elements/opus.c +++ b/tests/check/elements/opus.c @@ -402,6 +402,20 @@ GST_START_TEST (test_opusdec_getcaps) "audio/x-opus, rate=(int){48000, 24000, 16000, 12000, 8000}, channels=(int)[1,2]"); run_getcaps_check_from_strings (NULL, "audio/x-raw, channels=(int)5000", "EMPTY"); + + /* Now add filters */ + + /* Formats not acceptable */ + run_getcaps_check_from_strings ("audio/x-opus, rate=(int)1000", NULL, + "EMPTY"); + run_getcaps_check_from_strings ("audio/x-opus, channels=(int)200", NULL, + "EMPTY"); + + /* Should restrict the result of the caps query to the selected rate/channels */ + run_getcaps_check_from_strings ("audio/x-opus, rate=(int)8000", NULL, + "audio/x-opus, rate=(int)8000, channels=(int)[1,8]"); + run_getcaps_check_from_strings ("audio/x-opus, channels=(int)2", NULL, + "audio/x-opus, rate=(int){48000, 24000, 16000, 12000, 8000}, channels=(int)2"); } GST_END_TEST; |