VideoRendererAndroid.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Created by Grishka on 12.08.2018.
  3. //
  4. #ifndef LIBTGVOIP_VIDEORENDERERANDROID_H
  5. #define LIBTGVOIP_VIDEORENDERERANDROID_H
  6. #include "../../video/VideoRenderer.h"
  7. #include "../../MessageThread.h"
  8. #include <jni.h>
  9. #include "../../BlockingQueue.h"
  10. namespace tgvoip{
  11. namespace video{
  12. class VideoRendererAndroid : public VideoRenderer{
  13. public:
  14. VideoRendererAndroid(jobject jobj);
  15. virtual ~VideoRendererAndroid();
  16. virtual void Reset(uint32_t codec, unsigned int width, unsigned int height, std::vector<Buffer>& csd) override;
  17. virtual void DecodeAndDisplay(Buffer frame, uint32_t pts) override;
  18. virtual void SetStreamEnabled(bool enabled) override;
  19. static jmethodID resetMethod;
  20. static jmethodID decodeAndDisplayMethod;
  21. static jmethodID setStreamEnabledMethod;
  22. static std::vector<uint32_t> availableDecoders;
  23. static int maxResolution;
  24. private:
  25. struct Request{
  26. enum Type{
  27. DecodeFrame,
  28. ResetDecoder,
  29. UpdateStreamState,
  30. Shutdown
  31. };
  32. Buffer buffer;
  33. Type type;
  34. };
  35. void RunThread();
  36. Thread* thread=NULL;
  37. bool running=true;
  38. BlockingQueue<Request> queue;
  39. std::vector<Buffer> csd;
  40. int width;
  41. int height;
  42. bool streamEnabled=true;
  43. uint32_t codec;
  44. jobject jobj;
  45. };
  46. }
  47. }
  48. #endif //LIBTGVOIP_VIDEORENDERERANDROID_H