diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2023-01-03 18:06:56 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@ocrete.ca> | 2023-01-12 18:48:35 -0500 |
commit | c52c66b575626c7ea76277831f53c81512ed33b2 (patch) | |
tree | 1a6555c7a4e6281b663db8abc61084e8660c0466 | |
parent | c51ae6112d28e984859b348f60bfeea8864b8606 (diff) | |
download | gstreamer-c52c66b575626c7ea76277831f53c81512ed33b2.tar.gz |
rtpopuspay: Return upstream channel filter based on OPUS vs MULTICAPS
Only allow 1 or 2 channels if the caps are OPUS, or 3+ if they are
MULTIOPUS.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3674>
-rw-r--r-- | subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c b/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c index e3b0d946e9..4167949b06 100644 --- a/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c +++ b/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c @@ -371,9 +371,9 @@ static GstCaps * gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, GstCaps * filter) { - GstCaps *caps, *peercaps, *tcaps; GstStructure *s; const gchar *stereo; + GstCaps *caps, *peercaps, *tcaps, *tempcaps; if (pad == GST_RTP_BASE_PAYLOAD_SRCPAD (payload)) return @@ -394,6 +394,40 @@ gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, caps = gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SINKPAD (payload)); + tempcaps = gst_caps_from_string ("application/x-rtp, " + "encoding-name=(string) { \"OPUS\", \"X-GST-OPUS-DRAFT-SPITTKA-00\"}"); + if (!gst_caps_can_intersect (peercaps, tempcaps)) { + GstCaps *multiopuscaps = gst_caps_new_simple ("audio/x-opus", + "channel-mapping-family", G_TYPE_INT, 1, + "channels", GST_TYPE_INT_RANGE, 3, 255, + NULL); + GstCaps *intersect_caps; + + intersect_caps = gst_caps_intersect_full (caps, multiopuscaps, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (caps); + gst_caps_unref (multiopuscaps); + caps = intersect_caps; + } + gst_caps_unref (tempcaps); + + tempcaps = gst_caps_new_simple ("application/x-rtp", + "encoding-name", G_TYPE_STRING, "MULTIOPUS", NULL); + if (!gst_caps_can_intersect (peercaps, tempcaps)) { + GstCaps *opuscaps = gst_caps_new_simple ("audio/x-opus", + "channel-mapping-family", G_TYPE_INT, 0, + "channels", GST_TYPE_INT_RANGE, 1, 2, + NULL); + GstCaps *intersect_caps; + + intersect_caps = gst_caps_intersect_full (caps, opuscaps, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (caps); + gst_caps_unref (opuscaps); + caps = intersect_caps; + } + gst_caps_unref (tempcaps); + s = gst_caps_get_structure (peercaps, 0); stereo = gst_structure_get_string (s, "stereo"); if (stereo != NULL) { |