VideoPlayer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <atomic>
  3. #include <mutex>
  4. #include "ECSDKMirrorManager.h"
  5. //#include "BufferQueue.h"
  6. //#include "videodecode.h"
  7. using namespace ECSDKFrameWork;
  8. /*
  9. * 用户实现:视频播放器功能
  10. * start:初始化并启动播放器
  11. * stop:停止并释放播放器
  12. * play:播放手机传输过来的视频数据
  13. * */
  14. #include <functional>
  15. typedef std::function<void (unsigned char*, int)> FUNCVIDEODATA;
  16. typedef std::function<void (bool, int, int)> FUNCVIDEOSTART;
  17. typedef struct ScreenSize
  18. {
  19. int Width;
  20. int Height;
  21. }_ScreenSize;
  22. class VideoPlayer : public IECVideoPlayer
  23. {
  24. public:
  25. VideoPlayer();
  26. ~VideoPlayer();
  27. virtual void play(const void *data, int32_t len) override;
  28. virtual void start(int width, int height) override;
  29. virtual void stop() override;
  30. void setScreenSize(ScreenSize size);
  31. void registerStartVideoCallback(FUNCVIDEOSTART func);
  32. void registerVideoDataCallback(FUNCVIDEODATA func);
  33. private:
  34. void DeliverFrameThread();
  35. static void *DeliverFrameThreadFunc(void *parameter);
  36. private:
  37. FUNCVIDEOSTART mFuncVideoStart = nullptr;
  38. FUNCVIDEODATA mFuncVideoData = nullptr;
  39. //BufferQueue* mPtrVideoQueue;
  40. pthread_t mDeliverFrameThread;
  41. //VideoDecode *m_pVideoPlayer;
  42. ScreenSize mScreenSize;
  43. std::atomic_bool mHasInit;
  44. std::mutex mMutex;
  45. };