media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.h

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 #ifndef _CC_SIPCC_SERVICE_H
michael@0 6 #define _CC_SIPCC_SERVICE_H
michael@0 7
michael@0 8 #include "CC_Service.h"
michael@0 9
michael@0 10 extern "C" {
michael@0 11 // Callbacks from SIPCC.
michael@0 12 void configCtlFetchReq(int device_handle);
michael@0 13 char* platGetIPAddr();
michael@0 14
michael@0 15 void CCAPI_DeviceListener_onDeviceEvent(ccapi_device_event_e type, cc_device_handle_t hDevice, cc_deviceinfo_ref_t dev_info);
michael@0 16 void CCAPI_DeviceListener_onFeatureEvent(ccapi_device_event_e type, cc_deviceinfo_ref_t /* device_info */, cc_featureinfo_ref_t feature_info);
michael@0 17 void CCAPI_LineListener_onLineEvent(ccapi_line_event_e eventType, cc_lineid_t line, cc_lineinfo_ref_t info);
michael@0 18 void CCAPI_CallListener_onCallEvent(ccapi_call_event_e eventType, cc_call_handle_t handle, cc_callinfo_ref_t info);
michael@0 19 }
michael@0 20
michael@0 21 #include "VcmSIPCCBinding.h"
michael@0 22 #include "CSFAudioControlWrapper.h"
michael@0 23 #include "CSFVideoControlWrapper.h"
michael@0 24 #include "CSFMediaProvider.h"
michael@0 25
michael@0 26 #include "base/lock.h"
michael@0 27 #include "base/waitable_event.h"
michael@0 28
michael@0 29 #include <vector>
michael@0 30 #include <set>
michael@0 31 #include "mozilla/Mutex.h"
michael@0 32
michael@0 33 namespace CSF
michael@0 34 {
michael@0 35 class PhoneConfig;
michael@0 36 DECLARE_NS_PTR(CC_SIPCCService);
michael@0 37
michael@0 38 class CC_SIPCCService : public CC_Service, public StreamObserver, public MediaProviderObserver
michael@0 39 {
michael@0 40 friend void ::configCtlFetchReq(int device_handle);
michael@0 41 friend char* ::platGetIPAddr();
michael@0 42
michael@0 43 public:
michael@0 44 CC_SIPCCService();
michael@0 45 virtual ~CC_SIPCCService();
michael@0 46
michael@0 47 /**
michael@0 48 * Public API
michael@0 49 */
michael@0 50 virtual void addCCObserver ( CC_Observer * observer );
michael@0 51 virtual void removeCCObserver ( CC_Observer * observer );
michael@0 52
michael@0 53 virtual bool init(const std::string& user, const std::string& password, const std::string& domain, const std::string& deviceName);
michael@0 54 virtual void destroy();
michael@0 55
michael@0 56 virtual void setDeviceName(const std::string& deviceName);
michael@0 57 virtual void setLoggingMask(int mask);
michael@0 58 virtual void setLocalAddressAndGateway(const std::string& localAddress, const std::string& defaultGW);
michael@0 59
michael@0 60 virtual bool startService();
michael@0 61 virtual void stop();
michael@0 62
michael@0 63 virtual bool isStarted();
michael@0 64
michael@0 65 virtual CC_DevicePtr getActiveDevice();
michael@0 66 virtual std::vector<CC_DevicePtr> getDevices();
michael@0 67
michael@0 68 virtual AudioControlPtr getAudioControl();
michael@0 69 virtual VideoControlPtr getVideoControl();
michael@0 70
michael@0 71 // From the StreamObserver interface
michael@0 72 virtual void registerStream(cc_call_handle_t call, int streamId, bool isVideo);
michael@0 73 virtual void deregisterStream(cc_call_handle_t call, int streamId);
michael@0 74 virtual void dtmfBurst(int digit, int direction, int duration);
michael@0 75 virtual void sendIFrame(cc_call_handle_t call);
michael@0 76
michael@0 77 virtual void onVideoModeChanged( bool enable );
michael@0 78 virtual void onKeyFrameRequested( int stream );
michael@0 79 virtual void onMediaLost( int callId );
michael@0 80 virtual void onMediaRestored( int callId );
michael@0 81
michael@0 82 virtual bool setLocalVoipPort(int port);
michael@0 83 virtual bool setRemoteVoipPort(int port);
michael@0 84 virtual bool setP2PMode(bool mode);
michael@0 85 virtual bool setSDPMode(bool mode);
michael@0 86
michael@0 87 /**
michael@0 88 * End of public API
michael@0 89 */
michael@0 90
michael@0 91 public:
michael@0 92 // These are used by the C callback functions to raise events.
michael@0 93 // This layer:
michael@0 94 // - converts the C handles to C++ objects
michael@0 95 // - invokes the member notify* functions to propagate events upwards
michael@0 96 // - invokes any other functions needed to perform "value added" event handling in ECC.
michael@0 97 static void onDeviceEvent(ccapi_device_event_e type, cc_device_handle_t hDevice, cc_deviceinfo_ref_t dev_info);
michael@0 98 static void onFeatureEvent(ccapi_device_event_e type, cc_deviceinfo_ref_t /* device_info */, cc_featureinfo_ref_t feature_info);
michael@0 99 static void onLineEvent(ccapi_line_event_e eventType, cc_lineid_t line, cc_lineinfo_ref_t info);
michael@0 100 static void onCallEvent(ccapi_call_event_e eventType, cc_call_handle_t handle, cc_callinfo_ref_t info);
michael@0 101
michael@0 102 private: // Helper functions
michael@0 103
michael@0 104 //These notify functions call through to CallControlManager
michael@0 105 void notifyDeviceEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info);
michael@0 106 void notifyFeatureEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info);
michael@0 107 void notifyCallEventObservers (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info);
michael@0 108 void notifyLineEventObservers (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info);
michael@0 109
michael@0 110 void endAllActiveCalls();
michael@0 111
michael@0 112 void applyLoggingMask(int newMask);
michael@0 113 void applyAudioVideoConfigSettings (PhoneConfig & phoneConfig);
michael@0 114
michael@0 115 bool isValidMediaPortRange(int mediaStartPort, int mediaEndPort);
michael@0 116 bool isValidDSCPValue(int value);
michael@0 117
michael@0 118 private: // Data Store
michael@0 119 // Singleton
michael@0 120 static CC_SIPCCService* _self;
michael@0 121
michael@0 122 std::string deviceName;
michael@0 123 cc_int32_t loggingMask;
michael@0 124
michael@0 125 //IP Address Info
michael@0 126 std::string localAddress;
michael@0 127 std::string defaultGW;
michael@0 128
michael@0 129 // SIPCC lifecycle
michael@0 130 bool bCreated;
michael@0 131 bool bStarted;
michael@0 132 mozilla::Mutex m_lock;
michael@0 133
michael@0 134 // Media Lifecycle
michael@0 135 VcmSIPCCBinding vcmMediaBridge;
michael@0 136
michael@0 137 // Observers
michael@0 138 std::set<CC_Observer *> ccObservers;
michael@0 139
michael@0 140 //AV Control Wrappers
michael@0 141 AudioControlWrapperPtr audioControlWrapper;
michael@0 142 VideoControlWrapperPtr videoControlWrapper;
michael@0 143
michael@0 144 // Santization work
michael@0 145 bool bUseConfig;
michael@0 146 std::string sipUser;
michael@0 147 std::string sipPassword;
michael@0 148 std::string sipDomain;
michael@0 149 };
michael@0 150 }
michael@0 151
michael@0 152 #endif

mercurial