| 6 |
| #define LIBTGVOIP_VIDEOSOURCE_H |
| 7 |
| 8 | #include "../Buffers.h" |
| 9 |
| 10 | #include <cstdint> |
| 11 | #include <functional> |
| 12 | #include <memory> |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 |
| 16 | namespace tgvoip |
| 17 | { |
| 18 |
| 19 | namespace video |
| 20 | { |
| 21 |
| 22 | class VideoSource |
| 23 | { |
| 24 | public: |
| 25 | using CallbackType = std::function<void(const Buffer& buffer, std::uint32_t flags, std::uint32_t m_rotation)>; |
| 26 |
| 27 | virtual ~VideoSource() = default; |
| 28 |
| 29 | static std::shared_ptr<VideoSource> Create(); |
| 30 | static std::vector<std::uint32_t> GetAvailableEncoders(); |
| 31 |
| 32 | void SetCallback(CallbackType callback); |
| 33 | void SetStreamStateCallback(std::function<void(bool)> callback); |
| 34 |
| 35 | virtual void Start() = 0; |
| 36 | virtual void Stop() = 0; |
| 37 | virtual void Reset(std::uint32_t codec, int maxResolution) = 0; |
| 38 | virtual void RequestKeyFrame() = 0; |
| 39 | virtual void SetBitrate(std::uint32_t bitrate) = 0; |
| 40 |
| 41 | [[nodiscard]] bool Failed() const; |
| 42 | [[nodiscard]] std::string GetErrorDescription() const; |
| 43 | std::vector<Buffer>& GetCodecSpecificData(); |
| 44 | [[nodiscard]] unsigned int GetFrameWidth() const; |
| 45 | [[nodiscard]] unsigned int GetFrameHeight() const; |
| 46 | void SetRotation(unsigned int rotation); |
| 47 |
| 48 | protected: |
| 49 | std::vector<Buffer> m_csd; |
| 50 | std::string m_error; |
| 51 |
| 52 | CallbackType m_callback; |
| 53 | std::function<void(bool)> m_streamStateCallback; |
| 54 |
| 55 | unsigned int m_width = 0; |
| 56 | unsigned int m_height = 0; |
| 57 | unsigned int m_rotation = 0; |
| 58 |
| 59 | bool m_failed = false; |
| 60 | }; |
| 61 |
| 62 | } // namespace video |
| 63 |
| 64 | } // namespace tgvoip |
| 65 |
| 66 | #endif // LIBTGVOIP_VIDEOSOURCE_H |
| 67 |