#pragma once #include #include #include #include #include class CRemoteWindow; struct Message { int32_t cmd; int32_t index; int64_t param_l; int64_t param_r; }; class IRender; class CIOBuffer; class CRemoteCtrl; class SocketRemote; class CMessageQueue { public: CMessageQueue(CRemoteCtrl* c); ~CMessageQueue(); void Start(EgoType type,std::array& ar); void Stop(); void PostMessage(int32_t cmd, int32_t index, int64_t l = 0, int64_t r = 0); void Process(CIOBuffer * pBuffer); void KeepAlive(bool balive); SocketRemote* GetRemoteClient(); void OnConnect(int32_t peer); void NotifyLeave(); void NotifyReq(int32_t peer, int32_t index); void OverlayVideo(RenderPosition pos, const webrtc::VideoFrame& frame); private: void EnQueue(CIOBuffer* pBuffer); void Run(); void OnIdle(); private: std::mutex _lock; std::condition_variable _cv; CIOBuffer* _head; CIOBuffer* _tail; std::thread _thread; bool _run; std::vector> _WindowArray; CRemoteCtrl* _ctrl; bool _alive = false; int32_t _peer = -1; };