rtpsession: Implement reset

Reset RTPSession when rtpsession changes state from PAUSED to READY.
Without this change, a stored last_rtptime in RTPSource could interfere
with RTP timestamp generation in RTCP Sender Report.

Fixes #510
This commit is contained in:
Linus Svensson 2018-10-16 12:38:46 +02:00 committed by Nicolas Dufresne
parent ac94c706da
commit 8fc8b7ee33
4 changed files with 46 additions and 1 deletions

View file

@ -1270,6 +1270,7 @@ gst_rtp_session_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_READY:
/* downstream is now releasing the dataflow and we can join. */
join_rtcp_thread (rtpsession);
rtp_session_reset (rtpsession->priv->session);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;

View file

@ -1060,6 +1060,47 @@ rtp_session_new (void)
return sess;
}
/**
* rtp_session_reset:
* @sess: an #RTPSession
*
* Reset the sources of @sess.
*/
void
rtp_session_reset (RTPSession * sess)
{
g_return_if_fail (RTP_IS_SESSION (sess));
/* remove all sources */
g_hash_table_remove_all (sess->ssrcs[sess->mask_idx]);
sess->total_sources = 0;
sess->stats.sender_sources = 0;
sess->stats.internal_sender_sources = 0;
sess->stats.internal_sources = 0;
sess->stats.active_sources = 0;
sess->generation = 0;
sess->first_rtcp = TRUE;
sess->next_rtcp_check_time = GST_CLOCK_TIME_NONE;
sess->last_rtcp_check_time = GST_CLOCK_TIME_NONE;
sess->last_rtcp_send_time = GST_CLOCK_TIME_NONE;
sess->last_rtcp_interval = GST_CLOCK_TIME_NONE;
sess->next_early_rtcp_time = GST_CLOCK_TIME_NONE;
sess->scheduled_bye = FALSE;
/* reset session stats */
sess->stats.bye_members = 0;
sess->stats.nacks_dropped = 0;
sess->stats.nacks_sent = 0;
sess->stats.nacks_received = 0;
sess->is_doing_ptp = TRUE;
g_list_free_full (sess->conflicting_addresses,
(GDestroyNotify) rtp_conflicting_address_free);
sess->conflicting_addresses = NULL;
}
/**
* rtp_session_set_callbacks:
* @sess: an #RTPSession

View file

@ -334,6 +334,7 @@ GType rtp_session_get_type (void);
/* create and configure */
RTPSession* rtp_session_new (void);
void rtp_session_reset (RTPSession *sess);
void rtp_session_set_callbacks (RTPSession *sess,
RTPSessionCallbacks *callbacks,
gpointer user_data);

View file

@ -255,6 +255,9 @@ rtp_source_reset (RTPSource * src)
src->bye_reason = NULL;
src->sent_bye = FALSE;
g_hash_table_remove_all (src->reported_in_sr_of);
g_queue_foreach (src->retained_feedback, (GFunc) gst_buffer_unref, NULL);
g_queue_clear (src->retained_feedback);
src->last_rtptime = -1;
src->stats.cycles = -1;
src->stats.jitter = 0;
@ -294,7 +297,6 @@ rtp_source_init (RTPSource * src)
src->clock_rate = -1;
src->packets = g_queue_new ();
src->seqnum_offset = -1;
src->last_rtptime = -1;
src->retained_feedback = g_queue_new ();
src->nacks = g_array_new (FALSE, FALSE, sizeof (guint32));