[Asterisk-Dev] SIP and IAX: Changing codec mid-call (NOT forcing codec at dial)

Mark Aiken aiken.mark at gmail.com
Fri Oct 7 08:32:18 MST 2005


Check out the code in the function sip_set_rtp_peer, in chan_sip.c, to see
how to trigger a reINVITE. The harder bit is adding code to trigger from the
dialplan. You want to be sure the SIP dialog is properly established as
well. chan_sip is quite fragile, be careful not to break it. :)


On 10/7/05, Daniel Floyd <ncsuengr00 at gmail.com> wrote:
>
> Hello all:
>
> I've spent the last week looking into this trying to see if there is
> any support for it and I can't find any. There appears to be ways to
> override/force a codec at dial time, at least for SIP. IAX appears to
> have something in CVS HEAD, but I can't find any docs/explanation for
> it and haven't dug into the code to figure it out yet. But either
> way, that's not what I'm looking for.
>
> I want a call (specifically incoming) to start out as ULAW (via
> allow/disallow statements in sip.conf and iax.conf) so I can do fax
> detection on it (although G726 seems to be pretty reliable for fax in
> my testing as well). If the call is a fax, leave the call unchanged.
> If the call isn't a fax, I want to change the codec to GSM. I know
> both SIP and IAX protocols support this -- SIP via re-INVITE and IAX
> by sending a new full VOICE packet with the new codec. Although, I'm
> not clear in IAX if that actually makes the far end change its codec
> as well, which would be desired in this situation.
>
> What would be great is a dialplan app that can be called to do this
> dirty work. For example:
>
> In extensions.conf:
>
> [incoming]
> exten => s,1,Answer
> exten => s,2,Ringing
> exten => s,3,NVFaxDetect(|td) ;Great App, by the way!
> exten => s,4,ChangeCodec(gsm)
> exten => s,105,NoOp(Codec changed failed!) ;Do something here if
> codec change fails.
> exten => s,106,Hangup
> exten => s,5,Dial(SIP/${OPERATOR})
>
> exten => fax,1,Dial(SIP/${FAX})
>
> I realize this is perhaps a little oversimpliflied since changing
> codecs is channel specific, so maybe SIPChangeCodec or IAXChangeCodec
> would probably be more realistic, but this gives the basic idea.
>
> Outbound calls are a easier since I know where the call is coming
> from. But I'm running CVS stable and right now the only way I see to
> do this with IAX is to define multiple IAX peers for the same host
> with the only difference being the allowed codec. Seems a little
> cluggy. Maybe the new stuff I saw in CVS HEAD gets around this, but
> like I said, I couldn't find anything about it with Google or on
> voip-info.org <http://voip-info.org>.
>
> Any thoughts?
>
> And I'm not opposed to trying my hand at this myself. I do pose as a
> software engineer by day. And I could probably even make this into
> work-related work. But any pointers from anyone familiar with the IAX
> and SIP code would be great as far as how simple or complex this might
> be based on where the code is at right now. If it would require a lot
> of "pot stirring", I don't know that I would want to mess with it, at
> least right now. And at the very least, I wanted to generate some
> discussion on the topic since I couldn't seem to find anything else on
> it.
>
> Thanks,
> Daniel
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20051007/9f219a4a/attachment.htm


More information about the asterisk-dev mailing list