This reverts commit 8eb37a39e79fe1098d3503dcb8c8c2d196203fed. Chrome now have its own implementation of TaskQueues that is based on Chrome threads.
cl was originally reviewed here:
https://codereview.webrtc.org/2060403002/
- Add task queue to Call with the intent of replacing the use of one of the process threads.
- Split VideoSendStream in two. VideoSendStreamInternal is created and used on the new task queue.
- BitrateAllocator is now created on libjingle's worker thread but always used on the new task queue instead of both encoder threads and the process thread.
- VideoEncoderConfig and VideoSendStream::Config support move semantics.
- The encoder thread is moved from VideoSendStream to ViEEncoder. Frames are forwarded directly to ViEEncoder which is responsible for timestamping ? and encoding the frames.
TBR=mflodman@webrtc.org
BUG=webrtc:5687
Review-Url: https://codereview.webrtc.org/2250123002
Cr-Commit-Position: refs/heads/master@{#14014}
diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc
index 17979d5..417720c 100644
--- a/webrtc/audio/audio_send_stream.cc
+++ b/webrtc/audio/audio_send_stream.cc
@@ -16,7 +16,9 @@
#include "webrtc/audio/conversion.h"
#include "webrtc/audio/scoped_voe_interface.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/event.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/task_queue.h"
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
#include "webrtc/modules/pacing/paced_sender.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -59,9 +61,11 @@
AudioSendStream::AudioSendStream(
const webrtc::AudioSendStream::Config& config,
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
+ rtc::TaskQueue* worker_queue,
CongestionController* congestion_controller,
BitrateAllocator* bitrate_allocator)
- : config_(config),
+ : worker_queue_(worker_queue),
+ config_(config),
audio_state_(audio_state),
bitrate_allocator_(bitrate_allocator) {
LOG(LS_INFO) << "AudioSendStream: " << config_.ToString();
@@ -109,8 +113,13 @@
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (config_.min_bitrate_kbps != -1 && config_.max_bitrate_kbps != -1) {
RTC_DCHECK_GE(config_.max_bitrate_kbps, config_.min_bitrate_kbps);
- bitrate_allocator_->AddObserver(this, config_.min_bitrate_kbps * 1000,
- config_.max_bitrate_kbps * 1000, 0, true);
+ rtc::Event thread_sync_event(false /* manual_reset */, false);
+ worker_queue_->PostTask([this, &thread_sync_event] {
+ bitrate_allocator_->AddObserver(this, config_.min_bitrate_kbps * 1000,
+ config_.max_bitrate_kbps * 1000, 0, true);
+ thread_sync_event.Set();
+ });
+ thread_sync_event.Wait(rtc::Event::kForever);
}
ScopedVoEInterface<VoEBase> base(voice_engine());
@@ -122,7 +131,13 @@
void AudioSendStream::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- bitrate_allocator_->RemoveObserver(this);
+ rtc::Event thread_sync_event(false /* manual_reset */, false);
+ worker_queue_->PostTask([this, &thread_sync_event] {
+ bitrate_allocator_->RemoveObserver(this);
+ thread_sync_event.Set();
+ });
+ thread_sync_event.Wait(rtc::Event::kForever);
+
ScopedVoEInterface<VoEBase> base(voice_engine());
int error = base->StopSend(config_.voe_channel_id);
if (error != 0) {