diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index cbcc54450162ff38a82551ec0a38ae2671fa90ca..995ac58f83cee9571f5c7e6d867a257a418a8d6b 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -5785,6 +5785,18 @@ static struct ast_frame *create_dtmf_frame(struct ast_rtp_instance *instance, en return &rtp->f; } +static inline void find_event_end_duration_in_frame(unsigned char *data, unsigned int *event, unsigned int *event_end, unsigned int *samples) +{ + /* Figure out event, event end, and samples */ + *event = ntohl(*((unsigned int *)(data))); + *event >>= 24; + *event_end = ntohl(*((unsigned int *)(data))); + *event_end <<= 8; + *event_end >>= 24; + *samples = ntohl(*((unsigned int *)(data))); + *samples &= 0xFFFF; +} + static void process_dtmf_rfc2833(struct ast_rtp_instance *instance, unsigned char *data, int len, unsigned int seqno, unsigned int timestamp, int payloadtype, int mark, struct frame_list *frames) { struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); @@ -5795,15 +5807,7 @@ static void process_dtmf_rfc2833(struct ast_rtp_instance *instance, unsigned cha ast_rtp_instance_get_remote_address(instance, &remote_address); - /* Figure out event, event end, and samples */ - event = ntohl(*((unsigned int *)(data))); - event >>= 24; - event_end = ntohl(*((unsigned int *)(data))); - event_end <<= 8; - event_end >>= 24; - samples = ntohl(*((unsigned int *)(data))); - samples &= 0xFFFF; - + find_event_end_duration_in_frame(data, &event, &event_end, &samples); if (rtp_debug_test_addr(&remote_address)) { ast_verbose("Got RTP RFC2833 from %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6d, mark %d, event %08x, end %d, duration %-5.5u) \n", ast_sockaddr_stringify(&remote_address), @@ -5926,6 +5930,7 @@ static void process_dtmf_rfc2833(struct ast_rtp_instance *instance, unsigned cha static struct ast_frame *bypass_dtmf_rfc4733(struct ast_rtp_instance *instance, unsigned char *data, int len, unsigned int seqno, unsigned int timestamp, int payloadtype, long ssrc, int hdrlen) { + unsigned int event, event_end, samples; struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); rtp->f.frametype = AST_FRAME_DTMF_BYPASS; @@ -5946,9 +5951,11 @@ static struct ast_frame *bypass_dtmf_rfc4733(struct ast_rtp_instance *instance, rtp->f.seqno = seqno; rtp->f.stream_num = rtp->stream_num; + find_event_end_duration_in_frame(data, &event, &event_end, &samples); if (ast_debug_rtp_packet_is_allowed) { - ast_debug(0, "RTP for Telephone Event: payload type = %d, len = %d, event = %hhu, timestamp = %ld, seqno = %d\n", - rtp->f.subclass.integer, rtp->f.datalen, *(unsigned char *)rtp->f.data.ptr, rtp->f.ts, rtp->f.seqno); + ast_debug(0, "RTP for Telephone Event: payload type = %d, len = %d, event = %hhu, timestamp = %ld, seqno = %d, event %08x, end %d, duration %-5.5u\n", + rtp->f.subclass.integer, rtp->f.datalen, *(unsigned char *)rtp->f.data.ptr, rtp->f.ts, + rtp->f.seqno, event, ((event_end & 0x80) ? 1 : 0), samples); } return &rtp->f; @@ -9382,6 +9389,8 @@ static int ast_rtp_send_dtmf_bypass(struct ast_rtp_instance *instance, struct as struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); struct ast_sockaddr remote_address = { {0,} }; int ice; + unsigned int event, event_end, samples; + unsigned char *data = (unsigned char *)(frame->data.ptr); ast_rtp_instance_get_remote_address(instance, &remote_address); if (ast_sockaddr_isnull(&remote_address)) { @@ -9406,11 +9415,13 @@ static int ast_rtp_send_dtmf_bypass(struct ast_rtp_instance *instance, struct as return res; } + find_event_end_duration_in_frame(data, &event, &event_end, &samples); if (rtp_debug_test_addr(&remote_address)) { - ast_verbose("Sent RTP Bypass packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n", + ast_verbose("Sent RTP Bypass packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d, event %08x, end %d, duration %-5.5u)\n", ast_sockaddr_stringify(&remote_address), ice ? " (via ICE)" : "", - AST_RTP_DTMF, rtp->seqno, rtp->lastdigitts, res - hdrlen); + AST_RTP_DTMF, rtp->seqno, rtp->lastdigitts, res - hdrlen, + event, ((event_end & 0x80) ? 1 : 0), samples); } rtp->seqno++;