From 4abdd3253e92bbe99ff4c8753801a2f1ddea68f8 Mon Sep 17 00:00:00 2001 From: "wenpeng.song" <wenpeng.song@iopsys.eu> Date: Wed, 24 Apr 2024 16:07:59 +0200 Subject: [PATCH] correction --- include/asterisk/channel.h | 26 ++++++++++++++++++++++++-- include/asterisk/res_pjsip.h | 3 +++ main/channel.c | 2 +- main/channel_internal_api.c | 6 +++--- res/res_rtp_asterisk.c | 2 +- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index a7ca21c604..704c999843 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -210,6 +210,28 @@ enum ast_bridge_result { AST_BRIDGE_RETRY = -3, }; +#ifndef _ast_sip_dtmf_mode_ +#define _ast_sip_dtmf_mode_ +/*! + * \brief DTMF modes for SIP endpoints + */ +enum ast_sip_dtmf_mode { + /*! No DTMF to be used */ + AST_SIP_DTMF_NONE, + /* XXX Should this be 2833 instead? */ + /*! Use RFC 4733 events for DTMF */ + AST_SIP_DTMF_RFC_4733, + /*! Use DTMF in the audio stream */ + AST_SIP_DTMF_INBAND, + /*! Use SIP INFO DTMF (blech) */ + AST_SIP_DTMF_INFO, + /*! Use SIP 4733 if supported by the other side or INBAND if not */ + AST_SIP_DTMF_AUTO, + /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */ + AST_SIP_DTMF_AUTO_INFO, +}; +#endif + typedef unsigned long long ast_group_t; struct ast_stream_topology; @@ -4330,8 +4352,8 @@ int ast_channel_emergency_ongoing_get(const struct ast_channel *chan); void ast_channel_emergency_ongoing_set(struct ast_channel *chan, int emergency_ongoing); int ast_channel_ptime_get(const struct ast_channel *chan); void ast_channel_ptime_set(struct ast_channel *chan, int ptime); -int ast_channel_dtmf_mode_get(const struct ast_channel *chan); -void ast_channel_dtmf_mode_set(struct ast_channel *chan, int dtmf_mode); +enum ast_sip_dtmf_mode ast_channel_dtmf_mode_get(const struct ast_channel *chan); +void ast_channel_dtmf_mode_set(struct ast_channel *chan, enum ast_sip_dtmf_mode dtmf_mode); /*! * \pre chan is locked diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h index 3e7efbf49e..ff6e25f654 100644 --- a/include/asterisk/res_pjsip.h +++ b/include/asterisk/res_pjsip.h @@ -529,6 +529,8 @@ enum ast_sip_100rel_mode { AST_SIP_100REL_REQUIRED, }; +#ifndef _ast_sip_dtmf_mode_ +#define _ast_sip_dtmf_mode_ /*! * \brief DTMF modes for SIP endpoints */ @@ -547,6 +549,7 @@ enum ast_sip_dtmf_mode { /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */ AST_SIP_DTMF_AUTO_INFO, }; +#endif /*! * \brief Methods of storing SIP digest authentication credentials. diff --git a/main/channel.c b/main/channel.c index 868efa31da..93a8cddce4 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4094,7 +4094,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int ast_channel_dtmf_digit_to_emulate_set(chan, 0); } - if (dropaudio || (ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF) && ast_channel_dtmf_mode_get(chan)!=3) ) { + if (dropaudio || (ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF) && ast_channel_dtmf_mode_get(chan)!=AST_SIP_DTMF_INFO) ) { if (dropaudio) ast_read_generator_actions(chan, f); ast_frfree(f); diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index 7aa73f5443..f9f90559b8 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -233,7 +233,7 @@ struct ast_channel { rtp_statistics *rtp_stats; /*!< RTP statistics */ int emergency_ongoing; /*!< indicate if an emergency session is ongoing */ int ptime; /*!< Negotiated ptime */ - int dtmf_mode; + enum ast_sip_dtmf_mode dtmf_mode; }; /*! \brief The monotonically increasing integer counter for channel uniqueids */ @@ -877,11 +877,11 @@ void ast_channel_codec_set(struct ast_channel *chan, const char *value) ast_copy_string(chan->codec, value, sizeof(chan->codec)); } -int ast_channel_dtmf_mode_get(const struct ast_channel *chan) +enum ast_sip_dtmf_mode ast_channel_dtmf_mode_get(const struct ast_channel *chan) { return chan->dtmf_mode; } -void ast_channel_dtmf_mode_set(struct ast_channel *chan, int dtmf_mode) +void ast_channel_dtmf_mode_set(struct ast_channel *chan, enum ast_sip_dtmf_mode dtmf_mode) { chan->dtmf_mode = dtmf_mode; } diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index ba0073b6ae..9ee13caba2 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -9368,7 +9368,7 @@ static int ast_rtp_send_dtmf_bypass(struct ast_rtp_instance *instance, struct as rtpheader = (unsigned char *)(frame->data.ptr - hdrlen); rtpheader[0] = htonl((2 << 30) | (payload << 16) | (frame->seqno?frame->seqno:rtp->seqno)); rtpheader[1] = htonl(frame->ts? frame->ts:rtp->lastdigitts); - rtpheader[2] = htonl(rtp->ssrc); + rtpheader[2] = htonl(frame->ssrc); res = rtp_sendto(instance, (void *) rtpheader, hdrlen + frame->datalen, 0, &remote_address, &ice); -- GitLab