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

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial