media/webrtc/signaling/src/softphonewrapper/CC_SIPCCDevice.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCDevice.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "CSFLog.h"
     1.9 +
    1.10 +#include "CC_Common.h"
    1.11 +
    1.12 +#include "CC_SIPCCDevice.h"
    1.13 +#include "CC_SIPCCDeviceInfo.h"
    1.14 +#include "CC_SIPCCFeatureInfo.h"
    1.15 +#include "CC_SIPCCCall.h"
    1.16 +
    1.17 +extern "C"
    1.18 +{
    1.19 +#include "cpr_types.h"
    1.20 +#include "config_api.h"
    1.21 +#include "ccapi_device.h"
    1.22 +#include "ccapi_device_info.h"
    1.23 +#include "ccapi_device_listener.h"
    1.24 +}
    1.25 +
    1.26 +using namespace std;
    1.27 +using namespace CSF;
    1.28 +
    1.29 +CSF_IMPLEMENT_WRAP(CC_SIPCCDevice, cc_device_handle_t);
    1.30 +
    1.31 +CC_DevicePtr CC_SIPCCDevice::createDevice ()
    1.32 +{
    1.33 +    cc_device_handle_t deviceHandle = CCAPI_Device_getDeviceID();
    1.34 +
    1.35 +    CC_SIPCCDevicePtr pSIPCCDevice = CC_SIPCCDevice::wrap(deviceHandle);
    1.36 +
    1.37 +    return pSIPCCDevice.get();
    1.38 +}
    1.39 +
    1.40 +CC_SIPCCDevice::CC_SIPCCDevice (cc_device_handle_t aDeviceHandle)
    1.41 +: deviceHandle(aDeviceHandle)
    1.42 +{
    1.43 +	enableVideo(true);
    1.44 +	enableCamera(true);
    1.45 +}
    1.46 +
    1.47 +CC_DeviceInfoPtr CC_SIPCCDevice::getDeviceInfo ()
    1.48 +{
    1.49 +    cc_deviceinfo_ref_t deviceInfoRef = CCAPI_Device_getDeviceInfo(deviceHandle);
    1.50 +    CC_DeviceInfoPtr deviceInfoPtr =
    1.51 +        CC_SIPCCDeviceInfo::wrap(deviceInfoRef).get();
    1.52 +
    1.53 +    //A call to CCAPI_Device_getDeviceInfo() needs a matching call to CCAPI_Device_releaseDeviceInfo()
    1.54 +    //However, the CC_SIPCCDeviceInfo() ctor/dtor does a retain/release internally, so I need to explicitly release
    1.55 +    //here to match up with the call to CCAPI_Device_getDeviceInfo().
    1.56 +
    1.57 +    CCAPI_Device_releaseDeviceInfo(deviceInfoRef);
    1.58 +
    1.59 +    //CCAPI_Device_getDeviceInfo() --> requires release be called.
    1.60 +    //CC_SIPCCDeviceInfo::CC_SIPCCDeviceInfo() -> Call retain (wrapped in smart_ptr)
    1.61 +    //CCAPI_Device_releaseDeviceInfo() --> this maps to the call to CCAPI_Device_getDeviceInfo()
    1.62 +    //CC_SIPCCDeviceInfo::~CC_SIPCCDeviceInfo() --> CCAPI_Device_releaseDeviceInfo() (when smart pointer destroyed)
    1.63 +
    1.64 +    return deviceInfoPtr;
    1.65 +}
    1.66 +
    1.67 +std::string CC_SIPCCDevice::toString()
    1.68 +{
    1.69 +    std::string result;
    1.70 +    char tmpString[11];
    1.71 +    csf_sprintf(tmpString, sizeof(tmpString), "%X", deviceHandle);
    1.72 +    result = tmpString;
    1.73 +    return result;
    1.74 +}
    1.75 +
    1.76 +CC_CallPtr CC_SIPCCDevice::createCall ()
    1.77 +{
    1.78 +    cc_call_handle_t callHandle = CCAPI_Device_CreateCall(deviceHandle);
    1.79 +
    1.80 +    return CC_SIPCCCall::wrap(callHandle).get();
    1.81 +}
    1.82 +
    1.83 +void CC_SIPCCDevice::enableVideo(bool enable)
    1.84 +{
    1.85 +    CCAPI_Device_enableVideo(deviceHandle, enable);
    1.86 +}
    1.87 +
    1.88 +void CC_SIPCCDevice::enableCamera(bool enable)
    1.89 +{
    1.90 +    CCAPI_Device_enableCamera(deviceHandle, enable);
    1.91 +}
    1.92 +
    1.93 +void CC_SIPCCDevice::setDigestNamePasswd (char *name, char *pw)
    1.94 +{
    1.95 +    CCAPI_Device_setDigestNamePasswd(deviceHandle, name, pw);
    1.96 +}

mercurial