From: <wt...@ke...> - 2007-04-25 16:38:22
|
CVS Root: /cvs/gstreamer Module: gst-plugins-bad Changes by: wtay Date: Wed Apr 25 2007 16:38:15 UTC Log message: * gst/rtpmanager/gstrtpsession.c: (rtcp_thread): Implement forward and reverse reconsideration. * gst/rtpmanager/rtpsession.c: (rtp_session_get_num_sources), (rtp_session_get_num_active_sources), (rtp_session_process_sr), (session_report_blocks): * gst/rtpmanager/rtpsession.h: Small cleanups. Modified files: . : ChangeLog gst/rtpmanager : gstrtpsession.c rtpsession.c rtpsession.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.2514&r2=1.2515 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpsession.c.diff?r1=1.6&r2=1.7 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/rtpmanager/rtpsession.c.diff?r1=1.4&r2=1.5 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/rtpmanager/rtpsession.h.diff?r1=1.2&r2=1.3 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v retrieving revision 1.2514 retrieving revision 1.2515 diff -u -d -r1.2514 -r1.2515 --- ChangeLog 25 Apr 2007 15:48:46 -0000 1.2514 +++ ChangeLog 25 Apr 2007 16:38:03 -0000 1.2515 @@ -1,5 +1,16 @@ 2007-04-25 Wim Taymans <wi...@fl...> + * gst/rtpmanager/gstrtpsession.c: (rtcp_thread): + Implement forward and reverse reconsideration. + + * gst/rtpmanager/rtpsession.c: (rtp_session_get_num_sources), + (rtp_session_get_num_active_sources), (rtp_session_process_sr), + (session_report_blocks): + * gst/rtpmanager/rtpsession.h: + Small cleanups. +2007-04-25 Wim Taymans <wi...@fl...> reviewed by: <delete if not using a buddy> * gst/rtpmanager/gstrtpbin.c: (create_stream), Index: gstrtpsession.c RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpsession.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gstrtpsession.c 25 Apr 2007 13:19:36 -0000 1.6 +++ gstrtpsession.c 25 Apr 2007 16:38:03 -0000 1.7 @@ -293,6 +293,13 @@ { GstClock *clock; GstClockID id; + gdouble interval; + GstClockTime current_time; + GstClockTime next_rtcp_check_time; + GstClockTime new_rtcp_send_time; + GstClockTime last_rtcp_send_time; + GstClockTimeDiff jitter; + guint members, prev_members; clock = gst_element_get_clock (GST_ELEMENT_CAST (rtpsession)); if (clock == NULL) @@ -301,34 +308,83 @@ GST_DEBUG_OBJECT (rtpsession, "entering RTCP thread"); GST_RTP_SESSION_LOCK (rtpsession); + /* get initial estimate */ + interval = rtp_session_get_reporting_interval (rtpsession->priv->session); + current_time = gst_clock_get_time (clock); + last_rtcp_send_time = current_time; + next_rtcp_check_time = current_time + (GST_SECOND * interval); + /* we keep track of members before and after the timeout to do reverse + * reconsideration. */ + prev_members = rtp_session_get_num_active_sources (rtpsession->priv->session); + GST_DEBUG_OBJECT (rtpsession, "first RTCP interval: %lf seconds", interval); while (!rtpsession->priv->stop_thread) { - gdouble timeout; - GstClockTime target; GstClockReturn res; - timeout = rtp_session_get_reporting_interval (rtpsession->priv->session); - GST_DEBUG_OBJECT (rtpsession, "next RTCP timeout: %lf", timeout); + GST_DEBUG_OBJECT (rtpsession, "next check time %" GST_TIME_FORMAT, + GST_TIME_ARGS (next_rtcp_check_time)); - target = gst_clock_get_time (clock); - target += GST_SECOND * timeout; + id = rtpsession->priv->id = + gst_clock_new_single_shot_id (clock, next_rtcp_check_time); + GST_RTP_SESSION_UNLOCK (rtpsession); + res = gst_clock_id_wait (id, &jitter); - id = rtpsession->priv->id = gst_clock_new_single_shot_id (clock, target); - GST_RTP_SESSION_UNLOCK (rtpsession); + GST_RTP_SESSION_LOCK (rtpsession); + gst_clock_id_unref (id); + rtpsession->priv->id = NULL; - res = gst_clock_id_wait (id, NULL); - if (res != GST_CLOCK_UNSCHEDULED) { - GST_DEBUG_OBJECT (rtpsession, "got RTCP timeout"); + if (rtpsession->priv->stop_thread) + break; + if (res != GST_CLOCK_UNSCHEDULED) + if (jitter < 0) + current_time = next_rtcp_check_time; + else + current_time = next_rtcp_check_time - jitter; + else + current_time = gst_clock_get_time (clock); + GST_DEBUG_OBJECT (rtpsession, "unlocked %d, jitter %" G_GINT64_FORMAT + ", current %" GST_TIME_FORMAT, res, jitter, + GST_TIME_ARGS (current_time)); + members = rtp_session_get_num_active_sources (rtpsession->priv->session); + if (members < prev_members) { + GstClockTime time_remaining; + /* some members went away */ + GST_DEBUG_OBJECT (rtpsession, "reverse reconsideration"); + time_remaining = next_rtcp_check_time - current_time; + new_rtcp_send_time = + current_time + (time_remaining * members / prev_members); + } else { + interval = rtp_session_get_reporting_interval (rtpsession->priv->session); + GST_DEBUG_OBJECT (rtpsession, "forward reconsideration: %lf seconds", + interval); + new_rtcp_send_time = (interval * GST_SECOND) + last_rtcp_send_time; + } + prev_members = members; + if (current_time >= new_rtcp_send_time) { + GST_DEBUG_OBJECT (rtpsession, "sending RTCP now"); /* make the session manager produce RTCP, we ignore the result. */ rtp_session_perform_reporting (rtpsession->priv->session); + GST_DEBUG_OBJECT (rtpsession, "next RTCP interval: %lf seconds", + next_rtcp_check_time = (interval * GST_SECOND) + current_time; + last_rtcp_send_time = current_time; } else { - GST_DEBUG_OBJECT (rtpsession, "got unscheduled"); + GST_DEBUG_OBJECT (rtpsession, "reconsider RTCP"); + next_rtcp_check_time = new_rtcp_send_time; } - - GST_RTP_SESSION_LOCK (rtpsession); - gst_clock_id_unref (id); - rtpsession->priv->id = NULL; } GST_RTP_SESSION_UNLOCK (rtpsession); Index: rtpsession.c RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/rtpsession.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- rtpsession.c 25 Apr 2007 13:19:36 -0000 1.4 +++ rtpsession.c 25 Apr 2007 16:38:03 -0000 1.5 @@ -703,10 +703,10 @@ * * Returns: The number of sources in @sess. */ -gint +guint rtp_session_get_num_sources (RTPSession * sess) - gint result; + guint result; g_return_val_if_fail (RTP_IS_SESSION (sess), FALSE); @@ -726,12 +726,12 @@ * Returns: The number of active sources in @sess. rtp_session_get_num_active_sources (RTPSession * sess) - g_return_val_if_fail (RTP_IS_SESSION (sess), FALSE); + g_return_val_if_fail (RTP_IS_SESSION (sess), 0); RTP_SESSION_LOCK (sess); result = sess->stats.active_sources; Index: rtpsession.h RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/rtpsession.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- rtpsession.h 25 Apr 2007 08:30:47 -0000 1.2 +++ rtpsession.h 25 Apr 2007 16:38:03 -0000 1.3 @@ -216,8 +216,8 @@ /* handling sources */ gboolean rtp_session_add_source (RTPSession *sess, RTPSource *src); -gint rtp_session_get_num_sources (RTPSession *sess); -gint rtp_session_get_num_active_sources (RTPSession *sess); +guint rtp_session_get_num_sources (RTPSession *sess); +guint rtp_session_get_num_active_sources (RTPSession *sess); RTPSource* rtp_session_get_source_by_ssrc (RTPSession *sess, guint32 ssrc); RTPSource* rtp_session_get_source_by_cname (RTPSession *sess, const gchar *cname); RTPSource* rtp_session_create_source (RTPSession *sess); |