Changeset 4663
- Timestamp:
- Nov 29, 2013 5:56:02 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2
- Files:
-
- 3 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/account.py
r4657 r4663 34 34 import accountsetting 35 35 import application 36 import call 36 37 37 38 # Account class … … 47 48 self.cfgChanged = False 48 49 self.buddyList = [] 50 self.callList = [] 49 51 50 52 def statusText(self): … … 73 75 status = '- not created -' 74 76 return status 77 78 def makeCall(self): 79 mycall = call.Call(self.app, self, pj.PJSUA_INVALID_ID) 80 callPrm = pj.CallOpParam() 81 callPrm.opt.audioCount = 1 82 callPrm.opt.videoCount = 0 83 mycall.uri = "sip:test1@pjsip.org" 84 self.callList.append(mycall) 85 mycall.makeCall(mycall.uri, callPrm) 75 86 76 87 def onRegState(self, prm): 77 88 self.app.updateAccount(self) 89 90 def onIncomingCall(self, prm): 91 mycall = call.Call(self.app, self, prm.callId) 92 self.callList.append(mycall) 93 self.app.updateCall(self) 94 callPrm = pj.CallOpParam() 95 msg = "Incoming call for account '%s'" % self.cfg.idUri 96 if msgbox.askquestion(msg, 'Accept call?', default=msgbox.YES) == u'yes': 97 callPrm.statusCode = 200 98 mycall.answer(callPrm) 99 else: 100 mycall.hangup(callPrm) 78 101 79 102 -
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/application.py
r4657 r4663 191 191 self._onTimer() 192 192 193 def updateCall(self, acc): 194 iid = str(acc.randId) 195 for call in acc.callList: 196 calliid = str(call.randId) 197 uri, status = call.statusText() 198 if self.tv.exists(calliid): 199 self.tv.item(call.iid, text=uri, values=(status,)) 200 else: 201 call.iid = self.tv.insert(iid, 0, calliid, open=True, text=uri, values=(status,)) 202 193 203 def updateAccount(self, acc): 194 204 iid = str(acc.randId) … … 270 280 self.accMenu = tk.Menu(top, tearoff=False) 271 281 # Labels, must match with _onAccContextMenu() 272 labels = [' Unregister', 'Reregister', 'Add buddy...', '-',282 labels = ['Call', '-', 'Unregister', 'Reregister', 'Add buddy...', '-', 273 283 'Online', 'Invisible', 'Away', 'Busy', '-', 274 284 'Settings...', '-', … … 351 361 return 352 362 353 if label=='Unregister': 363 if label=='Call': 364 acc.makeCall() 365 elif label=='Unregister': 354 366 acc.setRegistration(False) 355 367 elif label=='Reregister': -
pjproject/branches/projects/pjsua2/pjsip-apps/src/samples/pjsua2_demo.cpp
r4647 r4663 24 24 using namespace pj; 25 25 26 class MyAccount; 27 28 class MyCall : public Call 29 { 30 private: 31 MyAccount *myAcc; 32 33 public: 34 MyCall(Account &acc, int call_id = PJSUA_INVALID_ID) 35 : Call(acc, call_id) 36 { 37 myAcc = (MyAccount *)&acc; 38 } 39 40 virtual void onCallState(OnCallStateParam &prm); 41 }; 42 26 43 class MyAccount : public Account 27 44 { 45 public: 46 std::vector<Call *> calls; 47 28 48 public: 29 49 MyAccount() 30 50 {} 31 51 52 ~MyAccount() 53 { 54 std::cout << "*** Account is being deleted: No of calls=" 55 << calls.size() << std::endl; 56 } 57 58 void removeCall(Call *call) 59 { 60 for (std::vector<Call *>::iterator it = calls.begin(); 61 it != calls.end(); ++it) 62 { 63 if (*it == call) { 64 calls.erase(it); 65 break; 66 } 67 } 68 } 69 32 70 virtual void onRegState(OnRegStateParam &prm) 33 71 { … … 36 74 << prm.code << std::endl; 37 75 } 76 77 virtual void onIncomingCall(OnIncomingCallParam &iprm) 78 { 79 Call *call = new MyCall(*this, iprm.callId); 80 CallInfo ci = call->getInfo(); 81 CallOpParam prm; 82 83 std::cout << "*** Incoming Call: " << ci.remoteURI << " [" 84 << ci.stateText << "]" << std::endl; 85 86 calls.push_back(call); 87 prm.statusCode = (pjsip_status_code)200; 88 call->answer(prm); 89 } 38 90 }; 91 92 void MyCall::onCallState(OnCallStateParam &prm) 93 { 94 CallInfo ci = getInfo(); 95 std::cout << "*** Call: " << ci.remoteURI << " [" << ci.stateText 96 << "]" << std::endl; 97 98 if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { 99 myAcc->removeCall(this); 100 /* Delete the call */ 101 delete this; 102 } 103 } 39 104 40 105 static void mainProg1() throw(Error) … … 65 130 acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", "*", 66 131 "test1", 0, "test1") ); 67 std::auto_ptr< Account> acc(new MyAccount);132 std::auto_ptr<MyAccount> acc(new MyAccount); 68 133 acc->create(acc_cfg); 69 134 70 135 pj_thread_sleep(2000); 71 136 137 // Make outgoing call 138 Call *call = new MyCall(*acc); 139 acc->calls.push_back(call); 140 CallOpParam prm(true); 141 prm.opt.audioCount = 1; 142 prm.opt.videoCount = 0; 143 call->makeCall("sip:test1@pjsip.org", prm); 144 145 // Hangup all calls 146 pj_thread_sleep(8000); 147 ep.hangupAllCalls(); 148 pj_thread_sleep(4000); 149 72 150 // Destroy library 73 151 std::cout << "*** PJSUA2 SHUTTING DOWN ***" << std::endl; … … 190 268 191 269 try { 192 mainProg ();270 mainProg1(); 193 271 std::cout << "Success" << std::endl; 194 272 } catch (Error & err) { -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/Makefile
r4639 r4663 1 1 include ../../../../build.mak 2 3 ifneq ($(findstring "$(TARGET_NAME)","darwin"),"") 4 OS=darwin 5 endif 2 6 3 7 OUT_DIR=output … … 5 9 LIBPJSUA2_SO=$(OUT_DIR)/pjsua2.dll 6 10 else 7 LIBPJSUA2_SO=$(OUT_DIR)/libpjsua2.so 11 ifeq ($(OS),darwin) 12 LIBPJSUA2_SO=$(OUT_DIR)/libpjsua2.jnilib 13 else 14 LIBPJSUA2_SO=$(OUT_DIR)/libpjsua2.so 15 endif 8 16 endif 9 17 … … 23 31 # OS specific 24 32 ifeq ($(OS),Windows_NT) 25 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,--kill-at26 MY_JNI_LIB = $(OUT_DIR)/pjsua2.dll33 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,--kill-at 34 MY_JNI_LIB = $(OUT_DIR)/pjsua2.dll 27 35 else 28 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,-soname,pjsua2.so 29 MY_JNI_LIB = $(OUT_DIR)/libpjsua2.so 30 MY_JNI_CFLAGS := -fPIC 36 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib 37 ifneq ($(OS),darwin) 38 MY_JNI_LDFLAGS := $(MY_JNI_LDFLAGS) -Wl,-soname,pjsua2.so 39 endif 40 MY_JNI_LIB = $(OUT_DIR)/libpjsua2.so 41 MY_JNI_CFLAGS := -fPIC $(MY_JNI_CFLAGS) 31 42 endif 32 43 … … 34 45 MY_SWIG = swig 35 46 MY_JDK = $(JAVA_HOME) 36 MY_JAVA = $(MY_JDK)/bin/java 37 MY_JAVAC = $(MY_JDK)/bin/javac 47 ifneq ($(findstring $(JAVA_BIN), bin),) 48 MY_JAVA = $(MY_JDK)/bin/java 49 MY_JAVAC = $(MY_JDK)/bin/javac 50 else 51 MY_JAVA = $(MY_JDK)/java 52 MY_JAVAC = $(MY_JDK)/javac 53 endif 38 54 MY_JNI_CFLAGS := $(MY_JNI_CFLAGS) -I$(MY_JDK)/include -I$(MY_JDK)/include/win32 \ 39 55 -I$(MY_JDK)/include/linux -I. -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i
r4662 r4663 37 37 %feature("director") Endpoint; 38 38 %feature("director") Account; 39 %feature("director") Call; 39 40 %feature("director") Buddy; 40 41 %feature("director") FindBuddyMatch; … … 79 80 %include "pjsua2/presence.hpp" 80 81 %include "pjsua2/account.hpp" 82 %include "pjsua2/call.hpp" 83 84 %template(CallMediaInfoVector) std::vector<pj::CallMediaInfo>; 81 85 82 86 %ignore pj::JsonDocument::allocElement; -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/python/setup.py
r4619 r4663 93 93 # Mac OS X depedencies 94 94 extra_link_args += ["-framework", "CoreFoundation", 95 "-framework", "AudioToolbox"] 95 "-framework", "AudioToolbox", 96 "-framework", "QTKit"] 96 97 # OS X Lion support 97 98 if platform.mac_ver()[0].startswith("10.7"): -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.i
r4662 r4663 8 8 9 9 typedef int pj_int32_t; 10 11 typedef unsigned int pj_uint32_t; 12 13 typedef unsigned short pj_uint16_t; 10 14 11 15 enum pj_file_access {PJ_O_RDONLY = 0x1101, PJ_O_WRONLY = 0x1102, PJ_O_RDWR = 0x1103, PJ_O_APPEND = 0x1108}; … … 33 37 typedef enum pj_turn_tp_type {PJ_TURN_TP_UDP = 17, PJ_TURN_TP_TCP = 6, PJ_TURN_TP_TLS = 255} pj_turn_tp_type; 34 38 39 typedef enum pjmedia_event_type {PJMEDIA_EVENT_NONE, PJMEDIA_EVENT_FMT_CHANGED = ((('H' << 24) | ('C' << 16)) | ('M' << 8)) | 'F', PJMEDIA_EVENT_WND_CLOSING = ((('L' << 24) | ('C' << 16)) | ('N' << 8)) | 'W', PJMEDIA_EVENT_WND_CLOSED = ((('O' << 24) | ('C' << 16)) | ('N' << 8)) | 'W', PJMEDIA_EVENT_WND_RESIZED = ((('Z' << 24) | ('R' << 16)) | ('N' << 8)) | 'W', PJMEDIA_EVENT_MOUSE_BTN_DOWN = ((('N' << 24) | ('D' << 16)) | ('S' << 8)) | 'M', PJMEDIA_EVENT_KEYFRAME_FOUND = ((('F' << 24) | ('R' << 16)) | ('F' << 8)) | 'I', PJMEDIA_EVENT_KEYFRAME_MISSING = ((('M' << 24) | ('R' << 16)) | ('F' << 8)) | 'I', PJMEDIA_EVENT_ORIENT_CHANGED = ((('T' << 24) | ('N' << 16)) | ('R' << 8)) | 'O'} pjmedia_event_type; 40 35 41 typedef enum pjmedia_srtp_use {PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, PJMEDIA_SRTP_MANDATORY} pjmedia_srtp_use; 36 42 … … 47 53 typedef enum pjmedia_type {PJMEDIA_TYPE_NONE, PJMEDIA_TYPE_AUDIO, PJMEDIA_TYPE_VIDEO, PJMEDIA_TYPE_APPLICATION, PJMEDIA_TYPE_UNKNOWN} pjmedia_type; 48 54 55 typedef enum pjmedia_dir {PJMEDIA_DIR_NONE = 0, PJMEDIA_DIR_ENCODING = 1, PJMEDIA_DIR_CAPTURE = PJMEDIA_DIR_ENCODING, PJMEDIA_DIR_DECODING = 2, PJMEDIA_DIR_PLAYBACK = PJMEDIA_DIR_DECODING, PJMEDIA_DIR_RENDER = PJMEDIA_DIR_DECODING, PJMEDIA_DIR_ENCODING_DECODING = 3, PJMEDIA_DIR_CAPTURE_PLAYBACK = PJMEDIA_DIR_ENCODING_DECODING, PJMEDIA_DIR_CAPTURE_RENDER = PJMEDIA_DIR_ENCODING_DECODING} pjmedia_dir; 56 57 typedef enum pjmedia_tp_proto {PJMEDIA_TP_PROTO_NONE = 0, PJMEDIA_TP_PROTO_RTP_AVP, PJMEDIA_TP_PROTO_RTP_SAVP, PJMEDIA_TP_PROTO_UNKNOWN} pjmedia_tp_proto; 58 49 59 typedef enum pjmedia_format_id {PJMEDIA_FORMAT_L16 = 0, PJMEDIA_FORMAT_PCM = PJMEDIA_FORMAT_L16, PJMEDIA_FORMAT_PCMA = ((('W' << 24) | ('A' << 16)) | ('L' << 8)) | 'A', PJMEDIA_FORMAT_ALAW = PJMEDIA_FORMAT_PCMA, PJMEDIA_FORMAT_PCMU = ((('W' << 24) | ('A' << 16)) | ('L' << 8)) | 'u', PJMEDIA_FORMAT_ULAW = PJMEDIA_FORMAT_PCMU, PJMEDIA_FORMAT_AMR = ((('R' << 24) | ('M' << 16)) | ('A' << 8)) | ' ', PJMEDIA_FORMAT_G729 = ((('9' << 24) | ('2' << 16)) | ('7' << 8)) | 'G', PJMEDIA_FORMAT_ILBC = ((('C' << 24) | ('B' << 16)) | ('L' << 8)) | 'I', PJMEDIA_FORMAT_RGB24 = ((('3' << 24) | ('B' << 16)) | ('G' << 8)) | 'R', PJMEDIA_FORMAT_RGBA = ((('A' << 24) | ('B' << 16)) | ('G' << 8)) | 'R', PJMEDIA_FORMAT_BGRA = ((('A' << 24) | ('R' << 16)) | ('G' << 8)) | 'B', PJMEDIA_FORMAT_RGB32 = PJMEDIA_FORMAT_RGBA, PJMEDIA_FORMAT_DIB = (((' ' << 24) | ('B' << 16)) | ('I' << 8)) | 'D', PJMEDIA_FORMAT_GBRP = ((('P' << 24) | ('R' << 16)) | ('B' << 8)) | 'G', PJMEDIA_FORMAT_AYUV = ((('V' << 24) | ('U' << 16)) | ('Y' << 8)) | 'A', PJMEDIA_FORMAT_YUY2 = ((('2' << 24) | ('Y' << 16)) | ('U' << 8)) | 'Y', PJMEDIA_FORMAT_UYVY = ((('Y' << 24) | ('V' << 16)) | ('Y' << 8)) | 'U', PJMEDIA_FORMAT_YVYU = ((('U' << 24) | ('Y' << 16)) | ('V' << 8)) | 'Y', PJMEDIA_FORMAT_I420 = ((('0' << 24) | ('2' << 16)) | ('4' << 8)) | 'I', PJMEDIA_FORMAT_IYUV = PJMEDIA_FORMAT_I420, PJMEDIA_FORMAT_YV12 = ((('2' << 24) | ('1' << 16)) | ('V' << 8)) | 'Y', PJMEDIA_FORMAT_I422 = ((('2' << 24) | ('2' << 16)) | ('4' << 8)) | 'I', PJMEDIA_FORMAT_I420JPEG = ((('0' << 24) | ('2' << 16)) | ('4' << 8)) | 'J', PJMEDIA_FORMAT_I422JPEG = ((('2' << 24) | ('2' << 16)) | ('4' << 8)) | 'J', PJMEDIA_FORMAT_H261 = ((('1' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_H263 = ((('3' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_H263P = ((('3' << 24) | ('6' << 16)) | ('2' << 8)) | 'P', PJMEDIA_FORMAT_H264 = ((('4' << 24) | ('6' << 16)) | ('2' << 8)) | 'H', PJMEDIA_FORMAT_MJPEG = ((('G' << 24) | ('P' << 16)) | ('J' << 8)) | 'M', PJMEDIA_FORMAT_MPEG1VIDEO = ((('V' << 24) | ('1' << 16)) | ('P' << 8)) | 'M', PJMEDIA_FORMAT_MPEG2VIDEO = ((('V' << 24) | ('2' << 16)) | ('P' << 8)) | 'M', PJMEDIA_FORMAT_MPEG4 = ((('4' << 24) | ('G' << 16)) | ('P' << 8)) | 'M'} pjmedia_format_id; 50 60 51 61 typedef enum pjsip_cred_data_type {PJSIP_CRED_DATA_PLAIN_PASSWD = 0, PJSIP_CRED_DATA_DIGEST = 1, PJSIP_CRED_DATA_EXT_AKA = 16} pjsip_cred_data_type; 52 62 63 typedef enum pjsip_dialog_cap_status {PJSIP_DIALOG_CAP_UNSUPPORTED = 0, PJSIP_DIALOG_CAP_SUPPORTED = 1, PJSIP_DIALOG_CAP_UNKNOWN = 2} pjsip_dialog_cap_status; 64 65 typedef enum pjsip_event_id_e {PJSIP_EVENT_UNKNOWN, PJSIP_EVENT_TIMER, PJSIP_EVENT_TX_MSG, PJSIP_EVENT_RX_MSG, PJSIP_EVENT_TRANSPORT_ERROR, PJSIP_EVENT_TSX_STATE, PJSIP_EVENT_USER} pjsip_event_id_e; 66 53 67 typedef enum pjsip_status_code {PJSIP_SC_TRYING = 100, PJSIP_SC_RINGING = 180, PJSIP_SC_CALL_BEING_FORWARDED = 181, PJSIP_SC_QUEUED = 182, PJSIP_SC_PROGRESS = 183, PJSIP_SC_OK = 200, PJSIP_SC_ACCEPTED = 202, PJSIP_SC_MULTIPLE_CHOICES = 300, PJSIP_SC_MOVED_PERMANENTLY = 301, PJSIP_SC_MOVED_TEMPORARILY = 302, PJSIP_SC_USE_PROXY = 305, PJSIP_SC_ALTERNATIVE_SERVICE = 380, PJSIP_SC_BAD_REQUEST = 400, PJSIP_SC_UNAUTHORIZED = 401, PJSIP_SC_PAYMENT_REQUIRED = 402, PJSIP_SC_FORBIDDEN = 403, PJSIP_SC_NOT_FOUND = 404, PJSIP_SC_METHOD_NOT_ALLOWED = 405, PJSIP_SC_NOT_ACCEPTABLE = 406, PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED = 407, PJSIP_SC_REQUEST_TIMEOUT = 408, PJSIP_SC_GONE = 410, PJSIP_SC_REQUEST_ENTITY_TOO_LARGE = 413, PJSIP_SC_REQUEST_URI_TOO_LONG = 414, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE = 415, PJSIP_SC_UNSUPPORTED_URI_SCHEME = 416, PJSIP_SC_BAD_EXTENSION = 420, PJSIP_SC_EXTENSION_REQUIRED = 421, PJSIP_SC_SESSION_TIMER_TOO_SMALL = 422, PJSIP_SC_INTERVAL_TOO_BRIEF = 423, PJSIP_SC_TEMPORARILY_UNAVAILABLE = 480, PJSIP_SC_CALL_TSX_DOES_NOT_EXIST = 481, PJSIP_SC_LOOP_DETECTED = 482, PJSIP_SC_TOO_MANY_HOPS = 483, PJSIP_SC_ADDRESS_INCOMPLETE = 484, PJSIP_AC_AMBIGUOUS = 485, PJSIP_SC_BUSY_HERE = 486, PJSIP_SC_REQUEST_TERMINATED = 487, PJSIP_SC_NOT_ACCEPTABLE_HERE = 488, PJSIP_SC_BAD_EVENT = 489, PJSIP_SC_REQUEST_UPDATED = 490, PJSIP_SC_REQUEST_PENDING = 491, PJSIP_SC_UNDECIPHERABLE = 493, PJSIP_SC_INTERNAL_SERVER_ERROR = 500, PJSIP_SC_NOT_IMPLEMENTED = 501, PJSIP_SC_BAD_GATEWAY = 502, PJSIP_SC_SERVICE_UNAVAILABLE = 503, PJSIP_SC_SERVER_TIMEOUT = 504, PJSIP_SC_VERSION_NOT_SUPPORTED = 505, PJSIP_SC_MESSAGE_TOO_LARGE = 513, PJSIP_SC_PRECONDITION_FAILURE = 580, PJSIP_SC_BUSY_EVERYWHERE = 600, PJSIP_SC_DECLINE = 603, PJSIP_SC_DOES_NOT_EXIST_ANYWHERE = 604, PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE = 606, PJSIP_SC_TSX_TIMEOUT = PJSIP_SC_REQUEST_TIMEOUT, PJSIP_SC_TSX_TRANSPORT_ERROR = PJSIP_SC_SERVICE_UNAVAILABLE, PJSIP_SC__force_32bit = 0x7FFFFFFF} pjsip_status_code; 68 69 typedef enum pjsip_hdr_e {PJSIP_H_ACCEPT, PJSIP_H_ACCEPT_ENCODING_UNIMP, PJSIP_H_ACCEPT_LANGUAGE_UNIMP, PJSIP_H_ALERT_INFO_UNIMP, PJSIP_H_ALLOW, PJSIP_H_AUTHENTICATION_INFO_UNIMP, PJSIP_H_AUTHORIZATION, PJSIP_H_CALL_ID, PJSIP_H_CALL_INFO_UNIMP, PJSIP_H_CONTACT, PJSIP_H_CONTENT_DISPOSITION_UNIMP, PJSIP_H_CONTENT_ENCODING_UNIMP, PJSIP_H_CONTENT_LANGUAGE_UNIMP, PJSIP_H_CONTENT_LENGTH, PJSIP_H_CONTENT_TYPE, PJSIP_H_CSEQ, PJSIP_H_DATE_UNIMP, PJSIP_H_ERROR_INFO_UNIMP, PJSIP_H_EXPIRES, PJSIP_H_FROM, PJSIP_H_IN_REPLY_TO_UNIMP, PJSIP_H_MAX_FORWARDS, PJSIP_H_MIME_VERSION_UNIMP, PJSIP_H_MIN_EXPIRES, PJSIP_H_ORGANIZATION_UNIMP, PJSIP_H_PRIORITY_UNIMP, PJSIP_H_PROXY_AUTHENTICATE, PJSIP_H_PROXY_AUTHORIZATION, PJSIP_H_PROXY_REQUIRE_UNIMP, PJSIP_H_RECORD_ROUTE, PJSIP_H_REPLY_TO_UNIMP, PJSIP_H_REQUIRE, PJSIP_H_RETRY_AFTER, PJSIP_H_ROUTE, PJSIP_H_SERVER_UNIMP, PJSIP_H_SUBJECT_UNIMP, PJSIP_H_SUPPORTED, PJSIP_H_TIMESTAMP_UNIMP, PJSIP_H_TO, PJSIP_H_UNSUPPORTED, PJSIP_H_USER_AGENT_UNIMP, PJSIP_H_VIA, PJSIP_H_WARNING_UNIMP, PJSIP_H_WWW_AUTHENTICATE, PJSIP_H_OTHER} pjsip_hdr_e; 54 70 55 71 typedef enum pjsip_transport_type_e {PJSIP_TRANSPORT_UNSPECIFIED, PJSIP_TRANSPORT_UDP, PJSIP_TRANSPORT_TCP, PJSIP_TRANSPORT_TLS, PJSIP_TRANSPORT_SCTP, PJSIP_TRANSPORT_LOOP, PJSIP_TRANSPORT_LOOP_DGRAM, PJSIP_TRANSPORT_START_OTHER, PJSIP_TRANSPORT_IPV6 = 128, PJSIP_TRANSPORT_UDP6 = PJSIP_TRANSPORT_UDP + PJSIP_TRANSPORT_IPV6, PJSIP_TRANSPORT_TCP6 = PJSIP_TRANSPORT_TCP + PJSIP_TRANSPORT_IPV6, PJSIP_TRANSPORT_TLS6 = PJSIP_TRANSPORT_TLS + PJSIP_TRANSPORT_IPV6} pjsip_transport_type_e; … … 61 77 typedef enum pjsip_ssl_method {PJSIP_SSL_UNSPECIFIED_METHOD = 0, PJSIP_TLSV1_METHOD = 31, PJSIP_SSLV2_METHOD = 20, PJSIP_SSLV3_METHOD = 30, PJSIP_SSLV23_METHOD = 23} pjsip_ssl_method; 62 78 79 typedef enum pjsip_tsx_state_e {PJSIP_TSX_STATE_NULL, PJSIP_TSX_STATE_CALLING, PJSIP_TSX_STATE_TRYING, PJSIP_TSX_STATE_PROCEEDING, PJSIP_TSX_STATE_COMPLETED, PJSIP_TSX_STATE_CONFIRMED, PJSIP_TSX_STATE_TERMINATED, PJSIP_TSX_STATE_DESTROYED, PJSIP_TSX_STATE_MAX} pjsip_tsx_state_e; 80 81 typedef enum pjsip_role_e {PJSIP_ROLE_UAC, PJSIP_ROLE_UAS, PJSIP_UAC_ROLE = PJSIP_ROLE_UAC, PJSIP_UAS_ROLE = PJSIP_ROLE_UAS} pjsip_role_e; 82 83 typedef enum pjsip_redirect_op {PJSIP_REDIRECT_REJECT, PJSIP_REDIRECT_ACCEPT, PJSIP_REDIRECT_ACCEPT_REPLACE, PJSIP_REDIRECT_PENDING, PJSIP_REDIRECT_STOP} pjsip_redirect_op; 84 63 85 typedef enum pjrpid_activity {PJRPID_ACTIVITY_UNKNOWN, PJRPID_ACTIVITY_AWAY, PJRPID_ACTIVITY_BUSY} pjrpid_activity; 64 86 65 87 typedef enum pjsip_evsub_state {PJSIP_EVSUB_STATE_NULL, PJSIP_EVSUB_STATE_SENT, PJSIP_EVSUB_STATE_ACCEPTED, PJSIP_EVSUB_STATE_PENDING, PJSIP_EVSUB_STATE_ACTIVE, PJSIP_EVSUB_STATE_TERMINATED, PJSIP_EVSUB_STATE_UNKNOWN} pjsip_evsub_state; 88 89 typedef enum pjsip_inv_state {PJSIP_INV_STATE_NULL, PJSIP_INV_STATE_CALLING, PJSIP_INV_STATE_INCOMING, PJSIP_INV_STATE_EARLY, PJSIP_INV_STATE_CONNECTING, PJSIP_INV_STATE_CONFIRMED, PJSIP_INV_STATE_DISCONNECTED} pjsip_inv_state; 66 90 67 91 enum pjsua_invalid_id_const_ {PJSUA_INVALID_ID = -1}; … … 85 109 typedef enum pjsua_buddy_status {PJSUA_BUDDY_STATUS_UNKNOWN, PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE} pjsua_buddy_status; 86 110 111 typedef enum pjsua_call_media_status {PJSUA_CALL_MEDIA_NONE, PJSUA_CALL_MEDIA_ACTIVE, PJSUA_CALL_MEDIA_LOCAL_HOLD, PJSUA_CALL_MEDIA_REMOTE_HOLD, PJSUA_CALL_MEDIA_ERROR} pjsua_call_media_status; 112 113 typedef int pjsua_vid_win_id; 114 115 typedef int pjsua_call_id; 116 117 typedef enum pjsua_med_tp_st {PJSUA_MED_TP_NULL, PJSUA_MED_TP_CREATING, PJSUA_MED_TP_IDLE, PJSUA_MED_TP_INIT, PJSUA_MED_TP_RUNNING, PJSUA_MED_TP_DISABLED} pjsua_med_tp_st; 118 119 typedef enum pjsua_call_vid_strm_op {PJSUA_CALL_VID_STRM_NO_OP, PJSUA_CALL_VID_STRM_ADD, PJSUA_CALL_VID_STRM_REMOVE, PJSUA_CALL_VID_STRM_CHANGE_DIR, PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, PJSUA_CALL_VID_STRM_START_TRANSMIT, PJSUA_CALL_VID_STRM_STOP_TRANSMIT, PJSUA_CALL_VID_STRM_SEND_KEYFRAME} pjsua_call_vid_strm_op; 120 121 typedef enum pjsua_vid_req_keyframe_method {PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1, PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2} pjsua_vid_req_keyframe_method; 122 123 typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4} pjsua_call_flag; 124 125 typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag; 126 -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.lst
r4662 r4663 1 pj/types.h pj_status_t pj_constants_ pj_uint8_t pj_int32_t 1 pj/types.h pj_status_t pj_constants_ pj_uint8_t pj_int32_t pj_uint32_t pj_uint16_t 2 2 pj/file_io.h pj_file_access 3 3 pj/log.h pj_log_decoration … … 8 8 pjnath/turn_session.h pj_turn_tp_type 9 9 10 pjmedia/transport_srtp.h pjmedia_srtp_use 11 pjmedia/vid_stream.h pjmedia_vid_stream_rc_method 12 pjmedia-videodev/videodev.h pjmedia_vid_dev_index pjmedia_vid_dev_std_index 10 pjmedia/event.h pjmedia_event_type 11 pjmedia/transport_srtp.h pjmedia_srtp_use 12 pjmedia/vid_stream.h pjmedia_vid_stream_rc_method 13 pjmedia-videodev/videodev.h pjmedia_vid_dev_index pjmedia_vid_dev_std_index 13 14 pjmedia/wav_port.h pjmedia_file_writer_option pjmedia_file_player_option 14 pjmedia/types.h pjmedia_type 15 pjmedia/types.h pjmedia_type pjmedia_dir pjmedia_tp_proto 15 16 pjmedia/format.h pjmedia_format_id 16 17 17 pjsip/sip_auth.h pjsip_cred_data_type 18 pjsip/sip_msg.h pjsip_status_code 19 pjsip/sip_transport.h pjsip_transport_type_e pjsip_transport_flags_e pjsip_transport_state 20 pjsip/sip_transport_tls.h pjsip_ssl_method 18 pjsip/sip_auth.h pjsip_cred_data_type 19 pjsip/sip_dialog.h pjsip_dialog_cap_status 20 pjsip/sip_event.h pjsip_event_id_e 21 pjsip/sip_msg.h pjsip_status_code pjsip_hdr_e 22 pjsip/sip_transport.h pjsip_transport_type_e pjsip_transport_flags_e pjsip_transport_state 23 pjsip/sip_transport_tls.h pjsip_ssl_method 24 pjsip/sip_transaction.h pjsip_tsx_state_e 25 pjsip/sip_types.h pjsip_role_e 26 pjsip/sip_util.h pjsip_redirect_op 21 27 22 28 pjsip-simple/rpid.h pjrpid_activity 23 29 pjsip-simple/evsub.h pjsip_evsub_state 24 30 25 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_buddy_status 31 pjsip-ua/sip_inv.h pjsip_inv_state 32 33 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag -
pjproject/branches/projects/pjsua2/pjsip/build/Makefile
r4662 r4663 91 91 export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 92 92 account.o endpoint.o json.o persistent.o types.o \ 93 siptypes.o presence.o media.o93 siptypes.o call.o presence.o media.o 94 94 export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 95 95 export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS) -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2.hpp
r4662 r4663 22 22 #include <pjsua2/endpoint.hpp> 23 23 #include <pjsua2/account.hpp> 24 #include <pjsua2/call.hpp> 24 25 #include <pjsua2/presence.hpp> 25 26 #include <pjsua2/media.hpp> -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4662 r4663 947 947 void transportClose(TransportId id) throw(Error); 948 948 949 /************************************************************************* 950 * Call operations 951 */ 952 953 /** 954 * Terminate all calls. This will initiate call hangup for all 955 * currently active calls. 956 */ 957 void hangupAllCalls(void); 958 949 959 /************************************************************************* 950 960 * Media operations … … 1123 1133 1124 1134 static void on_buddy_state(pjsua_buddy_id buddy_id); 1135 // Call callbacks 1136 static void on_call_state(pjsua_call_id call_id, pjsip_event *e); 1137 static void on_call_tsx_state(pjsua_call_id call_id, 1138 pjsip_transaction *tsx, 1139 pjsip_event *e); 1140 static void on_call_media_state(pjsua_call_id call_id); 1141 static void on_call_sdp_created(pjsua_call_id call_id, 1142 pjmedia_sdp_session *sdp, 1143 pj_pool_t *pool, 1144 const pjmedia_sdp_session *rem_sdp); 1145 static void on_stream_created(pjsua_call_id call_id, 1146 pjmedia_stream *strm, 1147 unsigned stream_idx, 1148 pjmedia_port **p_port); 1149 static void on_stream_destroyed(pjsua_call_id call_id, 1150 pjmedia_stream *strm, 1151 unsigned stream_idx); 1152 static void on_dtmf_digit(pjsua_call_id call_id, int digit); 1153 static void on_call_transfer_request(pjsua_call_id call_id, 1154 const pj_str_t *dst, 1155 pjsip_status_code *code); 1156 static void on_call_transfer_request2(pjsua_call_id call_id, 1157 const pj_str_t *dst, 1158 pjsip_status_code *code, 1159 pjsua_call_setting *opt); 1160 static void on_call_transfer_status(pjsua_call_id call_id, 1161 int st_code, 1162 const pj_str_t *st_text, 1163 pj_bool_t final, 1164 pj_bool_t *p_cont); 1165 static void on_call_replace_request(pjsua_call_id call_id, 1166 pjsip_rx_data *rdata, 1167 int *st_code, 1168 pj_str_t *st_text); 1169 static void on_call_replace_request2(pjsua_call_id call_id, 1170 pjsip_rx_data *rdata, 1171 int *st_code, 1172 pj_str_t *st_text, 1173 pjsua_call_setting *opt); 1174 static void on_call_replaced(pjsua_call_id old_call_id, 1175 pjsua_call_id new_call_id); 1176 static void on_call_rx_offer(pjsua_call_id call_id, 1177 const pjmedia_sdp_session *offer, 1178 void *reserved, 1179 pjsip_status_code *code, 1180 pjsua_call_setting *opt); 1181 static pjsip_redirect_op on_call_redirected(pjsua_call_id call_id, 1182 const pjsip_uri *target, 1183 const pjsip_event *e); 1184 static pj_status_t 1185 on_call_media_transport_state(pjsua_call_id call_id, 1186 const pjsua_med_tp_state_info *info); 1187 static void on_call_media_event(pjsua_call_id call_id, 1188 unsigned med_idx, 1189 pjmedia_event *event); 1190 static pjmedia_transport* 1191 on_create_media_transport(pjsua_call_id call_id, 1192 unsigned media_idx, 1193 pjmedia_transport *base_tp, 1194 unsigned flags); 1125 1195 }; 1126 1196 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/media.hpp
r4662 r4663 126 126 }; 127 127 128 typedef void* MediaPort; 128 /** 129 * Media port, corresponds to pjmedia_port 130 */ 131 typedef void *MediaPort; 129 132 130 133 /** -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp
r4658 r4663 394 394 unsigned usageCount; 395 395 396 public: 396 397 /** Construct from pjsua_transport_info */ 397 398 void fromPj(const pjsua_transport_info &info); … … 419 420 420 421 /** 421 * Source IP address of the message. 422 */ 423 string srcIp; 424 425 /** 426 * Source port number of the message. 427 */ 428 unsigned srcPort; 429 422 * Source address of the message. 423 */ 424 SocketAddress srcAddress; 425 426 /** 427 * Pointer to original pjsip_rx_data. Only valid when the struct 428 * is constructed from PJSIP's pjsip_rx_data. 429 */ 430 void *pjRxData; 431 432 public: 430 433 /** 431 434 * Construct from PJSIP's pjsip_rx_data … … 434 437 }; 435 438 439 /** 440 * This structure describes an outgoing SIP message. It corresponds to the 441 * pjsip_tx_data structure in PJSIP library. 442 */ 443 struct SipTxData 444 { 445 /** 446 * A short info string describing the request, which normally contains 447 * the request method and its CSeq. 448 */ 449 string info; 450 451 /** 452 * The whole message data as a string, containing both the header section 453 * and message body section. 454 */ 455 string wholeMsg; 456 457 /** 458 * Destination address of the message. 459 */ 460 SocketAddress dstAddress; 461 462 /** 463 * Pointer to original pjsip_tx_data. Only valid when the struct 464 * is constructed from PJSIP's pjsip_tx_data. 465 */ 466 void *pjTxData; 467 468 public: 469 /** 470 * Construct from PJSIP's pjsip_tx_data 471 */ 472 void fromPj(pjsip_tx_data &tdata); 473 }; 474 475 /** 476 * This structure describes SIP transaction object. It corresponds to the 477 * pjsip_transaction structure in PJSIP library. 478 */ 479 struct SipTransaction 480 { 481 /* Transaction identification. */ 482 pjsip_role_e role; /**< Role (UAS or UAC) */ 483 string method; /**< The method. */ 484 485 /* State and status. */ 486 int statusCode; /**< Last status code seen. */ 487 string statusText; /**< Last reason phrase. */ 488 pjsip_tsx_state_e state; /**< State. */ 489 490 /* Messages and timer. */ 491 SipTxData lastTx; /**< Msg kept for retrans. */ 492 493 /* Original pjsip_transaction. */ 494 void *pjTransaction; /**< pjsip_transaction. */ 495 496 public: 497 /** 498 * Construct from PJSIP's pjsip_transaction 499 */ 500 void fromPj(pjsip_transaction &tsx); 501 }; 502 503 /** 504 * This structure describes timer event. 505 */ 506 struct TimerEvent 507 { 508 TimerEntry entry; /**< The timer entry. */ 509 }; 510 511 /** 512 * This structure describes transaction state changed event. 513 */ 514 struct TsxStateEvent 515 { 516 struct 517 { 518 SipRxData rdata; /**< The incoming message. */ 519 SipTxData tdata; /**< The outgoing message. */ 520 TimerEntry timer; /**< The timer. */ 521 pj_status_t status; /**< Transport error status. */ 522 GenericData data; /**< Generic data. */ 523 } src; /**< Event source. */ 524 SipTransaction tsx; /**< The transaction. */ 525 pjsip_tsx_state_e prevState; /**< Previous state. */ 526 pjsip_event_id_e type; /**< Type of event source: 527 * - PJSIP_EVENT_TX_MSG 528 * - PJSIP_EVENT_RX_MSG, 529 * - PJSIP_EVENT_TRANSPORT_ERROR 530 * - PJSIP_EVENT_TIMER 531 * - PJSIP_EVENT_USER 532 */ 533 }; 534 535 /** 536 * This structure describes message transmission event. 537 */ 538 struct TxMsgEvent 539 { 540 SipTxData tdata; /**< The transmit data buffer. */ 541 }; 542 543 /** 544 * This structure describes transmission error event. 545 */ 546 struct TxErrorEvent 547 { 548 SipTxData tdata; /**< The transmit data. */ 549 SipTransaction tsx; /**< The transaction. */ 550 }; 551 552 /** 553 * This structure describes message arrival event. 554 */ 555 struct RxMsgEvent 556 { 557 SipRxData rdata; /**< The receive data buffer. */ 558 }; 559 560 /** 561 * This structure describes user event. 562 */ 563 struct UserEvent 564 { 565 GenericData user1; /**< User data 1. */ 566 GenericData user2; /**< User data 2. */ 567 GenericData user3; /**< User data 3. */ 568 GenericData user4; /**< User data 4. */ 569 }; 570 571 /** 572 * This structure describe event descriptor to fully identify a SIP event. It 573 * corresponds to the pjsip_event structure in PJSIP library. 574 */ 575 struct SipEvent 576 { 577 /** 578 * The event type, can be any value of \b pjsip_event_id_e. 579 */ 580 pjsip_event_id_e type; 581 582 /** 583 * The event body, which fields depends on the event type. 584 */ 585 struct 586 { 587 /** 588 * Timer event. 589 */ 590 TimerEvent timer; 591 592 /** 593 * Transaction state has changed event. 594 */ 595 TsxStateEvent tsxState; 596 597 /** 598 * Message transmission event. 599 */ 600 TxMsgEvent txMsg; 601 602 /** 603 * Transmission error event. 604 */ 605 TxErrorEvent txError; 606 607 /** 608 * Message arrival event. 609 */ 610 RxMsgEvent rxMsg; 611 612 /** 613 * User event. 614 */ 615 UserEvent user; 616 617 } body; 618 619 /** 620 * Pointer to its original pjsip_event. Only valid when the struct is 621 * constructed from PJSIP's pjsip_event. 622 */ 623 void *pjEvent; 624 625 public: 626 /** 627 * Construct from PJSIP's pjsip_event 628 */ 629 void fromPj(const pjsip_event &ev); 630 }; 436 631 437 632 ////////////////////////////////////////////////////////////////////////////// … … 449 644 string subType; 450 645 646 public: 451 647 /** 452 648 * Construct from PJSIP's pjsip_media_type … … 475 671 string hValue; 476 672 673 public: 477 674 /** 478 675 * Initiaize from PJSIP header. … … 514 711 string body; 515 712 713 public: 516 714 /** 517 715 * Initiaize from PJSIP's pjsip_multipart_part. … … 540 738 { 541 739 /** 542 * Optional remote target URI (i.e. Target header). If NULL, the target543 * will be set to the remote URI (To header). At the moment this field544 * is only used when sending initial INVITE and MESSAGE requests.545 */ 546 string 740 * Optional remote target URI (i.e. Target header). If empty (""), the 741 * target will be set to the remote URI (To header). At the moment this 742 * field is only used when sending initial INVITE and MESSAGE requests. 743 */ 744 string targetUri; 547 745 548 746 /** 549 747 * Additional message headers to be included in the outgoing message. 550 748 */ 551 SipHeaderVector 749 SipHeaderVector headers; 552 750 553 751 /** … … 555 753 * in this structure. 556 754 */ 557 string 755 string contentType; 558 756 559 757 /** … … 561 759 * message doesn't have a body. 562 760 */ 563 string 761 string msgBody; 564 762 565 763 /** … … 569 767 * contains a body, the body will be added to the multipart bodies. 570 768 */ 571 SipMediaType 769 SipMediaType multipartContentType; 572 770 573 771 /** … … 577 775 * the body will be added to the multipart bodies. 578 776 */ 579 SipMultipartPartVector multipartParts; 580 777 SipMultipartPartVector multipartParts; 778 779 public: 780 /** 781 * Check if the options are empty. If the options are set with empty 782 * values, there will be no additional information sent with outgoing 783 * SIP message. 784 * 785 * @return True if the options are empty. 786 */ 787 bool isEmpty() const; 788 581 789 /** 582 790 * Initiaize from PJSUA's pjsua_msg_data. … … 590 798 }; 591 799 800 ////////////////////////////////////////////////////////////////////////////// 592 801 593 802 /** … … 600 809 * MIME type. Default is "text/plain". 601 810 */ 602 string contentType;811 string contentType; 603 812 604 813 /** 605 814 * The message content. 606 815 */ 607 string content;816 string content; 608 817 609 818 /** … … 611 820 */ 612 821 SipTxOption txOption; 613 822 614 823 /** 615 824 * User data, which will be given back when the IM callback is called. 616 825 */ 617 Token userData; 826 Token userData; 827 828 public: 829 /** 830 * Default constructor initializes with zero/empty values. 831 */ 832 SendInstantMessageParam(); 618 833 }; 619 834 … … 628 843 * True to indicate to remote that local person is currently typing an IM. 629 844 */ 630 bool isTyping;845 bool isTyping; 631 846 632 847 /** 633 848 * List of headers etc to be included in outgoing request. 634 849 */ 635 SipTxOption txOption; 850 SipTxOption txOption; 851 852 public: 853 /** 854 * Default constructor initializes with zero/empty values. 855 */ 856 SendTypingIndicationParam(); 636 857 }; 637 858 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp
r4657 r4663 74 74 typedef void *TransportHandle; 75 75 76 /** 77 * Timer entry, corresponds to pj_timer_entry 78 */ 79 typedef void *TimerEntry; 80 81 /** 82 * Generic data 83 */ 84 typedef void *GenericData; 85 76 86 /* 77 87 * Forward declaration of Account to be used … … 211 221 }; 212 222 223 ////////////////////////////////////////////////////////////////////////////// 224 225 /** 226 * Representation of time value. 227 */ 228 struct TimeValue 229 { 230 /** 231 * The seconds part of the time. 232 */ 233 long sec; 234 235 /** 236 * The miliseconds fraction of the time. 237 */ 238 long msec; 239 240 public: 241 /** 242 * Convert from pjsip 243 */ 244 void fromPj(const pj_time_val &prm); 245 }; 213 246 214 247 } // namespace pj -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4662 r4663 26 26 using namespace std; 27 27 28 #include <pjsua2/account.hpp> 29 #include <pjsua2/call.hpp> 30 28 31 #define THIS_FILE "endpoint.cpp" 29 32 #define MAX_STUN_SERVERS 32 … … 695 698 } 696 699 700 // Call callbacks 701 void Endpoint::on_call_state(pjsua_call_id call_id, pjsip_event *e) 702 { 703 Call *call = Call::lookup(call_id); 704 if (!call) { 705 return; 706 } 707 708 OnCallStateParam prm; 709 prm.e.fromPj(*e); 710 711 call->onCallState(prm); 712 /* If the state is DISCONNECTED, call may have already been deleted 713 * by the application in the callback, so do not access it anymore here. 714 */ 715 } 716 717 void Endpoint::on_call_tsx_state(pjsua_call_id call_id, 718 pjsip_transaction *tsx, 719 pjsip_event *e) 720 { 721 Call *call = Call::lookup(call_id); 722 if (!call) { 723 return; 724 } 725 726 OnCallTsxStateParam prm; 727 prm.e.fromPj(*e); 728 729 call->onCallTsxState(prm); 730 } 731 732 void Endpoint::on_call_media_state(pjsua_call_id call_id) 733 { 734 Call *call = Call::lookup(call_id); 735 if (!call) { 736 return; 737 } 738 739 OnCallMediaStateParam prm; 740 call->onCallMediaState(prm); 741 } 742 743 void Endpoint::on_call_sdp_created(pjsua_call_id call_id, 744 pjmedia_sdp_session *sdp, 745 pj_pool_t *pool, 746 const pjmedia_sdp_session *rem_sdp) 747 { 748 Call *call = Call::lookup(call_id); 749 if (!call) { 750 return; 751 } 752 753 OnCallSdpCreatedParam prm; 754 string orig_sdp; 755 756 prm.sdp.fromPj(*sdp); 757 orig_sdp = prm.sdp.wholeSdp; 758 if (rem_sdp) 759 prm.remSdp.fromPj(*rem_sdp); 760 761 call->onCallSdpCreated(prm); 762 763 /* Check if application modifies the SDP */ 764 if (orig_sdp != prm.sdp.wholeSdp) { 765 pjmedia_sdp_parse(pool, (char*)prm.sdp.wholeSdp.c_str(), 766 prm.sdp.wholeSdp.size(), &sdp); 767 } 768 } 769 770 void Endpoint::on_stream_created(pjsua_call_id call_id, 771 pjmedia_stream *strm, 772 unsigned stream_idx, 773 pjmedia_port **p_port) 774 { 775 Call *call = Call::lookup(call_id); 776 if (!call) { 777 return; 778 } 779 780 OnStreamCreatedParam prm; 781 prm.stream = strm; 782 prm.streamIdx = stream_idx; 783 prm.pPort = (void *)*p_port; 784 785 call->onStreamCreated(prm); 786 787 if (prm.pPort != (void *)*p_port) 788 *p_port = (pjmedia_port *)prm.pPort; 789 } 790 791 void Endpoint::on_stream_destroyed(pjsua_call_id call_id, 792 pjmedia_stream *strm, 793 unsigned stream_idx) 794 { 795 Call *call = Call::lookup(call_id); 796 if (!call) { 797 return; 798 } 799 800 OnStreamDestroyedParam prm; 801 prm.stream = strm; 802 prm.streamIdx = stream_idx; 803 804 call->onStreamDestroyed(prm); 805 } 806 807 void Endpoint::on_dtmf_digit(pjsua_call_id call_id, int digit) 808 { 809 Call *call = Call::lookup(call_id); 810 if (!call) { 811 return; 812 } 813 814 OnDtmfDigitParam prm; 815 char buf[10]; 816 pj_ansi_sprintf(buf, "%c", digit); 817 prm.digit = (string)buf; 818 819 call->onDtmfDigit(prm); 820 } 821 822 void Endpoint::on_call_transfer_request2(pjsua_call_id call_id, 823 const pj_str_t *dst, 824 pjsip_status_code *code, 825 pjsua_call_setting *opt) 826 { 827 Call *call = Call::lookup(call_id); 828 if (!call) { 829 return; 830 } 831 832 OnCallTransferRequestParam prm; 833 prm.dstUri = pj2Str(*dst); 834 prm.statusCode = *code; 835 prm.opt.fromPj(*opt); 836 837 call->onCallTransferRequest(prm); 838 839 *code = prm.statusCode; 840 *opt = prm.opt.toPj(); 841 } 842 843 void Endpoint::on_call_transfer_status(pjsua_call_id call_id, 844 int st_code, 845 const pj_str_t *st_text, 846 pj_bool_t final, 847 pj_bool_t *p_cont) 848 { 849 Call *call = Call::lookup(call_id); 850 if (!call) { 851 return; 852 } 853 854 OnCallTransferStatusParam prm; 855 prm.statusCode = (pjsip_status_code)st_code; 856 prm.reason = pj2Str(*st_text); 857 prm.finalNotify = final; 858 prm.cont = *p_cont; 859 860 call->onCallTransferStatus(prm); 861 862 *p_cont = prm.cont; 863 } 864 865 void Endpoint::on_call_replace_request2(pjsua_call_id call_id, 866 pjsip_rx_data *rdata, 867 int *st_code, 868 pj_str_t *st_text, 869 pjsua_call_setting *opt) 870 { 871 Call *call = Call::lookup(call_id); 872 if (!call) { 873 return; 874 } 875 876 OnCallReplaceRequestParam prm; 877 prm.rdata.fromPj(*rdata); 878 prm.statusCode = (pjsip_status_code)*st_code; 879 prm.reason = pj2Str(*st_text); 880 prm.opt.fromPj(*opt); 881 882 call->onCallReplaceRequest(prm); 883 884 *st_code = prm.statusCode; 885 *st_text = str2Pj(prm.reason); 886 *opt = prm.opt.toPj(); 887 } 888 889 void Endpoint::on_call_replaced(pjsua_call_id old_call_id, 890 pjsua_call_id new_call_id) 891 { 892 Call *call = Call::lookup(old_call_id); 893 if (!call) { 894 return; 895 } 896 897 OnCallReplacedParam prm; 898 prm.newCallId = new_call_id; 899 900 call->onCallReplaced(prm); 901 } 902 903 void Endpoint::on_call_rx_offer(pjsua_call_id call_id, 904 const pjmedia_sdp_session *offer, 905 void *reserved, 906 pjsip_status_code *code, 907 pjsua_call_setting *opt) 908 { 909 Call *call = Call::lookup(call_id); 910 if (!call) { 911 return; 912 } 913 914 OnCallRxOfferParam prm; 915 prm.offer.fromPj(*offer); 916 prm.statusCode = *code; 917 prm.opt.fromPj(*opt); 918 919 call->onCallRxOffer(prm); 920 921 *code = prm.statusCode; 922 *opt = prm.opt.toPj(); 923 } 924 925 pjsip_redirect_op Endpoint::on_call_redirected(pjsua_call_id call_id, 926 const pjsip_uri *target, 927 const pjsip_event *e) 928 { 929 Call *call = Call::lookup(call_id); 930 if (!call) { 931 return PJSIP_REDIRECT_STOP; 932 } 933 934 OnCallRedirectedParam prm; 935 char uristr[PJSIP_MAX_URL_SIZE]; 936 int len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, target, uristr, 937 sizeof(uristr)); 938 if (len < 1) { 939 pj_ansi_strcpy(uristr, "--URI too long--"); 940 } 941 prm.targetUri = string(uristr); 942 if (e) 943 prm.e.fromPj(*e); 944 else 945 prm.e.type = PJSIP_EVENT_UNKNOWN; 946 947 return call->onCallRedirected(prm); 948 } 949 950 pj_status_t 951 Endpoint::on_call_media_transport_state(pjsua_call_id call_id, 952 const pjsua_med_tp_state_info *info) 953 { 954 Call *call = Call::lookup(call_id); 955 if (!call) { 956 return PJ_SUCCESS; 957 } 958 959 OnCallMediaTransportStateParam prm; 960 prm.medIdx = info->med_idx; 961 prm.state = info->state; 962 prm.status = info->status; 963 prm.sipErrorCode = info->sip_err_code; 964 965 call->onCallMediaTransportState(prm); 966 967 return PJ_SUCCESS; 968 } 969 970 void Endpoint::on_call_media_event(pjsua_call_id call_id, 971 unsigned med_idx, 972 pjmedia_event *event) 973 { 974 Call *call = Call::lookup(call_id); 975 if (!call) { 976 return; 977 } 978 979 OnCallMediaEventParam prm; 980 prm.medIdx = med_idx; 981 prm.ev.fromPj(*event); 982 983 call->onCallMediaEvent(prm); 984 } 985 986 pjmedia_transport* 987 Endpoint::on_create_media_transport(pjsua_call_id call_id, 988 unsigned media_idx, 989 pjmedia_transport *base_tp, 990 unsigned flags) 991 { 992 Call *call = Call::lookup(call_id); 993 if (!call) { 994 return base_tp; 995 } 996 997 OnCreateMediaTransportParam prm; 998 prm.mediaIdx = media_idx; 999 prm.mediaTp = base_tp; 1000 prm.flags = flags; 1001 1002 call->onCreateMediaTransport(prm); 1003 1004 return (pjmedia_transport *)prm.mediaTp; 1005 } 697 1006 698 1007 /////////////////////////////////////////////////////////////////////////////// … … 753 1062 ua_cfg.cb.on_buddy_state = &Endpoint::on_buddy_state; 754 1063 1064 /* Call callbacks */ 1065 ua_cfg.cb.on_call_state = &Endpoint::on_call_state; 1066 ua_cfg.cb.on_call_tsx_state = &Endpoint::on_call_tsx_state; 1067 ua_cfg.cb.on_call_media_state = &Endpoint::on_call_media_state; 1068 ua_cfg.cb.on_call_sdp_created = &Endpoint::on_call_sdp_created; 1069 ua_cfg.cb.on_stream_created = &Endpoint::on_stream_created; 1070 ua_cfg.cb.on_stream_destroyed = &Endpoint::on_stream_destroyed; 1071 ua_cfg.cb.on_dtmf_digit = &Endpoint::on_dtmf_digit; 1072 ua_cfg.cb.on_call_transfer_request2 = &Endpoint::on_call_transfer_request2; 1073 ua_cfg.cb.on_call_transfer_status = &Endpoint::on_call_transfer_status; 1074 ua_cfg.cb.on_call_replace_request2 = &Endpoint::on_call_replace_request2; 1075 ua_cfg.cb.on_call_replaced = &Endpoint::on_call_replaced; 1076 ua_cfg.cb.on_call_rx_offer = &Endpoint::on_call_rx_offer; 1077 ua_cfg.cb.on_call_redirected = &Endpoint::on_call_redirected; 1078 ua_cfg.cb.on_call_media_transport_state = 1079 &Endpoint::on_call_media_transport_state; 1080 ua_cfg.cb.on_call_media_event = &Endpoint::on_call_media_event; 1081 ua_cfg.cb.on_create_media_transport = &Endpoint::on_create_media_transport; 1082 755 1083 /* Init! */ 756 1084 PJSUA2_CHECK_EXPR( pjsua_init(&ua_cfg, &log_cfg, &med_cfg) ); … … 977 1305 978 1306 /////////////////////////////////////////////////////////////////////////////// 979 1307 /* 1308 * Call operations 1309 */ 1310 1311 void Endpoint::hangupAllCalls(void) 1312 { 1313 pjsua_call_hangup_all(); 1314 } 1315 1316 /////////////////////////////////////////////////////////////////////////////// 980 1317 /* 981 1318 * Media API -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp
r4658 r4663 324 324 void SipRxData::fromPj(pjsip_rx_data &rdata) 325 325 { 326 char straddr[PJ_INET6_ADDRSTRLEN+10]; 327 326 328 info = pjsip_rx_data_get_info(&rdata); 327 329 wholeMsg = string(rdata.msg_info.msg_buf, rdata.msg_info.len); 328 srcIp = rdata.pkt_info.src_name; 329 srcPort = rdata.pkt_info.src_port; 330 pj_sockaddr_print(&rdata.pkt_info.src_addr, straddr, sizeof(straddr), 3); 331 srcAddress = straddr; 332 pjRxData = (void *)&rdata; 330 333 } 331 334 … … 424 427 /////////////////////////////////////////////////////////////////////////////// 425 428 429 void SipEvent::fromPj(const pjsip_event &ev) 430 { 431 type = ev.type; 432 if (type == PJSIP_EVENT_TIMER) { 433 body.timer.entry = ev.body.timer.entry; 434 } else if (type == PJSIP_EVENT_TSX_STATE) { 435 body.tsxState.prevState = (pjsip_tsx_state_e) 436 ev.body.tsx_state.prev_state; 437 body.tsxState.tsx.fromPj(*ev.body.tsx_state.tsx); 438 if (body.tsxState.type == PJSIP_EVENT_TX_MSG) { 439 body.tsxState.src.tdata.fromPj(*ev.body.tsx_state.src.tdata); 440 } else if (body.tsxState.type == PJSIP_EVENT_RX_MSG) { 441 body.tsxState.src.rdata.fromPj(*ev.body.tsx_state.src.rdata); 442 } else if (body.tsxState.type == PJSIP_EVENT_TRANSPORT_ERROR) { 443 body.tsxState.src.status = ev.body.tsx_state.src.status; 444 } else if (body.tsxState.type == PJSIP_EVENT_TIMER) { 445 body.tsxState.src.timer = ev.body.tsx_state.src.timer; 446 } else if (body.tsxState.type == PJSIP_EVENT_USER) { 447 body.tsxState.src.data = ev.body.tsx_state.src.data; 448 } 449 } else if (type == PJSIP_EVENT_TX_MSG) { 450 body.txMsg.tdata.fromPj(*ev.body.tx_msg.tdata); 451 } else if (type == PJSIP_EVENT_RX_MSG) { 452 body.rxMsg.rdata.fromPj(*ev.body.rx_msg.rdata); 453 } else if (type == PJSIP_EVENT_TRANSPORT_ERROR) { 454 body.txError.tdata.fromPj(*ev.body.tx_error.tdata); 455 body.txError.tsx.fromPj(*ev.body.tx_error.tsx); 456 } else if (type == PJSIP_EVENT_USER) { 457 body.user.user1 = ev.body.user.user1; 458 } 459 pjEvent = (void *)&ev; 460 } 461 462 void SipTxData::fromPj(pjsip_tx_data &tdata) 463 { 464 char straddr[PJ_INET6_ADDRSTRLEN+10]; 465 466 info = pjsip_tx_data_get_info(&tdata); 467 pjsip_tx_data_encode(&tdata); 468 wholeMsg = string(tdata.buf.start, tdata.buf.end - tdata.buf.start); 469 pj_sockaddr_print(&tdata.tp_info.dst_addr, straddr, sizeof(straddr), 3); 470 dstAddress = straddr; 471 pjTxData = (void *)&tdata; 472 } 473 474 void SipTransaction::fromPj(pjsip_transaction &tsx) 475 { 476 this->role = tsx.role; 477 this->method = pj2Str(tsx.method.name); 478 this->statusCode = tsx.status_code; 479 this->statusText = pj2Str(tsx.status_text); 480 this->lastTx.fromPj(*tsx.last_tx); 481 this->pjTransaction = (void *)&tsx; 482 } 483 484 bool SipTxOption::isEmpty() const 485 { 486 return (targetUri == "" && headers.size() == 0 && contentType == "" && 487 msgBody == "" && multipartContentType.type == "" && 488 multipartContentType.subType == "" && multipartParts.size() == 0); 489 } 490 426 491 void SipTxOption::fromPj(const pjsua_msg_data &prm) throw(Error) 427 492 { … … 475 540 } 476 541 } 542 543 ////////////////////////////////////////////////////////////////////////////// 544 545 SendInstantMessageParam::SendInstantMessageParam() 546 : contentType("text/plain"), content(""), userData(NULL) 547 { 548 } 549 550 SendTypingIndicationParam::SendTypingIndicationParam() 551 : isTyping(false) 552 { 553 } -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/types.cpp
r4644 r4663 86 86 } 87 87 88 /////////////////////////////////////////////////////////////////////////////// 89 90 void TimeValue::fromPj(const pj_time_val &prm) 91 { 92 this->sec = prm.sec; 93 this->msec = prm.msec; 94 } 95
Note: See TracChangeset
for help on using the changeset viewer.