EgoWindow.h 2.5 KB

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