|
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 #pragma once |
|
6 |
|
7 #include "CallControlManager.h" |
|
8 #include "PhoneDetailsImpl.h" |
|
9 #include "CC_SIPCCService.h" |
|
10 #include "mozilla/Mutex.h" |
|
11 |
|
12 |
|
13 #include <set> |
|
14 #include <map> |
|
15 |
|
16 namespace CSF |
|
17 { |
|
18 class CallControlManagerImpl: public CallControlManager, public CC_Observer |
|
19 { |
|
20 public: |
|
21 CallControlManagerImpl(); |
|
22 virtual bool destroy(); |
|
23 virtual ~CallControlManagerImpl(); |
|
24 |
|
25 // Observers |
|
26 virtual void addCCObserver ( CC_Observer * observer ); |
|
27 virtual void removeCCObserver ( CC_Observer * observer ); |
|
28 |
|
29 virtual void addECCObserver ( ECC_Observer * observer ); |
|
30 virtual void removeECCObserver ( ECC_Observer * observer ); |
|
31 |
|
32 // Config and global setup |
|
33 virtual void setMultiClusterMode(bool allowMultipleClusters); |
|
34 virtual void setSIPCCLoggingMask(const cc_int32_t mask); |
|
35 virtual void setAuthenticationString(const std::string &authString); |
|
36 virtual void setSecureCachePath(const std::string &secureCachePath); |
|
37 |
|
38 // Add local codecs |
|
39 virtual void setAudioCodecs(int codecMask); |
|
40 virtual void setVideoCodecs(int codecMask); |
|
41 |
|
42 virtual AuthenticationStatusEnum::AuthenticationStatus getAuthenticationStatus(); |
|
43 |
|
44 virtual bool registerUser( const std::string& deviceName, const std::string& user, const std::string& password, const std::string& domain ); |
|
45 |
|
46 virtual bool startP2PMode(const std::string& user); |
|
47 |
|
48 virtual bool startSDPMode(); |
|
49 |
|
50 virtual bool disconnect(); |
|
51 virtual std::string getPreferredDeviceName(); |
|
52 virtual std::string getPreferredLineDN(); |
|
53 virtual ConnectionStatusEnum::ConnectionStatus getConnectionStatus(); |
|
54 virtual std::string getCurrentServer(); |
|
55 |
|
56 // Currently controlled device |
|
57 virtual CC_DevicePtr getActiveDevice(); |
|
58 |
|
59 // All known devices |
|
60 virtual PhoneDetailsVtrPtr getAvailablePhoneDetails(); |
|
61 virtual PhoneDetailsPtr getAvailablePhoneDetails(const std::string& deviceName); |
|
62 |
|
63 // Media setup |
|
64 virtual VideoControlPtr getVideoControl(); |
|
65 virtual AudioControlPtr getAudioControl(); |
|
66 |
|
67 virtual bool setProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key, std::string& value); |
|
68 virtual std::string getProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key); |
|
69 |
|
70 private: // Data Storage |
|
71 |
|
72 // Observers |
|
73 mozilla::Mutex m_lock; |
|
74 std::set<CC_Observer *> ccObservers; |
|
75 std::set<ECC_Observer *> eccObservers; |
|
76 |
|
77 // Config and global setup |
|
78 std::string username; |
|
79 std::string password; |
|
80 std::string authString; |
|
81 std::string secureCachePath; |
|
82 bool multiClusterMode; |
|
83 cc_int32_t sipccLoggingMask; |
|
84 |
|
85 AuthenticationStatusEnum::AuthenticationStatus authenticationStatus; |
|
86 |
|
87 std::string preferredDevice; |
|
88 std::string preferredLineDN; |
|
89 CC_ServicePtr phone; // The generic handle, for simple operations. |
|
90 CC_SIPCCServicePtr softPhone; // For setup operations not available on the generic API. |
|
91 |
|
92 // All known devices |
|
93 typedef std::map<std::string, PhoneDetailsImplPtr> PhoneDetailsMap; |
|
94 PhoneDetailsMap phoneDetailsMap; |
|
95 |
|
96 // store connection state |
|
97 ConnectionStatusEnum::ConnectionStatus connectionState; |
|
98 |
|
99 public: // Listeners for stacks controlled by CallControlManager |
|
100 // CC_Observers |
|
101 void onDeviceEvent (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info); |
|
102 void onFeatureEvent (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info); |
|
103 void onLineEvent (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info); |
|
104 void onCallEvent (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info); |
|
105 |
|
106 private: //member functions |
|
107 |
|
108 // CC_Observers |
|
109 void notifyDeviceEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info); |
|
110 void notifyFeatureEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info); |
|
111 void notifyLineEventObservers (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info); |
|
112 void notifyCallEventObservers (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info); |
|
113 |
|
114 // ECC_Observers |
|
115 void notifyAvailablePhoneEvent (AvailablePhoneEventType::AvailablePhoneEvent event, |
|
116 const PhoneDetailsPtr phoneDetails); |
|
117 void notifyAuthenticationStatusChange (AuthenticationStatusEnum::AuthenticationStatus); |
|
118 void notifyConnectionStatusChange(ConnectionStatusEnum::ConnectionStatus status); |
|
119 void setConnectionState(ConnectionStatusEnum::ConnectionStatus status); |
|
120 }; |
|
121 |
|
122 } |