5 | | {{{ |
6 | | pjsua_call_make_call(): |
7 | | pjsua_call_on_incoming(): |
8 | | pjsua_call_update(): |
9 | | pjsua_call_reinvite(): |
10 | | pjsua_call_on_rx_offer(): |
11 | | pjsua_call_on_create_offer(): |
12 | | { |
13 | | pjsua_media_channel_init(); |
14 | | pjsua_media_channel_create_sdp(); |
15 | | } |
| 6 | '''pjsua_call_make_call()''' : :: |
| 7 | '''pjsua_call_on_incoming()''' : :: |
| 8 | '''pjsua_call_update()''' : :: |
| 9 | '''pjsua_call_reinvite()''' : :: |
| 10 | '''pjsua_call_on_rx_offer()''' : :: |
| 11 | '''pjsua_call_on_create_offer()''' : :: |
| 12 | pjsua_media_channel_init();[[BR]] |
| 13 | pjsua_media_channel_create_sdp(); |
49 | | pjsua_media_channel_deinit(): |
50 | | { |
51 | | stop_media_session(); |
52 | | pjmedia_transport_media_stop(); |
53 | | pjmedia_transport_close(srtp); |
54 | | } |
55 | | }}} |
56 | | |
57 | | = Reasons for Fix/Change = |
58 | | |
59 | | The interface above has some drawbacks: |
60 | | |
61 | | 1. The main drawback is it does not distinguish between a new/freshly created call and existing call (which needs updating the media because of re-INVITE/UPDATE), functions such as pjsua_call_on_create_offer() will actually re-initialize the media, hence causing problems such as ticket #525 (crash on UPDATE/re-INVITE). |
62 | | 1. It requires media transports to be re-created during application startup and kept-alive throughout the application lifetime. The drawbacks of this are (as documented by ticket #539): |
63 | | a. it requires STUN and TURN transport to be kept-alive, which means it needs to send periodic keep-alive packets, and this is not good for battery consumption in mobile devices. |
64 | | a. it requires TURN long-term allocation, which will fail if the NAT/mapped public IP address mapping has changed. |
65 | | a. even when TURN is not used it may still fail when normal UDP media transport (i.e. not ICE) is used and the IP address (STUN or not) changes. |
66 | | a. it allocates a lot of resources when the number of max_calls is large. |
| 37 | '''pjsua_media_channel_deinit()''' : :: |
| 38 | stop_media_session();[[BR]] |
| 39 | pjmedia_transport_media_stop();[[BR]] |
| 40 | pjmedia_transport_close(srtp); |
97 | | pjsua_call_on_state_changed(DISCONNECTED): |
98 | | pjsua_call_on_media_update(HOLD): |
99 | | { |
100 | | pjsua_media_channel_deinit(); |
101 | | } |
102 | | }}} |
| 64 | '''pjsua_call_on_media_update()''' : :: |
| 65 | pjsua_media_channel_update(); |
| 66 | |
| 67 | '''pjsua_call_on_state_changed(DISCONNECTED)''' : :: |
| 68 | '''pjsua_call_on_media_update(HOLD)''' : :: |
| 69 | pjsua_media_channel_deinit(); |
| 70 | |
| 71 | == pjsua_media.c == |
| 72 | |
| 73 | and this is the implementation of media channel functions above: |
| 74 | |
| 75 | '''pjsua_media_channel_init()''' : :: |
| 76 | pjmedia_transport_srtp_create();[[BR]] |
| 77 | ''pjmedia_transport_media_create();'' |
| 78 | |
| 79 | '''pjsua_media_channel_create_sdp()''' : :: |
| 80 | pjmedia_endpt_create_sdp();[[BR]] |
| 81 | ''pjmedia_transport_encode_sdp();'' |
| 82 | |
| 83 | '''pjsua_media_channel_update()''' : :: |
| 84 | pjmedia_transport_media_start();[[BR]] |
| 85 | pjmedia_session_create(); |
| 86 | |
| 87 | '''pjsua_media_channel_deinit()''' : :: |
| 88 | stop_media_session();[[BR]] |
| 89 | pjmedia_transport_media_stop();[[BR]] |
| 90 | pjmedia_transport_close(srtp); |
111 | | pjsua_media_channel_create_sdp(): |
112 | | { |
113 | | pjmedia_endpt_create_sdp(); |
114 | | pjmedia_transport_media_create(); |
115 | | } |
116 | | |
117 | | pjsua_media_channel_update(): |
118 | | { |
119 | | pjmedia_transport_media_start(); |
120 | | pjmedia_session_create(); |
121 | | } |
122 | | |
123 | | pjsua_media_channel_deinit(): |
124 | | { |
125 | | stop_media_session(); |
126 | | pjmedia_transport_media_stop(); |
127 | | pjmedia_transport_close(srtp); |
128 | | } |
129 | | }}} |
130 | | |
131 | | == Create Media Transport On-Demand == |
132 | | |
133 | | Media transport (including SRTP) will be created before call. |
134 | | |