EgoWindow.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include "api.h"
  3. #include "cap_interface.h"
  4. #include "message_queue.h"
  5. #define WM_NOTIFY_REP WM_APP+1
  6. #define WM_NOTIFY_ANSWER WM_APP+2
  7. //#define WM_NOTIFY_LEAVE WM_APP+3
  8. #define WM_NOTIFY_CANDIDATE WM_APP+4
  9. #define WM_NOTIFY_OFFER WM_APP+5
  10. #define WM_ASK_PING WM_APP+6
  11. #define WM_ASK_CHANNEL WM_APP+7
  12. #define WM_ASK_VIDEOREQ WM_APP+8
  13. class CPeerConnection;
  14. class IRender;
  15. class CEgoClient;
  16. enum ControlState
  17. {
  18. Check,
  19. Process,
  20. };
  21. class IOverlayVideo;
  22. class CEgoWindow : public CMessageQueue
  23. {
  24. public:
  25. CEgoWindow(CEgoClient* _egoclient,IRender * render,RenderPosition pos);
  26. virtual void Start() override;
  27. virtual void Process(CIOBuffer* pBuffer) override;
  28. virtual void Stop() override;
  29. virtual void OnIdle() override;
  30. void PostMessage(int32_t type, int64_t l = 0, int64_t r = 0);
  31. void SetPeer(int32_t peer);
  32. //void CreateVideoReq();
  33. //void DelayNextVideoReq();
  34. //void DelayDataChannel();
  35. //void DelayStartPing();
  36. void SendData(CIOBuffer& pBuffer);
  37. void SetPeerNotify();
  38. //virtual void WriteCanMessage(std::unordered_map<int32_t, cannet_frame>& node, bool bLidar) override;
  39. int32_t GetSteerAngle();
  40. void OnNotifyRep(int32_t peer);
  41. void OnNotifyAnswer(CIOBuffer* pBuffer);
  42. void OnNotifyLeave();
  43. void OnNotifyCandidate(CIOBuffer* pBuffer);
  44. void OnNotifyOffer(CIOBuffer* pBuffer);
  45. static void RemoteFrameCallback(void* user_data,
  46. const webrtc::VideoFrame& frame);
  47. 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);
  48. void SetSize(int32_t width, int32_t height);
  49. void OnAskVideoReq();
  50. void OnAskDataChannel();
  51. void OnAskPing();
  52. void StopPing();
  53. ControlState GetControlState();
  54. void SetControlState(ControlState state);
  55. CEgoClient* GetEgoClient();
  56. void SetReady(bool b);
  57. void OverlayVideo(const webrtc::VideoFrame& frame);
  58. private:
  59. void InitPeerConnection(int32_t peer);
  60. void SetRenderWindow(int32_t width, int32_t height);
  61. private:
  62. CEgoClient* _client;
  63. std::unique_ptr<CPeerConnection> _peerconnection;
  64. int32_t _peer;
  65. RenderPosition _pos;
  66. BITMAPINFO bmi_;
  67. //SocketClient* _client;
  68. bool start_;
  69. //bool _channelcreated;
  70. //std::mutex buffer_lock_;
  71. std::unique_ptr<uint8_t> image_;
  72. std::unique_ptr<uint8_t> _rotate;
  73. //std::thread _delayThread;
  74. IRender* _render;
  75. ControlState _control;
  76. //std::unique_ptr<IPeerNotify> _peerNotify;
  77. };