Changeset 4762 for pjproject/trunk/doc/pjsip-book/call.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/call.rst
r4704 r4762 1 2 1 3 2 Calls 4 3 ===== 5 Calls are represented by âCall class.4 Calls are represented by Call class. 6 5 7 6 Subclassing the Call Class 8 7 ------------------------------------ 9 To use the Call class, normally application SHOULD create its own subclass, such as:: 8 To use the Call class, normally application SHOULD create its own subclass, such as: 9 10 .. code-block:: c++ 10 11 11 12 class MyCall : public Call … … 30 31 Making Outgoing Calls 31 32 -------------------------------------- 32 Making outgoing call is simple, just invoke âmakeCall() method of the Call object. Assuming you have the Account object as acc variable and destination URI string in dst_uri, you can initiate outgoing call with the snippet below:: 33 Making outgoing call is simple, just invoke makeCall() method of the Call object. Assuming you have the Account object as acc variable and destination URI string in dest_uri, you can initiate outgoing call with the snippet below: 34 35 .. code-block:: c++ 33 36 34 37 Call *call = new MyCall(*acc); … … 37 40 call->makeCall(dest_uri, prm); 38 41 } catch(Error& err) { 39 } 40 41 The snippet above creates a Call object and initiates outgoing call to dst_uri using the default call settings. Subsequent operations to the call can use the method in the âcall instance, and events to the call will be reported to the callback. More on the callback will be explained a bit later. 42 cout << err.info() << endl; 43 } 44 45 The snippet above creates a Call object and initiates outgoing call to dest_uri using the default call settings. Subsequent operations to the call can use the method in the call instance, and events to the call will be reported to the callback. More on the callback will be explained a bit later. 42 46 43 47 Receiving Incoming Calls 44 48 -------------------------------------- 45 Incoming calls are reported as âonIncomingCall() of the âAccount class. You must derive a class from the Account class to handle incoming calls. 46 47 Below is a sample code of the callback implementation:: 49 Incoming calls are reported as onIncomingCall() of the Account class. You must derive a class from the Account class to handle incoming calls. 50 51 Below is a sample code of the callback implementation: 52 53 .. code-block:: c++ 48 54 49 55 void MyAccount::onIncomingCall(OnIncomingCallParam &iprm) … … 51 57 Call *call = new MyCall(*this, iprm.callId); 52 58 CallOpParam prm; 53 prm.statusCode = (pjsip_status_code)200;59 prm.statusCode = PJSIP_SC_OK; 54 60 call->answer(prm); 55 61 } 56 62 57 For incoming calls, the call instance is created in the callback parameteras shown above. Application should make sure to store the call instance during the lifetime of the call (that is until the call is disconnected).63 For incoming calls, the call instance is created in the callback function as shown above. Application should make sure to store the call instance during the lifetime of the call (that is until the call is disconnected). 58 64 59 65 Call Properties 66 ---------------- 67 All call properties such as state, media state, remote peer information, etc. are stored as CallInfo class, which can be retrieved from the call object with using getInfo() method of the Call. 68 69 Call Disconnection 60 70 ------------------- 61 All call properties such as state, media state, remote peer information, etc. are stored as âCallInfo class, which can be retrieved from the call object with using getInfo() method of the Call.62 63 Call Disconnection64 --------------------------------------65 71 Call disconnection event is a special event since once the callback that reports this event returns, the call is no longer valid and any operations invoked to the call object will raise error exception. Thus, it is recommended to delete the call object inside the callback. 66 72 67 The call disconnection is reported in âonCallState() method of âCall and it can be detected as follows:: 73 The call disconnection is reported in onCallState() method of Call and it can be detected as follows: 74 75 .. code-block:: c++ 68 76 69 77 void MyCall::onCallState(OnCallStateParam &prm) … … 78 86 Working with Call's Audio Media 79 87 ------------------------------------------------- 80 You can only operate with the call's audio media (e.g. connecting the call to the sound device in the conference bridge) when the call's audio media is ready (or active). The changes to the call's media state is reported in âonCallMediaState() callback, and if the callâs audio media is ready (or active) the function getMedia() will return a valid audio media. 81 82 Below is a sample code to connect the call to the sound device when the media is active:: 88 You can only operate with the call's audio media (e.g. connecting the call to the sound device in the conference bridge) when the call's audio media is ready (or active). The changes to the call's media state is reported in onCallMediaState() callback, and if the calls audio media is ready (or active) the function Call.getMedia() will return a valid audio media. 89 90 Below is a sample code to connect the call to the sound device when the media is active: 91 92 .. code-block:: c++ 83 93 84 94 void MyCall::onCallMediaState(OnCallMediaStateParam &prm) 85 95 { 86 96 CallInfo ci = getInfo(); 87 // Iterate all medias97 // Iterate all the call medias 88 98 for (unsigned i = 0; i < ci.media.size(); i++) { 89 if (getMedia(i)) { // Check if the media is valid 90 AudioMedia *aud_med = getMedia(i); 99 if (ci.media[i].type==PJMEDIA_TYPE_AUDIO && getMedia(i)) { 100 AudioMedia *aud_med = (AudioMedia *)getMedia(i); 101 91 102 // Connect the call audio media to sound device 92 aud_med->startTransmit(); 93 ->startTransmit(*aud_med); 103 AudDevManager& mgr = Endpoint::instance().audDevManager(); 104 aud_med->startTransmit(mgr.getPlaybackDevMedia()); 105 mgr.getCaptureDevMedia().startTransmit(*aud_med); 94 106 } 95 107 } … … 99 111 100 112 Call Operations 101 -------------------------------------- 102 Some of the operations to the Call object, such as making outgoing call, answering, holding, sending re-INVITE, etc. Please see the reference documentation of Call for more info. 103 113 ------------------- 114 You can invoke operations to the Call object, such as hanging up, putting the call on hold, sending re-INVITE, etc. Please see the reference documentation of Call for more info. 115 116 Instant Messaging(IM) 117 --------------------- 118 You can send IM within a call using Call.sendInstantMessage(). The transmission status of outgoing instant messages is reported in Call.onInstantMessageStatus() callback method. 119 120 In addition to sending instant messages, you can also send typing indication using Call.sendTypingIndication(). 121 122 Incoming IM and typing indication received within a call will be reported in the callback functions Call.onInstantMessage() and Call.onTypingIndication(). 123 124 Alternatively, you can send IM and typing indication outside a call by using Buddy.sendInstantMessage() and Buddy.sendTypingIndication(). For more information, please see Presence documentation. 125 126 127 Class Reference 128 --------------- 129 Call 130 ++++ 131 .. doxygenclass:: pj::Call 132 :path: xml 133 :members: 134 135 Settings 136 ++++++++ 137 .. doxygenstruct:: pj::CallSetting 138 :path: xml 139 140 141 Info and Statistics 142 +++++++++++++++++++ 143 .. doxygenstruct:: pj::CallInfo 144 :path: xml 145 146 .. doxygenstruct:: pj::CallMediaInfo 147 :path: xml 148 149 .. doxygenstruct:: pj::StreamInfo 150 :path: xml 151 152 .. doxygenstruct:: pj::StreamStat 153 :path: xml 154 155 .. doxygenstruct:: pj::JbufState 156 :path: xml 157 158 .. doxygenstruct:: pj::RtcpStat 159 :path: xml 160 161 .. doxygenstruct:: pj::RtcpStreamStat 162 :path: xml 163 164 .. doxygenstruct:: pj::MathStat 165 :path: xml 166 167 .. doxygenstruct:: pj::MediaTransportInfo 168 :path: xml 169 170 171 Callback Parameters 172 +++++++++++++++++++ 173 .. doxygenstruct:: pj::OnCallStateParam 174 :path: xml 175 176 .. doxygenstruct:: pj::OnCallTsxStateParam 177 :path: xml 178 179 .. doxygenstruct:: pj::OnCallMediaStateParam 180 :path: xml 181 182 .. doxygenstruct:: pj::OnCallSdpCreatedParam 183 :path: xml 184 185 .. doxygenstruct:: pj::OnStreamCreatedParam 186 :path: xml 187 188 .. doxygenstruct:: pj::OnStreamDestroyedParam 189 :path: xml 190 191 .. doxygenstruct:: pj::OnDtmfDigitParam 192 :path: xml 193 194 .. doxygenstruct:: pj::OnCallTransferRequestParam 195 :path: xml 196 197 .. doxygenstruct:: pj::OnCallTransferStatusParam 198 :path: xml 199 200 .. doxygenstruct:: pj::OnCallReplaceRequestParam 201 :path: xml 202 203 .. doxygenstruct:: pj::OnCallReplacedParam 204 :path: xml 205 206 .. doxygenstruct:: pj::OnCallRxOfferParam 207 :path: xml 208 209 .. doxygenstruct:: pj::OnCallRedirectedParam 210 :path: xml 211 212 .. doxygenstruct:: pj::OnCallMediaEventParam 213 :path: xml 214 215 .. doxygenstruct:: pj::OnCallMediaTransportStateParam 216 :path: xml 217 218 .. doxygenstruct:: pj::OnCreateMediaTransportParam 219 :path: xml 220 221 .. doxygenstruct:: pj::CallOpParam 222 :path: xml 223 224 .. doxygenstruct:: pj::CallSendRequestParam 225 :path: xml 226 227 .. doxygenstruct:: pj::CallVidSetStreamParam 228 :path: xml 229 230 Other 231 +++++ 232 .. doxygenstruct:: pj::MediaEvent 233 :path: xml 234 235 .. doxygenstruct:: pj::MediaFmtChangedEvent 236 :path: xml 237 238 .. doxygenstruct:: pj::SdpSession 239 :path: xml 240 241 .. doxygenstruct:: pj::RtcpSdes 242 :path: xml 243 244
Note: See TracChangeset
for help on using the changeset viewer.