From a4dd6ccb42d8f54a38cef926f6f8eed0389c5bdd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 9 Nov 2013 23:02:11 +0500 Subject: [PATCH] fix some issues in passthrough of fec packets --- src/switch_core_media.c | 18 +++++++++++++++++- src/switch_rtp.c | 5 ++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index bbef0b79bd..61048d9ad2 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -495,6 +495,8 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se if (!exists) { + switch_ssize_t hlen = -1; + if (engine->payload_map && !engine->payload_map->allocated) { pmap = engine->payload_map; } else { @@ -507,6 +509,7 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se pmap->rm_encoding = pmap->iananame; pmap->ptime = ptime; pmap->rate = rate; + pmap->hash = switch_ci_hashfunc_default(pmap->iananame, &hlen); } pmap->allocated = 1; @@ -5643,6 +5646,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_media_handle_t *smh; ice_t *ice_out; int vp8 = 0; + int red = 0; payload_map_t *pmap; switch_assert(session); @@ -6216,6 +6220,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess vp8 = v_engine->cur_payload_map->pt; } + if (!strcasecmp(v_engine->cur_payload_map->rm_encoding, "red")) { + red = v_engine->cur_payload_map->pt; + } + rate = v_engine->cur_payload_map->rm_rate; switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\n", v_engine->cur_payload_map->pt, v_engine->cur_payload_map->rm_encoding, @@ -6299,6 +6307,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess vp8 = ianacode; } + if (!strcasecmp(imp->iananame, "red")) { + red = ianacode; + } + if (channels > 1) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\n", ianacode, imp->iananame, imp->samples_per_second, channels); @@ -6377,11 +6389,15 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "b=AS:%d\n", bw); } - if (vp8) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtcp-fb:%d ccm fir\n", vp8); } + + if (red) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), + "a=rtcp-fb:%d nack\n", vp8); + } switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\n", v_engine->ssrc, smh->cname); switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s v0\n", v_engine->ssrc, smh->msid); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index a0e80013f0..aa296c95da 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -399,7 +399,6 @@ struct switch_rtp { switch_core_session_t *session; payload_map_t **pmaps; payload_map_t *pmap_tail; - int pmap_ttl; #ifdef ENABLE_ZRTP zrtp_session_t *zrtp_session; @@ -6200,10 +6199,10 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra rtp_session->stats.outbound.packet_count++; } - if (frame->pmap && rtp_session->pmaps && *rtp_session->pmaps && rtp_session->pmap_ttl > 1) { + if (frame->pmap && rtp_session->pmaps && *rtp_session->pmaps) { payload_map_t *pmap; - switch_mutex_lock(rtp_session->flag_mutex); + switch_mutex_lock(rtp_session->flag_mutex); for (pmap = *rtp_session->pmaps; pmap; pmap = pmap->next) { if (pmap->hash == frame->pmap->hash && !strcmp(pmap->iananame, frame->pmap->iananame)) { payload = pmap->recv_pt;