Changes between Version 3 and Version 4 of 0.9/Media_Interface_Change


Ignore:
Timestamp:
Jun 16, 2008 9:08:56 PM (16 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 0.9/Media_Interface_Change

    v3 v4  
    11= Background = 
    22 
    3 Currently this is how the media channel interacts with SIP call in PJSUA-LIB: 
     3== pjsua_call.c == 
     4Currently this is how the media channel interacts with SIP call in PJSUA-LIB. 
    45 
    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(); 
    1614 
    17 pjsua_call_on_media_update(): 
    18 { 
    19         pjsua_media_channel_update(); 
    20 } 
     15 '''pjsua_call_on_media_update()''' : :: 
     16   pjsua_media_channel_update(); 
    2117 
    22 pjsua_call_on_state_changed(DISCONNECTED): 
    23 pjsua_call_on_media_update(HOLD): 
    24 { 
    25         pjsua_media_channel_deinit(); 
    26 } 
    27 }}} 
     18 '''pjsua_call_on_state_changed(DISCONNECTED)''' : :: 
     19 '''pjsua_call_on_media_update(HOLD)''' : :: 
     20   pjsua_media_channel_deinit(); 
     21 
     22== pjsua_media.c == 
    2823 
    2924and this is the implementation of media channel functions above: 
    3025 
    31 {{{ 
    32 pjsua_media_channel_init() 
    33 { 
    34         pjmedia_transport_srtp_create(); 
    35 } 
     26 '''pjsua_media_channel_init()''' : :: 
     27   pjmedia_transport_srtp_create(); 
    3628 
    37 pjsua_media_channel_create_sdp(): 
    38 { 
    39         pjmedia_endpt_create_sdp(); 
    40         pjmedia_transport_media_create(); 
    41 } 
     29 '''pjsua_media_channel_create_sdp()''' : :: 
     30   pjmedia_endpt_create_sdp();[[BR]] 
     31   pjmedia_transport_media_create(); 
    4232 
    43 pjsua_media_channel_update(): 
    44 { 
    45         pjmedia_transport_media_start(); 
    46         pjmedia_session_create(); 
    47 } 
     33 '''pjsua_media_channel_update()''' : :: 
     34   pjmedia_transport_media_start();[[BR]] 
     35   pjmedia_session_create(); 
    4836 
    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); 
    6741 
    6842 
    6943 
    70 = New Design Specification = 
     44= New = 
    7145 
    72 == Distinguish Between Fresh Call and UPDATE/re-INVITE == 
     46(Changes in italics) 
    7347 
    74 {{{ 
    75 pjsua_call_make_call(): 
    76 pjsua_call_on_incoming(): 
    77 { 
    78         pjsua_media_channel_init(); 
    79         pjsua_media_channel_create_sdp(); 
    80 } 
     48== pjsua_call.c == 
     49Currently this is how the media channel interacts with SIP call in PJSUA-LIB. 
    8150 
    82 pjsua_call_update(): 
    83 pjsua_call_reinvite(): 
    84 pjsua_call_on_rx_offer(): 
    85 pjsua_call_on_create_offer(): 
    86 { 
    87         if (media==NULL) 
    88            pjsua_media_channel_init(); 
    89         pjsua_media_channel_create_sdp(); 
    90 } 
     51 '''pjsua_call_make_call()''' : :: 
     52 '''pjsua_call_on_incoming()''' : :: 
     53   pjsua_media_channel_init();[[BR]] 
     54   pjsua_media_channel_create_sdp(); 
    9155 
    92 pjsua_call_on_media_update(): 
    93 { 
    94         pjsua_media_channel_update(); 
    95 } 
     56 '' 
     57 '''pjsua_call_update()''' : :: 
     58 '''pjsua_call_reinvite()''' : :: 
     59 '''pjsua_call_on_rx_offer()''' : :: 
     60 '''pjsua_call_on_create_offer()''' : :: 
     61   pjsua_media_channel_create_sdp(); 
     62 '' 
    9663 
    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 
     73and 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); 
    10391 
    10492 
    105 {{{ 
    106 pjsua_media_channel_init() 
    107 { 
    108         pjmedia_transport_srtp_create(); 
    109 } 
    11093 
    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