| 6 |
| // Copyright © 2020 Mikhail Filimonov. All rights reserved. |
| 7 | // |
| 8 | #ifndef TGCALLS_DESKTOP_CAPTURE_SOURCE_H__ |
| 9 | #define TGCALLS_DESKTOP_CAPTURE_SOURCE_H__ |
| 10 |
| 11 | #include <string> |
| 12 |
| 13 | #ifdef WEBRTC_WIN |
| 14 | // Compiler errors in conflicting Windows headers if not included here. |
| 15 | #include <winsock2.h> |
| 16 | #endif // WEBRTC_WIN |
| 17 |
| 18 | namespace tgcalls { |
| 19 |
| 20 | class VideoSource { |
| 21 | public: |
| 22 | virtual ~VideoSource() = default; |
| 23 |
| 24 | virtual std::string deviceIdKey() = 0; |
| 25 | virtual std::string title() = 0; |
| 26 | virtual std::string uniqueKey() = 0; |
| 27 | }; |
| 28 |
| 29 | struct DesktopSize { |
| 30 | int width = 0; |
| 31 | int height = 0; |
| 32 | }; |
| 33 |
| 34 | struct DesktopCaptureSourceData { |
| 35 | DesktopSize aspectSize; |
| 36 | double fps = 24.; |
| 37 | bool captureMouse = true; |
| 38 |
| 39 | std::string cachedKey() const; |
| 40 | }; |
| 41 |
| 42 | class DesktopCaptureSource : public VideoSource { |
| 43 | public: |
| 44 | DesktopCaptureSource( |
| 45 | long long uniqueId, |
| 46 | std::string title, |
| 47 | bool isWindow); |
| 48 |
| 49 | static DesktopCaptureSource Invalid() { |
| 50 | return InvalidTag{}; |
| 51 | } |
| 52 |
| 53 | long long uniqueId() const; |
| 54 | bool isWindow() const; |
| 55 |
| 56 | std::string deviceIdKey() const; |
| 57 | std::string title() const; |
| 58 | std::string uniqueKey() const; |
| 59 |
| 60 | bool valid() const { |
| 61 | return _valid; |
| 62 | } |
| 63 | explicit operator bool() const { |
| 64 | return _valid; |
| 65 | } |
| 66 |
| 67 | private: |
| 68 | struct InvalidTag {}; |
| 69 | DesktopCaptureSource(InvalidTag) : _valid(false) { |
| 70 | } |
| 71 |
| 72 | std::string deviceIdKey() override; |
| 73 | std::string title() override; |
| 74 | std::string uniqueKey() override; |
| 75 |
| 76 | long long _uniqueId = 0; |
| 77 | std::string _title; |
| 78 | bool _isWindow = false; |
| 79 | bool _valid = true; |
| 80 |
| 81 | }; |
| 82 |
| 83 | } // namespace tgcalls |
| 84 |
| 85 | #endif // TGCALLS_DESKTOP_CAPTURE_SOURCE_H__ |
| 86 |