|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "CSFLog.h" |
|
6 |
|
7 #include "CC_Common.h" |
|
8 |
|
9 #include "CC_SIPCCDevice.h" |
|
10 #include "CC_SIPCCDeviceInfo.h" |
|
11 #include "CC_SIPCCFeatureInfo.h" |
|
12 #include "CC_SIPCCCall.h" |
|
13 |
|
14 extern "C" |
|
15 { |
|
16 #include "cpr_types.h" |
|
17 #include "config_api.h" |
|
18 #include "ccapi_device.h" |
|
19 #include "ccapi_device_info.h" |
|
20 #include "ccapi_device_listener.h" |
|
21 } |
|
22 |
|
23 using namespace std; |
|
24 using namespace CSF; |
|
25 |
|
26 CSF_IMPLEMENT_WRAP(CC_SIPCCDevice, cc_device_handle_t); |
|
27 |
|
28 CC_DevicePtr CC_SIPCCDevice::createDevice () |
|
29 { |
|
30 cc_device_handle_t deviceHandle = CCAPI_Device_getDeviceID(); |
|
31 |
|
32 CC_SIPCCDevicePtr pSIPCCDevice = CC_SIPCCDevice::wrap(deviceHandle); |
|
33 |
|
34 return pSIPCCDevice.get(); |
|
35 } |
|
36 |
|
37 CC_SIPCCDevice::CC_SIPCCDevice (cc_device_handle_t aDeviceHandle) |
|
38 : deviceHandle(aDeviceHandle) |
|
39 { |
|
40 enableVideo(true); |
|
41 enableCamera(true); |
|
42 } |
|
43 |
|
44 CC_DeviceInfoPtr CC_SIPCCDevice::getDeviceInfo () |
|
45 { |
|
46 cc_deviceinfo_ref_t deviceInfoRef = CCAPI_Device_getDeviceInfo(deviceHandle); |
|
47 CC_DeviceInfoPtr deviceInfoPtr = |
|
48 CC_SIPCCDeviceInfo::wrap(deviceInfoRef).get(); |
|
49 |
|
50 //A call to CCAPI_Device_getDeviceInfo() needs a matching call to CCAPI_Device_releaseDeviceInfo() |
|
51 //However, the CC_SIPCCDeviceInfo() ctor/dtor does a retain/release internally, so I need to explicitly release |
|
52 //here to match up with the call to CCAPI_Device_getDeviceInfo(). |
|
53 |
|
54 CCAPI_Device_releaseDeviceInfo(deviceInfoRef); |
|
55 |
|
56 //CCAPI_Device_getDeviceInfo() --> requires release be called. |
|
57 //CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo() -> Call retain (wrapped in smart_ptr) |
|
58 //CCAPI_Device_releaseDeviceInfo() --> this maps to the call to CCAPI_Device_getDeviceInfo() |
|
59 //CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() --> CCAPI_Device_releaseDeviceInfo() (when smart pointer destroyed) |
|
60 |
|
61 return deviceInfoPtr; |
|
62 } |
|
63 |
|
64 std::string CC_SIPCCDevice::toString() |
|
65 { |
|
66 std::string result; |
|
67 char tmpString[11]; |
|
68 csf_sprintf(tmpString, sizeof(tmpString), "%X", deviceHandle); |
|
69 result = tmpString; |
|
70 return result; |
|
71 } |
|
72 |
|
73 CC_CallPtr CC_SIPCCDevice::createCall () |
|
74 { |
|
75 cc_call_handle_t callHandle = CCAPI_Device_CreateCall(deviceHandle); |
|
76 |
|
77 return CC_SIPCCCall::wrap(callHandle).get(); |
|
78 } |
|
79 |
|
80 void CC_SIPCCDevice::enableVideo(bool enable) |
|
81 { |
|
82 CCAPI_Device_enableVideo(deviceHandle, enable); |
|
83 } |
|
84 |
|
85 void CC_SIPCCDevice::enableCamera(bool enable) |
|
86 { |
|
87 CCAPI_Device_enableCamera(deviceHandle, enable); |
|
88 } |
|
89 |
|
90 void CC_SIPCCDevice::setDigestNamePasswd (char *name, char *pw) |
|
91 { |
|
92 CCAPI_Device_setDigestNamePasswd(deviceHandle, name, pw); |
|
93 } |