EgoWindow.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma once
  2. #include "api.h"
  3. #include "message_queue.h"
  4. #include "PCANBasic.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. class CCarSim;
  17. class CUdpSensor;
  18. class CControlSensor;
  19. enum ControlState
  20. {
  21. Check,
  22. Process,
  23. };
  24. class CEgoWindow : public CMessageQueue
  25. {
  26. public:
  27. CEgoWindow(CEgoClient* _egoclient,IRender * render,RenderPosition pos);
  28. //启动窗口
  29. virtual void Start() override;
  30. //处理,可能是处理缓存区数据的
  31. virtual void Process(CIOBuffer* pBuffer) override;
  32. //停止
  33. virtual void Stop() override;
  34. //空闲状态
  35. virtual void OnIdle() override;
  36. //发送消息,向窗口发送消息
  37. void PostMessage(int32_t type, int64_t l = 0, int64_t r = 0);
  38. //可能用于设置对等体标识
  39. void SetPeer(int32_t peer);
  40. //void CreateVideoReq();
  41. //void DelayNextVideoReq();
  42. //void DelayDataChannel();
  43. //void DelayStartPing();
  44. //发送数据
  45. void SendData(CIOBuffer& pBuffer);
  46. //可能用于设置对等体通知
  47. void SetPeerNotify();
  48. //virtual void WriteCanMessage(std::unordered_map<int32_t, cannet_frame>& node, bool bLidar) override;
  49. int32_t GetSteerAngle();
  50. //接收视频流数据,接入pbuffer接入函数
  51. void OnNotifyRep(int32_t peer);
  52. void OnNotifyAnswer(CIOBuffer* pBuffer);
  53. void OnNotifyLeave();
  54. void OnNotifyCandidate(CIOBuffer* pBuffer);
  55. void OnNotifyOffer(CIOBuffer* pBuffer);
  56. //这可能是帧回调函数
  57. static void FrameCallback(void* user_data,
  58. const uint8_t* yptr, int32_t strideY,
  59. const uint8_t* uptr, int32_t strideU,
  60. const uint8_t* vptr, int32_t strideV,
  61. const int32_t stride, const int frame_width,
  62. const int frame_height);
  63. //可能是ARGB32帧准备函数
  64. 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);
  65. //设置窗口尺寸
  66. void SetSize(int32_t width, int32_t height);
  67. //视频请求函数,用于处理视频请求
  68. void OnAskVideoReq();
  69. //数据通道请求函数,用于处理数据通道请求
  70. void OnAskDataChannel();
  71. void OnAskPing();
  72. void StopPing();
  73. ControlState GetControlState();
  74. void SetControlState(ControlState state);
  75. CEgoClient* GetEgoClient();
  76. void SetReady(bool b);
  77. //显示雷达函数,用于显示雷达数据
  78. void DisplayRadar(int32_t radar0, int32_t radar1, int32_t radar2, int32_t radar3, int32_t radar4, int32_t radar5, int32_t radar6, int32_t radar7, int32_t radar8);
  79. void DisplayPing(int32_t temp,double temp1);
  80. void DisplayStatue(FeedData data);
  81. void WriteStatue(TPCANMsg* CANMsg);
  82. void WriteCan(CIOBuffer* pBuffer);
  83. private:
  84. void InitPeerConnection(int32_t peer);
  85. void SetRenderWindow(int32_t width, int32_t height);
  86. private:
  87. CControlSensor* _controlSensor;
  88. CEgoClient* _client;
  89. std::unique_ptr<CPeerConnection> _peerconnection;
  90. int32_t _peer;
  91. RenderPosition _pos;
  92. BITMAPINFO bmi_;
  93. //SocketClient* _client;
  94. bool start_;
  95. //bool _channelcreated;
  96. //std::mutex buffer_lock_;
  97. std::unique_ptr<uint8_t> image_;
  98. std::unique_ptr<uint8_t> _rotate;
  99. //std::thread _delayThread;
  100. IRender* _render;
  101. ControlState _control;
  102. //std::unique_ptr<IPeerNotify> _peerNotify;
  103. };