Make LoadObserver settable per video send stream. Gives client flexibility and makes the implementation slightly simpler. See discussion in: https://codereview.webrtc.org/1269863005/
BUG=webrtc:4690 Review URL: https://codereview.webrtc.org/1325263002 Cr-Commit-Position: refs/heads/master@{#9891}
This commit is contained in:
parent
a9839dd037
commit
e526974759
@ -803,7 +803,6 @@ WebRtcVideoChannel2::WebRtcVideoChannel2(
|
||||
options_.SetAll(options);
|
||||
options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_);
|
||||
webrtc::Call::Config config;
|
||||
config.overuse_callback = this;
|
||||
if (voice_engine != NULL) {
|
||||
config.voice_engine = voice_engine->voe()->engine();
|
||||
}
|
||||
@ -1131,10 +1130,13 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) {
|
||||
for (uint32 used_ssrc : sp.ssrcs)
|
||||
send_ssrcs_.insert(used_ssrc);
|
||||
|
||||
webrtc::VideoSendStream::Config config(this);
|
||||
config.overuse_callback = this;
|
||||
|
||||
WebRtcVideoSendStream* stream =
|
||||
new WebRtcVideoSendStream(call_.get(),
|
||||
sp,
|
||||
webrtc::VideoSendStream::Config(this),
|
||||
config,
|
||||
external_encoder_factory_,
|
||||
options_,
|
||||
bitrate_config_.max_bitrate_bps,
|
||||
|
||||
@ -1746,15 +1746,14 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
|
||||
EXPECT_TRUE(channel_->SetSend(true));
|
||||
|
||||
// Trigger overuse.
|
||||
ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
|
||||
FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
|
||||
webrtc::LoadObserver* overuse_callback =
|
||||
fake_call_->GetConfig().overuse_callback;
|
||||
send_stream->GetConfig().overuse_callback;
|
||||
ASSERT_TRUE(overuse_callback != NULL);
|
||||
overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
|
||||
|
||||
EXPECT_TRUE(capturer.CaptureFrame());
|
||||
ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
|
||||
FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
|
||||
|
||||
EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
|
||||
|
||||
if (enable_overuse && !is_screenshare) {
|
||||
@ -2343,9 +2342,12 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) {
|
||||
cricket::VideoOptions options;
|
||||
options.cpu_overuse_detection.Set(true);
|
||||
EXPECT_TRUE(channel_->SetOptions(options));
|
||||
|
||||
// Trigger overuse.
|
||||
ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
|
||||
webrtc::LoadObserver* overuse_callback =
|
||||
fake_call_->GetConfig().overuse_callback;
|
||||
fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback;
|
||||
ASSERT_TRUE(overuse_callback != NULL);
|
||||
overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
|
||||
|
||||
// Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2.
|
||||
|
||||
@ -74,10 +74,6 @@ class Call {
|
||||
// VoiceEngine used for audio/video synchronization for this Call.
|
||||
VoiceEngine* voice_engine = nullptr;
|
||||
|
||||
// Callback for overuse and normal usage based on the jitter of incoming
|
||||
// captured frames. 'nullptr' disables the callback.
|
||||
LoadObserver* overuse_callback = nullptr;
|
||||
|
||||
// Bitrate config used until valid bitrate estimates are calculated. Also
|
||||
// used to cap total bitrate used.
|
||||
struct BitrateConfig {
|
||||
|
||||
@ -41,30 +41,6 @@ const int Call::Config::kDefaultStartBitrateBps = 300000;
|
||||
|
||||
namespace internal {
|
||||
|
||||
class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver {
|
||||
public:
|
||||
explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback)
|
||||
: overuse_callback_(overuse_callback) {
|
||||
DCHECK(overuse_callback != nullptr);
|
||||
}
|
||||
|
||||
virtual ~CpuOveruseObserverProxy() {}
|
||||
|
||||
void OveruseDetected() override {
|
||||
rtc::CritScope lock(&crit_);
|
||||
overuse_callback_->OnLoadUpdate(LoadObserver::kOveruse);
|
||||
}
|
||||
|
||||
void NormalUsage() override {
|
||||
rtc::CritScope lock(&crit_);
|
||||
overuse_callback_->OnLoadUpdate(LoadObserver::kUnderuse);
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::CriticalSection crit_;
|
||||
LoadObserver* overuse_callback_ GUARDED_BY(crit_);
|
||||
};
|
||||
|
||||
class Call : public webrtc::Call, public PacketReceiver {
|
||||
public:
|
||||
explicit Call(const Call::Config& config);
|
||||
@ -138,8 +114,6 @@ class Call : public webrtc::Call, public PacketReceiver {
|
||||
std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
|
||||
std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
|
||||
|
||||
rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_;
|
||||
|
||||
VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Call);
|
||||
@ -172,11 +146,6 @@ Call::Call(const Call::Config& config)
|
||||
Trace::CreateTrace();
|
||||
module_process_thread_->Start();
|
||||
|
||||
if (config.overuse_callback) {
|
||||
overuse_observer_proxy_.reset(
|
||||
new CpuOveruseObserverProxy(config.overuse_callback));
|
||||
}
|
||||
|
||||
SetBitrateControllerConfig(config_.bitrate_config);
|
||||
}
|
||||
|
||||
@ -248,8 +217,7 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
|
||||
|
||||
// TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
|
||||
// the call has already started.
|
||||
VideoSendStream* send_stream = new VideoSendStream(
|
||||
overuse_observer_proxy_.get(), num_cpu_cores_,
|
||||
VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_,
|
||||
module_process_thread_.get(), channel_group_.get(),
|
||||
rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config,
|
||||
suspended_video_send_ssrcs_);
|
||||
|
||||
@ -488,15 +488,10 @@ void CallPerfTest::TestCpuOveruse(LoadObserver::Load tested_load,
|
||||
observation_complete_->Set();
|
||||
}
|
||||
|
||||
Call::Config GetSenderCallConfig() override {
|
||||
Call::Config config;
|
||||
config.overuse_callback = this;
|
||||
return config;
|
||||
}
|
||||
|
||||
void ModifyConfigs(VideoSendStream::Config* send_config,
|
||||
std::vector<VideoReceiveStream::Config>* receive_configs,
|
||||
VideoEncoderConfig* encoder_config) override {
|
||||
send_config->overuse_callback = this;
|
||||
send_config->encoder_settings.encoder = &encoder_;
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +101,6 @@ std::string VideoSendStream::Config::ToString() const {
|
||||
|
||||
namespace internal {
|
||||
VideoSendStream::VideoSendStream(
|
||||
CpuOveruseObserver* overuse_observer,
|
||||
int num_cpu_cores,
|
||||
ProcessThread* module_process_thread,
|
||||
ChannelGroup* channel_group,
|
||||
@ -162,7 +161,7 @@ VideoSendStream::VideoSendStream(
|
||||
|
||||
input_.reset(new internal::VideoCaptureInput(
|
||||
module_process_thread_, vie_encoder_, config_.local_renderer,
|
||||
&stats_proxy_, overuse_observer));
|
||||
&stats_proxy_, this));
|
||||
|
||||
// 28 to match packet overhead in ModuleRtpRtcpImpl.
|
||||
DCHECK_LE(config_.rtp.max_packet_size, static_cast<size_t>(0xFFFF - 28));
|
||||
@ -390,6 +389,16 @@ VideoSendStream::Stats VideoSendStream::GetStats() {
|
||||
return stats_proxy_.GetStats();
|
||||
}
|
||||
|
||||
void VideoSendStream::OveruseDetected() {
|
||||
if (config_.overuse_callback)
|
||||
config_.overuse_callback->OnLoadUpdate(LoadObserver::kOveruse);
|
||||
}
|
||||
|
||||
void VideoSendStream::NormalUsage() {
|
||||
if (config_.overuse_callback)
|
||||
config_.overuse_callback->OnLoadUpdate(LoadObserver::kUnderuse);
|
||||
}
|
||||
|
||||
void VideoSendStream::ConfigureSsrcs() {
|
||||
vie_channel_->SetSSRC(config_.rtp.ssrcs.front(), kViEStreamTypeNormal, 0);
|
||||
for (size_t i = 0; i < config_.rtp.ssrcs.size(); ++i) {
|
||||
|
||||
@ -28,17 +28,16 @@
|
||||
namespace webrtc {
|
||||
|
||||
class ChannelGroup;
|
||||
class CpuOveruseObserver;
|
||||
class ProcessThread;
|
||||
class ViEChannel;
|
||||
class ViEEncoder;
|
||||
|
||||
namespace internal {
|
||||
|
||||
class VideoSendStream : public webrtc::VideoSendStream {
|
||||
class VideoSendStream : public webrtc::VideoSendStream,
|
||||
public webrtc::CpuOveruseObserver {
|
||||
public:
|
||||
VideoSendStream(CpuOveruseObserver* overuse_observer,
|
||||
int num_cpu_cores,
|
||||
VideoSendStream(int num_cpu_cores,
|
||||
ProcessThread* module_process_thread,
|
||||
ChannelGroup* channel_group,
|
||||
int channel_id,
|
||||
@ -59,6 +58,10 @@ class VideoSendStream : public webrtc::VideoSendStream {
|
||||
bool ReconfigureVideoEncoder(const VideoEncoderConfig& config) override;
|
||||
Stats GetStats() override;
|
||||
|
||||
// webrtc::CpuOveruseObserver implementation.
|
||||
void OveruseDetected() override;
|
||||
void NormalUsage() override;
|
||||
|
||||
typedef std::map<uint32_t, RtpState> RtpStateMap;
|
||||
RtpStateMap GetRtpStates() const;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class LoadObserver;
|
||||
class VideoEncoder;
|
||||
|
||||
// Class to deliver captured frame to the video send stream.
|
||||
@ -122,6 +123,10 @@ class VideoSendStream : public SendStream {
|
||||
// Transport for outgoing packets.
|
||||
newapi::Transport* send_transport = nullptr;
|
||||
|
||||
// Callback for overuse and normal usage based on the jitter of incoming
|
||||
// captured frames. 'nullptr' disables the callback.
|
||||
LoadObserver* overuse_callback = nullptr;
|
||||
|
||||
// Called for each I420 frame before encoding the frame. Can be used for
|
||||
// effects, snapshots etc. 'nullptr' disables the callback.
|
||||
I420FrameCallback* pre_encode_callback = nullptr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user