Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: webrtc/video/video_send_stream.h

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Fix audio thread check when adding audio to bitrateallocator. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video/video_send_stream.h
diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h
index c67dc70199b989e41a129deba1bbccdb758d564b..932264265dddf75e3e762b6325141c0e4ae07957 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"
@@ -24,7 +26,6 @@
#include "webrtc/video/payload_router.h"
#include "webrtc/video/send_delay_stats.h"
#include "webrtc/video/send_statistics_proxy.h"
-#include "webrtc/video/video_capture_input.h"
#include "webrtc/video/vie_encoder.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
@@ -37,32 +38,29 @@ class CongestionController;
class IvfFileWriter;
class ProcessThread;
class RtpRtcp;
-class ViEEncoder;
class VieRemb;
class RtcEventLog;
-namespace vcm {
-class VideoSender;
-} // namespace vcm
-
namespace internal {
-class VideoSendStream : public webrtc::VideoSendStream,
- public webrtc::CpuOveruseObserver,
- public webrtc::BitrateAllocatorObserver,
- public webrtc::VCMProtectionCallback,
- public EncodedImageCallback {
+class VideoSendStreamImpl;
+
+// VideoSendStream implements webrtc::VideoSendStream.
+// Internally, it delegates all public methods to VideoSendStreamImpl and / or
+// VieEncoder. VideoSendStreamInternal is created and deleted on |worker_queue|.
+class VideoSendStream : public webrtc::VideoSendStream {
public:
VideoSendStream(int num_cpu_cores,
ProcessThread* module_process_thread,
+ rtc::TaskQueue* worker_queue,
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,
+ VideoSendStream::Config config,
+ VideoEncoderConfig encoder_config,
const std::map<uint32_t, RtpState>& suspended_ssrcs);
~VideoSendStream() override;
@@ -74,101 +72,26 @@ class VideoSendStream : public webrtc::VideoSendStream,
void Start() override;
void Stop() override;
VideoCaptureInput* Input() override;
- void ReconfigureVideoEncoder(const VideoEncoderConfig& config) override;
+ void ReconfigureVideoEncoder(VideoEncoderConfig) override;
Stats GetStats() override;
- // webrtc::CpuOveruseObserver implementation.
- void OveruseDetected() override;
- void NormalUsage() override;
-
typedef std::map<uint32_t, RtpState> RtpStateMap;
- RtpStateMap GetRtpStates() const;
-
- int GetPaddingNeededBps() const;
-
- // Implements BitrateAllocatorObserver.
- uint32_t OnBitrateUpdated(uint32_t bitrate_bps,
- uint8_t fraction_loss,
- int64_t rtt) override;
-
- protected:
- // Implements webrtc::VCMProtectionCallback.
- int ProtectionRequest(const FecProtectionParams* delta_params,
- const FecProtectionParams* key_params,
- uint32_t* sent_video_rate_bps,
- uint32_t* sent_nack_rate_bps,
- uint32_t* sent_fec_rate_bps) override;
+ RtpStateMap StopPermanentlyAndGetRtpStates();
private:
- struct EncoderSettings {
- VideoCodec video_codec;
- VideoEncoderConfig config;
- };
-
- // Implements EncodedImageCallback. The implementation routes encoded frames
- // to the |payload_router_| and |config.pre_encode_callback| if set.
- // Called on an arbitrary encoder callback thread.
- EncodedImageCallback::Result OnEncodedImage(
- const EncodedImage& encoded_image,
- const CodecSpecificInfo* codec_specific_info,
- const RTPFragmentationHeader* fragmentation) override;
+ class ConstructionTask;
+ class DestructAndGetRtpStateTask;
- static bool EncoderThreadFunction(void* obj);
- void EncoderProcess();
-
- void ConfigureProtection();
- void ConfigureSsrcs();
+ rtc::ThreadChecker thread_checker_;
+ rtc::TaskQueue* const worker_queue_;
+ rtc::Event thread_sync_event_;
SendStatisticsProxy stats_proxy_;
const VideoSendStream::Config config_;
- std::map<uint32_t, RtpState> suspended_ssrcs_;
-
- ProcessThread* const module_process_thread_;
- CallStats* const call_stats_;
- CongestionController* const congestion_controller_;
- BitrateAllocator* const bitrate_allocator_;
- VieRemb* const remb_;
-
- static const bool kEnableFrameRecording = false;
- static const int kMaxLayers = 3;
- std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers];
-
- rtc::PlatformThread encoder_thread_;
- rtc::Event encoder_wakeup_event_;
- volatile int stop_encoder_thread_;
- rtc::CriticalSection encoder_settings_crit_;
- std::unique_ptr<EncoderSettings> pending_encoder_settings_
- GUARDED_BY(encoder_settings_crit_);
- uint32_t encoder_max_bitrate_bps_ GUARDED_BY(encoder_settings_crit_);
- uint32_t encoder_target_rate_bps_ GUARDED_BY(encoder_settings_crit_);
-
- enum class State {
- kStopped, // VideoSendStream::Start has not yet been called.
- kStarted, // VideoSendStream::Start has been called.
- // VideoSendStream::Start has been called but the encoder have timed out.
- kEncoderTimedOut,
- };
- rtc::Optional<State> pending_state_change_ GUARDED_BY(encoder_settings_crit_);
-
- // Only used on the encoder thread.
- rtc::ThreadChecker encoder_thread_checker_;
- State state_ ACCESS_ON(&encoder_thread_checker_);
- std::unique_ptr<EncoderSettings> current_encoder_settings_
- ACCESS_ON(&encoder_thread_checker_);
-
- OveruseFrameDetector overuse_detector_;
- ViEEncoder vie_encoder_;
- EncoderStateFeedback encoder_feedback_;
- ProtectionBitrateCalculator protection_bitrate_calculator_;
-
- vcm::VideoSender* const video_sender_;
-
- const std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
- // RtpRtcp modules, declared here as they use other members on construction.
- const std::vector<RtpRtcp*> rtp_rtcp_modules_;
- PayloadRouter payload_router_;
- VideoCaptureInput input_;
+ std::unique_ptr<VideoSendStreamImpl> send_stream_;
+ std::unique_ptr<ViEEncoder> vie_encoder_;
};
+
} // namespace internal
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698