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

Unified Diff: webrtc/video/video_send_stream.cc

Issue 1763693002: Move encoder thread to VideoSendStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 4 years, 10 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
« no previous file with comments | « webrtc/video/video_send_stream.h ('k') | webrtc/video/vie_encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/video_send_stream.cc
diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc
index 7ae55dcf72af857985f368602967764f3735ae82..c98e5187dbbaae1443b33bff14be403788742357 100644
--- a/webrtc/video/video_send_stream.cc
+++ b/webrtc/video/video_send_stream.cc
@@ -171,6 +171,9 @@ VideoSendStream::VideoSendStream(
call_stats_(call_stats),
congestion_controller_(congestion_controller),
remb_(remb),
+ encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
+ encoder_wakeup_event_(false, false),
+ stop_encoder_thread_(0),
overuse_detector_(
Clock::GetRealTimeClock(),
GetCpuOveruseOptions(config.encoder_settings.full_overuse_time),
@@ -203,7 +206,7 @@ VideoSendStream::VideoSendStream(
bitrate_allocator),
vcm_(vie_encoder_.vcm()),
rtp_rtcp_modules_(vie_channel_.rtp_rtcp()),
- input_(&vie_encoder_,
+ input_(&encoder_wakeup_event_,
config_.local_renderer,
&stats_proxy_,
&overuse_detector_) {
@@ -303,12 +306,20 @@ VideoSendStream::VideoSendStream(
vie_channel_.RegisterSendFrameCountObserver(&stats_proxy_);
module_process_thread_->RegisterModule(&overuse_detector_);
+
+ encoder_thread_.Start();
+ encoder_thread_.SetPriority(rtc::kHighPriority);
}
VideoSendStream::~VideoSendStream() {
LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString();
Stop();
+ // Stop the encoder thread permanently.
+ rtc::AtomicOps::ReleaseStore(&stop_encoder_thread_, 1);
+ encoder_wakeup_event_.Set();
+ encoder_thread_.Stop();
+
module_process_thread_->DeRegisterModule(&overuse_detector_);
vie_channel_.RegisterSendFrameCountObserver(nullptr);
vie_channel_.RegisterSendBitrateObserver(nullptr);
@@ -351,6 +362,24 @@ void VideoSendStream::Stop() {
vie_receiver_->StopReceive();
}
+bool VideoSendStream::EncoderThreadFunction(void* obj) {
+ static_cast<VideoSendStream*>(obj)->EncoderProcess();
+ // We're done, return false to abort.
+ return false;
+}
+
+void VideoSendStream::EncoderProcess() {
+ while (true) {
+ encoder_wakeup_event_.Wait(rtc::Event::kForever);
+ if (rtc::AtomicOps::AcquireLoad(&stop_encoder_thread_))
+ return;
+
+ VideoFrame frame;
+ if (input_.GetVideoFrame(&frame))
+ vie_encoder_.EncodeVideoFrame(frame);
+ }
+}
+
void VideoSendStream::ReconfigureVideoEncoder(
const VideoEncoderConfig& config) {
TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder");
« no previous file with comments | « webrtc/video/video_send_stream.h ('k') | webrtc/video/vie_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698