Changeset 5899
- Timestamp:
- Oct 17, 2018 4:38:39 AM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp
r5717 r5899 40 40 41 41 virtual void onCallState(OnCallStateParam &prm); 42 virtual void onCallTransferRequest(OnCallTransferRequestParam &prm); 43 virtual void onCallReplaced(OnCallReplacedParam &prm); 42 44 }; 43 45 … … 55 57 std::cout << "*** Account is being deleted: No of calls=" 56 58 << calls.size() << std::endl; 59 60 for (std::vector<Call *>::iterator it = calls.begin(); 61 it != calls.end(); ) 62 { 63 delete (*it); 64 it = calls.erase(it); 65 } 57 66 } 58 67 … … 100 109 101 110 if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { 102 myAcc->removeCall(this);111 //myAcc->removeCall(this); 103 112 /* Delete the call */ 104 delete this; 105 } 106 } 113 //delete this; 114 } 115 } 116 117 void MyCall::onCallTransferRequest(OnCallTransferRequestParam &prm) 118 { 119 /* Create new Call for call transfer */ 120 prm.newCall = new MyCall(*myAcc); 121 } 122 123 void MyCall::onCallReplaced(OnCallReplacedParam &prm) 124 { 125 /* Create new Call for call replace */ 126 prm.newCall = new MyCall(*myAcc, prm.newCallId); 127 } 128 107 129 108 130 static void mainProg1(Endpoint &ep) throw(Error) … … 148 170 // Destroy library 149 171 std::cout << "*** PJSUA2 SHUTTING DOWN ***" << std::endl; 150 delete call; 151 delete acc; 172 delete acc; /* Will delete all calls too */ 152 173 } 153 174 … … 347 368 ep.libCreate(); 348 369 349 mainProg 3(ep);370 mainProg1(ep); 350 371 ret = PJ_SUCCESS; 351 372 } catch (Error & err) { -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5872 r5899 1037 1037 * transferred to. 1038 1038 * @param code Status code to be returned for the call transfer 1039 * request. On input, it contains status code 20 0.1039 * request. On input, it contains status code 202. 1040 1040 */ 1041 1041 void (*on_call_transfer_request)(pjsua_call_id call_id, … … 1054 1054 * transferred to. 1055 1055 * @param code Status code to be returned for the call transfer 1056 * request. On input, it contains status code 20 0.1056 * request. On input, it contains status code 202. 1057 1057 * @param opt The current call setting, application can update 1058 1058 * this setting for the call being transferred. -
pjproject/trunk/pjsip/include/pjsua2/call.hpp
r5877 r5899 785 785 * The destination where the call will be transferred to. 786 786 */ 787 string dstUri;787 string dstUri; 788 788 789 789 /** 790 790 * Status code to be returned for the call transfer request. On input, 791 * it contains status code 20 0.792 */ 793 pjsip_status_code statusCode;791 * it contains status code 202. 792 */ 793 pjsip_status_code statusCode; 794 794 795 795 /** … … 797 797 * for the call being transferred. 798 798 */ 799 CallSetting opt; 799 CallSetting opt; 800 801 /** 802 * New Call derived object instantiated by application when the call 803 * transfer is about to be accepted. 804 */ 805 Call *newCall; 800 806 }; 801 807 … … 867 873 * The new call id. 868 874 */ 869 pjsua_call_id newCallId; 875 pjsua_call_id newCallId; 876 877 /** 878 * New Call derived object instantiated by application. 879 */ 880 Call *newCall; 870 881 }; 871 882 … … 1717 1728 /** 1718 1729 * Notify application on call being transferred (i.e. REFER is received). 1719 * Application can decide to accept/reject transfer request 1720 * by setting the code (default is 202). When this callback 1721 * is not implemented, the default behavior is to accept the 1722 * transfer. 1730 * Application can decide to accept/reject transfer request by setting 1731 * the code (default is 202). When this callback is not implemented, 1732 * the default behavior is to accept the transfer. 1733 * 1734 * If application decides to accept the transfer request, it must also 1735 * instantiate the new Call object for the transfer operation and return 1736 * this new Call object to prm.newCall. 1737 * 1738 * If application does not specify new Call object, library will reuse the 1739 * existing Call object for initiating the new call (to the transfer 1740 * destination). In this case, any events from both calls (transferred and 1741 * transferring) will be delivered to the same Call object, where the call 1742 * ID will be switched back and forth between callbacks. Application must 1743 * be careful to not destroy the Call object when receiving disconnection 1744 * event of the transferred call after the transfer process is completed. 1723 1745 * 1724 1746 * @param prm Callback parameter. … … 1753 1775 * 1754 1776 * After this callback is called, normally PJSUA-API will disconnect 1755 * this call and establish a new call \a newCallId. 1777 * this call and establish a new call. To be able to control the call, 1778 * e.g: hold, transfer, change media parameters, application must 1779 * instantiate a new Call object for the new call using call ID 1780 * specified in prm.newCallId, and return the Call object via 1781 * prm.newCall. 1756 1782 * 1757 1783 * @param prm Callback parameter. … … 1953 1979 std::vector<Media *> medias; 1954 1980 pj_pool_t *sdp_pool; 1981 Call *child; /* New outgoing call in call transfer. */ 1955 1982 }; 1956 1983 -
pjproject/trunk/pjsip/src/pjsua2/call.cpp
r5878 r5899 450 450 451 451 Call::Call(Account& account, int call_id) 452 : acc(account), id(call_id) 452 : acc(account), id(call_id), userData(NULL), sdp_pool(NULL), child(NULL) 453 453 { 454 454 if (call_id != PJSUA_INVALID_ID) … … 503 503 { 504 504 Call *call = (Call*)pjsua_call_get_user_data(call_id); 505 if (call) 506 call->id = call_id; 505 if (call && call_id != call->id) { 506 if (call->child && call->child->id == PJSUA_INVALID_ID) { 507 /* This must be a new call from call transfer */ 508 call = call->child; 509 pjsua_call_set_user_data(call_id, call); 510 } 511 call->id = call_id; 512 } 507 513 return call; 508 514 } … … 821 827 } 822 828 medias.clear(); 829 830 /* Remove this Call object association */ 831 pjsua_call_set_user_data(id, NULL); 823 832 } 824 833 -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5891 r5899 1192 1192 prm.statusCode = *code; 1193 1193 prm.opt.fromPj(*opt); 1194 prm.newCall = NULL; 1194 1195 1195 1196 call->onCallTransferRequest(prm); … … 1197 1198 *code = prm.statusCode; 1198 1199 *opt = prm.opt.toPj(); 1200 if (*code/100 <= 2) { 1201 if (prm.newCall) { 1202 /* We don't manage (e.g: create, delete) the call child, 1203 * so let's just override any existing child. 1204 */ 1205 call->child = prm.newCall; 1206 call->child->id = PJSUA_INVALID_ID; 1207 } else { 1208 PJ_LOG(4,(THIS_FILE, 1209 "Warning: application reuses Call instance in " 1210 "call transfer (call ID:%d)", call_id)); 1211 } 1212 } 1199 1213 } 1200 1214 … … 1255 1269 OnCallReplacedParam prm; 1256 1270 prm.newCallId = new_call_id; 1271 prm.newCall = NULL; 1257 1272 1258 1273 call->onCallReplaced(prm); 1274 1275 if (prm.newCall) { 1276 /* Sanity checks */ 1277 pj_assert(prm.newCall->id == new_call_id); 1278 pj_assert(prm.newCall->acc.getId() == call->acc.getId()); 1279 pj_assert(pjsua_call_get_user_data(new_call_id) == prm.newCall); 1280 } else { 1281 PJ_LOG(4,(THIS_FILE, 1282 "Warning: application has not created new Call instance " 1283 "for call replace (old call ID:%d, new call ID: %d)", 1284 old_call_id, new_call_id)); 1285 } 1259 1286 } 1260 1287
Note: See TracChangeset
for help on using the changeset viewer.