From 8592584e11d13f1c0083ca7198dbcb2c9aefa02e Mon Sep 17 00:00:00 2001 From: Grzegorz Sluja <grzegorz.sluja@sigma.se> Date: Fri, 4 Aug 2023 10:24:51 +0200 Subject: [PATCH] Fix RTP packet's timestamp based on the real incoming packet's lenght --- src/channels/chan_voicemngr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index 2c9d6d2..21f1527 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -77,7 +77,7 @@ static int chan_voicemngr_in_conference(const struct chan_voicemngr_pvt *p); static int cwtimeout_cb(const void *data); static int cwbeep_cb(const void *data); static int r4hanguptimeout_cb(const void *data); -static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel *p, uint8_t *packet_buf, int type, int marker, int dtmf_timestamp, int seqno); +static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel *p, uint8_t *packet_buf, int type, int marker, int dtmf_timestamp, int seqno, int len); static void chan_voicemngr_process_rtcp_packet(struct chan_voicemngr_subchannel *p, uint8_t *rtcp_frame, uint32_t rtcp_size); static int chan_voicemngr_mute_connection(struct chan_voicemngr_subchannel *p); static int chan_voicemngr_unmute_connection(struct chan_voicemngr_subchannel *p); @@ -1658,7 +1658,7 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame pvt_lock(sub->parent, "TELCHAN write frame"); /* generate the rtp header */ - chan_voicemngr_generate_rtp_packet(sub, ap->rtp, RTP_PT_CN, 0, 0, frame->seqno); + chan_voicemngr_generate_rtp_packet(sub, ap->rtp, RTP_PT_CN, 0, 0, frame->seqno, frame->len); sip_client_id = chan_voicemngr_get_sip_client_id(sub); if (sip_client_id >= 0 && sip_client_id < MAX_SIP_CLIENTS) { @@ -1694,7 +1694,7 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame pvt_lock(sub->parent, "TELCHAN write frame"); /* generate the rtp header */ - chan_voicemngr_generate_rtp_packet(sub, ap->rtp, map_ast_codec_id_to_rtp(frame->subclass.format), 0, 0, frame->seqno); + chan_voicemngr_generate_rtp_packet(sub, ap->rtp, map_ast_codec_id_to_rtp(frame->subclass.format), 0, 0, frame->seqno, frame->len); sip_client_id = chan_voicemngr_get_sip_client_id(sub); if (sip_client_id >= 0 && sip_client_id < MAX_SIP_CLIENTS) { @@ -5407,7 +5407,7 @@ static int chan_voicemngr_close_connection(struct chan_voicemngr_subchannel *sub } /* Generate rtp payload, 12 bytes of header and 160 bytes of ulaw payload */ -static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel *sub, uint8_t *packet_buf, int type, int marker, int dtmf_timestamp, int seqno) +static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel *sub, uint8_t *packet_buf, int type, int marker, int dtmf_timestamp, int seqno, int len) { unsigned short* packet_buf16 = (unsigned short*)packet_buf; unsigned int* packet_buf32 = (unsigned int*)packet_buf; @@ -5421,7 +5421,7 @@ static void chan_voicemngr_generate_rtp_packet(struct chan_voicemngr_subchannel packet_buf[1] |= marker?0x80:0x00; packet_buf16[1] = htons(seqno ? seqno : sub->sequence_number++); //Add sequence number packet_buf32[1] = htonl(sub->time_stamp); //Add timestamp - sub->time_stamp += sub->period*8; + sub->time_stamp += len*8; packet_buf32[2] = sub->ssrc; } -- GitLab