#pragma once #include "api.h" #include "cap_interface.h" #include "message_queue.h" #define WM_NOTIFY_REP WM_APP+1 #define WM_NOTIFY_ANSWER WM_APP+2 //#define WM_NOTIFY_LEAVE WM_APP+3 #define WM_NOTIFY_CANDIDATE WM_APP+4 #define WM_NOTIFY_OFFER WM_APP+5 #define WM_ASK_PING WM_APP+6 #define WM_ASK_CHANNEL WM_APP+7 #define WM_ASK_VIDEOREQ WM_APP+8 class CPeerConnection; class IRender; class CEgoClient; enum ControlState { Check, Process, }; class IOverlayVideo; class CEgoWindow : public CMessageQueue { public: CEgoWindow(CEgoClient* _egoclient,IRender * render,RenderPosition pos); virtual void Start() override; virtual void Process(CIOBuffer* pBuffer) override; virtual void Stop() override; virtual void OnIdle() override; void PostMessage(int32_t type, int64_t l = 0, int64_t r = 0); void SetPeer(int32_t peer); //void CreateVideoReq(); //void DelayNextVideoReq(); //void DelayDataChannel(); //void DelayStartPing(); void SendData(CIOBuffer& pBuffer); void SetPeerNotify(); //virtual void WriteCanMessage(std::unordered_map& node, bool bLidar) override; int32_t GetSteerAngle(); void OnNotifyRep(int32_t peer); void OnNotifyAnswer(CIOBuffer* pBuffer); void OnNotifyLeave(); void OnNotifyCandidate(CIOBuffer* pBuffer); void OnNotifyOffer(CIOBuffer* pBuffer); static void RemoteFrameCallback(void* user_data, const webrtc::VideoFrame& frame); void OnArgb32FrameReady(const uint8_t* yptr, int32_t strideY, const uint8_t* uptr, int32_t strideU, const uint8_t* vptr, int32_t strideV, const int32_t stride, const int frame_width, const int frame_height); void SetSize(int32_t width, int32_t height); void OnAskVideoReq(); void OnAskDataChannel(); void OnAskPing(); void StopPing(); ControlState GetControlState(); void SetControlState(ControlState state); CEgoClient* GetEgoClient(); void SetReady(bool b); void OverlayVideo(const webrtc::VideoFrame& frame); private: void InitPeerConnection(int32_t peer); void SetRenderWindow(int32_t width, int32_t height); private: CEgoClient* _client; std::unique_ptr _peerconnection; int32_t _peer; RenderPosition _pos; BITMAPINFO bmi_; //SocketClient* _client; bool start_; //bool _channelcreated; //std::mutex buffer_lock_; std::unique_ptr image_; std::unique_ptr _rotate; //std::thread _delayThread; IRender* _render; ControlState _control; //std::unique_ptr _peerNotify; };