WebRtcPlayer.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_WEBRTCPLAYER_H
  11. #define ZLMEDIAKIT_WEBRTCPLAYER_H
  12. #include "WebRtcTransport.h"
  13. #include "Rtsp/RtspMediaSource.h"
  14. namespace mediakit {
  15. class WebRtcPlayer : public WebRtcTransportImp {
  16. public:
  17. using Ptr = std::shared_ptr<WebRtcPlayer>;
  18. static Ptr create(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info);
  19. MediaInfo getMediaInfo() { return _media_info; }
  20. protected:
  21. ///////WebRtcTransportImp override///////
  22. void onStartWebRTC() override;
  23. void onDestory() override;
  24. void onRtcConfigure(RtcConfigure &configure) const override;
  25. private:
  26. WebRtcPlayer(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info);
  27. void sendConfigFrames(uint32_t before_seq, uint32_t sample_rate, uint32_t timestamp, uint64_t ntp_timestamp);
  28. private:
  29. // 媒体相关元数据 [AUTO-TRANSLATED:f4cf8045]
  30. // Media related metadata
  31. MediaInfo _media_info;
  32. // 播放的rtsp源 [AUTO-TRANSLATED:9963eed1]
  33. // Playing rtsp source
  34. std::weak_ptr<RtspMediaSource> _play_src;
  35. // rtp 直接转发情况下通常会缺少 sps/pps, 在转发 rtp 前, 先发送一次相关帧信息, 部分情况下是可以播放的 [AUTO-TRANSLATED:65fdf16a]
  36. // In the case of direct RTP forwarding, sps/pps is usually missing. Before forwarding RTP, send the relevant frame information once. In some cases, it can be played.
  37. bool _send_config_frames_once { false };
  38. // 播放rtsp源的reader对象 [AUTO-TRANSLATED:7b305055]
  39. // Reader object for playing rtsp source
  40. RtspMediaSource::RingType::RingReader::Ptr _reader;
  41. };
  42. }// namespace mediakit
  43. #endif // ZLMEDIAKIT_WEBRTCPLAYER_H