diff --git a/gst-libs/gst/rtp/gstrtpbasepayload.c b/gst-libs/gst/rtp/gstrtpbasepayload.c index bb86946d6d..8be9df36f3 100644 --- a/gst-libs/gst/rtp/gstrtpbasepayload.c +++ b/gst-libs/gst/rtp/gstrtpbasepayload.c @@ -1475,6 +1475,25 @@ gst_rtp_base_payload_negotiate (GstRTPBasePayload * payload) payload->priv->header_exts); g_ptr_array_foreach (to_add, (GFunc) add_item_to, payload->priv->header_exts); + /* let extensions update their internal state from sinkcaps */ + if (payload->priv->sinkcaps) { + gint i; + + for (i = 0; i < payload->priv->header_exts->len; i++) { + GstRTPHeaderExtension *ext; + + ext = g_ptr_array_index (payload->priv->header_exts, i); + if (!gst_rtp_header_extension_set_non_rtp_sink_caps (ext, + payload->priv->sinkcaps)) { + GST_WARNING_OBJECT (payload, + "Failed to update rtp header extension (%s) from sink caps", + GST_OBJECT_NAME (ext)); + res = FALSE; + GST_OBJECT_UNLOCK (payload); + goto ext_out; + } + } + } /* add extension information to srccaps */ g_ptr_array_foreach (payload->priv->header_exts, (GFunc) add_header_ext_to_caps, srccaps); diff --git a/gst-libs/gst/rtp/gstrtphdrext.c b/gst-libs/gst/rtp/gstrtphdrext.c index e3a908c46a..1988e4469d 100644 --- a/gst-libs/gst/rtp/gstrtphdrext.c +++ b/gst-libs/gst/rtp/gstrtphdrext.c @@ -394,6 +394,36 @@ gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext, return klass->set_attributes_from_caps (ext, caps); } +/** + * gst_rtp_header_extension_set_non_rtp_sink_caps: + * @ext: a #GstRTPHeaderExtension + * @caps: sink #GstCaps + * + * Passes RTP payloader's sink (i.e. not payloaded) @caps to the header + * extension. + * + * Returns: Whether @caps could be read successfully + * + * Since: 1.20 + */ +gboolean +gst_rtp_header_extension_set_non_rtp_sink_caps (GstRTPHeaderExtension * ext, + const GstCaps * caps) +{ + GstRTPHeaderExtensionClass *klass; + + g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); + g_return_val_if_fail (GST_IS_RTP_HEADER_EXTENSION (ext), FALSE); + g_return_val_if_fail (ext->ext_id <= MAX_RTP_EXT_ID, FALSE); + klass = GST_RTP_HEADER_EXTENSION_GET_CLASS (ext); + + if (klass->set_non_rtp_sink_caps) { + return klass->set_non_rtp_sink_caps (ext, caps); + } + + return TRUE; +} + /** * gst_rtp_header_extension_set_caps_from_attributes: * @ext: a #GstRTPHeaderExtension diff --git a/gst-libs/gst/rtp/gstrtphdrext.h b/gst-libs/gst/rtp/gstrtphdrext.h index 551ba306bc..1f0e9b1ca0 100644 --- a/gst-libs/gst/rtp/gstrtphdrext.h +++ b/gst-libs/gst/rtp/gstrtphdrext.h @@ -138,7 +138,9 @@ struct _GstRTPHeaderExtension * information is provided to help writing extensions in particular cases. * @read: read from a rtp payloaded buffer and extract the extension * information, optionally adding some meta onto the output buffer. - * @set_attributes_from_caps: read the caps information to set the necesary + * @set_non_rtp_sink_caps: read any information from sink caps that the header + * extension needs for its function. + * @set_attributes_from_caps: read the caps information to set the necessary * attributes that may be signaled e.g. with an SDP. * @set_caps_from_attributes: write the necessary caps field/s for the configured * attributes e.g. as signalled with SDP. @@ -169,6 +171,8 @@ struct _GstRTPHeaderExtensionClass const guint8 * data, gsize size, GstBuffer * buffer); + gboolean (*set_non_rtp_sink_caps) (GstRTPHeaderExtension * ext, + const GstCaps * caps); gboolean (*set_attributes_from_caps) (GstRTPHeaderExtension * ext, const GstCaps * caps); gboolean (*set_caps_from_attributes) (GstRTPHeaderExtension * ext, @@ -217,6 +221,9 @@ gboolean gst_rtp_header_extension_read (GstRTPHeaderExt gsize size, GstBuffer * buffer); GST_RTP_API +gboolean gst_rtp_header_extension_set_non_rtp_sink_caps (GstRTPHeaderExtension * ext, + const GstCaps * caps); +GST_RTP_API gboolean gst_rtp_header_extension_set_caps_from_attributes (GstRTPHeaderExtension * ext, GstCaps * caps); GST_RTP_API