diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2007-04-27 15:09:12 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-08-11 02:30:26 +0100 |
commit | a7b80281d1af025bde9fba40c5eee798a00f2f21 (patch) | |
tree | cec18995d9eaf6ecd4215c9cd88a7e5697512f05 /gst/rtpmanager/gstrtpsession.c | |
parent | 43f0b878c9acd2314bf9a9f260e15ef77169e778 (diff) |
gst/rtpmanager/gstrtpsession.c: Move reconsideration code to the rtpsession object.
Original commit message from CVS:
* gst/rtpmanager/gstrtpsession.c: (rtcp_thread),
(gst_rtp_session_send_rtcp), (gst_rtp_session_reconsider):
Move reconsideration code to the rtpsession object.
Simplify timout handling and add reconsideration.
* gst/rtpmanager/rtpsession.c: (rtp_session_class_init),
(rtp_session_init), (rtp_session_finalize), (on_bye_ssrc),
(on_bye_timeout), (on_timeout), (rtp_session_set_callbacks),
(obtain_source), (rtp_session_create_source),
(update_arrival_stats), (rtp_session_process_rtp),
(rtp_session_process_sr), (rtp_session_process_rr),
(rtp_session_process_bye), (rtp_session_process_rtcp),
(calculate_rtcp_interval), (rtp_session_send_bye),
(rtp_session_next_timeout), (session_start_rtcp),
(session_report_blocks), (session_cleanup), (session_sdes),
(session_bye), (is_rtcp_time), (rtp_session_on_timeout):
* gst/rtpmanager/rtpsession.h:
Handle timeout of inactive sources and senders.
Implement BYE scheduling.
* gst/rtpmanager/rtpsource.c: (calculate_jitter),
(rtp_source_process_sr), (rtp_source_get_last_sr),
(rtp_source_get_last_rb):
* gst/rtpmanager/rtpsource.h:
Add members to check for timeouts.
* gst/rtpmanager/rtpstats.c: (rtp_stats_init_defaults),
(rtp_stats_calculate_rtcp_interval), (rtp_stats_add_rtcp_jitter),
(rtp_stats_calculate_bye_interval):
* gst/rtpmanager/rtpstats.h:
Use RFC algorithm for calculating the reporting interval.
Diffstat (limited to 'gst/rtpmanager/gstrtpsession.c')
-rw-r--r-- | gst/rtpmanager/gstrtpsession.c | 112 |
1 files changed, 45 insertions, 67 deletions
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index bc297235..9545a92d 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -144,13 +144,15 @@ static gint gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload, gpointer user_data); static GstClockTime gst_rtp_session_get_time (RTPSession * sess, gpointer user_data); +static void gst_rtp_session_reconsider (RTPSession * sess, gpointer user_data); static RTPSessionCallbacks callbacks = { gst_rtp_session_process_rtp, gst_rtp_session_send_rtp, gst_rtp_session_send_rtcp, gst_rtp_session_clock_rate, - gst_rtp_session_get_time + gst_rtp_session_get_time, + gst_rtp_session_reconsider }; /* GObject vmethods */ @@ -293,44 +295,39 @@ rtcp_thread (GstRTPSession * rtpsession) { 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; + GstClockTime next_timeout; clock = gst_element_get_clock (GST_ELEMENT_CAST (rtpsession)); if (clock == NULL) return; + current_time = gst_clock_get_time (clock); + 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) { GstClockReturn res; + /* get initial estimate */ + next_timeout = + rtp_session_next_timeout (rtpsession->priv->session, current_time); + + GST_DEBUG_OBJECT (rtpsession, "next check time %" GST_TIME_FORMAT, - GST_TIME_ARGS (next_rtcp_check_time)); + GST_TIME_ARGS (next_timeout)); + + /* leave if no more timeouts, the session ended */ + if (next_timeout == GST_CLOCK_TIME_NONE) + break; id = rtpsession->priv->id = - gst_clock_new_single_shot_id (clock, next_rtcp_check_time); + gst_clock_new_single_shot_id (clock, next_timeout); GST_RTP_SESSION_UNLOCK (rtpsession); - res = gst_clock_id_wait (id, &jitter); + res = gst_clock_id_wait (id, NULL); GST_RTP_SESSION_LOCK (rtpsession); gst_clock_id_unref (id); @@ -339,52 +336,16 @@ rtcp_thread (GstRTPSession * rtpsession) 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); - - interval = rtp_session_get_reporting_interval (rtpsession->priv->session); - - GST_DEBUG_OBJECT (rtpsession, "next RTCP interval: %lf seconds", - interval); - next_rtcp_check_time = (interval * GST_SECOND) + current_time; - last_rtcp_send_time = current_time; - } else { - GST_DEBUG_OBJECT (rtpsession, "reconsider RTCP"); - next_rtcp_check_time = new_rtcp_send_time; - } + /* update current time */ + current_time = gst_clock_get_time (clock); + + /* we get unlocked because we need to perform reconsideration, don't perform + * the timeout but get a new reporting estimate. */ + GST_DEBUG_OBJECT (rtpsession, "unlocked %d, current %" GST_TIME_FORMAT, + res, GST_TIME_ARGS (current_time)); + + /* perform actions, we ignore result. */ + rtp_session_on_timeout (rtpsession->priv->session, current_time); } GST_RTP_SESSION_UNLOCK (rtpsession); @@ -536,6 +497,8 @@ gst_rtp_session_send_rtcp (RTPSession * sess, RTPSource * src, GST_DEBUG_OBJECT (rtpsession, "sending RTCP"); + gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); + if (rtpsession->send_rtcp_src) { result = gst_pad_push (rtpsession->send_rtcp_src, buffer); } else { @@ -616,6 +579,21 @@ gst_rtp_session_get_time (RTPSession * sess, gpointer user_data) return result; } +/* called when the session manager asks us to reconsider the timeout */ +static void +gst_rtp_session_reconsider (RTPSession * sess, gpointer user_data) +{ + GstRTPSession *rtpsession; + + rtpsession = GST_RTP_SESSION_CAST (user_data); + + GST_RTP_SESSION_LOCK (rtpsession); + GST_DEBUG_OBJECT (rtpsession, "unlock timer for reconsideration"); + if (rtpsession->priv->id) + gst_clock_id_unschedule (rtpsession->priv->id); + GST_RTP_SESSION_UNLOCK (rtpsession); +} + static GstFlowReturn gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event) { |