diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index b5f9a40b410a2103991f798dcb98e2286588c852..d9c86f5ba82efe50c6be8ff074031c4882765acd 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -3044,6 +3044,7 @@ static void audio_packet_handler(pe_packet_t *p) { struct ast_frame frame = { .src = "TELCHAN", }; struct chan_voicemngr_pvt *pvt; int sip_client_id = -1; + unsigned int* packet_buf32 = (unsigned int*)ap->rtp; // Clear the RTP marker bit if ((payload_type & RTP_MARKER_BIT) && payload_type < RTCP_SR) @@ -3101,7 +3102,7 @@ static void audio_packet_handler(pe_packet_t *p) { } else { ast_debug(9, "Wrong sip client id: %d\n", sip_client_id); } - + sub->dsp_ssrc = packet_buf32[2]; // save the DSP's SSRC } else if (packet_type == CHAN_VOICEMNGR_RTCP_SR || packet_type == CHAN_VOICEMNGR_RTCP_RR) { frame.frametype = AST_FRAME_RTCP; frame.data.ptr = ap->rtp; @@ -3634,7 +3635,8 @@ static struct chan_voicemngr_pvt *chan_voicemngr_allocate_pvt(void) sub->channel_state = ONHOOK; sub->time_stamp = 0; sub->sequence_number = 0; - sub->ssrc = 0; + sub->far_end_ssrc = 0; + sub->dsp_ssrc = 0; sub->codec = -1; sub->parent = tmp; sub->cw_timer_id = -1; @@ -3900,7 +3902,8 @@ static void chan_voicemngr_show_subchannels(struct ast_cli_args *a, struct chan_ ast_cli(a->fd, " Connection init : %d\n", sub->connection_init); ast_cli(a->fd, " Codec used : %s\n", chan_voicemngr_get_codec_string(sub->codec)); ast_cli(a->fd, " RTP sequence number : %d\n", sub->sequence_number); - ast_cli(a->fd, " RTP SSRC : %d\n", sub->ssrc); + ast_cli(a->fd, " RTP Far End SSRC : %d\n", sub->far_end_ssrc); + ast_cli(a->fd, " RTP DSP SSRC : %d\n", sub->dsp_ssrc); ast_cli(a->fd, " RTP timestamp : %d\n", sub->time_stamp); ast_cli(a->fd, " CW Timer id : %d\n", sub->cw_timer_id); ast_cli(a->fd, " CW Beep Timer id : %d\n", sub->cwBeep_timer_id); @@ -5216,7 +5219,7 @@ static int chan_voicemngr_signal_callerid(struct ast_channel *chan, struct chan_ static int chan_voicemngr_create_connection(struct chan_voicemngr_subchannel *sub) { if (!sub->connection_init) { /* generate random nr for rtp header */ - sub->ssrc = rand(); + sub->far_end_ssrc = rand(); ast_debug(1, "Creating virtual Asterisk connection for pvt line_id=%i connection_id=%d\n", sub->parent->line_id, sub->connection_id); sub->connection_init = 1; @@ -5484,7 +5487,7 @@ static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel packet_buf16[1] = htons(seqno ? seqno : sub->sequence_number++); //Add sequence number packet_buf32[1] = htonl(rtp_timestamp ? rtp_timestamp : sub->time_stamp); //Add timestamp sub->time_stamp += sub->period*8; - packet_buf32[2] = sub->ssrc; + packet_buf32[2] = sub->far_end_ssrc; } /* @@ -5498,6 +5501,7 @@ static void chan_voicemngr_process_rtcp_packet(struct chan_voicemngr_subchannel { struct rtcp_header_t *rtcp_hdr = (struct rtcp_header_t *)rtcp_frame; uint8_t *packet_end = rtcp_frame + rtcp_size; + unsigned int* packet_buf32 = (unsigned int*)rtcp_frame; while ((uint8_t *)rtcp_hdr + sizeof(struct rtcp_header_t) <= packet_end && // Minimum RTCP packet size validation RTCP_GET_VERSION(rtcp_hdr) == RTP_VERSION && // RTP version validation @@ -5506,12 +5510,13 @@ static void chan_voicemngr_process_rtcp_packet(struct chan_voicemngr_subchannel case RTCP_SR: p->jitter_count++; p->farEndInterrivalJitter += RTCP_SR_GET_INTERARRIVAL_JITTER(rtcp_hdr); + packet_buf32[7] = p->dsp_ssrc; // replace Source Identifier with dsp's SSRC /* Intentional fall through */ case RTCP_RR: case RTCP_SDES: case RTCP_XR: - // Replace SSRC for all types of RTCP packets above - rtcp_hdr->ssrc = p->ssrc; + // Replace SSRC with far end SSRC for all types of RTCP packets above + rtcp_hdr->ssrc = p->far_end_ssrc; break; default: diff --git a/src/channels/chan_voicemngr.h b/src/channels/chan_voicemngr.h index a61cfb99361e14cf1df3b5618499fdb92401f9d1..6975f5bc29f97b795dbe7b25ae8bc482e2f6021f 100644 --- a/src/channels/chan_voicemngr.h +++ b/src/channels/chan_voicemngr.h @@ -155,7 +155,8 @@ struct chan_voicemngr_subchannel { uint16_t sequence_number; /* Endpoint RTP sequence number state */ unsigned int time_stamp; /* Endpoint RTP time stamp state */ unsigned int period; /* Endpoint RTP period */ - unsigned int ssrc; /* Endpoint RTP synchronization source */ + unsigned int far_end_ssrc; /* Endpoint RTP synchronization source of far end */ + unsigned int dsp_ssrc; /* Endpoint RTP synchronization source of DUT's DSP */ int codec; /* Used codec */ struct chan_voicemngr_pvt *parent; /* chan_voicemngr_line owning this subchannel */ int cw_timer_id; /* Current call waiting timer id, -1 if no active timer */