From 975e1fecb3047212c06ffc4b1ab99c469a17b2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 1 Jun 2010 19:28:01 -0400 Subject: [PATCH] rtpsession: Add property for minimum interval between Regular RTCP messages This can be changed according to RFC 4585 --- gst/rtpmanager/gstrtpsession.c | 16 ++++++++++++++++ gst/rtpmanager/rtpsession.c | 14 ++++++++++++++ gst/rtpmanager/rtpstats.c | 6 ++++++ gst/rtpmanager/rtpstats.h | 3 +++ 4 files changed, 39 insertions(+) diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 751b7f8cce..f10ab92e65 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -199,6 +199,7 @@ enum #define DEFAULT_NUM_SOURCES 0 #define DEFAULT_NUM_ACTIVE_SOURCES 0 #define DEFAULT_USE_PIPELINE_CLOCK FALSE +#define DEFAULT_RTCP_MIN_INTERVAL (RTP_STATS_MIN_INTERVAL * GST_SECOND) enum { @@ -213,6 +214,7 @@ enum PROP_NUM_ACTIVE_SOURCES, PROP_INTERNAL_SESSION, PROP_USE_PIPELINE_CLOCK, + PROP_RTCP_MIN_INTERVAL, PROP_LAST }; @@ -588,6 +590,12 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass) DEFAULT_USE_PIPELINE_CLOCK, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_RTCP_MIN_INTERVAL, + g_param_spec_uint64 ("rtcp-min-interval", "Minimum RTCP interval", + "Minimum interval between Regular RTCP packet (in ns)", + 0, G_MAXUINT64, DEFAULT_RTCP_MIN_INTERVAL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_session_change_state); gstelement_class->request_new_pad = @@ -693,6 +701,10 @@ gst_rtp_session_set_property (GObject * object, guint prop_id, case PROP_USE_PIPELINE_CLOCK: priv->use_pipeline_clock = g_value_get_boolean (value); break; + case PROP_RTCP_MIN_INTERVAL: + g_object_set_property (G_OBJECT (priv->session), "rtcp-min-interval", + value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -745,6 +757,10 @@ gst_rtp_session_get_property (GObject * object, guint prop_id, case PROP_USE_PIPELINE_CLOCK: g_value_set_boolean (value, priv->use_pipeline_clock); break; + case PROP_RTCP_MIN_INTERVAL: + g_object_get_property (G_OBJECT (priv->session), "rtcp-min-interval", + value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 4b1513d180..43a4e2e54f 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -56,6 +56,7 @@ enum #define DEFAULT_NUM_SOURCES 0 #define DEFAULT_NUM_ACTIVE_SOURCES 0 #define DEFAULT_SOURCES NULL +#define DEFAULT_RTCP_MIN_INTERVAL (RTP_STATS_MIN_INTERVAL * GST_SECOND) enum { @@ -72,6 +73,7 @@ enum PROP_NUM_ACTIVE_SOURCES, PROP_SOURCES, PROP_FAVOR_NEW, + PROP_RTCP_MIN_INTERVAL, PROP_LAST }; @@ -360,6 +362,11 @@ rtp_session_class_init (RTPSessionClass * klass) "Resolve SSRC conflict in favor of new sources", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_RTCP_MIN_INTERVAL, + g_param_spec_uint64 ("rtcp-min-interval", "Minimum RTCP interval", + "Minimum interval between Regular RTCP packet (in ns)", + 0, G_MAXUINT64, DEFAULT_RTCP_MIN_INTERVAL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); klass->get_source_by_ssrc = GST_DEBUG_FUNCPTR (rtp_session_get_source_by_ssrc); @@ -505,6 +512,10 @@ rtp_session_set_property (GObject * object, guint prop_id, case PROP_FAVOR_NEW: sess->favor_new = g_value_get_boolean (value); break; + case PROP_RTCP_MIN_INTERVAL: + rtp_stats_set_min_interval (&sess->stats, + (gdouble) g_value_get_uint64 (value) / GST_SECOND); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -556,6 +567,9 @@ rtp_session_get_property (GObject * object, guint prop_id, case PROP_FAVOR_NEW: g_value_set_boolean (value, sess->favor_new); break; + case PROP_RTCP_MIN_INTERVAL: + g_value_set_uint64 (value, sess->stats.min_interval * GST_SECOND); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/rtpmanager/rtpstats.c b/gst/rtpmanager/rtpstats.c index a31e7e52ff..8fe1d1fce6 100644 --- a/gst/rtpmanager/rtpstats.c +++ b/gst/rtpmanager/rtpstats.c @@ -286,3 +286,9 @@ rtp_stats_get_packets_lost (const RTPSourceStats * stats) return lost; } + +void +rtp_stats_set_min_interval (RTPSessionStats * stats, gdouble min_interval) +{ + stats->min_interval = min_interval; +} diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h index d657cdfed0..643da004ab 100644 --- a/gst/rtpmanager/rtpstats.h +++ b/gst/rtpmanager/rtpstats.h @@ -195,4 +195,7 @@ GstClockTime rtp_stats_calculate_rtcp_interval (RTPSessionStats *stats, gbo GstClockTime rtp_stats_add_rtcp_jitter (RTPSessionStats *stats, GstClockTime interval); GstClockTime rtp_stats_calculate_bye_interval (RTPSessionStats *stats); gint64 rtp_stats_get_packets_lost (const RTPSourceStats *stats); + +void rtp_stats_set_min_interval (RTPSessionStats *stats, + gdouble min_interval); #endif /* __RTP_STATS_H__ */