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 11 #ifndef VIDEO_VIDEO_SEND_STREAM_H_ 12 #define VIDEO_VIDEO_SEND_STREAM_H_ 13 14 #include <map> 15 #include <memory> 16 #include <vector> 17 18 #include "api/fec_controller.h" 19 #include "api/video/video_stream_encoder_interface.h" 20 #include "call/bitrate_allocator.h" 21 #include "call/video_receive_stream.h" 22 #include "call/video_send_stream.h" 23 #include "rtc_base/event.h" 24 #include "rtc_base/task_queue.h" 25 #include "rtc_base/thread_checker.h" 26 #include "video/send_delay_stats.h" 27 #include "video/send_statistics_proxy.h" 28 29 namespace webrtc { 30 namespace test { 31 class VideoSendStreamPeer; 32 } // namespace test 33 34 class CallStats; 35 class IvfFileWriter; 36 class ProcessThread; 37 class RateLimiter; 38 class RtpRtcp; 39 class RtpTransportControllerSendInterface; 40 class RtcEventLog; 41 42 namespace internal { 43 44 class VideoSendStreamImpl; 45 46 // VideoSendStream implements webrtc::VideoSendStream. 47 // Internally, it delegates all public methods to VideoSendStreamImpl and / or 48 // VideoStreamEncoder. VideoSendStreamInternal is created and deleted on 49 // |worker_queue|. 50 class VideoSendStream : public webrtc::VideoSendStream { 51 public: 52 using RtpStateMap = std::map<uint32_t, RtpState>; 53 using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>; 54 55 VideoSendStream( 56 Clock* clock, 57 int num_cpu_cores, 58 ProcessThread* module_process_thread, 59 TaskQueueFactory* task_queue_factory, 60 RtcpRttStats* call_stats, 61 RtpTransportControllerSendInterface* transport, 62 BitrateAllocatorInterface* bitrate_allocator, 63 SendDelayStats* send_delay_stats, 64 RtcEventLog* event_log, 65 VideoSendStream::Config config, 66 VideoEncoderConfig encoder_config, 67 const std::map<uint32_t, RtpState>& suspended_ssrcs, 68 const std::map<uint32_t, RtpPayloadState>& suspended_payload_states, 69 std::unique_ptr<FecController> fec_controller); 70 71 ~VideoSendStream() override; 72 73 void DeliverRtcp(const uint8_t* packet, size_t length); 74 75 // webrtc::VideoSendStream implementation. 76 void UpdateActiveSimulcastLayers( 77 const std::vector<bool> active_layers) override; 78 void Start() override; 79 void Stop() override; 80 81 void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override; 82 std::vector<rtc::scoped_refptr<Resource>> GetAdaptationResources() override; 83 84 void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source, 85 const DegradationPreference& degradation_preference) override; 86 87 void ReconfigureVideoEncoder(VideoEncoderConfig) override; 88 Stats GetStats() override; 89 90 void StopPermanentlyAndGetRtpStates(RtpStateMap* rtp_state_map, 91 RtpPayloadStateMap* payload_state_map); 92 93 private: 94 friend class test::VideoSendStreamPeer; 95 96 class ConstructionTask; 97 98 absl::optional<float> GetPacingFactorOverride() const; 99 100 rtc::ThreadChecker thread_checker_; 101 rtc::TaskQueue* const worker_queue_; 102 rtc::Event thread_sync_event_; 103 104 SendStatisticsProxy stats_proxy_; 105 const VideoSendStream::Config config_; 106 const VideoEncoderConfig::ContentType content_type_; 107 std::unique_ptr<VideoSendStreamImpl> send_stream_; 108 std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_; 109 }; 110 111 } // namespace internal 112 } // namespace webrtc 113 114 #endif // VIDEO_VIDEO_SEND_STREAM_H_ 115