video_send_stream.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VIDEO_VIDEO_SEND_STREAM_H_
  11. #define VIDEO_VIDEO_SEND_STREAM_H_
  12. #include <map>
  13. #include <memory>
  14. #include <vector>
  15. #include "api/fec_controller.h"
  16. #include "api/video/video_stream_encoder_interface.h"
  17. #include "call/bitrate_allocator.h"
  18. #include "call/video_receive_stream.h"
  19. #include "call/video_send_stream.h"
  20. #include "rtc_base/event.h"
  21. #include "rtc_base/task_queue.h"
  22. #include "rtc_base/thread_checker.h"
  23. #include "video/send_delay_stats.h"
  24. #include "video/send_statistics_proxy.h"
  25. namespace webrtc {
  26. namespace test {
  27. class VideoSendStreamPeer;
  28. } // namespace test
  29. class CallStats;
  30. class IvfFileWriter;
  31. class ProcessThread;
  32. class RateLimiter;
  33. class RtpRtcp;
  34. class RtpTransportControllerSendInterface;
  35. class RtcEventLog;
  36. namespace internal {
  37. class VideoSendStreamImpl;
  38. // VideoSendStream implements webrtc::VideoSendStream.
  39. // Internally, it delegates all public methods to VideoSendStreamImpl and / or
  40. // VideoStreamEncoder. VideoSendStreamInternal is created and deleted on
  41. // |worker_queue|.
  42. class VideoSendStream : public webrtc::VideoSendStream {
  43. public:
  44. using RtpStateMap = std::map<uint32_t, RtpState>;
  45. using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>;
  46. VideoSendStream(
  47. Clock* clock,
  48. int num_cpu_cores,
  49. ProcessThread* module_process_thread,
  50. TaskQueueFactory* task_queue_factory,
  51. RtcpRttStats* call_stats,
  52. RtpTransportControllerSendInterface* transport,
  53. BitrateAllocatorInterface* bitrate_allocator,
  54. SendDelayStats* send_delay_stats,
  55. RtcEventLog* event_log,
  56. VideoSendStream::Config config,
  57. VideoEncoderConfig encoder_config,
  58. const std::map<uint32_t, RtpState>& suspended_ssrcs,
  59. const std::map<uint32_t, RtpPayloadState>& suspended_payload_states,
  60. std::unique_ptr<FecController> fec_controller);
  61. ~VideoSendStream() override;
  62. void DeliverRtcp(const uint8_t* packet, size_t length);
  63. // webrtc::VideoSendStream implementation.
  64. void UpdateActiveSimulcastLayers(
  65. const std::vector<bool> active_layers) override;
  66. void Start() override;
  67. void Stop() override;
  68. void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
  69. std::vector<rtc::scoped_refptr<Resource>> GetAdaptationResources() override;
  70. void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
  71. const DegradationPreference& degradation_preference) override;
  72. void ReconfigureVideoEncoder(VideoEncoderConfig) override;
  73. Stats GetStats() override;
  74. void StopPermanentlyAndGetRtpStates(RtpStateMap* rtp_state_map,
  75. RtpPayloadStateMap* payload_state_map);
  76. private:
  77. friend class test::VideoSendStreamPeer;
  78. class ConstructionTask;
  79. absl::optional<float> GetPacingFactorOverride() const;
  80. rtc::ThreadChecker thread_checker_;
  81. rtc::TaskQueue* const worker_queue_;
  82. rtc::Event thread_sync_event_;
  83. SendStatisticsProxy stats_proxy_;
  84. const VideoSendStream::Config config_;
  85. const VideoEncoderConfig::ContentType content_type_;
  86. std::unique_ptr<VideoSendStreamImpl> send_stream_;
  87. std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_;
  88. };
  89. } // namespace internal
  90. } // namespace webrtc
  91. #endif // VIDEO_VIDEO_SEND_STREAM_H_