mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
rtpbin: RTPArrivalStats -> RTPPacketInfo
Rename a structure because we are also going to use this for the sender bits.
This commit is contained in:
parent
c795b72988
commit
47662f9ca4
4 changed files with 98 additions and 100 deletions
|
@ -119,7 +119,7 @@ G_DEFINE_TYPE (RTPSession, rtp_session, G_TYPE_OBJECT);
|
|||
|
||||
static guint32 rtp_session_create_new_ssrc (RTPSession * sess);
|
||||
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,
|
||||
guint32 ssrc, gboolean * created);
|
||||
static GstFlowReturn rtp_session_schedule_bye_locked (RTPSession * sess,
|
||||
|
@ -1163,12 +1163,12 @@ static RTPSourceCallbacks callbacks = {
|
|||
|
||||
static gboolean
|
||||
check_collision (RTPSession * sess, RTPSource * source,
|
||||
RTPArrivalStats * arrival, gboolean rtp)
|
||||
RTPPacketInfo * pinfo, gboolean rtp)
|
||||
{
|
||||
guint32 ssrc;
|
||||
|
||||
/* If we have no arrival address, we can't do collision checking */
|
||||
if (!arrival->address)
|
||||
/* If we have no pinfo address, we can't do collision checking */
|
||||
if (!pinfo->address)
|
||||
return FALSE;
|
||||
|
||||
ssrc = rtp_source_get_ssrc (source);
|
||||
|
@ -1185,17 +1185,17 @@ check_collision (RTPSession * sess, RTPSource * source,
|
|||
}
|
||||
|
||||
if (from) {
|
||||
if (__g_socket_address_equal (from, arrival->address)) {
|
||||
if (__g_socket_address_equal (from, pinfo->address)) {
|
||||
/* Address is the same */
|
||||
return FALSE;
|
||||
} else {
|
||||
GST_LOG ("we have a third-party collision or loop ssrc:%x", ssrc);
|
||||
if (sess->favor_new) {
|
||||
if (rtp_source_find_conflicting_address (source,
|
||||
arrival->address, arrival->current_time)) {
|
||||
pinfo->address, pinfo->current_time)) {
|
||||
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,
|
||||
buf1);
|
||||
g_free (buf1);
|
||||
|
@ -1208,18 +1208,18 @@ check_collision (RTPSession * sess, RTPSource * source,
|
|||
* a new source. Save old address in possible conflict list
|
||||
*/
|
||||
rtp_source_add_conflicting_address (source, from,
|
||||
arrival->current_time);
|
||||
pinfo->current_time);
|
||||
|
||||
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,"
|
||||
" saving old as known conflict", ssrc, buf1, buf2);
|
||||
|
||||
if (rtp)
|
||||
rtp_source_set_rtp_from (source, arrival->address);
|
||||
rtp_source_set_rtp_from (source, pinfo->address);
|
||||
else
|
||||
rtp_source_set_rtcp_from (source, arrival->address);
|
||||
rtp_source_set_rtcp_from (source, pinfo->address);
|
||||
|
||||
g_free (buf1);
|
||||
g_free (buf2);
|
||||
|
@ -1234,9 +1234,9 @@ check_collision (RTPSession * sess, RTPSource * source,
|
|||
} else {
|
||||
/* We don't already have a from address for RTP, just set it */
|
||||
if (rtp)
|
||||
rtp_source_set_rtp_from (source, arrival->address);
|
||||
rtp_source_set_rtp_from (source, pinfo->address);
|
||||
else
|
||||
rtp_source_set_rtcp_from (source, arrival->address);
|
||||
rtp_source_set_rtcp_from (source, pinfo->address);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1246,16 +1246,16 @@ check_collision (RTPSession * sess, RTPSource * source,
|
|||
*/
|
||||
} else {
|
||||
/* This is sending with our ssrc, is it an address we already know */
|
||||
if (rtp_source_find_conflicting_address (source, arrival->address,
|
||||
arrival->current_time)) {
|
||||
if (rtp_source_find_conflicting_address (source, pinfo->address,
|
||||
pinfo->current_time)) {
|
||||
/* Its a known conflict, its probably a loop, not a collision
|
||||
* lets just drop the incoming packet
|
||||
*/
|
||||
GST_DEBUG ("Our packets are being looped back to us, dropping");
|
||||
} else {
|
||||
/* Its a new collision, lets change our SSRC */
|
||||
rtp_source_add_conflicting_address (source, arrival->address,
|
||||
arrival->current_time);
|
||||
rtp_source_add_conflicting_address (source, pinfo->address,
|
||||
pinfo->current_time);
|
||||
|
||||
GST_DEBUG ("Collision for SSRC %x", ssrc);
|
||||
/* mark the source BYE */
|
||||
|
@ -1266,7 +1266,7 @@ check_collision (RTPSession * sess, RTPSource * 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. */
|
||||
static RTPSource *
|
||||
obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
|
||||
RTPArrivalStats * arrival, gboolean rtp)
|
||||
RTPPacketInfo * pinfo, gboolean rtp)
|
||||
{
|
||||
RTPSource *source;
|
||||
|
||||
|
@ -1322,11 +1322,11 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
|
|||
g_object_set (source, "probation", 0, NULL);
|
||||
|
||||
/* store from address, if any */
|
||||
if (arrival->address) {
|
||||
if (pinfo->address) {
|
||||
if (rtp)
|
||||
rtp_source_set_rtp_from (source, arrival->address);
|
||||
rtp_source_set_rtp_from (source, pinfo->address);
|
||||
else
|
||||
rtp_source_set_rtcp_from (source, arrival->address);
|
||||
rtp_source_set_rtcp_from (source, pinfo->address);
|
||||
}
|
||||
|
||||
/* configure a callback on the source */
|
||||
|
@ -1337,7 +1337,7 @@ obtain_source (RTPSession * sess, guint32 ssrc, gboolean * created,
|
|||
} else {
|
||||
*created = FALSE;
|
||||
/* 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;
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
/* update last activity */
|
||||
source->last_activity = arrival->current_time;
|
||||
source->last_activity = pinfo->current_time;
|
||||
if (rtp)
|
||||
source->last_rtp_activity = arrival->current_time;
|
||||
source->last_rtp_activity = pinfo->current_time;
|
||||
g_object_ref (source);
|
||||
|
||||
return source;
|
||||
|
@ -1550,51 +1550,51 @@ rtp_session_create_source (RTPSession * sess)
|
|||
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.
|
||||
* This function is typically called when a validated packet is received.
|
||||
* This function should be called with the SESSION_LOCK
|
||||
*/
|
||||
static void
|
||||
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
|
||||
update_packet_info (RTPSession * sess, RTPPacketInfo * pinfo,
|
||||
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
|
||||
GstClockTime running_time, guint64 ntpnstime)
|
||||
{
|
||||
GstNetAddressMeta *meta;
|
||||
GstRTPBuffer rtpb = { NULL };
|
||||
|
||||
/* get time of arrival */
|
||||
arrival->current_time = current_time;
|
||||
arrival->running_time = running_time;
|
||||
arrival->ntpnstime = ntpnstime;
|
||||
/* get time of pinfo */
|
||||
pinfo->current_time = current_time;
|
||||
pinfo->running_time = running_time;
|
||||
pinfo->ntpnstime = ntpnstime;
|
||||
|
||||
/* 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) {
|
||||
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);
|
||||
} else {
|
||||
arrival->payload_len = 0;
|
||||
pinfo->payload_len = 0;
|
||||
}
|
||||
|
||||
/* for netbuffer we can store the IP address to check for collisions */
|
||||
meta = gst_buffer_get_net_address_meta (buffer);
|
||||
if (arrival->address)
|
||||
g_object_unref (arrival->address);
|
||||
if (pinfo->address)
|
||||
g_object_unref (pinfo->address);
|
||||
if (meta) {
|
||||
arrival->address = G_SOCKET_ADDRESS (g_object_ref (meta->addr));
|
||||
pinfo->address = G_SOCKET_ADDRESS (g_object_ref (meta->addr));
|
||||
} else {
|
||||
arrival->address = NULL;
|
||||
pinfo->address = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clean_arrival_stats (RTPArrivalStats * arrival)
|
||||
clean_packet_info (RTPPacketInfo * pinfo)
|
||||
{
|
||||
if (arrival->address)
|
||||
g_object_unref (arrival->address);
|
||||
if (pinfo->address)
|
||||
g_object_unref (pinfo->address);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1666,7 +1666,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
RTPSource *source;
|
||||
gboolean created;
|
||||
gboolean prevsender, prevactive;
|
||||
RTPArrivalStats arrival = { NULL, };
|
||||
RTPPacketInfo pinfo = { NULL, };
|
||||
guint32 csrcs[16];
|
||||
guint8 i, count;
|
||||
guint64 oldrate;
|
||||
|
@ -1693,11 +1693,11 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
|
||||
RTP_SESSION_LOCK (sess);
|
||||
|
||||
/* update arrival stats */
|
||||
update_arrival_stats (sess, &arrival, TRUE, buffer, current_time,
|
||||
/* update pinfo stats */
|
||||
update_packet_info (sess, &pinfo, TRUE, buffer, current_time,
|
||||
running_time, -1);
|
||||
|
||||
source = obtain_source (sess, ssrc, &created, &arrival, TRUE);
|
||||
source = obtain_source (sess, ssrc, &created, &pinfo, TRUE);
|
||||
if (!source)
|
||||
goto collision;
|
||||
|
||||
|
@ -1706,7 +1706,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
oldrate = source->bitrate;
|
||||
|
||||
/* let source process the packet */
|
||||
result = rtp_source_process_rtp (source, buffer, &arrival);
|
||||
result = rtp_source_process_rtp (source, buffer, &pinfo);
|
||||
|
||||
/* source became active */
|
||||
if (source_update_active (sess, source, prevactive))
|
||||
|
@ -1731,7 +1731,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
csrc = csrcs[i];
|
||||
|
||||
/* get source */
|
||||
csrc_src = obtain_source (sess, csrc, &created, &arrival, TRUE);
|
||||
csrc_src = obtain_source (sess, csrc, &created, &pinfo, TRUE);
|
||||
if (!csrc_src)
|
||||
continue;
|
||||
|
||||
|
@ -1748,7 +1748,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
|
||||
RTP_SESSION_UNLOCK (sess);
|
||||
|
||||
clean_arrival_stats (&arrival);
|
||||
clean_packet_info (&pinfo);
|
||||
|
||||
return result;
|
||||
|
||||
|
@ -1763,7 +1763,7 @@ collision:
|
|||
{
|
||||
RTP_SESSION_UNLOCK (sess);
|
||||
gst_buffer_unref (buffer);
|
||||
clean_arrival_stats (&arrival);
|
||||
clean_packet_info (&pinfo);
|
||||
GST_DEBUG ("ignoring packet because its collisioning");
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -1771,7 +1771,7 @@ collision:
|
|||
|
||||
static void
|
||||
rtp_session_process_rb (RTPSession * sess, RTPSource * source,
|
||||
GstRTCPPacket * packet, RTPArrivalStats * arrival)
|
||||
GstRTCPPacket * packet, RTPPacketInfo * pinfo)
|
||||
{
|
||||
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 other sender to see if we are better or worse. */
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
@ -1815,7 +1815,7 @@ rtp_session_process_rb (RTPSession * sess, RTPSource * source,
|
|||
*/
|
||||
static void
|
||||
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;
|
||||
guint64 ntptime;
|
||||
|
@ -1826,9 +1826,9 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
&packet_count, &octet_count);
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
|
@ -1841,7 +1841,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
prevsender = RTP_SOURCE_IS_SENDER (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);
|
||||
|
||||
source_update_sender (sess, source, prevsender);
|
||||
|
@ -1849,7 +1849,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
if (created)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1861,7 +1861,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
*/
|
||||
static void
|
||||
rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet,
|
||||
RTPArrivalStats * arrival)
|
||||
RTPPacketInfo * pinfo)
|
||||
{
|
||||
guint32 senderssrc;
|
||||
RTPSource *source;
|
||||
|
@ -1871,21 +1871,21 @@ rtp_session_process_rr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
|
||||
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)
|
||||
return;
|
||||
|
||||
if (created)
|
||||
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);
|
||||
}
|
||||
|
||||
/* Get SDES items and store them in the SSRC */
|
||||
static void
|
||||
rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
|
||||
RTPArrivalStats * arrival)
|
||||
RTPPacketInfo * pinfo)
|
||||
{
|
||||
guint items, i, j;
|
||||
gboolean more_items, more_entries;
|
||||
|
@ -1908,7 +1908,7 @@ rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
|
|||
changed = FALSE;
|
||||
|
||||
/* 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)
|
||||
return;
|
||||
|
||||
|
@ -1974,7 +1974,7 @@ rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
|
|||
*/
|
||||
static void
|
||||
rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
||||
RTPArrivalStats * arrival)
|
||||
RTPPacketInfo * pinfo)
|
||||
{
|
||||
guint count, i;
|
||||
gchar *reason;
|
||||
|
@ -1994,7 +1994,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
|||
GST_DEBUG ("SSRC: %08x", ssrc);
|
||||
|
||||
/* 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)
|
||||
return;
|
||||
|
||||
|
@ -2005,7 +2005,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
|||
}
|
||||
|
||||
/* 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);
|
||||
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
|
||||
* BYE ourselves. */
|
||||
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;
|
||||
|
||||
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 =
|
||||
gst_util_uint64_scale (time_remaining, members, pmembers);
|
||||
|
||||
GST_DEBUG ("reverse reconsideration %" GST_TIME_FORMAT,
|
||||
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
|
||||
* 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
|
||||
rtp_session_process_app (RTPSession * sess, GstRTCPPacket * packet,
|
||||
RTPArrivalStats * arrival)
|
||||
RTPPacketInfo * pinfo)
|
||||
{
|
||||
GST_DEBUG ("received APP");
|
||||
}
|
||||
|
@ -2200,7 +2200,7 @@ rtp_session_process_nack (RTPSession * sess, guint32 sender_ssrc,
|
|||
|
||||
static void
|
||||
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);
|
||||
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,
|
||||
GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->map.data,
|
||||
fci_length);
|
||||
GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time;
|
||||
GST_BUFFER_TIMESTAMP (fci_buffer) = pinfo->running_time;
|
||||
}
|
||||
|
||||
RTP_SESSION_UNLOCK (sess);
|
||||
|
@ -2238,7 +2238,7 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
|
|||
return;
|
||||
|
||||
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 ||
|
||||
|
@ -2292,7 +2292,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
{
|
||||
GstRTCPPacket packet;
|
||||
gboolean more, is_bye = FALSE, do_sync = FALSE;
|
||||
RTPArrivalStats arrival = { NULL, };
|
||||
RTPPacketInfo pinfo = { NULL, };
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
GstRTCPBuffer rtcp = { NULL, };
|
||||
|
||||
|
@ -2305,9 +2305,8 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
GST_DEBUG ("received RTCP packet");
|
||||
|
||||
RTP_SESSION_LOCK (sess);
|
||||
/* update arrival stats */
|
||||
update_arrival_stats (sess, &arrival, FALSE, buffer, current_time, -1,
|
||||
ntpnstime);
|
||||
/* update pinfo stats */
|
||||
update_packet_info (sess, &pinfo, FALSE, buffer, current_time, -1, ntpnstime);
|
||||
|
||||
/* start processing the compound packet */
|
||||
gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp);
|
||||
|
@ -2325,26 +2324,26 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
|
||||
switch (type) {
|
||||
case GST_RTCP_TYPE_SR:
|
||||
rtp_session_process_sr (sess, &packet, &arrival, &do_sync);
|
||||
rtp_session_process_sr (sess, &packet, &pinfo, &do_sync);
|
||||
break;
|
||||
case GST_RTCP_TYPE_RR:
|
||||
rtp_session_process_rr (sess, &packet, &arrival);
|
||||
rtp_session_process_rr (sess, &packet, &pinfo);
|
||||
break;
|
||||
case GST_RTCP_TYPE_SDES:
|
||||
rtp_session_process_sdes (sess, &packet, &arrival);
|
||||
rtp_session_process_sdes (sess, &packet, &pinfo);
|
||||
break;
|
||||
case GST_RTCP_TYPE_BYE:
|
||||
is_bye = TRUE;
|
||||
/* don't try to attempt lip-sync anymore for streams with a BYE */
|
||||
do_sync = FALSE;
|
||||
rtp_session_process_bye (sess, &packet, &arrival);
|
||||
rtp_session_process_bye (sess, &packet, &pinfo);
|
||||
break;
|
||||
case GST_RTCP_TYPE_APP:
|
||||
rtp_session_process_app (sess, &packet, &arrival);
|
||||
rtp_session_process_app (sess, &packet, &pinfo);
|
||||
break;
|
||||
case GST_RTCP_TYPE_RTPFB:
|
||||
case GST_RTCP_TYPE_PSFB:
|
||||
rtp_session_process_feedback (sess, &packet, &arrival, current_time);
|
||||
rtp_session_process_feedback (sess, &packet, &pinfo, current_time);
|
||||
break;
|
||||
default:
|
||||
GST_WARNING ("got unknown RTCP packet");
|
||||
|
@ -2361,17 +2360,17 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
if (sess->scheduled_bye) {
|
||||
if (is_bye) {
|
||||
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 {
|
||||
/* 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,
|
||||
sess->stats.avg_rtcp_packet_size, arrival.bytes);
|
||||
sess->stats.avg_rtcp_packet_size, pinfo.bytes);
|
||||
RTP_SESSION_UNLOCK (sess);
|
||||
|
||||
clean_arrival_stats (&arrival);
|
||||
clean_packet_info (&pinfo);
|
||||
|
||||
/* notify caller of sr packets in the callback */
|
||||
if (do_sync && sess->callbacks.sync_rtcp) {
|
||||
|
|
|
@ -863,8 +863,7 @@ get_clock_rate (RTPSource * src, guint8 payload)
|
|||
* 50 milliseconds apart and arrive 60 milliseconds apart, then the jitter is 10
|
||||
* milliseconds. */
|
||||
static void
|
||||
calculate_jitter (RTPSource * src, GstBuffer * buffer,
|
||||
RTPArrivalStats * arrival)
|
||||
calculate_jitter (RTPSource * src, GstBuffer * buffer, RTPPacketInfo * pinfo)
|
||||
{
|
||||
GstClockTime running_time;
|
||||
guint32 rtparrival, transit, rtptime;
|
||||
|
@ -874,7 +873,7 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer,
|
|||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
/* 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;
|
||||
|
||||
if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))
|
||||
|
@ -1001,7 +1000,7 @@ do_bitrate_estimation (RTPSource * src, GstClockTime running_time,
|
|||
*/
|
||||
GstFlowReturn
|
||||
rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
|
||||
RTPArrivalStats * arrival)
|
||||
RTPPacketInfo * pinfo)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
guint16 seqnr, udelta;
|
||||
|
@ -1084,22 +1083,22 @@ rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
|
|||
GST_WARNING ("duplicate or reordered packet (seqnr %d)", seqnr);
|
||||
}
|
||||
|
||||
src->stats.octets_received += arrival->payload_len;
|
||||
src->stats.bytes_received += arrival->bytes;
|
||||
src->stats.octets_received += pinfo->payload_len;
|
||||
src->stats.bytes_received += pinfo->bytes;
|
||||
src->stats.packets_received++;
|
||||
/* 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 */
|
||||
src->is_sender = 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,
|
||||
seqnr, src->stats.packets_received, src->stats.octets_received);
|
||||
|
||||
/* calculate jitter for the stats */
|
||||
calculate_jitter (src, buffer, arrival);
|
||||
calculate_jitter (src, buffer, pinfo);
|
||||
|
||||
/* we're ready to push the RTP packet now */
|
||||
result = push_packet (src, buffer);
|
||||
|
|
|
@ -229,7 +229,7 @@ void rtp_source_set_rtp_from (RTPSource *src, GSocketAddress *
|
|||
void rtp_source_set_rtcp_from (RTPSource *src, GSocketAddress *address);
|
||||
|
||||
/* 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,
|
||||
GstClockTime running_time);
|
||||
|
|
|
@ -56,15 +56,15 @@ typedef struct {
|
|||
} RTPReceiverReport;
|
||||
|
||||
/**
|
||||
* RTPArrivalStats:
|
||||
* RTPPacketInfo:
|
||||
* @address: address of the sender of the packet
|
||||
* @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
|
||||
* @running_time: time of a packet as buffer running_time
|
||||
* @ntpnstime: time of a packet NTP time in nanoseconds
|
||||
* @bytes: bytes of the packet including lowlevel overhead
|
||||
* @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 {
|
||||
GSocketAddress *address;
|
||||
|
@ -73,7 +73,7 @@ typedef struct {
|
|||
guint64 ntpnstime;
|
||||
guint bytes;
|
||||
guint payload_len;
|
||||
} RTPArrivalStats;
|
||||
} RTPPacketInfo;
|
||||
|
||||
/**
|
||||
* RTPSourceStats:
|
||||
|
|
Loading…
Reference in a new issue