GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
GstClockTime current_time;
+ guint64 ntpnstime;
GstFlowReturn ret;
rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
GST_LOG_OBJECT (rtpsession, "received RTCP packet");
current_time = gst_clock_get_time (priv->sysclock);
- ret = rtp_session_process_rtcp (priv->session, buffer, current_time);
+ get_current_times (rtpsession, NULL, &ntpnstime);
+
+ ret =
+ rtp_session_process_rtcp (priv->session, buffer, current_time, ntpnstime);
gst_object_unref (rtpsession);
static void
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
- GstClockTime running_time)
+ GstClockTime running_time, guint64 ntpnstime)
{
/* get time of arrival */
arrival->current_time = current_time;
arrival->running_time = running_time;
+ arrival->ntpnstime = ntpnstime;
/* get packet size including header overhead */
arrival->bytes = GST_BUFFER_SIZE (buffer) + sess->header_len;
RTP_SESSION_LOCK (sess);
/* update arrival stats */
update_arrival_stats (sess, &arrival, TRUE, buffer, current_time,
- running_time);
+ running_time, -1);
/* ignore more RTP packets when we left the session */
if (sess->source->received_bye)
/* 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 other sender to see if we are better or worse. */
- rtp_source_process_rb (source, arrival->current_time, fractionlost,
+ rtp_source_process_rb (source, arrival->ntpnstime, fractionlost,
packetslost, exthighestseq, jitter, lsr, dlsr);
}
}
* @sess: and #RTPSession
* @buffer: an RTCP buffer
* @current_time: the current system time
+ * @ntpnstime: the current NTP time in nanoseconds
*
* Process an RTCP buffer in the session manager. This function takes ownership
* of @buffer.
*/
GstFlowReturn
rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
- GstClockTime current_time)
+ GstClockTime current_time, guint64 ntpnstime)
{
GstRTCPPacket packet;
gboolean more, is_bye = FALSE, do_sync = FALSE;
RTP_SESSION_LOCK (sess);
/* update arrival stats */
- update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1);
+ update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1,
+ ntpnstime);
if (sess->sent_bye)
goto ignore;
GstClockTime current_time,
GstClockTime running_time);
GstFlowReturn rtp_session_process_rtcp (RTPSession *sess, GstBuffer *buffer,
- GstClockTime current_time);
+ GstClockTime current_time,
+ guint64 ntpnstime);
/* processing packets for sending */
GstFlowReturn rtp_session_send_rtp (RTPSession *sess, gpointer data, gboolean is_list,
/**
* rtp_source_process_rb:
* @src: an #RTPSource
- * @time: the current time in nanoseconds since 1970
+ * @ntpnstime: the current time in nanoseconds since 1970
* @fractionlost: fraction lost since last SR/RR
* @packetslost: the cumululative number of packets lost
* @exthighestseq: the extended last sequence number received
* Update the report block in @src.
*/
void
-rtp_source_process_rb (RTPSource * src, GstClockTime time, guint8 fractionlost,
- gint32 packetslost, guint32 exthighestseq, guint32 jitter, guint32 lsr,
- guint32 dlsr)
+rtp_source_process_rb (RTPSource * src, GstClockTime ntpnstime,
+ guint8 fractionlost, gint32 packetslost, guint32 exthighestseq,
+ guint32 jitter, guint32 lsr, guint32 dlsr)
{
RTPReceiverReport *curr;
gint curridx;
guint32 ntp, A;
+ guint64 f_ntp;
g_return_if_fail (RTP_IS_SOURCE (src));
curr->lsr = lsr;
curr->dlsr = dlsr;
+ /* convert the NTP time in nanoseconds to 32.32 fixed point */
+ f_ntp = gst_util_uint64_scale (ntpnstime, (1LL << 32), GST_SECOND);
/* calculate round trip, round the time up */
- ntp = ((gst_rtcp_unix_to_ntp (time) + 0xffff) >> 16) & 0xffffffff;
+ ntp = ((f_ntp + 0xffff) >> 16) & 0xffffffff;
+
A = dlsr + lsr;
if (A > 0 && ntp > A)
A = ntp - A;
void rtp_source_process_bye (RTPSource *src, const gchar *reason);
void rtp_source_process_sr (RTPSource *src, GstClockTime time, guint64 ntptime,
guint32 rtptime, guint32 packet_count, guint32 octet_count);
-void rtp_source_process_rb (RTPSource *src, GstClockTime time, guint8 fractionlost,
+void rtp_source_process_rb (RTPSource *src, guint64 ntpnstime, guint8 fractionlost,
gint32 packetslost, guint32 exthighestseq, guint32 jitter,
guint32 lsr, guint32 dlsr);
* RTPArrivalStats:
* @current_time: current time according to the system clock
* @running_time: arrival time of a packet as buffer running_time
+ * @ntpnstime: arrival time of a packet NTP time in nanoseconds
* @have_address: if the @address field contains a valid address
* @address: address of the sender of the packet
* @bytes: bytes of the packet including lowlevel overhead
typedef struct {
GstClockTime current_time;
GstClockTime running_time;
+ guint64 ntpnstime;
gboolean have_address;
GstNetAddress address;
guint bytes;