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

Unified Diff: webrtc/call/call.cc

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Rebased Created 4 years, 5 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/call/call.cc
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index c85eaf6990b8ceb1a8a9a0f17fe6ca8b19064c68..bfa8b59d2d8550fd95f6da121cc8eb50b3f2dfb0 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -9,7 +9,6 @@
*/
#include <string.h>
-
#include <algorithm>
#include <map>
#include <memory>
@@ -22,6 +21,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/task_queue.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/base/trace_event.h"
@@ -74,8 +74,8 @@ class Call : public webrtc::Call,
webrtc::AudioReceiveStream* receive_stream) override;
webrtc::VideoSendStream* CreateVideoSendStream(
- const webrtc::VideoSendStream::Config& config,
- const VideoEncoderConfig& encoder_config) override;
+ webrtc::VideoSendStream::Config config,
+ VideoEncoderConfig encoder_config) override;
stefan-webrtc 2016/07/08 15:56:41 Should we change this for audio above too, and for
perkj_webrtc 2016/07/11 11:41:07 This match CreateVideoReceiveStream now. I guess a
void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override;
webrtc::VideoReceiveStream* CreateVideoReceiveStream(
@@ -196,6 +196,11 @@ class Call : public webrtc::Call,
VieRemb remb_;
const std::unique_ptr<CongestionController> congestion_controller_;
const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
+ // TODO(perkj): |worker_queue_| is supposed to replace
+ // |module_process_thread_|.
+ // |worker_queue| is defined last to ensure all pending tasks are cancelled
+ // and deleted before any other members.
+ rtc::TaskQueue worker_queue_;
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
};
@@ -235,7 +240,8 @@ Call::Call(const Call::Config& config)
remb_(clock_),
congestion_controller_(
new CongestionController(clock_, this, &remb_, event_log_.get())),
- video_send_delay_stats_(new SendDelayStats(clock_)) {
+ video_send_delay_stats_(new SendDelayStats(clock_)),
+ worker_queue_("worker_queue") {
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
@@ -265,7 +271,10 @@ Call::Call(const Call::Config& config)
Call::~Call() {
RTC_DCHECK(!remb_.InUse());
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
- UpdateSendHistograms();
+ {
+ rtc::CritScope lock(&bitrate_crit_);
+ UpdateSendHistograms();
+ }
UpdateReceiveHistograms();
RTC_CHECK(audio_send_ssrcs_.empty());
RTC_CHECK(video_send_ssrcs_.empty());
@@ -419,22 +428,28 @@ void Call::DestroyAudioReceiveStream(
}
webrtc::VideoSendStream* Call::CreateVideoSendStream(
- const webrtc::VideoSendStream::Config& config,
- const VideoEncoderConfig& encoder_config) {
+ webrtc::VideoSendStream::Config config,
+ VideoEncoderConfig encoder_config) {
TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
video_send_delay_stats_->AddSsrcs(config);
+ event_log_->LogVideoSendStreamConfig(config);
+
// TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
// the call has already started.
+ // Copy ssrcs from |config| since |config| is moved.
+ std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
VideoSendStream* send_stream = new VideoSendStream(
- num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
- congestion_controller_.get(), bitrate_allocator_.get(),
- video_send_delay_stats_.get(), &remb_, event_log_.get(), config,
- encoder_config, suspended_video_send_ssrcs_);
+ num_cpu_cores_, module_process_thread_.get(), &worker_queue_,
+ call_stats_.get(), congestion_controller_.get(), bitrate_allocator_.get(),
+ video_send_delay_stats_.get(), &remb_, event_log_.get(),
+ std::move(config), std::move(encoder_config),
+ suspended_video_send_ssrcs_);
+
{
WriteLockScoped write_lock(*send_crit_);
- for (uint32_t ssrc : config.rtp.ssrcs) {
+ for (uint32_t ssrc : ssrcs) {
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
video_send_ssrcs_[ssrc] = send_stream;
}
@@ -442,7 +457,7 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
}
send_stream->SignalNetworkState(video_network_state_);
UpdateAggregateNetworkState();
- event_log_->LogVideoSendStreamConfig(config);
+
return send_stream;
}
@@ -469,11 +484,11 @@ void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
}
RTC_CHECK(send_stream_impl != nullptr);
- VideoSendStream::RtpStateMap rtp_state = send_stream_impl->GetRtpStates();
+ VideoSendStream::RtpStateMap rtp_state =
+ send_stream_impl->StopPermanentlyAndGetRtpStates();
for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin();
- it != rtp_state.end();
- ++it) {
+ it != rtp_state.end(); ++it) {
suspended_video_send_ssrcs_[it->first] = it->second;
}
@@ -698,6 +713,15 @@ void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss,
int64_t rtt_ms) {
+ // TODO(perkj): Consider making sure CongestionController operates on
+ // |worker_queue_|.
+ if (!worker_queue_.IsCurrent()) {
+ worker_queue_.PostTask([this, target_bitrate_bps, fraction_loss, rtt_ms] {
+ OnNetworkChanged(target_bitrate_bps, fraction_loss, rtt_ms);
+ });
+ return;
+ }
+ RTC_DCHECK_RUN_ON(&worker_queue_);
bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss,
rtt_ms);

Powered by Google App Engine
This is Rietveld 408576698