mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
rtpbasepayload: pass optional caps fields in a GstStructure
For more flexibility, allow to pass the extra output caps fields as a GstStructure. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/952>
This commit is contained in:
parent
cc8f54468e
commit
6434db5298
2 changed files with 58 additions and 15 deletions
|
@ -891,6 +891,51 @@ update_max_ptime (GstRTPBasePayload * rtpbasepayload)
|
|||
rtpbasepayload->max_ptime = DEFAULT_MAX_PTIME;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_caps (GQuark field_id, const GValue * value, GstCaps * caps)
|
||||
{
|
||||
gst_caps_set_value (caps, g_quark_to_string (field_id), value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtp_base_payload_set_outcaps_structure:
|
||||
* @payload: a #GstRTPBasePayload
|
||||
* @s: (nullable): a #GstStructure with the caps fields
|
||||
*
|
||||
* Configure the output caps with the optional fields.
|
||||
*
|
||||
* Returns: %TRUE if the caps could be set.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
gboolean
|
||||
gst_rtp_base_payload_set_outcaps_structure (GstRTPBasePayload * payload,
|
||||
GstStructure * s)
|
||||
{
|
||||
GstCaps *srccaps;
|
||||
|
||||
/* fill in the defaults, their properties cannot be negotiated. */
|
||||
srccaps = gst_caps_new_simple ("application/x-rtp",
|
||||
"media", G_TYPE_STRING, payload->media,
|
||||
"clock-rate", G_TYPE_INT, payload->clock_rate,
|
||||
"encoding-name", G_TYPE_STRING, payload->encoding_name, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (payload, "defaults: %" GST_PTR_FORMAT, srccaps);
|
||||
|
||||
if (s && gst_structure_n_fields (s) > 0) {
|
||||
gst_structure_foreach (s, (GstStructureForeachFunc) _set_caps, srccaps);
|
||||
|
||||
GST_DEBUG_OBJECT (payload, "custom added: %" GST_PTR_FORMAT, srccaps);
|
||||
}
|
||||
|
||||
gst_caps_replace (&payload->priv->subclass_srccaps, srccaps);
|
||||
gst_caps_unref (srccaps);
|
||||
|
||||
return gst_rtp_base_payload_negotiate (payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtp_base_payload_set_outcaps:
|
||||
* @payload: a #GstRTPBasePayload
|
||||
|
@ -908,31 +953,25 @@ gboolean
|
|||
gst_rtp_base_payload_set_outcaps (GstRTPBasePayload * payload,
|
||||
const gchar * fieldname, ...)
|
||||
{
|
||||
GstCaps *srccaps;
|
||||
|
||||
/* fill in the defaults, their properties cannot be negotiated. */
|
||||
srccaps = gst_caps_new_simple ("application/x-rtp",
|
||||
"media", G_TYPE_STRING, payload->media,
|
||||
"clock-rate", G_TYPE_INT, payload->clock_rate,
|
||||
"encoding-name", G_TYPE_STRING, payload->encoding_name, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (payload, "defaults: %" GST_PTR_FORMAT, srccaps);
|
||||
gboolean result;
|
||||
GstStructure *s = NULL;
|
||||
|
||||
if (fieldname) {
|
||||
va_list varargs;
|
||||
|
||||
s = gst_structure_new_empty ("unused");
|
||||
|
||||
/* override with custom properties */
|
||||
va_start (varargs, fieldname);
|
||||
gst_caps_set_simple_valist (srccaps, fieldname, varargs);
|
||||
gst_structure_set_valist (s, fieldname, varargs);
|
||||
va_end (varargs);
|
||||
|
||||
GST_DEBUG_OBJECT (payload, "custom added: %" GST_PTR_FORMAT, srccaps);
|
||||
}
|
||||
|
||||
gst_caps_replace (&payload->priv->subclass_srccaps, srccaps);
|
||||
gst_caps_unref (srccaps);
|
||||
result = gst_rtp_base_payload_set_outcaps_structure (payload, s);
|
||||
|
||||
return gst_rtp_base_payload_negotiate (payload);
|
||||
gst_clear_structure (&s);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -160,6 +160,10 @@ GST_RTP_API
|
|||
gboolean gst_rtp_base_payload_set_outcaps (GstRTPBasePayload *payload,
|
||||
const gchar *fieldname, ...);
|
||||
|
||||
GST_RTP_API
|
||||
gboolean gst_rtp_base_payload_set_outcaps_structure (GstRTPBasePayload *payload,
|
||||
GstStructure *s);
|
||||
|
||||
GST_RTP_API
|
||||
gboolean gst_rtp_base_payload_is_filled (GstRTPBasePayload *payload,
|
||||
guint size, GstClockTime duration);
|
||||
|
|
Loading…
Reference in a new issue