From c5939300552919d854462739ca555c5f37697a21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 12 Jan 2023 14:32:30 -0500 Subject: [PATCH] rtopuspay: Use GstStaticCaps to cache parsed caps Part-of: --- subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c b/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c index e2e1578..e62868c 100644 --- a/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c +++ b/subprojects/gst-plugins-good/gst/rtp/gstrtpopuspay.c @@ -374,6 +374,10 @@ gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, GstStructure *s; int channel_mapping_family = 0; GstCaps *caps, *peercaps, *tcaps, *tempcaps; + static GstStaticCaps opus_static_caps = GST_STATIC_CAPS ("application/x-rtp, " + "encoding-name=(string) { \"OPUS\", \"X-GST-OPUS-DRAFT-SPITTKA-00\"}"); + static GstStaticCaps multiopus_static_caps = + GST_STATIC_CAPS ("application/x-rtp, encoding-name=(string)MULTIOPUS"); if (pad == GST_RTP_BASE_PAYLOAD_SRCPAD (payload)) return @@ -394,8 +398,7 @@ 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\"}"); + tempcaps = gst_static_caps_get (&opus_static_caps); if (!gst_caps_can_intersect (peercaps, tempcaps)) { GstCaps *multiopuscaps = gst_caps_new_simple ("audio/x-opus", "channel-mapping-family", G_TYPE_INT, 1, @@ -411,8 +414,7 @@ gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, } gst_caps_unref (tempcaps); - tempcaps = gst_caps_new_simple ("application/x-rtp", - "encoding-name", G_TYPE_STRING, "MULTIOPUS", NULL); + tempcaps = gst_static_caps_get (&multiopus_static_caps); if (!gst_caps_can_intersect (peercaps, tempcaps)) { GstCaps *opuscaps = gst_caps_new_simple ("audio/x-opus", "channel-mapping-family", G_TYPE_INT, 0, -- 2.7.4