|
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 "CC_Common.h" |
|
8 #include "CC_Observer.h" |
|
9 |
|
10 #include <vector> |
|
11 |
|
12 extern "C" |
|
13 { |
|
14 #include "ccapi_types.h" |
|
15 #include "ccapi_service.h" |
|
16 } |
|
17 |
|
18 namespace CSF |
|
19 { |
|
20 class ECC_API CC_Service |
|
21 { |
|
22 public: |
|
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CC_Service) |
|
24 protected: |
|
25 CC_Service() {} |
|
26 public: |
|
27 virtual ~CC_Service() {}; |
|
28 |
|
29 public: |
|
30 /** |
|
31 * Clients use CC_Observer to receive CCAPI events (Device, Line, Call) from the service. |
|
32 */ |
|
33 virtual void addCCObserver ( CC_Observer * observer ) = 0; |
|
34 virtual void removeCCObserver ( CC_Observer * observer ) = 0; |
|
35 |
|
36 /** |
|
37 * Use init() immediately on creating the service, and destroy() when finished with it. |
|
38 * password is required for Asterisk not CUCM. |
|
39 * deviceName is required for CUCM not Asterisk. |
|
40 */ |
|
41 virtual bool init(const std::string& user, const std::string& password, const std::string& domain, const std::string& deviceName) = 0; |
|
42 virtual void destroy() = 0; |
|
43 |
|
44 /** |
|
45 * TODO: Set config parameters prior to starting the service. |
|
46 * Need to design a nice abstraction for this accommodating SIPCC and CTI. |
|
47 */ |
|
48 |
|
49 /** |
|
50 * Use start() to attempt to register for a device and stop() to cancel a current |
|
51 * registration (or registration attempt). |
|
52 */ |
|
53 virtual bool startService() = 0; |
|
54 virtual void stop() = 0; |
|
55 |
|
56 |
|
57 /** |
|
58 * Check on the current status/health of the service. |
|
59 */ |
|
60 virtual bool isStarted() = 0; |
|
61 |
|
62 /** |
|
63 * Obtain the currently selected Device. |
|
64 * If multiple devices are discoverable (i.e. in CTI), all known devices will appear |
|
65 * in getDevices(), but only the ActiveDevice will be controllable at any given time. |
|
66 */ |
|
67 virtual CC_DevicePtr getActiveDevice() = 0; |
|
68 virtual std::vector<CC_DevicePtr> getDevices() = 0; |
|
69 |
|
70 /** |
|
71 * Global settings for audio and video control. Return nullptr if Media control is not |
|
72 * available in this implementation. Return nullptr in any case if media is not yet |
|
73 * initialized. |
|
74 * TODO: Assuming for now that media init aligns with init/destroy. |
|
75 */ |
|
76 virtual AudioControlPtr getAudioControl() = 0; |
|
77 virtual VideoControlPtr getVideoControl() = 0; |
|
78 |
|
79 virtual bool setLocalVoipPort(int port) = 0; |
|
80 virtual bool setRemoteVoipPort(int port) = 0; |
|
81 virtual bool setP2PMode(bool mode) = 0; |
|
82 virtual bool setSDPMode(bool mode) = 0; |
|
83 |
|
84 private: |
|
85 CC_Service(const CC_Service& rhs); |
|
86 CC_Service& operator=(const CC_Service& rhs); |
|
87 }; |
|
88 } |