| 1 | /* |
|---|
| 2 | The phapipp module implements thin C++ wrapper around phapi |
|---|
| 3 | Copyright (C) 2007 Vadim Lebedev <vadim@mbdsys.com> |
|---|
| 4 | |
|---|
| 5 | This library is free software; you can redistribute it and/or |
|---|
| 6 | modify it under the terms of the GNU Lesser General Public |
|---|
| 7 | License as published by the Free Software Foundation; either |
|---|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|---|
| 9 | |
|---|
| 10 | This library is distributed in the hope that it will be useful, |
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | Lesser General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU Lesser General Public |
|---|
| 16 | License along with this library; if not, write to the Free Software |
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #include <assert.h> |
|---|
| 22 | #include <stdlib.h> |
|---|
| 23 | #include <string.h> |
|---|
| 24 | #include <stdio.h> |
|---|
| 25 | |
|---|
| 26 | #include "phapipp.h" |
|---|
| 27 | |
|---|
| 28 | #if defined(_WIN32) |
|---|
| 29 | #include <windows.h> |
|---|
| 30 | # ifdef _WIN32_WCE |
|---|
| 31 | # include "connmgr_status.h" |
|---|
| 32 | # endif |
|---|
| 33 | #define strdup _strdup |
|---|
| 34 | #endif |
|---|
| 35 | |
|---|
| 36 | namespace verona { |
|---|
| 37 | |
|---|
| 38 | static phapi *uniqueobj; |
|---|
| 39 | |
|---|
| 40 | phapi::phapi() |
|---|
| 41 | { |
|---|
| 42 | assert(uniqueobj == 0); |
|---|
| 43 | uniqueobj = this; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | phapi::~phapi() |
|---|
| 48 | { |
|---|
| 49 | assert(uniqueobj == this); |
|---|
| 50 | uniqueobj = 0; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | int phapi::init(bool asyncMode) |
|---|
| 56 | { |
|---|
| 57 | return phInit(&callbacks, 0, asyncMode); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | void phapi::terminate() |
|---|
| 62 | { |
|---|
| 63 | phTerminate(); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | int phapi::addAuthInfo(const char* username, const char* userid, const char* passwd, |
|---|
| 69 | const char *realm, const char* ha1) |
|---|
| 70 | { |
|---|
| 71 | return phAddAuthInfo(username, userid, passwd, ha1, realm); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | int phapi::addVline(const char* displayname, const char* username, const char* host, |
|---|
| 76 | const char* proxy, int regTimeout, int mobility) |
|---|
| 77 | { |
|---|
| 78 | return phAddVline3(displayname, username, host, proxy, regTimeout, mobility); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | int phapi::delVline(int vlid) |
|---|
| 82 | { |
|---|
| 83 | return phDelVline(vlid); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | int phapi::vlRegister(int vlid) |
|---|
| 87 | { |
|---|
| 88 | return phvlRegister(vlid); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | int phapi::sendOptions(int vlid, const char *to) |
|---|
| 92 | { |
|---|
| 93 | return phLineSendOptions(vlid, to); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | int phapi::placeCall(int vlid, const char* uri, void* userdata, int rcid, int streams, |
|---|
| 97 | const char* adev, const char* audio_addr, const char* video_addr) |
|---|
| 98 | { |
|---|
| 99 | return phLinePlaceCall4(vlid, uri, userdata, rcid, streams, adev, audio_addr, video_addr); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | int phapi::acceptCall(int cid, void* userData, int streams, |
|---|
| 104 | const char* audio_addr, const char* video_addr) |
|---|
| 105 | { |
|---|
| 106 | return phAcceptCall4(cid, userData, streams, audio_addr, video_addr); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | int phapi::rejectCall(int cid, int reason, const char *uri) |
|---|
| 111 | { |
|---|
| 112 | return uri ? phRejectCall(cid, reason) : phRejectCall2(cid, uri, reason); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | int phapi::ringingCall(int cid) |
|---|
| 117 | { |
|---|
| 118 | return phRingingCall(cid); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | int phapi::closeCall(int cid) |
|---|
| 122 | { |
|---|
| 123 | return phCloseCall(cid); |
|---|
| 124 | |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | int phapi::holdCall(int cid) |
|---|
| 128 | { |
|---|
| 129 | return phHoldCall(cid); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | int phapi::resumeCall(int cid) |
|---|
| 133 | { |
|---|
| 134 | return phResumeCall(cid); |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | int phapi::blindTransferCall(int cid, const char *uri) |
|---|
| 138 | { |
|---|
| 139 | return phBlindTransferCall(cid, uri); |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | int phapi::sendDtmf(int cid, int dtmfChar, int mode) |
|---|
| 143 | { |
|---|
| 144 | return phSendDtmf(cid, dtmfChar, mode); |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | int phapi::messageInCall(int cid, const char *mime, const char *buff) |
|---|
| 148 | { |
|---|
| 149 | return phCallSendMessage(cid, (char*) mime, (char*) buff); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | int phapi::getSipCallID(int cid, char *idbuf, int bufsize) |
|---|
| 154 | { |
|---|
| 155 | return phCallGetSipCallID(cid, idbuf, bufsize); |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | int phapi::setFollowMe(int vlid, const char *uri) |
|---|
| 159 | { |
|---|
| 160 | return phLineSetFollowMe(vlid, uri); |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | int phapi::setBusy(int vlid, bool busy) |
|---|
| 164 | { |
|---|
| 165 | return phLineSetBusy(vlid, busy); |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | int phapi::sendMessage(int vlid, const char* to, const char* buff, const char* mime, |
|---|
| 169 | const char* target, const char* sipcid) |
|---|
| 170 | { |
|---|
| 171 | return phLineSendMessage2(vlid, target, to, buff, mime, sipcid); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | int phapi::subscribe(int vlid, const char* to, int winfo, char* data, int use_proxy, int expire) |
|---|
| 177 | { |
|---|
| 178 | return phLineSubscribe2(vlid, to, winfo, data, use_proxy, expire); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | int phapi::unsubscribe(int sid, int winfo) |
|---|
| 183 | { |
|---|
| 184 | return phLineUnsubscribe(sid, winfo); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | int phapi::publish(int vlid, const char* to, const char* evt, const char* ctt, const char* content, |
|---|
| 189 | int expires) |
|---|
| 190 | { |
|---|
| 191 | if (expires == -1) |
|---|
| 192 | expires = 600; |
|---|
| 193 | |
|---|
| 194 | return phLinePublish2(vlid, to, evt, ctt, content, expires); |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | int phapi::poll() |
|---|
| 200 | { |
|---|
| 201 | return phPoll(); |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | void phapi::refresh() |
|---|
| 205 | { |
|---|
| 206 | phRefresh(); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | void phapi::setLogFile(const char* logFile) |
|---|
| 211 | { |
|---|
| 212 | phSetLogFileName(logFile); |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | int phapi::mobility(int vlid) |
|---|
| 217 | { |
|---|
| 218 | return phLineGetMobility(vlid); |
|---|
| 219 | |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | int phapi::setUsername2(int vlid, const char* username) |
|---|
| 223 | { |
|---|
| 224 | return phLineSetUsername2(vlid, username); |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | int phapi::getLineSipAddress(int vlid, char *buf, int size) |
|---|
| 230 | { |
|---|
| 231 | return phLineGetSipAddress(vlid, buf, size); |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | void phapi::setUaString(const char *uastr) |
|---|
| 235 | { |
|---|
| 236 | phSetUaString(uastr); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | void phapi::changeAudioCodecList(const char *audio_codecs) |
|---|
| 240 | { |
|---|
| 241 | ph_config_s *phcfg = ph_get_config(); |
|---|
| 242 | const size_t S = sizeof(phcfg->audio_codecs); |
|---|
| 243 | |
|---|
| 244 | strncpy(phcfg->audio_codecs, audio_codecs, S); |
|---|
| 245 | phcfg->audio_codecs[S-1] = 0; |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | void phapi::changeVideoCodecList(const char *video_codecs) |
|---|
| 249 | { |
|---|
| 250 | ph_config_s *phcfg = ph_get_config(); |
|---|
| 251 | const size_t S = sizeof(phcfg->video_codecs); |
|---|
| 252 | |
|---|
| 253 | strncpy(phcfg->video_codecs, video_codecs, S); |
|---|
| 254 | phcfg->video_codecs[S-1] = 0; |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | #if defined(_WIN32_WCE) |
|---|
| 258 | char * phapi::getLocalIpFromDescription(const char *description) |
|---|
| 259 | { |
|---|
| 260 | DWORD pcbBufferSize = 0; |
|---|
| 261 | ConnMgrQueryDetailedStatus(0,&pcbBufferSize); |
|---|
| 262 | CONNMGR_CONNECTION_DETAILED_STATUS * pStatusBuffer = (CONNMGR_CONNECTION_DETAILED_STATUS *)calloc(pcbBufferSize, 1); |
|---|
| 263 | |
|---|
| 264 | if(!ConnMgrQueryDetailedStatus(pStatusBuffer,&pcbBufferSize)) |
|---|
| 265 | { |
|---|
| 266 | for (CONNMGR_CONNECTION_DETAILED_STATUS * curItem = pStatusBuffer; curItem != 0; curItem = curItem->pNext) |
|---|
| 267 | { |
|---|
| 268 | WCHAR NameBuffer[512]; |
|---|
| 269 | mbstowcs(NameBuffer,description,512); |
|---|
| 270 | |
|---|
| 271 | if (curItem->pIPAddr != NULL && (curItem->szAdapterName && !wcscmp(NameBuffer,curItem->szAdapterName) || curItem->szDescription && !wcscmp(NameBuffer,curItem->szDescription))) |
|---|
| 272 | { |
|---|
| 273 | WCHAR addressAsString[128]; |
|---|
| 274 | DWORD addressSize = sizeof(addressAsString); |
|---|
| 275 | |
|---|
| 276 | WSAAddressToString((LPSOCKADDR)curItem->pIPAddr->IPAddr,128,0,addressAsString,&addressSize); |
|---|
| 277 | |
|---|
| 278 | char *local_ip = new char[128]; |
|---|
| 279 | WideCharToMultiByte(CP_ACP, 0, addressAsString, -1,local_ip, 128, NULL, NULL); |
|---|
| 280 | return local_ip; |
|---|
| 281 | } |
|---|
| 282 | } |
|---|
| 283 | } |
|---|
| 284 | return ""; |
|---|
| 285 | } |
|---|
| 286 | #endif |
|---|
| 287 | |
|---|
| 288 | void phapi::changeLocalIP(const char *local_ip) |
|---|
| 289 | { |
|---|
| 290 | ph_config_s *phcfg = ph_get_config(); |
|---|
| 291 | const size_t S = sizeof(phcfg->local_ip_addr); |
|---|
| 292 | strncpy(phcfg->local_ip_addr, local_ip, S); |
|---|
| 293 | phcfg->local_ip_addr[S-1] = 0; |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | std::map<char*, char*> phapi::getAudioCaptureDevices() |
|---|
| 297 | { |
|---|
| 298 | ph_audio_card_desc_t* device_tab = NULL; |
|---|
| 299 | int pos = 0; |
|---|
| 300 | int i = 0; |
|---|
| 301 | std::map<char*, char*> device_map; |
|---|
| 302 | |
|---|
| 303 | pos = phAudioCaptureCardList(&device_tab); |
|---|
| 304 | |
|---|
| 305 | for (i = 0; i < pos; i++) |
|---|
| 306 | { |
|---|
| 307 | device_map.insert(std::pair<char*, char*>(device_tab[i].id, device_tab[i].name)); |
|---|
| 308 | printf("MSSndCard id:%s name:%s !!!!\n", device_tab[i].id, device_tab[i].name); |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | if(device_tab) |
|---|
| 312 | delete device_tab; |
|---|
| 313 | |
|---|
| 314 | return device_map; |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | std::map<char*, char*> phapi::getVideoWebcamDevices() |
|---|
| 318 | { |
|---|
| 319 | ph_video_web_cam_desc_t* device_tab = NULL; |
|---|
| 320 | int pos =0; |
|---|
| 321 | int i = 0; |
|---|
| 322 | std::map<char *, char*> device_map; |
|---|
| 323 | |
|---|
| 324 | pos = phVideoWebcamList(&device_tab); |
|---|
| 325 | |
|---|
| 326 | for (i = 0; i < pos; i++) |
|---|
| 327 | { |
|---|
| 328 | device_map.insert(std::pair<char*, char*>(device_tab[i].id, device_tab[i].name)); |
|---|
| 329 | printf("webcam id:%s name:%s !!!!\n", device_tab[i].id, device_tab[i].name); |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | if(device_tab) |
|---|
| 333 | delete device_tab; |
|---|
| 334 | |
|---|
| 335 | return device_map; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | std::map<char*, char*> phapi::getAudioPlaybackDevices() |
|---|
| 339 | { |
|---|
| 340 | ph_audio_card_desc_t* device_tab = NULL; |
|---|
| 341 | int pos = 0; |
|---|
| 342 | int i = 0; |
|---|
| 343 | std::map<char*, char*> device_map; |
|---|
| 344 | |
|---|
| 345 | pos = phAudioPlaybackCardList(&device_tab); |
|---|
| 346 | |
|---|
| 347 | for (i = 0; i < pos; i++) |
|---|
| 348 | { |
|---|
| 349 | device_map.insert(std::pair<char*, char*>(device_tab[i].id, device_tab[i].name)); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | if(device_tab) |
|---|
| 353 | delete device_tab; |
|---|
| 354 | |
|---|
| 355 | return device_map; |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | void phapi::changeAudioDeviceIn(const char *devstr) |
|---|
| 359 | { |
|---|
| 360 | phChangeAudioDeviceIn(devstr); |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | void phapi::changeAudioDeviceOut(const char *devstr) |
|---|
| 364 | { |
|---|
| 365 | phChangeAudioDeviceOut(devstr); |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | void phapi::changeVideoDevices(const char *devstr) |
|---|
| 369 | { |
|---|
| 370 | phChangeVideoDevices(devstr); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | int phapi::setSoftRecvVolumeGain(int cid, float gain) |
|---|
| 374 | { |
|---|
| 375 | return phAudioSoftRecvVolumeGain(cid, gain); |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | int phapi::setSoftSendVolumeGain(int cid, float gain) |
|---|
| 379 | { |
|---|
| 380 | return phAudioSoftSendVolumeGain(cid, gain); |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | int phapi::setRecvVolumeLevel(int cid, int level) |
|---|
| 384 | { |
|---|
| 385 | return phAudioRecvVolumeLevel(cid, level); |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | int phapi::setSendVolumeLevel(int cid, int level) |
|---|
| 389 | { |
|---|
| 390 | return phAudioSendVolumeLevel(cid, level); |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | int phapi::mutePlayback(int cid, int val) |
|---|
| 394 | { |
|---|
| 395 | return phAudioMutePlayback(cid, val); |
|---|
| 396 | } |
|---|
| 397 | |
|---|
| 398 | int phapi::muteCapture(int cid, int val) |
|---|
| 399 | { |
|---|
| 400 | return phAudioMuteCapture(cid, val); |
|---|
| 401 | } |
|---|
| 402 | |
|---|
| 403 | int phapi::setSoundFileGain(phStream* phstream,float gain) |
|---|
| 404 | { |
|---|
| 405 | return phSetSoundFileGain(phstream,gain); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | phStream * phapi::playSoundFile(const char * filename, int interval, const char* deviceid) |
|---|
| 409 | { |
|---|
| 410 | return phPlaySoundFile(filename,interval,deviceid); |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | int phapi::stopSoundFile(phStream * phstream) |
|---|
| 414 | { |
|---|
| 415 | return phStopSoundFile(phstream); |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | phStream * phapi::videoStartPreview(const char* deviceid) |
|---|
| 419 | { |
|---|
| 420 | phStream * stream = phVideoStartPreview(deviceid); |
|---|
| 421 | return stream; |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | int phapi::videoStopPreview(phStream * phstream) |
|---|
| 425 | { |
|---|
| 426 | return phVideoStopPreview(phstream); |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | int phapi::videoSetDefaultImage(const char* path) |
|---|
| 430 | { |
|---|
| 431 | return phVideoSetDefaultImage(path); |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | void phapi::onCallProgress(int cid, const phCallStateInfo_t *info) |
|---|
| 435 | { |
|---|
| 436 | if(info->event == phDTMF) |
|---|
| 437 | onDtmfProgress(cid,info->dtmfDigit); |
|---|
| 438 | else if(info->event == phCALLCLOSED || info->event == phCALLERROR) { |
|---|
| 439 | #if defined(_WIN32_WCE) |
|---|
| 440 | onCallProgress2(cid,info->event,(wchar_t*)"",info->errorCode); |
|---|
| 441 | #else |
|---|
| 442 | onCallProgress2(cid,info->event,(char*)"",info->errorCode); |
|---|
| 443 | #endif |
|---|
| 444 | }else { |
|---|
| 445 | #if defined(_WIN32_WCE) |
|---|
| 446 | int utfsize = MultiByteToWideChar(CP_ACP, 0, info->remoteUri, -1, NULL, 0); |
|---|
| 447 | wchar_t *tmp = (wchar_t *)alloca((utfsize + 1) * sizeof(*tmp)); |
|---|
| 448 | |
|---|
| 449 | MultiByteToWideChar(CP_ACP, 0, info->remoteUri, -1,tmp, utfsize); |
|---|
| 450 | onCallProgress2(cid,info->event, tmp,info->errorCode); |
|---|
| 451 | #else |
|---|
| 452 | onCallProgress2(cid,info->event,(char*)info->remoteUri,info->errorCode); |
|---|
| 453 | #endif |
|---|
| 454 | } |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | #if defined(_WIN32_WCE) |
|---|
| 458 | void phapi::onCallProgress2(int cid, phCallStateEvent status, wchar_t * uri, int error) |
|---|
| 459 | #else |
|---|
| 460 | void phapi::onCallProgress2(int cid, phCallStateEvent status, char * uri, int error) |
|---|
| 461 | #endif |
|---|
| 462 | { |
|---|
| 463 | |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | void phapi::onDtmfProgress(int cid, int) |
|---|
| 467 | { |
|---|
| 468 | |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | void phapi::onTransferProgress(int cid, const phTransferStateInfo_t *info) { } |
|---|
| 472 | void phapi::onConfProgress(int cfid, const phConfStateInfo_t *info) { } |
|---|
| 473 | void phapi::onRegProgress(int regid, int status) { } |
|---|
| 474 | void phapi::onMsgProgress(int mid, const phMsgStateInfo_t *info) |
|---|
| 475 | { |
|---|
| 476 | onMsgProgress2(mid, (char *)info->rawctt, (char *)info->content); |
|---|
| 477 | } |
|---|
| 478 | void phapi::onMsgProgress2(int mid, char * type, char * content) { } |
|---|
| 479 | void phapi::onConnectionLost(const char* host, int port) { } |
|---|
| 480 | #if defined(_WIN32_WCE) |
|---|
| 481 | void phapi::onNotifyProgress (const char* event, const char* from, const char *ctt, wchar_t* content) { } |
|---|
| 482 | #else |
|---|
| 483 | void phapi::onNotifyProgress (const char* event, const char* from, const char *ctt, const char* content) { } |
|---|
| 484 | #endif |
|---|
| 485 | void phapi::onSubscriptionProgress(int sid, const phSubscriptionStateInfo_t *info) { } |
|---|
| 486 | void phapi::onFrameReady(int cid, phVideoFrameReceivedEvent_t *ev) { } |
|---|
| 487 | void phapi::onPhLogCsl(const char *msg){ } |
|---|
| 488 | |
|---|
| 489 | void phapi::onSoundFileStopped(void *userdata , unsigned int _id, void *arg){} |
|---|
| 490 | |
|---|
| 491 | void phapi::onQosEvent(int cid, const phQosInfo_t * info){} |
|---|
| 492 | |
|---|
| 493 | void phapi::callProgress(int cid, const phCallStateInfo_t *info) |
|---|
| 494 | { |
|---|
| 495 | if (uniqueobj) |
|---|
| 496 | uniqueobj->onCallProgress(cid, info); |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | void phapi::transferProgress(int cid, const phTransferStateInfo_t *info) |
|---|
| 500 | { |
|---|
| 501 | if (uniqueobj) |
|---|
| 502 | uniqueobj->onTransferProgress(cid, info); |
|---|
| 503 | |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | |
|---|
| 507 | void phapi::confProgress(int cfid, const phConfStateInfo_t *info) |
|---|
| 508 | { |
|---|
| 509 | if (uniqueobj) |
|---|
| 510 | uniqueobj->onConfProgress(cfid, info); |
|---|
| 511 | |
|---|
| 512 | } |
|---|
| 513 | |
|---|
| 514 | void phapi::regProgress(int regid, int status) |
|---|
| 515 | { |
|---|
| 516 | if (uniqueobj) |
|---|
| 517 | uniqueobj->onRegProgress(regid, status); |
|---|
| 518 | |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | void phapi::msgProgress(int mid, const phMsgStateInfo_t *info) |
|---|
| 522 | { |
|---|
| 523 | if (uniqueobj) |
|---|
| 524 | uniqueobj->onMsgProgress(mid, info); |
|---|
| 525 | |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | void phapi::connectionLost(const char *host, int port) |
|---|
| 529 | { |
|---|
| 530 | if (uniqueobj) |
|---|
| 531 | uniqueobj->onConnectionLost(host, port); |
|---|
| 532 | } |
|---|
| 533 | |
|---|
| 534 | void phapi::notifyProgress (const char* event, const char* from, const char *ctt, const char* content) |
|---|
| 535 | { |
|---|
| 536 | #if defined(_WIN32_WCE) |
|---|
| 537 | int utfsize = MultiByteToWideChar(CP_ACP, 0, content, -1, NULL, 0); |
|---|
| 538 | wchar_t *tmp = (wchar_t *)alloca((utfsize + 1) * sizeof(*tmp)); |
|---|
| 539 | |
|---|
| 540 | MultiByteToWideChar(CP_ACP, 0, content, -1,tmp, utfsize); |
|---|
| 541 | |
|---|
| 542 | if (uniqueobj) |
|---|
| 543 | uniqueobj->onNotifyProgress(event, from, ctt, tmp); |
|---|
| 544 | #else |
|---|
| 545 | if (uniqueobj) |
|---|
| 546 | uniqueobj->onNotifyProgress(event, from, ctt, content); |
|---|
| 547 | #endif |
|---|
| 548 | |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | void phapi::subscriptionProgress(int sid, const phSubscriptionStateInfo_t *info) |
|---|
| 552 | { |
|---|
| 553 | if (uniqueobj) |
|---|
| 554 | uniqueobj->onSubscriptionProgress(sid, info); |
|---|
| 555 | |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | void phapi::frameReady(int cid, phVideoFrameReceivedEvent_t *ev) |
|---|
| 560 | { |
|---|
| 561 | if (uniqueobj) |
|---|
| 562 | uniqueobj->onFrameReady(cid, ev); |
|---|
| 563 | |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | void phapi::phLogCsl(const char *msg) |
|---|
| 567 | { |
|---|
| 568 | if (uniqueobj) |
|---|
| 569 | uniqueobj->onPhLogCsl(msg); |
|---|
| 570 | } |
|---|
| 571 | |
|---|
| 572 | void phapi::soundFileStopped(void *userdata , unsigned int _id, void *arg) |
|---|
| 573 | { |
|---|
| 574 | if (uniqueobj) |
|---|
| 575 | uniqueobj->onSoundFileStopped(userdata,_id,arg); |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | void phapi::qosEvent(int cid, const phQosInfo_t * info) |
|---|
| 579 | { |
|---|
| 580 | if (uniqueobj) |
|---|
| 581 | uniqueobj->onQosEvent(cid, info); |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | phCallbacks_t phapi::callbacks = { |
|---|
| 585 | phapi::callProgress, |
|---|
| 586 | phapi::transferProgress, |
|---|
| 587 | phapi::confProgress, |
|---|
| 588 | phapi::regProgress, |
|---|
| 589 | phapi::msgProgress, |
|---|
| 590 | phapi::connectionLost, |
|---|
| 591 | phapi::notifyProgress, |
|---|
| 592 | phapi::subscriptionProgress, |
|---|
| 593 | phapi::frameReady, |
|---|
| 594 | 0, |
|---|
| 595 | #ifdef HAVE_CSL |
|---|
| 596 | phapi::phLogCsl, |
|---|
| 597 | #endif /*!HAVE_CSL*/ |
|---|
| 598 | phapi::soundFileStopped, |
|---|
| 599 | phapi::qosEvent |
|---|
| 600 | }; |
|---|
| 601 | |
|---|
| 602 | |
|---|
| 603 | } |
|---|
| 604 | /* |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | #ifdef TEST |
|---|
| 608 | |
|---|
| 609 | using namespace verona; |
|---|
| 610 | |
|---|
| 611 | stdphapi* myphapi = new stdphapi; |
|---|
| 612 | |
|---|
| 613 | |
|---|
| 614 | void testAuth(const std::string& name, const std::string& id, const std::string& pw, const std::string& realm) |
|---|
| 615 | { |
|---|
| 616 | myphapi->addAuthInfo(name, id, pw, realm); |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | |
|---|
| 620 | int main(int argc, char *argv[]) |
|---|
| 621 | { |
|---|
| 622 | |
|---|
| 623 | } |
|---|
| 624 | |
|---|
| 625 | #endif |
|---|
| 626 | */ |
|---|