mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
rtpbin: remove more ntpnstime and cleanups
Remove some code where we pass ntpnstime around, we can do most things with the running_time just fine. Rename a variable in the ArrivalStats struct so that it's clear that this is the current system time.
This commit is contained in:
parent
74241e549f
commit
5a4ecc9da1
4 changed files with 25 additions and 31 deletions
|
@ -1341,7 +1341,6 @@ gst_rtp_session_chain_recv_rtp (GstPad * pad, GstBuffer * buffer)
|
||||||
GstRtpSessionPrivate *priv;
|
GstRtpSessionPrivate *priv;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstClockTime current_time, running_time;
|
GstClockTime current_time, running_time;
|
||||||
guint64 ntpnstime;
|
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
|
||||||
rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
|
rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
|
||||||
|
@ -1356,15 +1355,13 @@ gst_rtp_session_chain_recv_rtp (GstPad * pad, GstBuffer * buffer)
|
||||||
running_time =
|
running_time =
|
||||||
gst_segment_to_running_time (&rtpsession->recv_rtp_seg, GST_FORMAT_TIME,
|
gst_segment_to_running_time (&rtpsession->recv_rtp_seg, GST_FORMAT_TIME,
|
||||||
timestamp);
|
timestamp);
|
||||||
/* add constant to convert running time to NTP time */
|
|
||||||
ntpnstime = running_time + priv->ntpnsbase;
|
|
||||||
} else {
|
} else {
|
||||||
get_current_times (rtpsession, &running_time, &ntpnstime);
|
get_current_times (rtpsession, &running_time, NULL);
|
||||||
}
|
}
|
||||||
current_time = gst_clock_get_time (priv->sysclock);
|
current_time = gst_clock_get_time (priv->sysclock);
|
||||||
|
|
||||||
ret = rtp_session_process_rtp (priv->session, buffer, current_time,
|
ret = rtp_session_process_rtp (priv->session, buffer, current_time,
|
||||||
running_time, ntpnstime);
|
running_time);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto push_error;
|
goto push_error;
|
||||||
|
|
||||||
|
|
|
@ -994,7 +994,7 @@ find_add_conflicting_addresses (RTPSession * sess, RTPArrivalStats * arrival)
|
||||||
RTPConflictingAddress *known_conflict = item->data;
|
RTPConflictingAddress *known_conflict = item->data;
|
||||||
|
|
||||||
if (gst_netaddress_equal (&arrival->address, &known_conflict->address)) {
|
if (gst_netaddress_equal (&arrival->address, &known_conflict->address)) {
|
||||||
known_conflict->time = arrival->time;
|
known_conflict->time = arrival->current_time;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1002,7 @@ find_add_conflicting_addresses (RTPSession * sess, RTPArrivalStats * arrival)
|
||||||
new_conflict = g_new0 (RTPConflictingAddress, 1);
|
new_conflict = g_new0 (RTPConflictingAddress, 1);
|
||||||
|
|
||||||
memcpy (&new_conflict->address, &arrival->address, sizeof (GstNetAddress));
|
memcpy (&new_conflict->address, &arrival->address, sizeof (GstNetAddress));
|
||||||
new_conflict->time = arrival->time;
|
new_conflict->time = arrival->current_time;
|
||||||
|
|
||||||
sess->conflicting_addresses = g_list_prepend (sess->conflicting_addresses,
|
sess->conflicting_addresses = g_list_prepend (sess->conflicting_addresses,
|
||||||
new_conflict);
|
new_conflict);
|
||||||
|
@ -1065,7 +1065,8 @@ check_collision (RTPSession * sess, RTPSource * source,
|
||||||
GST_DEBUG ("Collision for SSRC %x", rtp_source_get_ssrc (source));
|
GST_DEBUG ("Collision for SSRC %x", rtp_source_get_ssrc (source));
|
||||||
on_ssrc_collision (sess, source);
|
on_ssrc_collision (sess, source);
|
||||||
|
|
||||||
rtp_session_schedule_bye_locked (sess, "SSRC Collision", arrival->time);
|
rtp_session_schedule_bye_locked (sess, "SSRC Collision",
|
||||||
|
arrival->current_time);
|
||||||
|
|
||||||
sess->change_ssrc = TRUE;
|
sess->change_ssrc = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1122,9 +1123,9 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* update last activity */
|
/* update last activity */
|
||||||
source->last_activity = arrival->time;
|
source->last_activity = arrival->current_time;
|
||||||
if (rtp)
|
if (rtp)
|
||||||
source->last_rtp_activity = arrival->time;
|
source->last_rtp_activity = arrival->current_time;
|
||||||
g_object_ref (source);
|
g_object_ref (source);
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
|
@ -1390,12 +1391,11 @@ rtp_session_create_source (RTPSession * sess)
|
||||||
static void
|
static void
|
||||||
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
|
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
|
||||||
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
|
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
|
||||||
GstClockTime running_time, guint64 ntpnstime)
|
GstClockTime running_time)
|
||||||
{
|
{
|
||||||
/* get time of arrival */
|
/* get time of arrival */
|
||||||
arrival->time = current_time;
|
arrival->current_time = current_time;
|
||||||
arrival->running_time = running_time;
|
arrival->running_time = running_time;
|
||||||
arrival->ntpnstime = ntpnstime;
|
|
||||||
|
|
||||||
/* get packet size including header overhead */
|
/* get packet size including header overhead */
|
||||||
arrival->bytes = GST_BUFFER_SIZE (buffer) + sess->header_len;
|
arrival->bytes = GST_BUFFER_SIZE (buffer) + sess->header_len;
|
||||||
|
@ -1420,7 +1420,6 @@ update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
|
||||||
* @sess: and #RTPSession
|
* @sess: and #RTPSession
|
||||||
* @buffer: an RTP buffer
|
* @buffer: an RTP buffer
|
||||||
* @current_time: the current system time
|
* @current_time: the current system time
|
||||||
* @ntpnstime: the NTP arrival time in nanoseconds
|
|
||||||
*
|
*
|
||||||
* Process an RTP buffer in the session manager. This function takes ownership
|
* Process an RTP buffer in the session manager. This function takes ownership
|
||||||
* of @buffer.
|
* of @buffer.
|
||||||
|
@ -1429,7 +1428,7 @@ update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
|
||||||
*/
|
*/
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
||||||
GstClockTime current_time, GstClockTime running_time, guint64 ntpnstime)
|
GstClockTime current_time, GstClockTime running_time)
|
||||||
{
|
{
|
||||||
GstFlowReturn result;
|
GstFlowReturn result;
|
||||||
guint32 ssrc;
|
guint32 ssrc;
|
||||||
|
@ -1449,7 +1448,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
||||||
RTP_SESSION_LOCK (sess);
|
RTP_SESSION_LOCK (sess);
|
||||||
/* update arrival stats */
|
/* update arrival stats */
|
||||||
update_arrival_stats (sess, &arrival, TRUE, buffer, current_time,
|
update_arrival_stats (sess, &arrival, TRUE, buffer, current_time,
|
||||||
running_time, ntpnstime);
|
running_time);
|
||||||
|
|
||||||
/* ignore more RTP packets when we left the session */
|
/* ignore more RTP packets when we left the session */
|
||||||
if (sess->source->received_bye)
|
if (sess->source->received_bye)
|
||||||
|
@ -1567,8 +1566,8 @@ rtp_session_process_rb (RTPSession * sess, RTPSource * source,
|
||||||
/* only deal with report blocks for our session, we update the stats of
|
/* only deal with report blocks for our session, we update the stats of
|
||||||
* the sender of the RTCP message. We could also compare our stats against
|
* the sender of the RTCP message. We could also compare our stats against
|
||||||
* the other sender to see if we are better or worse. */
|
* the other sender to see if we are better or worse. */
|
||||||
rtp_source_process_rb (source, arrival->time, fractionlost, packetslost,
|
rtp_source_process_rb (source, arrival->current_time, fractionlost,
|
||||||
exthighestseq, jitter, lsr, dlsr);
|
packetslost, exthighestseq, jitter, lsr, dlsr);
|
||||||
|
|
||||||
on_ssrc_active (sess, source);
|
on_ssrc_active (sess, source);
|
||||||
}
|
}
|
||||||
|
@ -1597,7 +1596,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
||||||
&packet_count, &octet_count);
|
&packet_count, &octet_count);
|
||||||
|
|
||||||
GST_DEBUG ("got SR packet: SSRC %08x, time %" GST_TIME_FORMAT,
|
GST_DEBUG ("got SR packet: SSRC %08x, time %" GST_TIME_FORMAT,
|
||||||
senderssrc, GST_TIME_ARGS (arrival->time));
|
senderssrc, GST_TIME_ARGS (arrival->current_time));
|
||||||
|
|
||||||
source = obtain_source (sess, senderssrc, &created, arrival, FALSE);
|
source = obtain_source (sess, senderssrc, &created, arrival, FALSE);
|
||||||
if (!source)
|
if (!source)
|
||||||
|
@ -1612,8 +1611,8 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
||||||
prevsender = RTP_SOURCE_IS_SENDER (source);
|
prevsender = RTP_SOURCE_IS_SENDER (source);
|
||||||
|
|
||||||
/* first update the source */
|
/* first update the source */
|
||||||
rtp_source_process_sr (source, arrival->time, ntptime, rtptime, packet_count,
|
rtp_source_process_sr (source, arrival->current_time, ntptime, rtptime,
|
||||||
octet_count);
|
packet_count, octet_count);
|
||||||
|
|
||||||
if (prevsender != RTP_SOURCE_IS_SENDER (source)) {
|
if (prevsender != RTP_SOURCE_IS_SENDER (source)) {
|
||||||
sess->stats.sender_sources++;
|
sess->stats.sender_sources++;
|
||||||
|
@ -1768,7 +1767,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* store time for when we need to time out this source */
|
/* store time for when we need to time out this source */
|
||||||
source->bye_time = arrival->time;
|
source->bye_time = arrival->current_time;
|
||||||
|
|
||||||
prevactive = RTP_SOURCE_IS_ACTIVE (source);
|
prevactive = RTP_SOURCE_IS_ACTIVE (source);
|
||||||
prevsender = RTP_SOURCE_IS_SENDER (source);
|
prevsender = RTP_SOURCE_IS_SENDER (source);
|
||||||
|
@ -1794,17 +1793,17 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
||||||
/* some members went away since the previous timeout estimate.
|
/* some members went away since the previous timeout estimate.
|
||||||
* Perform reverse reconsideration but only when we are not scheduling a
|
* Perform reverse reconsideration but only when we are not scheduling a
|
||||||
* BYE ourselves. */
|
* BYE ourselves. */
|
||||||
if (arrival->time < sess->next_rtcp_check_time) {
|
if (arrival->current_time < sess->next_rtcp_check_time) {
|
||||||
GstClockTime time_remaining;
|
GstClockTime time_remaining;
|
||||||
|
|
||||||
time_remaining = sess->next_rtcp_check_time - arrival->time;
|
time_remaining = sess->next_rtcp_check_time - arrival->current_time;
|
||||||
sess->next_rtcp_check_time =
|
sess->next_rtcp_check_time =
|
||||||
gst_util_uint64_scale (time_remaining, members, pmembers);
|
gst_util_uint64_scale (time_remaining, members, pmembers);
|
||||||
|
|
||||||
GST_DEBUG ("reverse reconsideration %" GST_TIME_FORMAT,
|
GST_DEBUG ("reverse reconsideration %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (sess->next_rtcp_check_time));
|
GST_TIME_ARGS (sess->next_rtcp_check_time));
|
||||||
|
|
||||||
sess->next_rtcp_check_time += arrival->time;
|
sess->next_rtcp_check_time += arrival->current_time;
|
||||||
|
|
||||||
/* mark pending reconsider. We only want to signal the reconsideration
|
/* mark pending reconsider. We only want to signal the reconsideration
|
||||||
* once after we handled all the source in the bye packet */
|
* once after we handled all the source in the bye packet */
|
||||||
|
@ -1866,7 +1865,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
||||||
|
|
||||||
RTP_SESSION_LOCK (sess);
|
RTP_SESSION_LOCK (sess);
|
||||||
/* update arrival stats */
|
/* update arrival stats */
|
||||||
update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1, -1);
|
update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1);
|
||||||
|
|
||||||
if (sess->sent_bye)
|
if (sess->sent_bye)
|
||||||
goto ignore;
|
goto ignore;
|
||||||
|
|
|
@ -286,7 +286,7 @@ RTPSource* rtp_session_create_source (RTPSession *sess);
|
||||||
/* processing packets from receivers */
|
/* processing packets from receivers */
|
||||||
GstFlowReturn rtp_session_process_rtp (RTPSession *sess, GstBuffer *buffer,
|
GstFlowReturn rtp_session_process_rtp (RTPSession *sess, GstBuffer *buffer,
|
||||||
GstClockTime current_time,
|
GstClockTime current_time,
|
||||||
GstClockTime running_time, guint64 ntpnstime);
|
GstClockTime running_time);
|
||||||
GstFlowReturn rtp_session_process_rtcp (RTPSession *sess, GstBuffer *buffer,
|
GstFlowReturn rtp_session_process_rtcp (RTPSession *sess, GstBuffer *buffer,
|
||||||
GstClockTime current_time);
|
GstClockTime current_time);
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,8 @@ typedef struct {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RTPArrivalStats:
|
* RTPArrivalStats:
|
||||||
* @time: arrival time of a packet according to the system clock
|
* @current_time: arrival time of a packet according to the system clock
|
||||||
* @running_time: arrival time of a packet as buffer running_time
|
* @running_time: arrival time of a packet as buffer running_time
|
||||||
* @ntpnstime: arrival time of a packet as NTP time in nanoseconds
|
|
||||||
* @have_address: if the @address field contains a valid address
|
* @have_address: if the @address field contains a valid address
|
||||||
* @address: address of the sender of the packet
|
* @address: address of the sender of the packet
|
||||||
* @bytes: bytes of the packet including lowlevel overhead
|
* @bytes: bytes of the packet including lowlevel overhead
|
||||||
|
@ -67,9 +66,8 @@ typedef struct {
|
||||||
* Structure holding information about the arrival stats of a packet.
|
* Structure holding information about the arrival stats of a packet.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GstClockTime time;
|
GstClockTime current_time;
|
||||||
GstClockTime running_time;
|
GstClockTime running_time;
|
||||||
guint64 ntpnstime;
|
|
||||||
gboolean have_address;
|
gboolean have_address;
|
||||||
GstNetAddress address;
|
GstNetAddress address;
|
||||||
guint bytes;
|
guint bytes;
|
||||||
|
|
Loading…
Reference in a new issue