WebRtcSession.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
  3. *
  4. * This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
  5. *
  6. * Use of this source code is governed by MIT-like license that can be found in the
  7. * LICENSE file in the root of the source tree. All contributing project authors
  8. * may be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef ZLMEDIAKIT_WEBRTCSESSION_H
  11. #define ZLMEDIAKIT_WEBRTCSESSION_H
  12. #include "WebRtcTransport.h"
  13. #include "Network/Session.h"
  14. #include "Http/HttpRequestSplitter.h"
  15. namespace toolkit {
  16. class TcpServer;
  17. }
  18. namespace mediakit {
  19. class WebRtcTransportImp;
  20. using namespace toolkit;
  21. class WebRtcSession : public Session, public HttpRequestSplitter {
  22. public:
  23. WebRtcSession(const Socket::Ptr &sock);
  24. void attachServer(const Server &server) override;
  25. void onRecv(const Buffer::Ptr &) override;
  26. void onError(const SockException &err) override;
  27. void onManager() override;
  28. static EventPoller::Ptr queryPoller(const Buffer::Ptr &buffer);
  29. protected:
  30. WebRtcTransportImp::Ptr _transport;
  31. private:
  32. //// HttpRequestSplitter override ////
  33. ssize_t onRecvHeader(const char *data, size_t len) override;
  34. const char *onSearchPacketTail(const char *data, size_t len) override;
  35. void onRecv_l(const char *data, size_t len);
  36. private:
  37. bool _over_tcp = false;
  38. bool _find_transport = true;
  39. Ticker _ticker;
  40. std::weak_ptr<toolkit::TcpServer> _server;
  41. };
  42. }// namespace mediakit
  43. #endif //ZLMEDIAKIT_WEBRTCSESSION_H