Changeset 4762 for pjproject/trunk/doc/pjsip-book/endpoint.rst
- Timestamp:
- Feb 24, 2014 11:00:15 AM (10 years ago)
- Location:
- pjproject/trunk/doc/pjsip-book
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/doc/pjsip-book
-
Property
svn:ignore
set to
xml
-
Property
svn:ignore
set to
-
pjproject/trunk/doc/pjsip-book/endpoint.rst
r4704 r4762 1 2 1 3 2 Endpoint 4 3 ************ 5 The âEndpoint class is a singleton class, and application MUST create one and at most one of this class instance before it can do anything else. This class is the core class of PJSUA2, and it provides the following functions:4 The Endpoint class is a singleton class, and application MUST create one and at most one of this class instance before it can do anything else, and similarly, once this class is destroyed, application must NOT call any library API. This class is the core class of PJSUA2, and it provides the following functions: 6 5 7 6 - Starting up and shutting down 8 7 - Customization of configurations, such as core UA (User Agent) SIP configuration, media configuration, and logging configuration 9 8 10 This sectionwill describe the functions above.9 This chapter will describe the functions above. 11 10 12 11 To use the Endpoint class, normally application does not need to subclass it unless: 13 12 14 - application wants to implement/override Endpoint âs callback methods to get the events such as transport state change or NAT detection completion, or13 - application wants to implement/override Endpoints callback methods to get the events such as transport state change or NAT detection completion, or 15 14 - application schedules a timer using Endpoint.utilTimerSchedule() API. In this case, application needs to implement the onTimer() callback to get the notification when the timer expires. 16 15 … … 25 24 Creating the Library 26 25 ---------------------- 27 Create the library by calling its libCreate() method:: 26 Create the library by calling its libCreate() method: 27 28 .. code-block:: c++ 28 29 29 30 try { 30 31 ep->libCreate(); 31 32 } catch(Error& err) { 32 cout << "Startup error: " << err. reason<< endl;33 cout << "Startup error: " << err.info() << endl; 33 34 } 34 35 … … 41 42 42 43 - UAConfig, to specify core SIP user agent settings. 43 - MediaConfig, to specify various media settings, including ICE and TURN.44 - MediaConfig, to specify various media *global* settings 44 45 - LogConfig, to customize logging settings. 45 46 46 To customize the settings, create instance of EpConfig class and specify them during the endpoint initialization (will be explained more later), for example:: 47 Note that some settings can be further specified on per account basis, in the AccountConfig. 48 49 To customize the settings, create instance of EpConfig class and specify them during the endpoint initialization (will be explained more later), for example: 50 51 .. code-block:: c++ 47 52 48 53 EpConfig ep_cfg; … … 51 56 ep_cfg.mediaConfig.sndClockRate = 16000; 52 57 53 Next, you can initialize the library by calling libInit():: 58 Next, you can initialize the library by calling libInit(): 59 60 .. code-block:: c++ 54 61 55 62 try { … … 58 65 ep->libInit(ep_cfg); 59 66 } catch(Error& err) { 60 cout << "Initialization error: " << err. reason<< endl;67 cout << "Initialization error: " << err.info() << endl; 61 68 } 62 69 … … 65 72 Creating One or More Transports 66 73 -------------------------------------------------- 67 Application needs to create one or more âtransports before it can send or receive SIP messages:: 74 Application needs to create one or more transports before it can send or receive SIP messages: 75 76 .. code-block:: c++ 68 77 69 78 try { … … 72 81 TransportId tid = ep->transportCreate(PJSIP_TRANSPORT_UDP, tcfg); 73 82 } catch(Error& err) { 74 cout << "Transport creation error: " << err. reason<< endl;83 cout << "Transport creation error: " << err.info() << endl; 75 84 } 76 85 77 The transportCreate() method returns the newly created âTransport ID and it takes the transport type and âTransportConfig object to customize the transport settings like bound address and listening port number. Without this, by default the transport will be bound to INADDR_ANY and any available port.86 The transportCreate() method returns the newly created Transport ID and it takes the transport type and TransportConfig object to customize the transport settings like bound address and listening port number. Without this, by default the transport will be bound to INADDR_ANY and any available port. 78 87 79 There is no real use of the âTransport ID, except to create userless account (with âAccount.create(), as will be explained later), and perhaps to display the list of transports to user if the application wants it.88 There is no real use of the Transport ID, except to create userless account (with Account.create(), as will be explained later), and perhaps to display the list of transports to user if the application wants it. 80 89 81 90 Starting the Library 82 91 -------------------- 83 Now we're ready to start the library. We need to start the library to finalize the initialization phase, e.g. to complete the initial STUN address resolution, initialize/start the sound device, etc. To start the library, call âlibStart() method:: 92 Now we're ready to start the library. We need to start the library to finalize the initialization phase, e.g. to complete the initial STUN address resolution, initialize/start the sound device, etc. To start the library, call libStart() method: 93 94 .. code-block:: c++ 84 95 85 96 try { 86 97 ep->libStart(); 87 98 } catch(Error& err) { 88 cout << "Startup error: " << err. reason<< endl;99 cout << "Startup error: " << err.info() << endl; 89 100 } 90 101 91 102 Shutting Down the Library 92 103 -------------------------------------- 93 Once the application exits, the library needs to be shutdown so that resources can be released back to the operating system. This is done by deleting the Endpoint instance, which will internally call âlibDestroy()::104 Once the application exits, the library needs to be shutdown so that resources can be released back to the operating system. Although this can be done by deleting the Endpoint instance, which will internally call libDestroy(), it is better to call it manually because on Java or Python there are problems with garbage collection as explained earlier: 94 105 106 .. code-block:: c++ 107 108 ep->libDestroy(); 95 109 delete ep; 96 110 111 112 Class Reference 113 --------------- 114 The Endpoint 115 ++++++++++++ 116 .. doxygenclass:: pj::Endpoint 117 :path: xml 118 :members: 119 120 Endpoint Configurations 121 +++++++++++++++++++++++ 122 Endpoint 123 ~~~~~~~~ 124 .. doxygenstruct:: pj::EpConfig 125 :path: xml 126 127 Media 128 ~~~~~ 129 .. doxygenstruct:: pj::MediaConfig 130 :path: xml 131 132 Logging 133 ~~~~~~~ 134 .. doxygenstruct:: pj::LogConfig 135 :path: xml 136 137 .. doxygenclass:: pj::LogWriter 138 :path: xml 139 :members: 140 141 .. doxygenstruct:: pj::LogEntry 142 :path: xml 143 144 User Agent 145 ~~~~~~~~~~ 146 .. doxygenstruct:: pj::UaConfig 147 :path: xml 148 149 150 Callback Parameters 151 +++++++++++++++++++ 152 .. doxygenstruct:: pj::OnNatDetectionCompleteParam 153 :path: xml 154 155 .. doxygenstruct:: pj::OnNatCheckStunServersCompleteParam 156 :path: xml 157 158 .. doxygenstruct:: pj::OnTimerParam 159 :path: xml 160 161 .. doxygenstruct:: pj::OnTransportStateParam 162 :path: xml 163 164 .. doxygenstruct:: pj::OnSelectAccountParam 165 :path: xml 166 167 168 Other 169 +++++ 170 .. doxygenstruct:: pj::PendingJob 171 :path: xml 172
Note: See TracChangeset
for help on using the changeset viewer.