EgoWindow.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. class CPeerConnection;
  10. class IRender;
  11. enum ControlState
  12. {
  13. Check,
  14. Process,
  15. };
  16. class CEgoWindow : public CMessageQueue
  17. {
  18. public:
  19. CEgoWindow(IRender * render,RenderPosition pos, SocketClient* c);
  20. virtual void Start() override;
  21. virtual void Process(CIOBuffer* pBuffer) override;
  22. virtual void Stop() override;
  23. virtual void OnIdle() override;
  24. void PostMessage(int32_t type, int64_t l = 0, int64_t r = 0);
  25. void SetPeer(int32_t peer);
  26. void CreateVideoReq();
  27. void DelayNextVideoReq();
  28. void DelayDataChannel();
  29. void DelayStartPing();
  30. void SendData(CIOBuffer* pBuffer);
  31. void SetPeerNotify();
  32. //virtual void WriteCanMessage(std::unordered_map<int32_t, cannet_frame>& node, bool bLidar) override;
  33. void OnNotifyRep(int32_t peer);
  34. void OnNotifyAnswer(CIOBuffer* pBuffer);
  35. void OnNotifyLeave();
  36. void OnNotifyCandidate(CIOBuffer* pBuffer);
  37. void OnNotifyOffer(CIOBuffer* pBuffer);
  38. static void FrameCallback(void* user_data,
  39. const uint8_t* yptr, int32_t strideY,
  40. const uint8_t* uptr, int32_t strideU,
  41. const uint8_t* vptr, int32_t strideV,
  42. const int32_t stride, const int frame_width,
  43. const int frame_height);
  44. 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);
  45. void SetSize(int32_t width, int32_t height);
  46. void AskVideoReq();
  47. void AskDataChannel();
  48. void StartPing();
  49. void StopPing();
  50. ControlState GetControlState();
  51. void SetControlState(ControlState state);
  52. private:
  53. void InitPeerConnection(int32_t peer);
  54. void SetRenderWindow(int32_t width, int32_t height);
  55. void StartRender(bool b);
  56. private:
  57. std::unique_ptr<CPeerConnection> _peerconnection;
  58. int32_t _peer;
  59. RenderPosition _pos;
  60. BITMAPINFO bmi_;
  61. SocketClient* _client;
  62. bool start_;
  63. //bool _channelcreated;
  64. std::mutex buffer_lock_;
  65. std::unique_ptr<uint8_t> image_;
  66. std::unique_ptr<uint8_t> _rotate;
  67. std::thread _delayThread;
  68. IRender* _render;
  69. ControlState _control;
  70. //std::unique_ptr<IPeerNotify> _peerNotify;
  71. };