| 1 | = Integrating Third Party Media Stack with PJSIP = |
| 2 | |
| 3 | == Introduction == |
| 4 | |
| 5 | PJSIP consists of several libraries which mostly are independent from one another. The library architecture diagram below shows how libraries are interacting with each other. |
| 6 | |
| 7 | |
| 8 | |
| 9 | == SIP and Media Interaction == |
| 10 | |
| 11 | Pseudo-code when creating a call (same flow for caller and callee): |
| 12 | |
| 13 | '''create_call()'''[[BR]] |
| 14 | {[[BR]] |
| 15 | ''// Create the dialog''[[BR]] |
| 16 | '''dlg = pjsip_dlg_create_uac/uas();''' |
| 17 | |
| 18 | ''// Create media transport (pair of RTP/RTCP socket) for''[[BR]] |
| 19 | ''// transmitting/receiving the media from remote endpoint''[[BR]] |
| 20 | '''media_transport = pjmedia_transport_udp_create();''' |
| 21 | |
| 22 | ''// Get the socket address info of the media transport''[[BR]] |
| 23 | ''// These are needed to create a complete SDP descriptor''[[BR]] |
| 24 | '''media_sock_info = pjmedia_transport_get_info(media_transport);''' |
| 25 | |
| 26 | ''// Create local SDP to be given to invite session''[[BR]] |
| 27 | '''sdp = pjmedia_endpt_create_sdp(media_sock_info);''' |
| 28 | |
| 29 | ''// Create the invite session, giving it both the dialog''[[BR]] |
| 30 | ''// and local SDP to be negotiated''[[BR]] |
| 31 | '''inv = pjsip_inv_create_uac/uas();'''[[BR]] |
| 32 | } |
| 33 | |
| 34 | '''pjsip_endpt_create_sdp(media_sock_info)'''[[BR]] |
| 35 | {[[BR]] |
| 36 | ''// Query list of codecs that we support''[[BR]] |
| 37 | '''codec_list[] = pjmedia_codec_mgr_enum_codecs();''' |
| 38 | |
| 39 | ''// Put each codec information in the SDP''[[BR]] |
| 40 | ... |
| 41 | |
| 42 | ''// Put media socket address info in SDP c= and m= line''[[BR]] |
| 43 | ... |
| 44 | |
| 45 | '''return sdp;''' |
| 46 | } |