pjsua custom sdp

≡放荡痞女 提交于 2019-12-08 06:24:00

问题


I'm using pjsua to create simple SIP UA. I need to insert custom body (SDP) in outgoing INVITE requests. As far as I know, pjsua does not support custom SDP, and I need to use more low-level API to do it. But for now I have to find any rude trick/hack/hotfix to insert custom SDP in pjsua-generated INVITE.

So that's the question: how could I do it?


回答1:


The seemingly simple solution is to modify the pjsua source. The key is to create a pjmedia_session out of your custom SDP on code paths of both incoming and outgoing calls. You wanna look into pjsua_call_make_call(), pjsua_call_answer() and pjsua_call_get_media_session(). If my memory serves me right, SDP is not processed until a call is answered.

You will still have to learn the core pjsip library. After all, pjsua uses it. This solution is not exactly simple but fits the general definition of a hack. :)




回答2:


You have different ways to modify request's SDP body:

  1. You can build a custom request by using pjsip_endpt_create_request, and directly work with the pjsip_tx_data structure. In this case , you can use pjsip_msg_body_create (http://www.pjsip.org/pjsip/docs/html/group_PJSIP_MSG__BODY.htm) by passing type, subtype and your custom body as a pj_str_t pointer. The response of this function should be stored in pjsip_tx_data's field msg.body.

  2. On the other hand, if you're using a pjsua_msg_data structure, and you don't mind handling multiple bodies, you can store the response from pjsip_msg_body_create into a
    pjsip_multipart_part (specifically into the body field) and add it to multipart_parts field inside the pjsup_msg_data object.

  3. You can create your own media transport by using the pjsua's on_create_media_transport callback. This is a bit more complex but, by far, more flexible. You will be able to define several transport related callbacks (send_rtp, send_rtcp, etc.) and, if I remember right, one of them is called on SDP body encoding, allowing you to modify it or set your own.

Hope this helps.




回答3:


If you use PJSUA2, you can use onCallSdpCreated() and on_call_sdp_created() to set custom sdp.



来源:https://stackoverflow.com/questions/11880030/pjsua-custom-sdp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!