michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "CSFLog.h" michael@0: michael@0: #include "CC_Common.h" michael@0: michael@0: #include "CC_SIPCCDevice.h" michael@0: #include "CC_SIPCCDeviceInfo.h" michael@0: #include "CC_SIPCCFeatureInfo.h" michael@0: #include "CC_SIPCCCall.h" michael@0: michael@0: extern "C" michael@0: { michael@0: #include "cpr_types.h" michael@0: #include "config_api.h" michael@0: #include "ccapi_device.h" michael@0: #include "ccapi_device_info.h" michael@0: #include "ccapi_device_listener.h" michael@0: } michael@0: michael@0: using namespace std; michael@0: using namespace CSF; michael@0: michael@0: CSF_IMPLEMENT_WRAP(CC_SIPCCDevice, cc_device_handle_t); michael@0: michael@0: CC_DevicePtr CC_SIPCCDevice::createDevice () michael@0: { michael@0: cc_device_handle_t deviceHandle = CCAPI_Device_getDeviceID(); michael@0: michael@0: CC_SIPCCDevicePtr pSIPCCDevice = CC_SIPCCDevice::wrap(deviceHandle); michael@0: michael@0: return pSIPCCDevice.get(); michael@0: } michael@0: michael@0: CC_SIPCCDevice::CC_SIPCCDevice (cc_device_handle_t aDeviceHandle) michael@0: : deviceHandle(aDeviceHandle) michael@0: { michael@0: enableVideo(true); michael@0: enableCamera(true); michael@0: } michael@0: michael@0: CC_DeviceInfoPtr CC_SIPCCDevice::getDeviceInfo () michael@0: { michael@0: cc_deviceinfo_ref_t deviceInfoRef = CCAPI_Device_getDeviceInfo(deviceHandle); michael@0: CC_DeviceInfoPtr deviceInfoPtr = michael@0: CC_SIPCCDeviceInfo::wrap(deviceInfoRef).get(); michael@0: michael@0: //A call to CCAPI_Device_getDeviceInfo() needs a matching call to CCAPI_Device_releaseDeviceInfo() michael@0: //However, the CC_SIPCCDeviceInfo() ctor/dtor does a retain/release internally, so I need to explicitly release michael@0: //here to match up with the call to CCAPI_Device_getDeviceInfo(). michael@0: michael@0: CCAPI_Device_releaseDeviceInfo(deviceInfoRef); michael@0: michael@0: //CCAPI_Device_getDeviceInfo() --> requires release be called. michael@0: //CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo() -> Call retain (wrapped in smart_ptr) michael@0: //CCAPI_Device_releaseDeviceInfo() --> this maps to the call to CCAPI_Device_getDeviceInfo() michael@0: //CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() --> CCAPI_Device_releaseDeviceInfo() (when smart pointer destroyed) michael@0: michael@0: return deviceInfoPtr; michael@0: } michael@0: michael@0: std::string CC_SIPCCDevice::toString() michael@0: { michael@0: std::string result; michael@0: char tmpString[11]; michael@0: csf_sprintf(tmpString, sizeof(tmpString), "%X", deviceHandle); michael@0: result = tmpString; michael@0: return result; michael@0: } michael@0: michael@0: CC_CallPtr CC_SIPCCDevice::createCall () michael@0: { michael@0: cc_call_handle_t callHandle = CCAPI_Device_CreateCall(deviceHandle); michael@0: michael@0: return CC_SIPCCCall::wrap(callHandle).get(); michael@0: } michael@0: michael@0: void CC_SIPCCDevice::enableVideo(bool enable) michael@0: { michael@0: CCAPI_Device_enableVideo(deviceHandle, enable); michael@0: } michael@0: michael@0: void CC_SIPCCDevice::enableCamera(bool enable) michael@0: { michael@0: CCAPI_Device_enableCamera(deviceHandle, enable); michael@0: } michael@0: michael@0: void CC_SIPCCDevice::setDigestNamePasswd (char *name, char *pw) michael@0: { michael@0: CCAPI_Device_setDigestNamePasswd(deviceHandle, name, pw); michael@0: }