Changeset 4663 for pjproject


Ignore:
Timestamp:
Nov 29, 2013 5:56:02 AM (10 years ago)
Author:
ming
Message:

Re #1519: Add Call API in pjsua2.

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  
    3434import accountsetting 
    3535import application 
     36import call 
    3637 
    3738# Account class 
     
    4748                self.cfgChanged = False 
    4849                self.buddyList = [] 
     50                self.callList = [] 
    4951 
    5052        def statusText(self): 
     
    7375                        status = '- not created -' 
    7476                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) 
    7586         
    7687        def onRegState(self, prm): 
    7788                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) 
    78101 
    79102 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/application.py

    r4657 r4663  
    191191                self._onTimer() 
    192192 
     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 
    193203        def updateAccount(self, acc): 
    194204                iid = str(acc.randId) 
     
    270280                self.accMenu = tk.Menu(top, tearoff=False) 
    271281                # Labels, must match with _onAccContextMenu() 
    272                 labels = ['Unregister', 'Reregister', 'Add buddy...', '-', 
     282                labels = ['Call', '-', 'Unregister', 'Reregister', 'Add buddy...', '-', 
    273283                          'Online', 'Invisible', 'Away', 'Busy', '-', 
    274284                          'Settings...', '-', 
     
    351361                        return 
    352362                 
    353                 if label=='Unregister': 
     363                if label=='Call': 
     364                        acc.makeCall() 
     365                elif label=='Unregister': 
    354366                        acc.setRegistration(False) 
    355367                elif label=='Reregister': 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/samples/pjsua2_demo.cpp

    r4647 r4663  
    2424using namespace pj; 
    2525 
     26class MyAccount; 
     27 
     28class MyCall : public Call 
     29{ 
     30private: 
     31    MyAccount *myAcc; 
     32 
     33public: 
     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 
    2643class MyAccount : public Account 
    2744{ 
     45public: 
     46    std::vector<Call *> calls; 
     47     
    2848public: 
    2949    MyAccount() 
    3050    {} 
    3151 
     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 
    3270    virtual void onRegState(OnRegStateParam &prm) 
    3371    { 
     
    3674                  << prm.code << std::endl; 
    3775    } 
     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    } 
    3890}; 
     91 
     92void 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} 
    39104 
    40105static void mainProg1() throw(Error) 
     
    65130    acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", "*", 
    66131                                                        "test1", 0, "test1") ); 
    67     std::auto_ptr<Account> acc(new MyAccount); 
     132    std::auto_ptr<MyAccount> acc(new MyAccount); 
    68133    acc->create(acc_cfg); 
    69  
     134     
    70135    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     
    72150    // Destroy library 
    73151    std::cout << "*** PJSUA2 SHUTTING DOWN ***" << std::endl; 
     
    190268 
    191269    try { 
    192         mainProg(); 
     270        mainProg1(); 
    193271        std::cout << "Success" << std::endl; 
    194272    } catch (Error & err) { 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/Makefile

    r4639 r4663  
    11include ../../../../build.mak 
     2 
     3ifneq ($(findstring "$(TARGET_NAME)","darwin"),"") 
     4  OS=darwin 
     5endif 
    26 
    37OUT_DIR=output 
     
    59LIBPJSUA2_SO=$(OUT_DIR)/pjsua2.dll 
    610else 
    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 
    816endif 
    917 
     
    2331# OS specific 
    2432ifeq ($(OS),Windows_NT) 
    25 MY_JNI_LDFLAGS   = -L$(MY_JDK)/lib -Wl,--kill-at 
    26 MY_JNI_LIB       = $(OUT_DIR)/pjsua2.dll 
     33  MY_JNI_LDFLAGS         = -L$(MY_JDK)/lib -Wl,--kill-at 
     34  MY_JNI_LIB       = $(OUT_DIR)/pjsua2.dll 
    2735else 
    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) 
    3142endif 
    3243 
     
    3445MY_SWIG          = swig 
    3546MY_JDK           = $(JAVA_HOME) 
    36 MY_JAVA          = $(MY_JDK)/bin/java 
    37 MY_JAVAC         = $(MY_JDK)/bin/javac 
     47ifneq ($(findstring $(JAVA_BIN), bin),) 
     48  MY_JAVA        = $(MY_JDK)/bin/java 
     49  MY_JAVAC       = $(MY_JDK)/bin/javac 
     50else 
     51  MY_JAVA        = $(MY_JDK)/java 
     52  MY_JAVAC       = $(MY_JDK)/javac 
     53endif 
    3854MY_JNI_CFLAGS    := $(MY_JNI_CFLAGS) -I$(MY_JDK)/include -I$(MY_JDK)/include/win32 \ 
    3955                   -I$(MY_JDK)/include/linux -I. 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i

    r4662 r4663  
    3737%feature("director") Endpoint;  
    3838%feature("director") Account; 
     39%feature("director") Call; 
    3940%feature("director") Buddy; 
    4041%feature("director") FindBuddyMatch; 
     
    7980%include "pjsua2/presence.hpp" 
    8081%include "pjsua2/account.hpp" 
     82%include "pjsua2/call.hpp" 
     83 
     84%template(CallMediaInfoVector)          std::vector<pj::CallMediaInfo>; 
    8185 
    8286%ignore pj::JsonDocument::allocElement; 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/python/setup.py

    r4619 r4663  
    9393    # Mac OS X depedencies 
    9494    extra_link_args += ["-framework", "CoreFoundation",  
    95                         "-framework", "AudioToolbox"] 
     95                        "-framework", "AudioToolbox", 
     96                        "-framework", "QTKit"] 
    9697    # OS X Lion support 
    9798    if platform.mac_ver()[0].startswith("10.7"): 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.i

    r4662 r4663  
    88 
    99typedef int pj_int32_t; 
     10 
     11typedef unsigned int pj_uint32_t; 
     12 
     13typedef unsigned short pj_uint16_t; 
    1014 
    1115enum pj_file_access {PJ_O_RDONLY = 0x1101, PJ_O_WRONLY = 0x1102, PJ_O_RDWR = 0x1103, PJ_O_APPEND = 0x1108}; 
     
    3337typedef enum pj_turn_tp_type {PJ_TURN_TP_UDP = 17, PJ_TURN_TP_TCP = 6, PJ_TURN_TP_TLS = 255} pj_turn_tp_type; 
    3438 
     39typedef 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 
    3541typedef enum pjmedia_srtp_use {PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, PJMEDIA_SRTP_MANDATORY} pjmedia_srtp_use; 
    3642 
     
    4753typedef enum pjmedia_type {PJMEDIA_TYPE_NONE, PJMEDIA_TYPE_AUDIO, PJMEDIA_TYPE_VIDEO, PJMEDIA_TYPE_APPLICATION, PJMEDIA_TYPE_UNKNOWN} pjmedia_type; 
    4854 
     55typedef 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 
     57typedef 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 
    4959typedef 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; 
    5060 
    5161typedef 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; 
    5262 
     63typedef 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 
     65typedef 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 
    5367typedef 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 
     69typedef 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; 
    5470 
    5571typedef 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; 
     
    6177typedef 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; 
    6278 
     79typedef 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 
     81typedef 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 
     83typedef enum pjsip_redirect_op {PJSIP_REDIRECT_REJECT, PJSIP_REDIRECT_ACCEPT, PJSIP_REDIRECT_ACCEPT_REPLACE, PJSIP_REDIRECT_PENDING, PJSIP_REDIRECT_STOP} pjsip_redirect_op; 
     84 
    6385typedef enum pjrpid_activity {PJRPID_ACTIVITY_UNKNOWN, PJRPID_ACTIVITY_AWAY, PJRPID_ACTIVITY_BUSY} pjrpid_activity; 
    6486 
    6587typedef 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 
     89typedef 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; 
    6690 
    6791enum pjsua_invalid_id_const_ {PJSUA_INVALID_ID = -1}; 
     
    85109typedef enum pjsua_buddy_status {PJSUA_BUDDY_STATUS_UNKNOWN, PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE} pjsua_buddy_status; 
    86110 
     111typedef 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 
     113typedef int pjsua_vid_win_id; 
     114 
     115typedef int pjsua_call_id; 
     116 
     117typedef 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 
     119typedef 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 
     121typedef 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 
     123typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4} pjsua_call_flag; 
     124 
     125typedef 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          
     1pj/types.h                      pj_status_t pj_constants_ pj_uint8_t pj_int32_t pj_uint32_t pj_uint16_t 
    22pj/file_io.h                    pj_file_access 
    33pj/log.h                        pj_log_decoration 
     
    88pjnath/turn_session.h           pj_turn_tp_type 
    99 
    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 
     10pjmedia/event.h                 pjmedia_event_type 
     11pjmedia/transport_srtp.h        pjmedia_srtp_use 
     12pjmedia/vid_stream.h            pjmedia_vid_stream_rc_method 
     13pjmedia-videodev/videodev.h     pjmedia_vid_dev_index pjmedia_vid_dev_std_index 
    1314pjmedia/wav_port.h              pjmedia_file_writer_option pjmedia_file_player_option 
    14 pjmedia/types.h                 pjmedia_type 
     15pjmedia/types.h                 pjmedia_type pjmedia_dir pjmedia_tp_proto 
    1516pjmedia/format.h                pjmedia_format_id 
    1617 
    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 
     18pjsip/sip_auth.h                pjsip_cred_data_type 
     19pjsip/sip_dialog.h              pjsip_dialog_cap_status 
     20pjsip/sip_event.h               pjsip_event_id_e 
     21pjsip/sip_msg.h                 pjsip_status_code pjsip_hdr_e 
     22pjsip/sip_transport.h           pjsip_transport_type_e pjsip_transport_flags_e pjsip_transport_state 
     23pjsip/sip_transport_tls.h       pjsip_ssl_method 
     24pjsip/sip_transaction.h         pjsip_tsx_state_e 
     25pjsip/sip_types.h               pjsip_role_e 
     26pjsip/sip_util.h                pjsip_redirect_op 
    2127 
    2228pjsip-simple/rpid.h             pjrpid_activity 
    2329pjsip-simple/evsub.h            pjsip_evsub_state 
    2430 
    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 
     31pjsip-ua/sip_inv.h              pjsip_inv_state 
     32 
     33pjsua-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  
    9191export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 
    9292                           account.o endpoint.o json.o persistent.o types.o \ 
    93                            siptypes.o presence.o media.o 
     93                           siptypes.o call.o presence.o media.o 
    9494export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 
    9595export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS)  
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2.hpp

    r4662 r4663  
    2222#include <pjsua2/endpoint.hpp> 
    2323#include <pjsua2/account.hpp> 
     24#include <pjsua2/call.hpp> 
    2425#include <pjsua2/presence.hpp> 
    2526#include <pjsua2/media.hpp> 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp

    r4662 r4663  
    947947    void transportClose(TransportId id) throw(Error); 
    948948 
     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     
    949959    /************************************************************************* 
    950960     * Media operations 
     
    11231133 
    11241134    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); 
    11251195}; 
    11261196 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/media.hpp

    r4662 r4663  
    126126}; 
    127127 
    128 typedef void* MediaPort; 
     128/** 
     129 * Media port, corresponds to pjmedia_port 
     130 */ 
     131typedef void *MediaPort; 
    129132 
    130133/** 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp

    r4658 r4663  
    394394    unsigned                usageCount; 
    395395 
     396public: 
    396397    /** Construct from pjsua_transport_info */ 
    397398    void fromPj(const pjsua_transport_info &info); 
     
    419420 
    420421    /** 
    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 
     432public: 
    430433    /** 
    431434     * Construct from PJSIP's pjsip_rx_data 
     
    434437}; 
    435438 
     439/** 
     440 * This structure describes an outgoing SIP message. It corresponds to the 
     441 * pjsip_tx_data structure in PJSIP library. 
     442 */ 
     443struct 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     
     468public: 
     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 */ 
     479struct 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     
     496public: 
     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 */ 
     506struct TimerEvent 
     507{ 
     508    TimerEntry          entry;          /**< The timer entry.           */ 
     509}; 
     510 
     511/** 
     512 * This structure describes transaction state changed event. 
     513 */ 
     514struct 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 */ 
     538struct TxMsgEvent 
     539{ 
     540    SipTxData           tdata;          /**< The transmit data buffer.  */ 
     541}; 
     542 
     543/** 
     544 * This structure describes transmission error event. 
     545 */ 
     546struct TxErrorEvent 
     547{ 
     548    SipTxData           tdata;          /**< The transmit data.         */ 
     549    SipTransaction      tsx;            /**< The transaction.           */ 
     550}; 
     551 
     552/** 
     553 * This structure describes message arrival event. 
     554 */ 
     555struct RxMsgEvent 
     556{ 
     557    SipRxData           rdata;          /**< The receive data buffer.   */ 
     558}; 
     559 
     560/** 
     561 * This structure describes user event. 
     562 */ 
     563struct 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 */ 
     575struct 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     
     625public: 
     626    /** 
     627     * Construct from PJSIP's pjsip_event 
     628     */ 
     629    void fromPj(const pjsip_event &ev); 
     630}; 
    436631 
    437632////////////////////////////////////////////////////////////////////////////// 
     
    449644    string              subType; 
    450645 
     646public: 
    451647    /** 
    452648     * Construct from PJSIP's pjsip_media_type 
     
    475671    string              hValue; 
    476672 
     673public: 
    477674    /** 
    478675     * Initiaize from PJSIP header. 
     
    514711    string              body; 
    515712 
     713public: 
    516714    /** 
    517715     * Initiaize from PJSIP's pjsip_multipart_part. 
     
    540738{ 
    541739    /** 
    542      * Optional remote target URI (i.e. Target header). If NULL, the target 
    543      * will be set to the remote URI (To header). At the moment this field 
    544      * is only used when sending initial INVITE and MESSAGE requests. 
    545      */ 
    546     string              targetUri; 
     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; 
    547745 
    548746    /** 
    549747     * Additional message headers to be included in the outgoing message. 
    550748     */ 
    551     SipHeaderVector     headers; 
     749    SipHeaderVector         headers; 
    552750 
    553751    /** 
     
    555753     * in this structure. 
    556754     */ 
    557     string              contentType; 
     755    string                  contentType; 
    558756 
    559757    /** 
     
    561759     * message doesn't have a body. 
    562760     */ 
    563     string              msgBody; 
     761    string                  msgBody; 
    564762 
    565763    /** 
     
    569767     * contains a body, the body will be added to the multipart bodies. 
    570768     */ 
    571     SipMediaType        multipartContentType; 
     769    SipMediaType            multipartContentType; 
    572770 
    573771    /** 
     
    577775     * the body will be added to the multipart bodies. 
    578776     */ 
    579     SipMultipartPartVector      multipartParts; 
    580  
     777    SipMultipartPartVector  multipartParts; 
     778 
     779public: 
     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     
    581789    /** 
    582790     * Initiaize from PJSUA's pjsua_msg_data. 
     
    590798}; 
    591799 
     800////////////////////////////////////////////////////////////////////////////// 
    592801 
    593802/** 
     
    600809     * MIME type. Default is "text/plain". 
    601810     */ 
    602     string contentType; 
     811    string      contentType; 
    603812     
    604813    /** 
    605814     * The message content. 
    606815     */ 
    607     string content; 
     816    string      content; 
    608817     
    609818    /** 
     
    611820     */ 
    612821    SipTxOption txOption; 
    613  
     822     
    614823    /** 
    615824     * User data, which will be given back when the IM callback is called. 
    616825     */ 
    617     Token userData; 
     826    Token       userData; 
     827     
     828public: 
     829    /** 
     830     * Default constructor initializes with zero/empty values. 
     831     */ 
     832    SendInstantMessageParam(); 
    618833}; 
    619834 
     
    628843     * True to indicate to remote that local person is currently typing an IM. 
    629844     */ 
    630     bool isTyping; 
     845    bool         isTyping; 
    631846     
    632847    /** 
    633848     * List of headers etc to be included in outgoing request. 
    634849     */ 
    635     SipTxOption txOption; 
     850    SipTxOption  txOption; 
     851     
     852public: 
     853    /** 
     854     * Default constructor initializes with zero/empty values. 
     855     */ 
     856    SendTypingIndicationParam(); 
    636857}; 
    637858 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp

    r4657 r4663  
    7474typedef void *TransportHandle; 
    7575 
     76/** 
     77 * Timer entry, corresponds to pj_timer_entry 
     78 */ 
     79typedef void *TimerEntry; 
     80 
     81/** 
     82 * Generic data 
     83 */ 
     84typedef void *GenericData; 
     85 
    7686/* 
    7787 * Forward declaration of Account to be used 
     
    211221}; 
    212222 
     223////////////////////////////////////////////////////////////////////////////// 
     224 
     225/** 
     226 * Representation of time value. 
     227 */ 
     228struct 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     
     240public: 
     241    /** 
     242     * Convert from pjsip 
     243     */ 
     244    void fromPj(const pj_time_val &prm); 
     245}; 
    213246 
    214247} // namespace pj 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp

    r4662 r4663  
    2626using namespace std; 
    2727 
     28#include <pjsua2/account.hpp> 
     29#include <pjsua2/call.hpp> 
     30 
    2831#define THIS_FILE               "endpoint.cpp" 
    2932#define MAX_STUN_SERVERS        32 
     
    695698} 
    696699 
     700// Call callbacks 
     701void 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 
     717void 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 
     732void 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 
     743void 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 
     770void 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 
     791void 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 
     807void 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 
     822void 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 
     843void 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 
     865void 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 
     889void 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 
     903void 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 
     925pjsip_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 
     950pj_status_t 
     951Endpoint::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 
     970void 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 
     986pjmedia_transport* 
     987Endpoint::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} 
    6971006 
    6981007/////////////////////////////////////////////////////////////////////////////// 
     
    7531062    ua_cfg.cb.on_buddy_state    = &Endpoint::on_buddy_state; 
    7541063 
     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 
    7551083    /* Init! */ 
    7561084    PJSUA2_CHECK_EXPR( pjsua_init(&ua_cfg, &log_cfg, &med_cfg) ); 
     
    9771305 
    9781306/////////////////////////////////////////////////////////////////////////////// 
    979  
     1307/* 
     1308 * Call operations 
     1309 */ 
     1310 
     1311void Endpoint::hangupAllCalls(void) 
     1312{ 
     1313    pjsua_call_hangup_all(); 
     1314} 
     1315 
     1316/////////////////////////////////////////////////////////////////////////////// 
    9801317/* 
    9811318 * Media API 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp

    r4658 r4663  
    324324void SipRxData::fromPj(pjsip_rx_data &rdata) 
    325325{ 
     326    char straddr[PJ_INET6_ADDRSTRLEN+10]; 
     327 
    326328    info        = pjsip_rx_data_get_info(&rdata); 
    327329    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; 
    330333} 
    331334 
     
    424427/////////////////////////////////////////////////////////////////////////////// 
    425428 
     429void 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 
     462void 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 
     474void 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 
     484bool SipTxOption::isEmpty() const 
     485{ 
     486    return (targetUri == "" && headers.size() == 0 && contentType == "" && 
     487            msgBody == "" && multipartContentType.type == "" && 
     488            multipartContentType.subType == "" && multipartParts.size() == 0); 
     489} 
     490 
    426491void SipTxOption::fromPj(const pjsua_msg_data &prm) throw(Error) 
    427492{ 
     
    475540    } 
    476541} 
     542 
     543////////////////////////////////////////////////////////////////////////////// 
     544 
     545SendInstantMessageParam::SendInstantMessageParam() 
     546: contentType("text/plain"), content(""), userData(NULL) 
     547{ 
     548} 
     549 
     550SendTypingIndicationParam::SendTypingIndicationParam() 
     551: isTyping(false) 
     552{ 
     553} 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/types.cpp

    r4644 r4663  
    8686} 
    8787 
     88/////////////////////////////////////////////////////////////////////////////// 
     89 
     90void 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.