mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 17:22:21 +00:00
tolerate offset dtmf payload (zoiper)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14883 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
45ecc4b0d3
commit
cd4d3f3dc5
@ -2065,18 +2065,42 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
*/
|
*/
|
||||||
if (bytes && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &&
|
if (bytes && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &&
|
||||||
!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833) && rtp_session->recv_msg.header.pt == rtp_session->te) {
|
!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833) && rtp_session->recv_msg.header.pt == rtp_session->te) {
|
||||||
|
switch_size_t len = bytes - rtp_header_len;
|
||||||
unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
|
unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
|
||||||
int end = packet[1] & 0x80 ? 1 : 0;
|
int end;
|
||||||
uint16_t duration = (packet[2] << 8) + packet[3];
|
uint16_t duration;
|
||||||
char key = switch_rfc2833_to_char(packet[0]);
|
char key;
|
||||||
uint16_t in_digit_seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
|
uint16_t in_digit_seq;
|
||||||
uint32_t ts = htonl(rtp_session->recv_msg.header.ts);
|
uint32_t ts;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(packet[0] || packet[1] || packet[2] || packet[3]) && len >= 8) {
|
||||||
|
packet += 4;
|
||||||
|
len -= 4;
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "DTMF payload offset by 4 bytes.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(packet[0] || packet[1] || packet[2] || packet[3])) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed DTMF payload check.\n");
|
||||||
|
rtp_session->dtmf_data.last_digit = 0;
|
||||||
|
rtp_session->dtmf_data.in_digit_ts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = packet[1] & 0x80 ? 1 : 0;
|
||||||
|
duration = (packet[2] << 8) + packet[3];
|
||||||
|
key = switch_rfc2833_to_char(packet[0]);
|
||||||
|
in_digit_seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
|
||||||
|
ts = htonl(rtp_session->recv_msg.header.ts);
|
||||||
|
|
||||||
if (in_digit_seq < rtp_session->dtmf_data.in_digit_seq) {
|
if (in_digit_seq < rtp_session->dtmf_data.in_digit_seq) {
|
||||||
if (rtp_session->dtmf_data.in_digit_seq - in_digit_seq > 100) {
|
if (rtp_session->dtmf_data.in_digit_seq - in_digit_seq > 100) {
|
||||||
rtp_session->dtmf_data.in_digit_seq = 0;
|
rtp_session->dtmf_data.in_digit_seq = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_2833
|
||||||
|
printf("packet[%d]: %02x %02x %02x %02x\n", (int) len, (unsigned) packet[0],(unsigned)
|
||||||
|
packet[1], (unsigned) packet[2], (unsigned) packet[3]);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (in_digit_seq > rtp_session->dtmf_data.in_digit_seq) {
|
if (in_digit_seq > rtp_session->dtmf_data.in_digit_seq) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user