[asterisk-dev] [asterisk-users] Fwd: Asterisk pjsip auto dtmf mode

Yaron Nachum nachum.yaron at gmail.com
Tue Jan 20 01:19:02 CST 2015


Thank you Matthew,
I will start working on the contribution.

I have a question for the developers, but before that I will explain what I
did.

I have been able to add auto dtmf mode on PJSIP channel. The basic idea is
to setup the dtmf mode just like RFC4733, but when going over the
codecs in res_pjsip_sdp_rtp.c,
I look for telephone-event, and if none exists I set the dtmf settings on
ast_sip_session_media->rtp instance to inband.

When sending dtmf in chan_pjsip.c I have added a condition if the dtmf
settings on ast_sip_session_media->rtp instance is inband send the dtmf as
inband.

The only thing I wasn't able to do is enable DSP for dtmf only when the dtmf
settings on ast_sip_session_media->rtp instance is inband. This is done in
res_pjsip_session.c  - ast_sip_session_alloc, and in chan_pjsip -
chan_pjsip_cng_tone_detected. The reason is that ast_sip_session_media
instance is not handled in these functions.

The question is how do I get access to ast_sip_session_media instance? I
have in both functions access to ast_sip_session instance.

Thank you,
Yaron.




On Mon, Jan 19, 2015 at 5:33 PM, Matthew Jordan <mjordan at digium.com> wrote:

>
>
> On Sat, Jan 17, 2015 at 12:04 AM, Yaron Nachum <nachum.yaron at gmail.com>
> wrote:
>
>> Hello Asterisk Users,
>> I have been looking for similar auto dtmf mode implementation on pjsip,
>> but didn't see it coming, so I decided to give it a try.
>> My basic plan was to do it as simple as possible with minimum changes
>> because I am not familiar with all Asterisk code. My idea is to use rfc4733
>> settings, but when going over the codecs check if telephone-event appear
>> and if not set the dtmf mode to inband on rtp instance.
>> I would appreciate if someone would look at what I did and see if I
>> didn't do stupid things. If you think this is something you would like to
>> add to one of the next releases I am willing to help - add the additional
>> dtmf mode ...
>> I based my development on 13.1.0. The following are my changes:
>>
>> In res/res_pjsip_sdp_rtp.c (I added session_media to get_codecs and used
>> it in order to update dtmf settings on rtp instance when telephone-event is
>> not included in the sdp):
>> 150:
>> static void get_codecs(struct ast_sip_session *session, const struct
>> pjmedia_sdp_media *stream, struct ast_rtp_codecs *codecs, struct
>> ast_sip_session_media *session_media)
>> 159:
>>         char fmt_param[256];
>>         int tel_event = 0;
>> 177:
>>                 ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
>>                 if (strcmp(name,"telephone-event") == 0) {
>>                         tel_event++;
>>                 }
>> 202:
>>         }
>>         if (tel_event==0) {
>>                 ast_rtp_instance_dtmf_mode_set(session_media->rtp,
>> AST_RTP_DTMF_MODE_INBAND);
>>         }
>>         /* Get the packetization, if it exists */
>> 241:
>>         get_codecs(session, stream, &codecs, session_media);
>>
>> In res/res_pjsip_session.c (Just activated DSP also on RFC dtmf mode - I
>> didn't find a way to test the rtp instance dtmf settiings because
>> session_media pointer is not there. Any advice for doing so would be
>> appreciated):
>> 1062:
>>         if (endpoint->dtmf == AST_SIP_DTMF_INBAND || endpoint->dtmf ==
>> AST_SIP_DTMF_RFC_4733) {
>>                 dsp_features |= DSP_FEATURE_DIGIT_DETECT;
>>         }
>>
>> In channels/chan_pjsip.c (1 change similar to the above, and 2 more
>> changes to send inband dtmf when rtp instance dtmf settings is inband)
>> 543:
>>        if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND ||
>> session->endpoint->dtmf == AST_SIP_DTMF_RFC_4733) {
>>                 ast_dsp_set_features(session->dsp,
>> DSP_FEATURE_DIGIT_DETECT);
>> 1420:
>>                if (!media || !media->rtp ||
>> (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND))
>> {
>>                         return -1;
>> 1523:
>>                if (!media || !media->rtp ||
>> (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND))
>> {
>>                         return -1;
>>
>> That's it!!! It works fine for me. Any remarks / advice would be
>> appreciated.
>>
>>
> Hey Yaron:
>
> Sounds like a good contribution. Since it is a code change, you may want
> to discuss it further over on the asterisk-dev list.
>
> If you're interested in submitting the contribution upstream to the
> project, you can find instructions on the Asterisk wiki:
>
> https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process
>
> Thanks!
>
> Matt
>
> --
> Matthew Jordan
> Digium, Inc. | Engineering Manager
> 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
> Check us out at: http://digium.com & http://asterisk.org
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>                http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150120/3b729390/attachment-0001.html>


More information about the asterisk-dev mailing list