| 6 |
| // Copyright © 2020 Mikhail Filimonov. All rights reserved. |
| 7 | // |
| 8 |
| 9 | #include "tgcalls/desktop_capturer/DesktopCaptureSource.h" |
| 10 |
| 11 | namespace tgcalls { |
| 12 |
| 13 | std::string DesktopCaptureSourceData::cachedKey() const { |
| 14 | return std::to_string(aspectSize.width) |
| 15 | + 'x' |
| 16 | + std::to_string(aspectSize.height) |
| 17 | + ':' |
| 18 | + std::to_string(fps) |
| 19 | + ':' |
| 20 | + (captureMouse ? '1' : '0'); |
| 21 | } |
| 22 |
| 23 | DesktopCaptureSource::DesktopCaptureSource( |
| 24 | long long uniqueId, |
| 25 | std::string title, |
| 26 | bool isWindow) |
| 27 | : _uniqueId(uniqueId) |
| 28 | , _title(std::move(title)) |
| 29 | , _isWindow(isWindow) { |
| 30 | } |
| 31 |
| 32 | long long DesktopCaptureSource::uniqueId() const { |
| 33 | return _uniqueId; |
| 34 | } |
| 35 |
| 36 | bool DesktopCaptureSource::isWindow() const { |
| 37 | return _isWindow; |
| 38 | } |
| 39 |
| 40 | std::string DesktopCaptureSource::deviceIdKey() const { |
| 41 | return std::string("desktop_capturer_") |
| 42 | + (_isWindow ? "window_" : "screen_") |
| 43 | + std::to_string(uniqueId()); |
| 44 | } |
| 45 |
| 46 | std::string DesktopCaptureSource::title() const { |
| 47 | return _isWindow ? _title : "Screen"; |
| 48 | } |
| 49 |
| 50 | std::string DesktopCaptureSource::uniqueKey() const { |
| 51 | return std::to_string(_uniqueId) |
| 52 | + ':' |
| 53 | + (_isWindow ? "Window" : "Screen"); |
| 54 | } |
| 55 |
| 56 | std::string DesktopCaptureSource::deviceIdKey() { |
| 57 | return static_cast<const DesktopCaptureSource*>(this)->deviceIdKey(); |
| 58 | } |
| 59 |
| 60 | std::string DesktopCaptureSource::title() { |
| 61 | return static_cast<const DesktopCaptureSource*>(this)->title(); |
| 62 | } |
| 63 |
| 64 | std::string DesktopCaptureSource::uniqueKey() { |
| 65 | return static_cast<const DesktopCaptureSource*>(this)->uniqueKey(); |
| 66 | } |
| 67 |
| 68 | } // namespace tgcalls |
| 69 |