]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6623 #resolve fix init and logging for rtcp
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 12 Sep 2014 20:41:49 +0000 (01:41 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 15 Sep 2014 15:08:09 +0000 (20:08 +0500)
src/include/switch_types.h
src/switch_rtp.c

index 07576099e354b1048a9375c8b07d9324404c9bbf..145d743274bbb1630a8cab317032b201165e1f97 100644 (file)
@@ -648,6 +648,7 @@ typedef struct {
        uint32_t cum_lost;            /* Packet loss calculation, cumulative number of packet lost */ 
        uint32_t last_recv_lsr_local; /* RTT calculation, When receiving an SR we save our local timestamp in fraction of 65536 seconds */
        uint32_t last_recv_lsr_peer;  /* RTT calculation, When receiving an SR we extract the middle 32bits of the remote NTP timestamp to include it in the next SR LSR */
+       uint32_t init;
 } switch_rtcp_numbers_t;
 
 typedef struct {
index 8e3ee117b6db0805cf37b0057e8181757f76eb4f..475f804675ad15ec3292f9de98b518ab74882a5f 100644 (file)
@@ -1418,6 +1418,10 @@ static void send_fir(switch_rtp_t *rtp_session)
                rtp_session->remote_ssrc = rtp_session->stats.rtcp.peer_ssrc;
        }
 
+       if (rtp_session->remote_ssrc == 0) {
+               rtp_session->remote_ssrc = ntohl(rtp_session->recv_msg.header.ssrc);
+       }
+
        if (rtp_session->remote_ssrc == 0) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Peer ssrc not known yet for FIR\n");
                return;
@@ -1884,6 +1888,7 @@ static void rtcp_stats_init(switch_rtp_t *rtp_session)
        switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
        stats->ssrc = ntohl(hdr->ssrc);
        stats->last_rpt_ts = rtp_session->timer.samplecount;
+       stats->init = 1;
        stats->last_rpt_ext_seq = 0;
        stats->last_rpt_cycle = 0;
        stats->last_pkt_tsdiff = 0;
@@ -1898,13 +1903,13 @@ static void rtcp_stats_init(switch_rtp_t *rtp_session)
        stats->rtcp_rtp_count = 0;
 
        if (!rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: rtcp disabled");
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: rtcp disabled\n");
        } else if (!rtp_session->rtcp_sock_output) {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "rtcp_stats_init: no rtcp socket");
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "rtcp_stats_init: no rtcp socket\n");
        } else if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_PASSTHRU]) {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: rtcp passthru");
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: rtcp passthru\n");
        } else {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: ssrc[%d] base_seq[%d]", stats->ssrc, stats->base_seq);
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: ssrc[%d] base_seq[%d]\n", stats->ssrc, stats->base_seq);
        }
 }
 
@@ -1951,7 +1956,7 @@ static int rtcp_stats(switch_rtp_t *rtp_session)
        }
 
        /* Verify that we are on the same stream source (we do not support multiple sources) */
-       if (ntohl(hdr->ssrc) != stats->ssrc || !stats->last_rpt_ts) {
+       if (ntohl(hdr->ssrc) != stats->ssrc || !stats->init) {
                rtcp_stats_init(rtp_session);
        }