diff options
author | Marc Leeman <m.leeman@televic.com> | 2020-07-03 12:25:31 +0200 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-12-04 14:51:38 +0000 |
commit | 102c60f82cb2ea60c484b60de91c24bf5a3d144c (patch) | |
tree | 6054f408870d7832c7d7006e13b2901e7c94b1a4 /gst | |
parent | 96831233a32d3b5bb036ddbe65ef307be5f2148c (diff) | |
download | gstreamer-plugins-bad-102c60f82cb2ea60c484b60de91c24bf5a3d144c.tar.gz |
rtpmanagerbad: allow setting caps on rtpsrc
rtpsrc tries to do a lookup of the caps based on the encoding-name. For
not so standard encodings, the caps can be set, avoiding the lookup.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1406>
Diffstat (limited to 'gst')
-rw-r--r-- | gst/rtp/gstrtpsrc.c | 43 | ||||
-rw-r--r-- | gst/rtp/gstrtpsrc.h | 1 |
2 files changed, 44 insertions, 0 deletions
diff --git a/gst/rtp/gstrtpsrc.c b/gst/rtp/gstrtpsrc.c index bd8253e3e..6dda142b0 100644 --- a/gst/rtp/gstrtpsrc.c +++ b/gst/rtp/gstrtpsrc.c @@ -59,6 +59,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_src_debug); #define DEFAULT_PROP_TTL 64 #define DEFAULT_PROP_TTL_MC 1 #define DEFAULT_PROP_ENCODING_NAME NULL +#define DEFAULT_PROP_CAPS NULL #define DEFAULT_PROP_LATENCY 200 #define DEFAULT_PROP_ADDRESS "0.0.0.0" @@ -78,6 +79,7 @@ enum PROP_ENCODING_NAME, PROP_LATENCY, PROP_MULTICAST_IFACE, + PROP_CAPS, PROP_LAST }; @@ -121,6 +123,12 @@ gst_rtp_src_rtpbin_request_pt_map_cb (GstElement * rtpbin, guint session_id, GST_DEBUG_OBJECT (self, "Requesting caps for session-id 0x%x and pt %u.", session_id, pt); + if (G_UNLIKELY (self->caps)) { + GST_DEBUG_OBJECT (self, + "Full caps were set, no need for lookup %" GST_PTR_FORMAT, self->caps); + return gst_caps_copy (self->caps); + } + /* the encoding-name has more relevant information */ if (self->encoding_name != NULL) { /* Unfortunately, the media needs to be passed in the function. Since @@ -231,6 +239,22 @@ gst_rtp_src_set_property (GObject * object, guint prop_id, else self->multi_iface = g_value_dup_string (value); break; + case PROP_CAPS: + { + const GstCaps *new_caps_val = gst_value_get_caps (value); + GstCaps *new_caps = NULL; + GstCaps *old_caps = self->caps; + + if (new_caps_val != NULL) { + new_caps = gst_caps_copy (new_caps_val); + } + + self->caps = new_caps; + + if (old_caps) + gst_caps_unref (old_caps); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -273,6 +297,9 @@ gst_rtp_src_get_property (GObject * object, guint prop_id, case PROP_MULTICAST_IFACE: g_value_set_string (value, self->multi_iface); break; + case PROP_CAPS: + gst_value_set_caps (value, self->caps); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -290,6 +317,9 @@ gst_rtp_src_finalize (GObject * gobject) g_free (self->multi_iface); + if (self->caps) + gst_caps_unref (self->caps); + g_mutex_clear (&self->lock); G_OBJECT_CLASS (parent_class)->finalize (gobject); } @@ -413,6 +443,18 @@ gst_rtp_src_class_init (GstRtpSrcClass * klass) DEFAULT_PROP_MULTICAST_IFACE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GstRtpSrc:caps: + * + * The RTP caps of the incoming stream. + * + * Since: 1.20 + */ + g_object_class_install_property (gobject_class, PROP_CAPS, + g_param_spec_boxed ("caps", "Caps", + "The caps of the incoming stream", GST_TYPE_CAPS, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&src_template)); @@ -753,6 +795,7 @@ gst_rtp_src_init (GstRtpSrc * self) self->ttl = DEFAULT_PROP_TTL; self->ttl_mc = DEFAULT_PROP_TTL_MC; self->encoding_name = DEFAULT_PROP_ENCODING_NAME; + self->caps = DEFAULT_PROP_CAPS; GST_OBJECT_FLAG_SET (GST_OBJECT (self), GST_ELEMENT_FLAG_SOURCE); gst_bin_set_suppressed_flags (GST_BIN (self), diff --git a/gst/rtp/gstrtpsrc.h b/gst/rtp/gstrtpsrc.h index 6af4a5b2a..ad773d9f4 100644 --- a/gst/rtp/gstrtpsrc.h +++ b/gst/rtp/gstrtpsrc.h @@ -51,6 +51,7 @@ struct _GstRtpSrc gint ttl_mc; gchar *encoding_name; gchar *multi_iface; + GstCaps *caps; /* Internal elements */ GstElement *rtpbin; |