diff --git a/gst/rtp/gstrtpopuspay.c b/gst/rtp/gstrtpopuspay.c index 871a18248e..48a454e470 100644 --- a/gst/rtp/gstrtpopuspay.c +++ b/gst/rtp/gstrtpopuspay.c @@ -101,11 +101,11 @@ gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; GstCaps *src_caps; - GstStructure *s; + GstStructure *s, *outcaps; const char *encoding_name = "OPUS"; gint channels, rate; - const char *sprop_stereo = NULL; - char *sprop_maxcapturerate = NULL; + + outcaps = gst_structure_new_empty ("unused"); src_caps = gst_pad_get_allowed_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload)); if (src_caps) { @@ -133,38 +133,27 @@ gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) GST_ERROR_OBJECT (payload, "More than 2 channels with channel-mapping-family=0 is invalid"); return FALSE; - } else if (channels == 2) { - sprop_stereo = "1"; } else { - sprop_stereo = "0"; + gst_structure_set (outcaps, "sprop-stereo", G_TYPE_STRING, + (channels == 2) ? "1" : "0", NULL); } } if (gst_structure_get_int (s, "rate", &rate)) { - sprop_maxcapturerate = g_strdup_printf ("%d", rate); + gchar *sprop_maxcapturerate = g_strdup_printf ("%d", rate); + + gst_structure_set (outcaps, "sprop-maxcapturerate", G_TYPE_STRING, + sprop_maxcapturerate, NULL); + + g_free (sprop_maxcapturerate); } gst_rtp_base_payload_set_options (payload, "audio", FALSE, encoding_name, 48000); - if (sprop_maxcapturerate && sprop_stereo) { - res = - gst_rtp_base_payload_set_outcaps (payload, "sprop-maxcapturerate", - G_TYPE_STRING, sprop_maxcapturerate, "sprop-stereo", G_TYPE_STRING, - sprop_stereo, NULL); - } else if (sprop_maxcapturerate) { - res = - gst_rtp_base_payload_set_outcaps (payload, "sprop-maxcapturerate", - G_TYPE_STRING, sprop_maxcapturerate, NULL); - } else if (sprop_stereo) { - res = - gst_rtp_base_payload_set_outcaps (payload, "sprop-stereo", - G_TYPE_STRING, sprop_stereo, NULL); - } else { - res = gst_rtp_base_payload_set_outcaps (payload, NULL); - } + res = gst_rtp_base_payload_set_outcaps_structure (payload, outcaps); - g_free (sprop_maxcapturerate); + gst_structure_free (outcaps); return res; }