mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
rtpopuspay: make use of gst_rtp_base_payload_set_outcaps_structure()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/832>
This commit is contained in:
parent
45d105bea2
commit
8b4147c757
1 changed files with 13 additions and 24 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue