| 6 |
| #define LIBTGVOIP_VIDEORENDERERANDROID_H |
| 7 |
| 8 | #include "../../MessageThread.h" |
| 9 | #include "../../video/VideoRenderer.h" |
| 10 |
| 11 | #include "../../BlockingQueue.h" |
| 12 | #include <jni.h> |
| 13 |
| 14 | namespace tgvoip |
| 15 | { |
| 16 | namespace video |
| 17 | { |
| 18 | class VideoRendererAndroid : public VideoRenderer |
| 19 | { |
| 20 | public: |
| 21 | VideoRendererAndroid(jobject jobj); |
| 22 | ~VideoRendererAndroid() override; |
| 23 | void Reset(std::uint32_t codec, unsigned int width, unsigned int height, std::vector<Buffer>& csd) override; |
| 24 | void DecodeAndDisplay(Buffer frame, std::uint32_t pts) override; |
| 25 | void SetStreamEnabled(bool enabled) override; |
| 26 | void SetRotation(std::uint16_t rotation) override; |
| 27 | void SetStreamPaused(bool paused) override; |
| 28 |
| 29 | static jmethodID resetMethod; |
| 30 | static jmethodID decodeAndDisplayMethod; |
| 31 | static jmethodID setStreamEnabledMethod; |
| 32 | static jmethodID setRotationMethod; |
| 33 | static std::vector<std::uint32_t> availableDecoders; |
| 34 | static int maxResolution; |
| 35 |
| 36 | private: |
| 37 | struct Request |
| 38 | { |
| 39 | enum Type |
| 40 | { |
| 41 | DecodeFrame, |
| 42 | ResetDecoder, |
| 43 | UpdateStreamState, |
| 44 | Shutdown |
| 45 | }; |
| 46 |
| 47 | Buffer buffer; |
| 48 | Type type; |
| 49 | }; |
| 50 | void RunThread(); |
| 51 | Thread* thread = nullptr; |
| 52 | bool running = true; |
| 53 | BlockingQueue<Request> queue; |
| 54 | std::vector<Buffer> csd; |
| 55 | unsigned int width; |
| 56 | unsigned int height; |
| 57 | bool streamEnabled = true; |
| 58 | bool streamPaused = false; |
| 59 | std::uint32_t codec; |
| 60 | std::uint16_t rotation = 0; |
| 61 | jobject jobj; |
| 62 | }; |
| 63 | } |
| 64 | } |
| 65 |
| 66 | #endif //LIBTGVOIP_VIDEORENDERERANDROID_H |
| 67 |