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 file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DEVICE_INFO_H_
6 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DEVICE_INFO_H_
7 
8 #include <map>
9 #include "modules/desktop_capture/desktop_capture_types.h"
10 
11 namespace webrtc {
12 
13 class DesktopDisplayDevice {
14 public:
15   DesktopDisplayDevice();
16   ~DesktopDisplayDevice();
17 
18   void setScreenId(const ScreenId screenId);
19   void setDeviceName(const char *deviceNameUTF8);
20   void setUniqueIdName(const char *deviceUniqueIdUTF8);
21   void setPid(pid_t pid);
22 
23   ScreenId getScreenId();
24   const char *getDeviceName();
25   const char *getUniqueIdName();
26   pid_t getPid();
27 
28   DesktopDisplayDevice& operator= (DesktopDisplayDevice& other);
29 
30 protected:
31   ScreenId screenId_;
32   char* deviceNameUTF8_;
33   char* deviceUniqueIdUTF8_;
34   pid_t pid_;
35 };
36 
37 typedef std::map<intptr_t,DesktopDisplayDevice*> DesktopDisplayDeviceList;
38 
39 class DesktopTab {
40 public:
41   DesktopTab();
42   ~DesktopTab();
43 
44   void setTabBrowserId(uint64_t tabBrowserId);
45   void setUniqueIdName(const char *tabUniqueIdUTF8);
46   void setTabName(const char *tabNameUTF8);
47   void setTabCount(const uint32_t count);
48 
49   uint64_t getTabBrowserId();
50   const char *getUniqueIdName();
51   const char *getTabName();
52   uint32_t getTabCount();
53 
54   DesktopTab& operator= (DesktopTab& other);
55 
56 protected:
57   uint64_t tabBrowserId_;
58   char* tabNameUTF8_;
59   char* tabUniqueIdUTF8_;
60   uint32_t tabCount_;
61 };
62 
63 typedef std::map<intptr_t, DesktopTab*> DesktopTabList;
64 
65 class DesktopDeviceInfo {
66 public:
~DesktopDeviceInfo()67   virtual ~DesktopDeviceInfo() {};
68 
69   virtual int32_t Init() = 0;
70   virtual int32_t Refresh() = 0;
71   virtual int32_t getDisplayDeviceCount() = 0;
72   virtual int32_t getDesktopDisplayDeviceInfo(int32_t nIndex,
73                                               DesktopDisplayDevice & desktopDisplayDevice) = 0;
74   virtual int32_t getWindowCount() = 0;
75   virtual int32_t getWindowInfo(int32_t nindex,
76                                 DesktopDisplayDevice &windowDevice) = 0;
77   virtual int32_t getTabCount() = 0;
78   virtual int32_t getTabInfo(int32_t nIndex,
79                              DesktopTab & desktopTab) = 0;
80 };
81 
82 class DesktopDeviceInfoImpl : public DesktopDeviceInfo {
83 public:
84   DesktopDeviceInfoImpl();
85   ~DesktopDeviceInfoImpl();
86 
87   int32_t Init() override;
88   int32_t Refresh() override;
89   int32_t getDisplayDeviceCount() override;
90   int32_t getDesktopDisplayDeviceInfo(int32_t nIndex,
91                                               DesktopDisplayDevice & desktopDisplayDevice) override;
92   int32_t getWindowCount() override;
93   int32_t getWindowInfo(int32_t nindex,
94                                 DesktopDisplayDevice &windowDevice) override;
95   int32_t getTabCount() override;
96   int32_t getTabInfo(int32_t nIndex,
97                              DesktopTab & desktopTab) override;
98   static DesktopDeviceInfo * Create();
99 protected:
100   DesktopDisplayDeviceList desktop_display_list_;
101   DesktopDisplayDeviceList desktop_window_list_;
102   DesktopTabList desktop_tab_list_;
103 
104   void CleanUp();
105   void CleanUpWindowList();
106   void CleanUpTabList();
107   void CleanUpScreenList();
108 
109   void InitializeWindowList();
110   virtual void InitializeTabList();
111   virtual void InitializeScreenList() = 0;
112 
113   void RefreshWindowList();
114   void RefreshTabList();
115   void RefreshScreenList();
116 
117   void DummyTabList(DesktopTabList &list);
118 };
119 };
120 
121 #endif
122