Chromium Code Reviews| Index: webrtc/video/video_send_stream.h |
| diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h |
| index 05f254d06b6d4aeeae217ae1de0f36e808f2c630..6b59fa422ca84371ae528ec878ecb6bebc48a971 100644 |
| --- a/webrtc/video/video_send_stream.h |
| +++ b/webrtc/video/video_send_stream.h |
| @@ -17,6 +17,8 @@ |
| #include "webrtc/call/bitrate_allocator.h" |
| #include "webrtc/base/criticalsection.h" |
| +#include "webrtc/base/event.h" |
| +#include "webrtc/base/task_queue.h" |
| #include "webrtc/call.h" |
| #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| #include "webrtc/modules/video_coding/protection_bitrate_calculator.h" |
| @@ -48,14 +50,16 @@ class VideoSender; |
| namespace internal { |
| -class VideoSendStream : public webrtc::VideoSendStream, |
| - public webrtc::CpuOveruseObserver, |
| - public webrtc::BitrateAllocatorObserver, |
| - public webrtc::VCMProtectionCallback, |
| - public EncodedImageCallback { |
| +class VideoSendStreamInternal; |
| + |
| +// VideoSendStream implements webrtc::VideoSendStream. |
| +// Internally, it delegates all public methods to VideoSendStreamInternal. |
| +// VideoSendStreamInternal in created and destructed on |worker_queu|. |
| +class VideoSendStream : public webrtc::VideoSendStream { |
| public: |
| VideoSendStream(int num_cpu_cores, |
| ProcessThread* module_process_thread, |
| + rtc::TaskQueue* worker_queu, |
|
tommi
2016/06/17 07:59:01
worker_queue
perkj_webrtc
2016/06/27 14:34:35
Done.
|
| CallStats* call_stats, |
| CongestionController* congestion_controller, |
| BitrateAllocator* bitrate_allocator, |
| @@ -78,15 +82,61 @@ class VideoSendStream : public webrtc::VideoSendStream, |
| void ReconfigureVideoEncoder(const VideoEncoderConfig& config) override; |
| Stats GetStats() override; |
| + typedef std::map<uint32_t, RtpState> RtpStateMap; |
| + RtpStateMap StopPermanentlyAndGetRtpStates(); |
| + |
| + private: |
| + class ConstructionTask; |
| + class DestructAndGetRTPStateTask; |
| + |
| + rtc::ThreadChecker thread_checker_; |
| + rtc::TaskQueue* const worker_queu_; |
|
tommi
2016/06/17 07:59:01
worker_queue_
perkj_webrtc
2016/06/27 14:34:35
Done.
|
| + std::unique_ptr<VideoSendStreamInternal> send_stream_; |
| + rtc::Event thread_sync_event_; |
| +}; |
| + |
| +class VideoSendStreamInternal : public webrtc::CpuOveruseObserver, |
| + public webrtc::BitrateAllocatorObserver, |
| + public webrtc::VCMProtectionCallback, |
| + public EncodedImageCallback { |
| + public: |
| + VideoSendStreamInternal(int num_cpu_cores, |
| + rtc::TaskQueue* worker_queu, |
|
tommi
2016/06/17 07:59:02
worker_queue :)
perkj_webrtc
2016/06/27 14:34:35
Done.
|
| + CallStats* call_stats, |
| + CongestionController* congestion_controller, |
| + BitrateAllocator* bitrate_allocator, |
| + SendDelayStats* send_delay_stats, |
| + VieRemb* remb, |
| + RtcEventLog* event_log, |
| + const VideoSendStream::Config& config, |
| + const VideoEncoderConfig& encoder_config, |
| + const std::map<uint32_t, RtpState>& suspended_ssrcs); |
|
tommi
2016/06/17 07:59:01
should any of these more expensive parameters be p
perkj_webrtc
2016/06/27 14:34:35
Done.
|
| + |
| + ~VideoSendStreamInternal() override; |
| + |
| + // RegisterProcessThread register |module_process_thread| with those objects |
| + // that use it. Registration have to happen on the thread where |
| + // |module_process_thread| where created (libjingles worker thread). |
| + // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue, |
| + // maybe |worker_queu|. |
| + void RegisterProcessThread(ProcessThread* module_process_thread); |
| + void DeRegisterProcessThread(); |
| + |
| + void SignalNetworkState(NetworkState state); |
| + bool DeliverRtcp(const uint8_t* packet, size_t length); |
| + |
| + // webrtc::VideoSendStream implementation. |
|
tommi
2016/06/17 07:59:01
are the below methods overrides?
perkj_webrtc
2016/06/27 14:34:35
No, not after splitting VideoSendStream in two. Vi
|
| + void Start(); |
| + void Stop(); |
| + VideoCaptureInput* Input(); |
| + void ReconfigureVideoEncoder(const VideoEncoderConfig& config); |
| + VideoSendStream::Stats GetStats(); |
| + VideoSendStream::RtpStateMap GetRtpStates() const; |
| + |
| // webrtc::CpuOveruseObserver implementation. |
| void OveruseDetected() override; |
| void NormalUsage() override; |
| - typedef std::map<uint32_t, RtpState> RtpStateMap; |
| - RtpStateMap GetRtpStates() const; |
| - |
| - int GetPaddingNeededBps() const; |
| - |
| // Implements BitrateAllocatorObserver. |
| void OnBitrateUpdated(uint32_t bitrate_bps, |
| uint8_t fraction_loss, |
| @@ -101,10 +151,7 @@ class VideoSendStream : public webrtc::VideoSendStream, |
| uint32_t* sent_fec_rate_bps) override; |
| private: |
| - struct EncoderSettings { |
| - VideoCodec video_codec; |
| - VideoEncoderConfig config; |
| - }; |
| + class CheckEncoderActivityTask; |
| // Implements EncodedImageCallback. The implementation routes encoded frames |
| // to the |payload_router_| and |config.pre_encode_callback| if set. |
| @@ -118,13 +165,17 @@ class VideoSendStream : public webrtc::VideoSendStream, |
| void ConfigureProtection(); |
| void ConfigureSsrcs(); |
| + void CheckEncoderActivity(); |
| SendStatisticsProxy stats_proxy_; |
| EncodedFrameCallbackAdapter encoded_frame_proxy_; |
| const VideoSendStream::Config config_; |
| std::map<uint32_t, RtpState> suspended_ssrcs_; |
| - ProcessThread* const module_process_thread_; |
| + ProcessThread* module_process_thread_; |
| + rtc::ThreadChecker module_process_thread_checker_; |
| + rtc::TaskQueue* const worker_queu_; |
|
tommi
2016/06/17 07:59:02
ditto
perkj_webrtc
2016/06/27 14:34:35
Done.
|
| + CheckEncoderActivityTask* check_encoder_activity_task_; |
| CallStats* const call_stats_; |
| CongestionController* const congestion_controller_; |
| BitrateAllocator* const bitrate_allocator_; |
| @@ -138,11 +189,17 @@ class VideoSendStream : public webrtc::VideoSendStream, |
| rtc::Event encoder_wakeup_event_; |
| volatile int stop_encoder_thread_; |
| rtc::CriticalSection encoder_settings_crit_; |
| - std::unique_ptr<EncoderSettings> pending_encoder_settings_ |
| + std::unique_ptr<VideoCodec> pending_encoder_settings_ |
| GUARDED_BY(encoder_settings_crit_); |
| - // Only used on the encoder thread. |
| + |
| bool send_stream_registered_as_observer_; |
| - std::unique_ptr<EncoderSettings> current_encoder_settings_; |
| + VideoCodec current_video_codec_; |
| + int max_padding_bitrate_; |
| + // The time we last received an encoded frame. This is used to |
| + // track when video is stopped long enough that we also want to stop sending |
| + // padding. |
| + int64_t time_of_last_frame_activity_ms_ GUARDED_BY(encoder_settings_crit_); |
| + uint32_t last_set_encoder_bitrate_bps_; |
| OveruseFrameDetector overuse_detector_; |
| ViEEncoder vie_encoder_; |