rtpbin: RTPArrivalStats -> RTPPacketInfo

Rename a structure because we are also going to use this for the sender
bits.
This commit is contained in:
Wim Taymans 2013-09-13 11:08:55 +02:00
parent c795b72988
commit 47662f9ca4
4 changed files with 98 additions and 100 deletions

View file

@ -119,7 +119,7 @@ G_DEFINE_TYPE (RTPSession, rtp_session, G_TYPE_OBJECT);
static guint32 rtp_session_create_new_ssrc (RTPSession * sess); static guint32 rtp_session_create_new_ssrc (RTPSession * sess);
static RTPSource *obtain_source (RTPSession * sess, guint32 ssrc, static RTPSource *obtain_source (RTPSession * sess, guint32 ssrc,
gboolean * created, RTPArrivalStats * arrival, gboolean rtp); gboolean * created, RTPPacketInfo * pinfo, gboolean rtp);
static RTPSource *obtain_internal_source (RTPSession * sess, static RTPSource *obtain_internal_source (RTPSession * sess,
guint32 ssrc, gboolean * created); guint32 ssrc, gboolean * created);
static GstFlowReturn rtp_session_schedule_bye_locked (RTPSession * sess, static GstFlowReturn rtp_session_schedule_bye_locked (RTPSession * sess,
@ -1163,12 +1163,12 @@ static RTPSourceCallbacks callbacks = {
static gboolean static gboolean
check_collision (RTPSession * sess, RTPSource * source, check_collision (RTPSession * sess, RTPSource * source,
RTPArrivalStats * arrival, gboolean rtp) RTPPacketInfo * pinfo, gboolean rtp)
{ {
guint32 ssrc; guint32 ssrc;
/* If we have no arrival address, we can't do collision checking */ /* If we have no pinfo address, we can't do collision checking */
if (!arrival->address) if (!pinfo->address)
return FALSE; return FALSE;
ssrc = rtp_source_get_ssrc (source); ssrc = rtp_source_get_ssrc (source);
@ -1185,17 +1185,17 @@ check_collision (RTPSession * sess, RTPSource * source,
} }
if (from) { if (from) {
if (__g_socket_address_equal (from, arrival->address)) { if (__g_socket_address_equal (from, pinfo->address)) {
/* Address is the same */ /* Address is the same */
return FALSE; return FALSE;
} else { } else {
GST_LOG ("we have a third-party collision or loop ssrc:%x", ssrc); GST_LOG ("we have a third-party collision or loop ssrc:%x", ssrc);
if (sess->favor_new) { if (sess->favor_new) {
if (rtp_source_find_conflicting_address (source, if (rtp_source_find_conflicting_address (source,
arrival->address, arrival->current_time)) { pinfo->address, pinfo->current_time)) {
gchar *buf1; gchar *buf1;
buf1 = __g_socket_address_to_string (arrival->address); buf1 = __g_socket_address_to_string (pinfo->address);
GST_LOG ("Known conflict on %x for %s, dropping packet", ssrc, GST_LOG ("Known conflict on %x for %s, dropping packet", ssrc,
buf1); buf1);
g_free (buf1); g_free (buf1);
@ -1208,18 +1208,18 @@ check_collision (RTPSession * sess, RTPSource * source,
* a new source. Save old address in possible conflict list * a new source. Save old address in possible conflict list
*/ */
rtp_source_add_conflicting_address (source, from, rtp_source_add_conflicting_address (source, from,
arrival->current_time); pinfo->current_time);
buf1 = __g_socket_address_to_string (from); buf1 = __g_socket_address_to_string (from);
buf2 = __g_socket_address_to_string (arrival->address); buf2 = __g_socket_address_to_string (pinfo->address);
GST_DEBUG ("New conflict for ssrc %x, replacing %s with %s," GST_DEBUG ("New conflict for ssrc %x, replacing %s with %s,"
" saving old as known conflict", ssrc, buf1, buf2); " saving old as known conflict", ssrc, buf1, buf2);
if (rtp) if (rtp)
rtp_source_set_rtp_from (source, arrival->address); rtp_source_set_rtp_from (source, pinfo->address);
else else
rtp_source_set_rtcp_from (source, arrival->address); rtp_source_set_rtcp_from (source, pinfo->address);
g_free (buf1); g_free (buf1);
g_free (buf2); g_free (buf2);
@ -1234,9 +1234,9 @@ check_collision (RTPSession * sess, RTPSource * source,
} else { } else {
/* We don't already have a from address for RTP, just set it */ /* We don't already have a from address for RTP, just set it */
if (rtp) if (rtp)
rtp_source_set_rtp_from (source, arrival->address); rtp_source_set_rtp_from (source, pinfo->address);
else else
rtp_source_set_rtcp_from (source, arrival->address); rtp_source_set_rtcp_from (source, pinfo->address);
return FALSE; return FALSE;
} }
@ -1246,16 +1246,16 @@ check_collision (RTPSession * sess, RTPSource * source,
*/ */
} else { } else {
/* This is sending with our ssrc, is it an address we already know */ /* This is sending with our ssrc, is it an address we already know */
if (rtp_source_find_conflicting_address (source, arrival->address, if (rtp_source_find_conflicting_address (source, pinfo->address,
arrival->current_time)) { pinfo->current_time)) {
/* Its a known conflict, its probably a loop, not a collision /* Its a known conflict, its probably a loop, not a collision
* lets just drop the incoming packet * lets just drop the incoming packet
*/ */
GST_DEBUG ("Our packets are being looped back to us, dropping"); GST_DEBUG ("Our packets are being looped back to us, dropping");
} else { } else {
/* Its a new collision, lets change our SSRC */ /* Its a new collision, lets change our SSRC */
rtp_source_add_conflicting_address (source, arrival->address, rtp_source_add_conflicting_address (source, pinfo->address,
arrival->current_time); pinfo->current_time);
GST_DEBUG ("Collision for SSRC %x", ssrc); GST_DEBUG ("Collision for SSRC %x", ssrc);
/* mark the source BYE */ /* mark the source BYE */
@ -1266,7 +1266,7 @@ check_collision (RTPSession * sess, RTPSource * source,
on_ssrc_collision (sess, source); on_ssrc_collision (sess, source);
rtp_session_schedule_bye_locked (sess, arrival->current_time); rtp_session_schedule_bye_locked (sess, pinfo->current_time);
} }
} }
@ -1302,7 +1302,7 @@ add_source (RTPSession * sess, RTPSource * src)
* unreffed after usage. */ * unreffed after usage. */
static RTPSource * static RTPSource *
obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created, obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
RTPArrivalStats * arrival, gboolean rtp) RTPPacketInfo * pinfo, gboolean rtp)
{ {
RTPSource *source; RTPSource *source;
@ -1322,11 +1322,11 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
g_object_set (source, "probation", 0, NULL); g_object_set (source, "probation", 0, NULL);
/* store from address, if any */ /* store from address, if any */
if (arrival->address) { if (pinfo->address) {
if (rtp) if (rtp)
rtp_source_set_rtp_from (source, arrival->address); rtp_source_set_rtp_from (source, pinfo->address);
else else
rtp_source_set_rtcp_from (source, arrival->address); rtp_source_set_rtcp_from (source, pinfo->address);
} }
/* configure a callback on the source */ /* configure a callback on the source */
@ -1337,7 +1337,7 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
} else { } else {
*created = FALSE; *created = FALSE;
/* check for collision, this updates the address when not previously set */ /* check for collision, this updates the address when not previously set */
if (check_collision (sess, source, arrival, rtp)) { if (check_collision (sess, source, pinfo, rtp)) {
return NULL; return NULL;
} }
/* Receiving RTCP packets of an SSRC is a strong indication that we /* Receiving RTCP packets of an SSRC is a strong indication that we
@ -1346,9 +1346,9 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
g_object_set (source, "probation", 0, NULL); g_object_set (source, "probation", 0, NULL);
} }
/* update last activity */ /* update last activity */
source->last_activity = arrival->current_time; source->last_activity = pinfo->current_time;
if (rtp) if (rtp)
source->last_rtp_activity = arrival->current_time; source->last_rtp_activity = pinfo->current_time;
g_object_ref (source); g_object_ref (source);
return source; return source;
@ -1550,51 +1550,51 @@ rtp_session_create_source (RTPSession * sess)
return source; return source;
} }
/* update the RTPArrivalStats structure with the current time and other bits /* update the RTPPacketInfo structure with the current time and other bits
* about the current buffer we are handling. * about the current buffer we are handling.
* This function is typically called when a validated packet is received. * This function is typically called when a validated packet is received.
* This function should be called with the SESSION_LOCK * This function should be called with the SESSION_LOCK
*/ */
static void static void
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival, update_packet_info (RTPSession * sess, RTPPacketInfo * pinfo,
gboolean rtp, GstBuffer * buffer, GstClockTime current_time, gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
GstClockTime running_time, guint64 ntpnstime) GstClockTime running_time, guint64 ntpnstime)
{ {
GstNetAddressMeta *meta; GstNetAddressMeta *meta;
GstRTPBuffer rtpb = { NULL }; GstRTPBuffer rtpb = { NULL };
/* get time of arrival */ /* get time of pinfo */
arrival->current_time = current_time; pinfo->current_time = current_time;
arrival->running_time = running_time; pinfo->running_time = running_time;
arrival->ntpnstime = ntpnstime; pinfo->ntpnstime = ntpnstime;
/* get packet size including header overhead */ /* get packet size including header overhead */
arrival->bytes = gst_buffer_get_size (buffer) + sess->header_len; pinfo->bytes = gst_buffer_get_size (buffer) + sess->header_len;
if (rtp) { if (rtp) {
gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtpb); gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtpb);
arrival->payload_len = gst_rtp_buffer_get_payload_len (&rtpb); pinfo->payload_len = gst_rtp_buffer_get_payload_len (&rtpb);
gst_rtp_buffer_unmap (&rtpb); gst_rtp_buffer_unmap (&rtpb);
} else { } else {
arrival->payload_len = 0; pinfo->payload_len = 0;
} }
/* for netbuffer we can store the IP address to check for collisions */ /* for netbuffer we can store the IP address to check for collisions */
meta = gst_buffer_get_net_address_meta (buffer); meta = gst_buffer_get_net_address_meta (buffer);
if (arrival->address) if (pinfo->address)
g_object_unref (arrival->address); g_object_unref (pinfo->address);
if (meta) { if (meta) {
arrival->address = G_SOCKET_ADDRESS (g_object_ref (meta->addr)); pinfo->address = G_SOCKET_ADDRESS (g_object_ref (meta->addr));
} else { } else {
arrival->address = NULL; pinfo->address = NULL;
} }
} }
static void static void
clean_arrival_stats (RTPArrivalStats * arrival) clean_packet_info (RTPPacketInfo * pinfo)
{ {
if (arrival->address) if (pinfo->address)
g_object_unref (arrival->address); g_object_unref (pinfo->address);
} }
static gboolean static gboolean
@ -1666,7 +1666,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
RTPSource *source; RTPSource *source;
gboolean created; gboolean created;
gboolean prevsender, prevactive; gboolean prevsender, prevactive;
RTPArrivalStats arrival = { NULL, }; RTPPacketInfo pinfo = { NULL, };
guint32 csrcs[16]; guint32 csrcs[16];
guint8 i, count; guint8 i, count;
guint64 oldrate; guint64 oldrate;
@ -1693,11 +1693,11 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
RTP_SESSION_LOCK (sess); RTP_SESSION_LOCK (sess);
/* update arrival stats */ /* update pinfo stats */
update_arrival_stats (sess, &arrival, TRUE, buffer, current_time, update_packet_info (sess, &pinfo, TRUE, buffer, current_time,
running_time, -1); running_time, -1);
source = obtain_source (sess, ssrc, &created, &arrival, TRUE); source = obtain_source (sess, ssrc, &created, &pinfo, TRUE);
if (!source) if (!source)
goto collision; goto collision;
@ -1706,7 +1706,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
oldrate = source->bitrate; oldrate = source->bitrate;
/* let source process the packet */ /* let source process the packet */
result = rtp_source_process_rtp (source, buffer, &arrival); result = rtp_source_process_rtp (source, buffer, &pinfo);
/* source became active */ /* source became active */
if (source_update_active (sess, source, prevactive)) if (source_update_active (sess, source, prevactive))
@ -1731,7 +1731,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
csrc = csrcs[i]; csrc = csrcs[i];
/* get source */ /* get source */
csrc_src = obtain_source (sess, csrc, &created, &arrival, TRUE); csrc_src = obtain_source (sess, csrc, &created, &pinfo, TRUE);
if (!csrc_src) if (!csrc_src)
continue; continue;
@ -1748,7 +1748,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
RTP_SESSION_UNLOCK (sess); RTP_SESSION_UNLOCK (sess);
clean_arrival_stats (&arrival); clean_packet_info (&pinfo);
return result; return result;
@ -1763,7 +1763,7 @@ collision:
{ {
RTP_SESSION_UNLOCK (sess); RTP_SESSION_UNLOCK (sess);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
clean_arrival_stats (&arrival); clean_packet_info (&pinfo);
GST_DEBUG ("ignoring packet because its collisioning"); GST_DEBUG ("ignoring packet because its collisioning");
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -1771,7 +1771,7 @@ collision:
static void static void
rtp_session_process_rb (RTPSession * sess, RTPSource * source, rtp_session_process_rb (RTPSession * sess, RTPSource * source,
GstRTCPPacket * packet, RTPArrivalStats * arrival) GstRTCPPacket * packet, RTPPacketInfo * pinfo)
{ {
guint count, i; guint count, i;
@ -1797,7 +1797,7 @@ rtp_session_process_rb (RTPSession * sess, RTPSource * source,
* 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. */
/* FIXME, need to keep track who the RB block is from */ /* FIXME, need to keep track who the RB block is from */
rtp_source_process_rb (source, arrival->ntpnstime, fractionlost, rtp_source_process_rb (source, pinfo->ntpnstime, fractionlost,
packetslost, exthighestseq, jitter, lsr, dlsr); packetslost, exthighestseq, jitter, lsr, dlsr);
} }
} }
@ -1815,7 +1815,7 @@ rtp_session_process_rb (RTPSession * sess, RTPSource * source,
*/ */
static void static void
rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival, gboolean * do_sync) RTPPacketInfo * pinfo, gboolean * do_sync)
{ {
guint32 senderssrc, rtptime, packet_count, octet_count; guint32 senderssrc, rtptime, packet_count, octet_count;
guint64 ntptime; guint64 ntptime;
@ -1826,9 +1826,9 @@ 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->current_time)); senderssrc, GST_TIME_ARGS (pinfo->current_time));
source = obtain_source (sess, senderssrc, &created, arrival, FALSE); source = obtain_source (sess, senderssrc, &created, pinfo, FALSE);
if (!source) if (!source)
return; return;
@ -1841,7 +1841,7 @@ 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->current_time, ntptime, rtptime, rtp_source_process_sr (source, pinfo->current_time, ntptime, rtptime,
packet_count, octet_count); packet_count, octet_count);
source_update_sender (sess, source, prevsender); source_update_sender (sess, source, prevsender);
@ -1849,7 +1849,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
if (created) if (created)
on_new_ssrc (sess, source); on_new_ssrc (sess, source);
rtp_session_process_rb (sess, source, packet, arrival); rtp_session_process_rb (sess, source, packet, pinfo);
g_object_unref (source); g_object_unref (source);
} }
@ -1861,7 +1861,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
*/ */
static void static void
rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival) RTPPacketInfo * pinfo)
{ {
guint32 senderssrc; guint32 senderssrc;
RTPSource *source; RTPSource *source;
@ -1871,21 +1871,21 @@ rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet,
GST_DEBUG ("got RR packet: SSRC %08x", senderssrc); GST_DEBUG ("got RR packet: SSRC %08x", senderssrc);
source = obtain_source (sess, senderssrc, &created, arrival, FALSE); source = obtain_source (sess, senderssrc, &created, pinfo, FALSE);
if (!source) if (!source)
return; return;
if (created) if (created)
on_new_ssrc (sess, source); on_new_ssrc (sess, source);
rtp_session_process_rb (sess, source, packet, arrival); rtp_session_process_rb (sess, source, packet, pinfo);
g_object_unref (source); g_object_unref (source);
} }
/* Get SDES items and store them in the SSRC */ /* Get SDES items and store them in the SSRC */
static void static void
rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival) RTPPacketInfo * pinfo)
{ {
guint items, i, j; guint items, i, j;
gboolean more_items, more_entries; gboolean more_items, more_entries;
@ -1908,7 +1908,7 @@ rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
changed = FALSE; changed = FALSE;
/* find src, no probation when dealing with RTCP */ /* find src, no probation when dealing with RTCP */
source = obtain_source (sess, ssrc, &created, arrival, FALSE); source = obtain_source (sess, ssrc, &created, pinfo, FALSE);
if (!source) if (!source)
return; return;
@ -1974,7 +1974,7 @@ rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
*/ */
static void static void
rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival) RTPPacketInfo * pinfo)
{ {
guint count, i; guint count, i;
gchar *reason; gchar *reason;
@ -1994,7 +1994,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
GST_DEBUG ("SSRC: %08x", ssrc); GST_DEBUG ("SSRC: %08x", ssrc);
/* find src and mark bye, no probation when dealing with RTCP */ /* find src and mark bye, no probation when dealing with RTCP */
source = obtain_source (sess, ssrc, &created, arrival, FALSE); source = obtain_source (sess, ssrc, &created, pinfo, FALSE);
if (!source) if (!source)
return; return;
@ -2005,7 +2005,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
} }
/* 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->current_time; source->bye_time = pinfo->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);
@ -2025,17 +2025,17 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
* 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 (sess->next_rtcp_check_time != GST_CLOCK_TIME_NONE && if (sess->next_rtcp_check_time != GST_CLOCK_TIME_NONE &&
arrival->current_time < sess->next_rtcp_check_time) { pinfo->current_time < sess->next_rtcp_check_time) {
GstClockTime time_remaining; GstClockTime time_remaining;
time_remaining = sess->next_rtcp_check_time - arrival->current_time; time_remaining = sess->next_rtcp_check_time - pinfo->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->current_time; sess->next_rtcp_check_time += pinfo->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 */
@ -2062,7 +2062,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
static void static void
rtp_session_process_app (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_app (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival) RTPPacketInfo * pinfo)
{ {
GST_DEBUG ("received APP"); GST_DEBUG ("received APP");
} }
@ -2200,7 +2200,7 @@ rtp_session_process_nack (RTPSession * sess, guint32 sender_ssrc,
static void static void
rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet, rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
RTPArrivalStats * arrival, GstClockTime current_time) RTPPacketInfo * pinfo, GstClockTime current_time)
{ {
GstRTCPType type = gst_rtcp_packet_get_type (packet); GstRTCPType type = gst_rtcp_packet_get_type (packet);
GstRTCPFBType fbtype = gst_rtcp_packet_fb_get_type (packet); GstRTCPFBType fbtype = gst_rtcp_packet_fb_get_type (packet);
@ -2221,7 +2221,7 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer, fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer,
GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->map.data, GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->map.data,
fci_length); fci_length);
GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time; GST_BUFFER_TIMESTAMP (fci_buffer) = pinfo->running_time;
} }
RTP_SESSION_UNLOCK (sess); RTP_SESSION_UNLOCK (sess);
@ -2238,7 +2238,7 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
return; return;
if (sess->rtcp_feedback_retention_window) { if (sess->rtcp_feedback_retention_window) {
rtp_source_retain_rtcp_packet (src, packet, arrival->running_time); rtp_source_retain_rtcp_packet (src, packet, pinfo->running_time);
} }
if (src->internal || if (src->internal ||
@ -2292,7 +2292,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
{ {
GstRTCPPacket packet; GstRTCPPacket packet;
gboolean more, is_bye = FALSE, do_sync = FALSE; gboolean more, is_bye = FALSE, do_sync = FALSE;
RTPArrivalStats arrival = { NULL, }; RTPPacketInfo pinfo = { NULL, };
GstFlowReturn result = GST_FLOW_OK; GstFlowReturn result = GST_FLOW_OK;
GstRTCPBuffer rtcp = { NULL, }; GstRTCPBuffer rtcp = { NULL, };
@ -2305,9 +2305,8 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
GST_DEBUG ("received RTCP packet"); GST_DEBUG ("received RTCP packet");
RTP_SESSION_LOCK (sess); RTP_SESSION_LOCK (sess);
/* update arrival stats */ /* update pinfo stats */
update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1, update_packet_info (sess, &pinfo, FALSE, buffer, current_time, -1, ntpnstime);
ntpnstime);
/* start processing the compound packet */ /* start processing the compound packet */
gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp); gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp);
@ -2325,26 +2324,26 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
switch (type) { switch (type) {
case GST_RTCP_TYPE_SR: case GST_RTCP_TYPE_SR:
rtp_session_process_sr (sess, &packet, &arrival, &do_sync); rtp_session_process_sr (sess, &packet, &pinfo, &do_sync);
break; break;
case GST_RTCP_TYPE_RR: case GST_RTCP_TYPE_RR:
rtp_session_process_rr (sess, &packet, &arrival); rtp_session_process_rr (sess, &packet, &pinfo);
break; break;
case GST_RTCP_TYPE_SDES: case GST_RTCP_TYPE_SDES:
rtp_session_process_sdes (sess, &packet, &arrival); rtp_session_process_sdes (sess, &packet, &pinfo);
break; break;
case GST_RTCP_TYPE_BYE: case GST_RTCP_TYPE_BYE:
is_bye = TRUE; is_bye = TRUE;
/* don't try to attempt lip-sync anymore for streams with a BYE */ /* don't try to attempt lip-sync anymore for streams with a BYE */
do_sync = FALSE; do_sync = FALSE;
rtp_session_process_bye (sess, &packet, &arrival); rtp_session_process_bye (sess, &packet, &pinfo);
break; break;
case GST_RTCP_TYPE_APP: case GST_RTCP_TYPE_APP:
rtp_session_process_app (sess, &packet, &arrival); rtp_session_process_app (sess, &packet, &pinfo);
break; break;
case GST_RTCP_TYPE_RTPFB: case GST_RTCP_TYPE_RTPFB:
case GST_RTCP_TYPE_PSFB: case GST_RTCP_TYPE_PSFB:
rtp_session_process_feedback (sess, &packet, &arrival, current_time); rtp_session_process_feedback (sess, &packet, &pinfo, current_time);
break; break;
default: default:
GST_WARNING ("got unknown RTCP packet"); GST_WARNING ("got unknown RTCP packet");
@ -2361,17 +2360,17 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
if (sess->scheduled_bye) { if (sess->scheduled_bye) {
if (is_bye) { if (is_bye) {
sess->stats.bye_members++; sess->stats.bye_members++;
UPDATE_AVG (sess->stats.avg_rtcp_packet_size, arrival.bytes); UPDATE_AVG (sess->stats.avg_rtcp_packet_size, pinfo.bytes);
} }
} else { } else {
/* keep track of average packet size */ /* keep track of average packet size */
UPDATE_AVG (sess->stats.avg_rtcp_packet_size, arrival.bytes); UPDATE_AVG (sess->stats.avg_rtcp_packet_size, pinfo.bytes);
} }
GST_DEBUG ("%p, received RTCP packet, avg size %u, %u", &sess->stats, GST_DEBUG ("%p, received RTCP packet, avg size %u, %u", &sess->stats,
sess->stats.avg_rtcp_packet_size, arrival.bytes); sess->stats.avg_rtcp_packet_size, pinfo.bytes);
RTP_SESSION_UNLOCK (sess); RTP_SESSION_UNLOCK (sess);
clean_arrival_stats (&arrival); clean_packet_info (&pinfo);
/* notify caller of sr packets in the callback */ /* notify caller of sr packets in the callback */
if (do_sync && sess->callbacks.sync_rtcp) { if (do_sync && sess->callbacks.sync_rtcp) {

View file

@ -863,8 +863,7 @@ get_clock_rate (RTPSource * src, guint8 payload)
* 50 milliseconds apart and arrive 60 milliseconds apart, then the jitter is 10 * 50 milliseconds apart and arrive 60 milliseconds apart, then the jitter is 10
* milliseconds. */ * milliseconds. */
static void static void
calculate_jitter (RTPSource * src, GstBuffer * buffer, calculate_jitter (RTPSource * src, GstBuffer * buffer, RTPPacketInfo * pinfo)
RTPArrivalStats * arrival)
{ {
GstClockTime running_time; GstClockTime running_time;
guint32 rtparrival, transit, rtptime; guint32 rtparrival, transit, rtptime;
@ -874,7 +873,7 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer,
GstRTPBuffer rtp = { NULL }; GstRTPBuffer rtp = { NULL };
/* get arrival time */ /* get arrival time */
if ((running_time = arrival->running_time) == GST_CLOCK_TIME_NONE) if ((running_time = pinfo->running_time) == GST_CLOCK_TIME_NONE)
goto no_time; goto no_time;
if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp)) if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))
@ -1001,7 +1000,7 @@ do_bitrate_estimation (RTPSource * src, GstClockTime running_time,
*/ */
GstFlowReturn GstFlowReturn
rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer, rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
RTPArrivalStats * arrival) RTPPacketInfo * pinfo)
{ {
GstFlowReturn result = GST_FLOW_OK; GstFlowReturn result = GST_FLOW_OK;
guint16 seqnr, udelta; guint16 seqnr, udelta;
@ -1084,22 +1083,22 @@ rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
GST_WARNING ("duplicate or reordered packet (seqnr %d)", seqnr); GST_WARNING ("duplicate or reordered packet (seqnr %d)", seqnr);
} }
src->stats.octets_received += arrival->payload_len; src->stats.octets_received += pinfo->payload_len;
src->stats.bytes_received += arrival->bytes; src->stats.bytes_received += pinfo->bytes;
src->stats.packets_received++; src->stats.packets_received++;
/* for the bitrate estimation */ /* for the bitrate estimation */
src->bytes_received += arrival->payload_len; src->bytes_received += pinfo->payload_len;
/* the source that sent the packet must be a sender */ /* the source that sent the packet must be a sender */
src->is_sender = TRUE; src->is_sender = TRUE;
src->validated = TRUE; src->validated = TRUE;
do_bitrate_estimation (src, arrival->running_time, &src->bytes_received); do_bitrate_estimation (src, pinfo->running_time, &src->bytes_received);
GST_LOG ("seq %d, PC: %" G_GUINT64_FORMAT ", OC: %" G_GUINT64_FORMAT, GST_LOG ("seq %d, PC: %" G_GUINT64_FORMAT ", OC: %" G_GUINT64_FORMAT,
seqnr, src->stats.packets_received, src->stats.octets_received); seqnr, src->stats.packets_received, src->stats.octets_received);
/* calculate jitter for the stats */ /* calculate jitter for the stats */
calculate_jitter (src, buffer, arrival); calculate_jitter (src, buffer, pinfo);
/* we're ready to push the RTP packet now */ /* we're ready to push the RTP packet now */
result = push_packet (src, buffer); result = push_packet (src, buffer);

View file

@ -229,7 +229,7 @@ void rtp_source_set_rtp_from (RTPSource *src, GSocketAddress *
void rtp_source_set_rtcp_from (RTPSource *src, GSocketAddress *address); void rtp_source_set_rtcp_from (RTPSource *src, GSocketAddress *address);
/* handling RTP */ /* handling RTP */
GstFlowReturn rtp_source_process_rtp (RTPSource *src, GstBuffer *buffer, RTPArrivalStats *arrival); GstFlowReturn rtp_source_process_rtp (RTPSource *src, GstBuffer *buffer, RTPPacketInfo *pinfo);
GstFlowReturn rtp_source_send_rtp (RTPSource *src, gpointer data, gboolean is_list, GstFlowReturn rtp_source_send_rtp (RTPSource *src, gpointer data, gboolean is_list,
GstClockTime running_time); GstClockTime running_time);

View file

@ -56,15 +56,15 @@ typedef struct {
} RTPReceiverReport; } RTPReceiverReport;
/** /**
* RTPArrivalStats: * RTPPacketInfo:
* @address: address of the sender of the packet * @address: address of the sender of the packet
* @current_time: current time according to the system clock * @current_time: current time according to the system clock
* @running_time: arrival time of a packet as buffer running_time * @running_time: time of a packet as buffer running_time
* @ntpnstime: arrival time of a packet NTP time in nanoseconds * @ntpnstime: time of a packet NTP time in nanoseconds
* @bytes: bytes of the packet including lowlevel overhead * @bytes: bytes of the packet including lowlevel overhead
* @payload_len: bytes of the RTP payload * @payload_len: bytes of the RTP payload
* *
* Structure holding information about the arrival stats of a packet. * Structure holding information about the packet.
*/ */
typedef struct { typedef struct {
GSocketAddress *address; GSocketAddress *address;
@ -73,7 +73,7 @@ typedef struct {
guint64 ntpnstime; guint64 ntpnstime;
guint bytes; guint bytes;
guint payload_len; guint payload_len;
} RTPArrivalStats; } RTPPacketInfo;
/** /**
* RTPSourceStats: * RTPSourceStats: