00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifdef __HAVE_MMSSIP__
00034
00035 #ifndef MMSSIP_H_
00036 #define MMSSIP_H_
00037
00038 #include <pjsua-lib/pjsua.h>
00039 #include <iostream>
00040 #include <sigc++/sigc++.h>
00041 #include <map>
00042
00043 using namespace std;
00044
00045 typedef struct {
00046 string user;
00047 string passwd;
00048 string registrar;
00049 string realm;
00050 bool autoanswer;
00051 } MMSSipAccount;
00052
00053 typedef enum {
00054 BUDDY_ONLINE = PJSUA_BUDDY_STATUS_ONLINE,
00055 BUDDY_OFFLINE = PJSUA_BUDDY_STATUS_OFFLINE,
00056 BUDDY_UNKNOWN = PJSUA_BUDDY_STATUS_UNKNOWN
00057 } MMSSipBuddyStatus;
00058
00059 typedef struct {
00060 string name;
00061 string uri;
00062 MMSSipBuddyStatus status;
00063 } MMSSipBuddy;
00064
00065 typedef struct {
00066 pj_thread_desc desc;
00067 pj_thread_t *thread;
00068 } MMSSipThread;
00069
00070 class MMSSip {
00071 private:
00072 string stunserver,
00073 nameserver;
00074 short int localPort;
00075
00076 vector<MMSSipThread> threadInfo;
00077
00078 map<int, MMSSipAccount> accounts;
00079 int defaultAccount;
00080 map<int, MMSSipBuddy> buddies;
00081
00082 public:
00083 MMSSip(const string &user,
00084 const string &passwd,
00085 const string ®istrar,
00086 const string &realm = "",
00087 const string &stunserver = "",
00088 const string &nameserver = "",
00089 const short int &localPort = 5060);
00090
00091 ~MMSSip();
00092
00093 const bool registerAccount(const string &user,
00094 const string &passwd,
00095 const string ®istrar,
00096 const string &realm,
00097 const bool defaultAccount = false,
00098 const bool autoanswer = false);
00099 const int call(const string &user, const string &domain = "");
00100 void hangup(int id = PJSUA_INVALID_ID);
00101 void answer(int id);
00102 void addBuddy(const string &name, const string &uri);
00103 MMSSipBuddy getBuddy(const int &id);
00104 bool setSpeakerVolume(const unsigned int percent);
00105 int getSpeakerVolume();
00106 bool getAutoAnswer(const int accountId);
00107 void setAutoAnswer(const int accountId, const bool value = true);
00108 bool registerRingtone(const string &filename);
00109 bool registerBusytone(const string &filename);
00110 bool registerCallingtone(const string &filename);
00111
00112
00113
00114
00115
00116
00117
00118 sigc::signal<void, int, int> *onCallSuccessfull;
00119
00120
00121
00122
00123
00124
00125
00126 sigc::signal<void, int, string, int> *onCallIncoming;
00127
00128
00129
00130
00131
00132
00133
00134 sigc::signal<void, int, int> *onCallDisconnected;
00135
00136
00137
00138
00139
00140
00141
00142 sigc::signal<void, int, int> *onCalling;
00143
00144
00145
00146
00147
00148
00149
00150 sigc::signal<void, MMSSipBuddy> *onBuddyStatus;
00151 };
00152
00153 #endif
00154 #endif