{
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) {
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;
}