[OpenSIPS-Users] Media server communication with OpenSIPS

Wadii ELMAJDI | Evenmedia wadii at evenmedia.fr
Thu Dec 29 20:57:06 UTC 2022


Hello,

The invite is relayed from OpenSIPS to Asterisk. Asterisk has UAS role here.
The data i'm hoping to transfer to OPENSIPS should be sent either with the 200 OK (Asterisk to OpenSIPS), during the call, or via BYE.
So neither PJSIP_HEADER nor PJSIP_RESPONSE_HEADER can help with my usecase.
I have already used  pjsip session refresh to renegotiate media codecs during a call, but i've never tried adding an extraheader to the re-invite/update method.
I will try this asap, thank you for the detailed answer.


________________________________
De : Users <users-bounces at lists.opensips.org> de la part de Gregory Massel <greg at switchtel.co.za>
Envoyé : jeudi 29 décembre 2022 20:28
À : users at lists.opensips.org <users at lists.opensips.org>
Objet : Re: [OpenSIPS-Users] Media server communication with OpenSIPS


You can send custom headers from Asterisk to OpenSIPS using:

https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Function_PJSIP_HEADER

If you need Asterisk to receive customer headers from OpenSIPS, you can read custom headers added by OpenSIPS to its 200 response using:

https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Function_PJSIP_RESPONSE_HEADER


If you are already midway through a call, you can force an UPDATE or re-INVITE using:

https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Function_PJSIP_SEND_SESSION_REFRESH


While I haven't personally tested, I'd expect that you should be able to signal custom information midway through a call with a Set(PJSIP_HEADER(add,X-MyHeader)=myvalue) followed by a Set(PJSIP_SEND_SESSION_REFRESH()=invite). This should then trigger a re-INVITE carrying the new X-MyHeader within it.

Similarly, after triggering the a re-INVITE or UPDATE, you should then be able to do a Set(MYVAR=PJSIP_RESPONSE_HEADER(read,X-MyHeader)) to extract what OpenSIPS has sent back to Asterisk in its 200 response.


Although more messy, there are also other tricks that you can use, including the CONNECTEDLINE function:

https://wiki.asterisk.org/wiki/display/AST/Manipulating+Party+ID+Information

https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Function_CONNECTEDLINE

e.g. If you did a Set(CONNECTEDLINE(name)=Information_I_wish_to_share_with_OpenSIPS), then this will, in one step, trigger an UPDATE or re-INVITE carrying the new connected party name in the SIP headers, detail which you can then extract from OpenSIPS. Similarly, you can also use this approach read information that OpenSIPS has sent to Asterisk, with a Set(MYVAR=CONNECTEDLINE(name)).

I mention this in case, for whatever reason, the first approach (described above) doesn't work as planned, however, the first approach is definitely preferable as you can carry the information in your own X- header, making it far easier to send/receive multiple headers.

On Tue, Dec 27, 2022 at 8:55 AM Wadii ELMAJDI | Evenmedia <wadii at evenmedia.fr<mailto:wadii at evenmedia.fr>> wrote:
>
> Hello,
>
>
> I am using Asterisk as a media server behind OpenSIPS.
> I need to send some additional data to opensips during the call or at the latest during the hangup. For instance a custom hang up reason.
> Asterisk does not allow neither to send a sequential request withing an ongoing dialog, nor add headers to a BYE method.
> The current solution I’m using is pushing a dialog var (dlg_push_var) using Call-ID via (mi_http), but that means I rely on a curl http request during my call…
> Is there any better option for a direct communication between the two boxes during a call ? without any intermediate server (Redis DB …)
>
> Thank you
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org<mailto:Users at lists.opensips.org>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
Users at lists.opensips.org<mailto:Users at lists.opensips.org>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20221229/2883afc7/attachment-0001.html>


More information about the Users mailing list