Rename ViEEncoder to VideoStreamEncoder
This CL:
- Renames the ViEEncoder class to VideoStreamEncoder, according to discussions.
- Renames variables 'vie_encode' to 'video_stream_encoder'.
- Formatting to match style guide.
- No other changes.
BUG=webrtc:8064
Review-Url: https://codereview.webrtc.org/2995433002
Cr-Commit-Position: refs/heads/master@{#19237}
diff --git a/webrtc/call/call_perf_tests.cc b/webrtc/call/call_perf_tests.cc
index f8461bf..558b75c 100644
--- a/webrtc/call/call_perf_tests.cc
+++ b/webrtc/call/call_perf_tests.cc
@@ -499,8 +499,8 @@
switch (test_phase_) {
case TestPhase::kStart:
if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
- // On adapting down, ViEEncoder::VideoSourceProxy will set only the
- // max pixel count, leaving the target unset.
+ // On adapting down, VideoStreamEncoder::VideoSourceProxy will set
+ // only the max pixel count, leaving the target unset.
test_phase_ = TestPhase::kAdaptedDown;
} else {
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
diff --git a/webrtc/media/engine/webrtcvideoengine_unittest.cc b/webrtc/media/engine/webrtcvideoengine_unittest.cc
index 9d4c809..d6a98de 100644
--- a/webrtc/media/engine/webrtcvideoengine_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine_unittest.cc
@@ -2272,7 +2272,7 @@
send_stream = fake_call_->GetVideoSendStreams().front();
// We have a new fake send stream, so it doesn't remember the old sink wants.
// In practice, it will be populated from
- // ViEEncoder::VideoSourceProxy::SetSource(), so simulate that here.
+ // VideoStreamEncoder::VideoSourceProxy::SetSource(), so simulate that here.
send_stream->InjectVideoSinkWants(wants);
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams());
diff --git a/webrtc/test/fake_encoder.h b/webrtc/test/fake_encoder.h
index 220af90..96218e5 100644
--- a/webrtc/test/fake_encoder.h
+++ b/webrtc/test/fake_encoder.h
@@ -102,7 +102,7 @@
// This class implements a multi-threaded fake encoder by posting
// FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
// alternating fashion. The class itself does not need to be thread safe,
-// as it is called from the task queue in ViEEncoder.
+// as it is called from the task queue in VideoStreamEncoder.
class MultithreadedFakeH264Encoder : public test::FakeH264Encoder {
public:
explicit MultithreadedFakeH264Encoder(Clock* clock);
diff --git a/webrtc/video/BUILD.gn b/webrtc/video/BUILD.gn
index f85510c..02431e0 100644
--- a/webrtc/video/BUILD.gn
+++ b/webrtc/video/BUILD.gn
@@ -44,8 +44,8 @@
"video_send_stream.h",
"video_stream_decoder.cc",
"video_stream_decoder.h",
- "vie_encoder.cc",
- "vie_encoder.h",
+ "video_stream_encoder.cc",
+ "video_stream_encoder.h",
]
if (!build_with_chromium && is_clang) {
@@ -257,7 +257,7 @@
"stream_synchronization_unittest.cc",
"video_receive_stream_unittest.cc",
"video_send_stream_tests.cc",
- "vie_encoder_unittest.cc",
+ "video_stream_encoder_unittest.cc",
]
deps = [
":video",
diff --git a/webrtc/video/encoder_rtcp_feedback.cc b/webrtc/video/encoder_rtcp_feedback.cc
index 11d46ff..1c5a31e 100644
--- a/webrtc/video/encoder_rtcp_feedback.cc
+++ b/webrtc/video/encoder_rtcp_feedback.cc
@@ -11,7 +11,7 @@
#include "webrtc/video/encoder_rtcp_feedback.h"
#include "webrtc/rtc_base/checks.h"
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
static const int kMinKeyFrameRequestIntervalMs = 300;
@@ -19,10 +19,10 @@
EncoderRtcpFeedback::EncoderRtcpFeedback(Clock* clock,
const std::vector<uint32_t>& ssrcs,
- ViEEncoder* encoder)
+ VideoStreamEncoder* encoder)
: clock_(clock),
ssrcs_(ssrcs),
- vie_encoder_(encoder),
+ video_stream_encoder_(encoder),
time_last_intra_request_ms_(ssrcs.size(), -1) {
RTC_DCHECK(!ssrcs.empty());
}
@@ -49,8 +49,8 @@
RTC_DCHECK(HasSsrc(ssrc));
size_t index = GetStreamIndex(ssrc);
{
- // TODO(mflodman): Move to ViEEncoder after some more changes making it
- // easier to test there.
+ // TODO(mflodman): Move to VideoStreamEncoder after some more changes making
+ // it easier to test there.
int64_t now_ms = clock_->TimeInMilliseconds();
rtc::CritScope lock(&crit_);
if (time_last_intra_request_ms_[index] + kMinKeyFrameRequestIntervalMs >
@@ -60,7 +60,7 @@
time_last_intra_request_ms_[index] = now_ms;
}
- vie_encoder_->OnReceivedIntraFrameRequest(index);
+ video_stream_encoder_->OnReceivedIntraFrameRequest(index);
}
} // namespace webrtc
diff --git a/webrtc/video/encoder_rtcp_feedback.h b/webrtc/video/encoder_rtcp_feedback.h
index e7a825c..2f24e31 100644
--- a/webrtc/video/encoder_rtcp_feedback.h
+++ b/webrtc/video/encoder_rtcp_feedback.h
@@ -19,13 +19,13 @@
namespace webrtc {
-class ViEEncoder;
+class VideoStreamEncoder;
class EncoderRtcpFeedback : public RtcpIntraFrameObserver {
public:
EncoderRtcpFeedback(Clock* clock,
const std::vector<uint32_t>& ssrcs,
- ViEEncoder* encoder);
+ VideoStreamEncoder* encoder);
void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
private:
@@ -34,7 +34,7 @@
Clock* const clock_;
const std::vector<uint32_t> ssrcs_;
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
rtc::CriticalSection crit_;
std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(crit_);
diff --git a/webrtc/video/encoder_rtcp_feedback_unittest.cc b/webrtc/video/encoder_rtcp_feedback_unittest.cc
index 12c0951..718ecac 100644
--- a/webrtc/video/encoder_rtcp_feedback_unittest.cc
+++ b/webrtc/video/encoder_rtcp_feedback_unittest.cc
@@ -16,22 +16,23 @@
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
#include "webrtc/video/send_statistics_proxy.h"
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
using ::testing::NiceMock;
namespace webrtc {
-class MockVieEncoder : public ViEEncoder {
+class MockVideoStreamEncoder : public VideoStreamEncoder {
public:
- explicit MockVieEncoder(SendStatisticsProxy* send_stats_proxy)
- : ViEEncoder(1,
- send_stats_proxy,
- VideoSendStream::Config::EncoderSettings("fake", 0, nullptr),
- nullptr,
- nullptr,
- std::unique_ptr<OveruseFrameDetector>()) {}
- ~MockVieEncoder() { Stop(); }
+ explicit MockVideoStreamEncoder(SendStatisticsProxy* send_stats_proxy)
+ : VideoStreamEncoder(1,
+ send_stats_proxy,
+ VideoSendStream::Config::EncoderSettings("fake", 0,
+ nullptr),
+ nullptr,
+ nullptr,
+ std::unique_ptr<OveruseFrameDetector>()) {}
+ ~MockVideoStreamEncoder() { Stop(); }
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
};
@@ -54,7 +55,7 @@
SimulatedClock simulated_clock_;
SendStatisticsProxy send_stats_proxy_;
- MockVieEncoder encoder_;
+ MockVideoStreamEncoder encoder_;
EncoderRtcpFeedback encoder_rtcp_feedback_;
};
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc
index de9ee76..a6f421a 100644
--- a/webrtc/video/send_statistics_proxy.cc
+++ b/webrtc/video/send_statistics_proxy.cc
@@ -717,8 +717,8 @@
}
void SendStatisticsProxy::SetAdaptationStats(
- const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts) {
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts) {
rtc::CritScope lock(&crit_);
SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_);
SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_);
@@ -726,24 +726,24 @@
}
void SendStatisticsProxy::OnCpuAdaptationChanged(
- const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts) {
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts) {
rtc::CritScope lock(&crit_);
++stats_.number_of_cpu_adapt_changes;
UpdateAdaptationStats(cpu_counts, quality_counts);
}
void SendStatisticsProxy::OnQualityAdaptationChanged(
- const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts) {
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts) {
rtc::CritScope lock(&crit_);
++stats_.number_of_quality_adapt_changes;
UpdateAdaptationStats(cpu_counts, quality_counts);
}
void SendStatisticsProxy::UpdateAdaptationStats(
- const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts) {
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts) {
cpu_downscales_ = cpu_counts.resolution;
quality_downscales_ = quality_counts.resolution;
@@ -753,8 +753,9 @@
stats_.bw_limited_framerate = quality_counts.fps > 0;
}
-void SendStatisticsProxy::SetAdaptTimer(const ViEEncoder::AdaptCounts& counts,
- StatsTimer* timer) {
+void SendStatisticsProxy::SetAdaptTimer(
+ const VideoStreamEncoder::AdaptCounts& counts,
+ StatsTimer* timer) {
if (counts.resolution >= 0 || counts.fps >= 0) {
// Adaptation enabled.
if (!stats_.suspended)
diff --git a/webrtc/video/send_statistics_proxy.h b/webrtc/video/send_statistics_proxy.h
index 5017598..81da6cb 100644
--- a/webrtc/video/send_statistics_proxy.h
+++ b/webrtc/video/send_statistics_proxy.h
@@ -27,7 +27,7 @@
#include "webrtc/video/overuse_frame_detector.h"
#include "webrtc/video/report_block_stats.h"
#include "webrtc/video/stats_counter.h"
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
#include "webrtc/video_send_stream.h"
namespace webrtc {
@@ -58,13 +58,15 @@
void OnIncomingFrame(int width, int height);
// Adaptation stats.
- void SetAdaptationStats(const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts);
- void OnCpuAdaptationChanged(const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts);
+ void SetAdaptationStats(
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts);
+ void OnCpuAdaptationChanged(
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts);
void OnQualityAdaptationChanged(
- const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts);
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts);
void OnEncoderStatsUpdate(uint32_t framerate, uint32_t bitrate);
void OnSuspendChange(bool is_suspended);
@@ -164,10 +166,12 @@
VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
EXCLUSIVE_LOCKS_REQUIRED(crit_);
- void SetAdaptTimer(const ViEEncoder::AdaptCounts& counts, StatsTimer* timer)
+ void SetAdaptTimer(const VideoStreamEncoder::AdaptCounts& counts,
+ StatsTimer* timer)
EXCLUSIVE_LOCKS_REQUIRED(crit_);
- void UpdateAdaptationStats(const ViEEncoder::AdaptCounts& cpu_counts,
- const ViEEncoder::AdaptCounts& quality_counts)
+ void UpdateAdaptationStats(
+ const VideoStreamEncoder::AdaptCounts& cpu_counts,
+ const VideoStreamEncoder::AdaptCounts& quality_counts)
EXCLUSIVE_LOCKS_REQUIRED(crit_);
Clock* const clock_;
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index 4f09e48..274aca8 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -368,8 +368,8 @@
}
TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_framerate);
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_resolution);
cpu_counts.fps = 1;
@@ -395,8 +395,8 @@
}
TEST_F(SendStatisticsProxyTest, GetQualityAdaptationStats) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_framerate);
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
quality_counts.fps = 1;
@@ -422,8 +422,8 @@
}
TEST_F(SendStatisticsProxyTest, GetStatsReportsCpuAdaptChanges) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_cpu_adapt_changes);
cpu_counts.resolution = 1;
@@ -441,8 +441,8 @@
}
TEST_F(SendStatisticsProxyTest, GetStatsReportsQualityAdaptChanges) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_quality_adapt_changes);
quality_counts.fps = 1;
@@ -474,8 +474,8 @@
// First RTP packet sent.
UpdateDataCounters(kFirstSsrc);
// Enable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
// Min runtime has not passed.
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1);
@@ -489,8 +489,8 @@
// First RTP packet sent.
UpdateDataCounters(kFirstSsrc);
// Enable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
// Min runtime has passed.
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
@@ -507,8 +507,8 @@
// First RTP packet sent.
UpdateDataCounters(kFirstSsrc);
// Enable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
// Adapt changes: 1, elapsed time: 10 sec => 6 per minute.
statistics_proxy_->OnCpuAdaptationChanged(cpu_counts, quality_counts);
@@ -523,8 +523,8 @@
UpdateDataCounters(kFirstSsrc);
// Disable quality adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.fps = -1;
quality_counts.resolution = -1;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
@@ -591,8 +591,8 @@
UpdateDataCounters(kFirstSsrc);
// Enable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
// Adapt changes: 2, elapsed time: 20 sec.
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
fake_clock_.AdvanceTimeMilliseconds(20000);
@@ -625,8 +625,8 @@
fake_clock_.AdvanceTimeMilliseconds(30000);
// Enable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
// Adapt changes: 1, elapsed time: 20 sec.
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
fake_clock_.AdvanceTimeMilliseconds(10000);
@@ -670,8 +670,8 @@
statistics_proxy_->OnSuspendChange(true);
// Enable adaptation, stats time not started when suspended.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
fake_clock_.AdvanceTimeMilliseconds(10000);
@@ -690,8 +690,8 @@
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsRestartsOnFirstSentPacket) {
// Send first packet, adaptation enabled.
// Elapsed time before first packet is sent should be excluded.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
fake_clock_.AdvanceTimeMilliseconds(10000);
UpdateDataCounters(kFirstSsrc);
@@ -711,8 +711,8 @@
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsStartedAfterFirstSentPacket) {
// Enable and disable adaptation.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
fake_clock_.AdvanceTimeMilliseconds(60000);
cpu_counts.fps = -1;
@@ -743,8 +743,8 @@
TEST_F(SendStatisticsProxyTest, AdaptChangesReportedAfterContentSwitch) {
// First RTP packet sent, cpu adaptation enabled.
UpdateDataCounters(kFirstSsrc);
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.fps = -1;
quality_counts.resolution = -1;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
@@ -904,8 +904,8 @@
}
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
cpu_counts.resolution = -1;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
@@ -918,8 +918,8 @@
}
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramUpdated) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
cpu_counts.resolution = 0;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
@@ -1216,8 +1216,8 @@
TEST_F(SendStatisticsProxyTest,
QualityLimitedHistogramsNotUpdatedWhenDisabled) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.resolution = -1;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
EncodedImage encoded_image;
@@ -1234,8 +1234,8 @@
TEST_F(SendStatisticsProxyTest,
QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.resolution = 0;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
EncodedImage encoded_image;
@@ -1256,8 +1256,8 @@
TEST_F(SendStatisticsProxyTest,
QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
const int kDownscales = 2;
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.resolution = kDownscales;
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
EncodedImage encoded_image;
@@ -1295,8 +1295,8 @@
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
// Resolution scaled due to quality.
- ViEEncoder::AdaptCounts cpu_counts;
- ViEEncoder::AdaptCounts quality_counts;
+ VideoStreamEncoder::AdaptCounts cpu_counts;
+ VideoStreamEncoder::AdaptCounts quality_counts;
quality_counts.resolution = 1;
statistics_proxy_->OnQualityAdaptationChanged(cpu_counts, quality_counts);
statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc
index 2c3a5c4..d55ad01 100644
--- a/webrtc/video/video_send_stream.cc
+++ b/webrtc/video/video_send_stream.cc
@@ -333,7 +333,7 @@
class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
public webrtc::OverheadObserver,
public webrtc::VCMProtectionCallback,
- public ViEEncoder::EncoderSink,
+ public VideoStreamEncoder::EncoderSink,
public VideoBitrateAllocationObserver {
public:
VideoSendStreamImpl(SendStatisticsProxy* stats_proxy,
@@ -342,7 +342,7 @@
RtpTransportControllerSendInterface* transport,
BitrateAllocator* bitrate_allocator,
SendDelayStats* send_delay_stats,
- ViEEncoder* vie_encoder,
+ VideoStreamEncoder* video_stream_encoder,
RtcEventLog* event_log,
const VideoSendStream::Config* config,
int initial_encoder_max_bitrate,
@@ -440,7 +440,7 @@
uint32_t encoder_max_bitrate_bps_;
uint32_t encoder_target_rate_bps_;
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
EncoderRtcpFeedback encoder_feedback_;
ProtectionBitrateCalculator protection_bitrate_calculator_;
@@ -469,7 +469,7 @@
ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream,
rtc::Event* done_event,
SendStatisticsProxy* stats_proxy,
- ViEEncoder* vie_encoder,
+ VideoStreamEncoder* video_stream_encoder,
ProcessThread* module_process_thread,
CallStats* call_stats,
RtpTransportControllerSendInterface* transport,
@@ -484,7 +484,7 @@
: send_stream_(send_stream),
done_event_(done_event),
stats_proxy_(stats_proxy),
- vie_encoder_(vie_encoder),
+ video_stream_encoder_(video_stream_encoder),
call_stats_(call_stats),
transport_(transport),
bitrate_allocator_(bitrate_allocator),
@@ -502,16 +502,16 @@
bool Run() override {
send_stream_->reset(new VideoSendStreamImpl(
stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_,
- bitrate_allocator_, send_delay_stats_, vie_encoder_, event_log_,
- config_, initial_encoder_max_bitrate_, std::move(suspended_ssrcs_),
- content_type_, keepalive_config_));
+ bitrate_allocator_, send_delay_stats_, video_stream_encoder_,
+ event_log_, config_, initial_encoder_max_bitrate_,
+ std::move(suspended_ssrcs_), content_type_, keepalive_config_));
return true;
}
std::unique_ptr<VideoSendStreamImpl>* const send_stream_;
rtc::Event* const done_event_;
SendStatisticsProxy* const stats_proxy_;
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
CallStats* const call_stats_;
RtpTransportControllerSendInterface* const transport_;
BitrateAllocator* const bitrate_allocator_;
@@ -643,15 +643,18 @@
encoder_config.content_type),
config_(std::move(config)),
content_type_(encoder_config.content_type) {
- vie_encoder_.reset(
- new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings,
- config_.pre_encode_callback, config_.post_encode_callback,
- std::unique_ptr<OveruseFrameDetector>()));
+ video_stream_encoder_.reset(
+ new VideoStreamEncoder(num_cpu_cores, &stats_proxy_,
+ config_.encoder_settings,
+ config_.pre_encode_callback,
+ config_.post_encode_callback,
+ std::unique_ptr<OveruseFrameDetector>()));
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
- &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(),
- module_process_thread, call_stats, transport, bitrate_allocator,
- send_delay_stats, event_log, &config_, encoder_config.max_bitrate_bps,
- suspended_ssrcs, encoder_config.content_type, keepalive_config)));
+ &send_stream_, &thread_sync_event_, &stats_proxy_,
+ video_stream_encoder_.get(), module_process_thread, call_stats, transport,
+ bitrate_allocator, send_delay_stats, event_log, &config_,
+ encoder_config.max_bitrate_bps, suspended_ssrcs,
+ encoder_config.content_type, keepalive_config)));
// Wait for ConstructionTask to complete so that |send_stream_| can be used.
// |module_process_thread| must be registered and deregistered on the thread
@@ -661,9 +664,9 @@
// TODO(sprang): Enable this also for regular video calls if it works well.
if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) {
// Only signal target bitrate for screenshare streams, for now.
- vie_encoder_->SetBitrateObserver(send_stream_.get());
+ video_stream_encoder_->SetBitrateObserver(send_stream_.get());
}
- vie_encoder_->RegisterProcessThread(module_process_thread);
+ video_stream_encoder_->RegisterProcessThread(module_process_thread);
ReconfigureVideoEncoder(std::move(encoder_config));
}
@@ -683,8 +686,8 @@
});
// It is expected that after VideoSendStream::Start has been called, incoming
- // frames are not dropped in ViEEncoder. To ensure this, Start has to be
- // synchronized.
+ // frames are not dropped in VideoStreamEncoder. To ensure this, Start has to
+ // be synchronized.
thread_sync_event_.Wait(rtc::Event::kForever);
}
@@ -699,7 +702,7 @@
rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
const DegradationPreference& degradation_preference) {
RTC_DCHECK_RUN_ON(&thread_checker_);
- vie_encoder_->SetSource(source, degradation_preference);
+ video_stream_encoder_->SetSource(source, degradation_preference);
}
void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
@@ -707,8 +710,9 @@
// ReconfigureVideoEncoder from the network thread.
// RTC_DCHECK_RUN_ON(&thread_checker_);
RTC_DCHECK(content_type_ == config.content_type);
- vie_encoder_->ConfigureEncoder(std::move(config), config_.rtp.max_packet_size,
- config_.rtp.nack.rtp_history_ms > 0);
+ video_stream_encoder_->ConfigureEncoder(std::move(config),
+ config_.rtp.max_packet_size,
+ config_.rtp.nack.rtp_history_ms > 0);
}
VideoSendStream::Stats VideoSendStream::GetStats() {
@@ -727,8 +731,8 @@
VideoSendStream::RtpStateMap VideoSendStream::StopPermanentlyAndGetRtpStates() {
RTC_DCHECK_RUN_ON(&thread_checker_);
- vie_encoder_->Stop();
- vie_encoder_->DeRegisterProcessThread();
+ video_stream_encoder_->Stop();
+ video_stream_encoder_->DeRegisterProcessThread();
VideoSendStream::RtpStateMap state_map;
send_stream_->DeRegisterProcessThread();
worker_queue_->PostTask(
@@ -765,7 +769,7 @@
RtpTransportControllerSendInterface* transport,
BitrateAllocator* bitrate_allocator,
SendDelayStats* send_delay_stats,
- ViEEncoder* vie_encoder,
+ VideoStreamEncoder* video_stream_encoder,
RtcEventLog* event_log,
const VideoSendStream::Config* config,
int initial_encoder_max_bitrate,
@@ -788,10 +792,10 @@
encoder_min_bitrate_bps_(0),
encoder_max_bitrate_bps_(initial_encoder_max_bitrate),
encoder_target_rate_bps_(0),
- vie_encoder_(vie_encoder),
+ video_stream_encoder_(video_stream_encoder),
encoder_feedback_(Clock::GetRealTimeClock(),
config_->rtp.ssrcs,
- vie_encoder),
+ video_stream_encoder),
protection_bitrate_calculator_(Clock::GetRealTimeClock(), this),
bandwidth_observer_(transport->send_side_cc()
->GetBitrateController()
@@ -887,7 +891,8 @@
RTC_DCHECK_GE(config_->encoder_settings.payload_type, 0);
RTC_DCHECK_LE(config_->encoder_settings.payload_type, 127);
- vie_encoder_->SetStartBitrate(bitrate_allocator_->GetStartBitrate(this));
+ video_stream_encoder_->SetStartBitrate(
+ bitrate_allocator_->GetStartBitrate(this));
// Only request rotation at the source when we positively know that the remote
// side doesn't support the rotation extension. This allows us to prepare the
@@ -900,7 +905,7 @@
return extension.uri == RtpExtension::kVideoRotationUri;
}) == config_->rtp.extensions.end();
- vie_encoder_->SetSink(this, rotation_applied);
+ video_stream_encoder_->SetSink(this, rotation_applied);
}
void VideoSendStreamImpl::RegisterProcessThread(
@@ -961,7 +966,7 @@
CheckEncoderActivityTask::kEncoderTimeOutMs);
}
- vie_encoder_->SendKeyFrame();
+ video_stream_encoder_->SendKeyFrame();
}
void VideoSendStreamImpl::Stop() {
@@ -977,7 +982,7 @@
check_encoder_activity_task_->Stop();
check_encoder_activity_task_ = nullptr;
}
- vie_encoder_->OnBitrateUpdated(0, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(0, 0, 0);
stats_proxy_->OnSetEncoderTargetRate(0);
}
@@ -1298,7 +1303,8 @@
encoder_target_rate_bps_ =
std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_);
- vie_encoder_->OnBitrateUpdated(encoder_target_rate_bps_, fraction_loss, rtt);
+ video_stream_encoder_->OnBitrateUpdated(encoder_target_rate_bps_,
+ fraction_loss, rtt);
stats_proxy_->OnSetEncoderTargetRate(encoder_target_rate_bps_);
return protection_bitrate;
}
@@ -1320,7 +1326,7 @@
if (!files.empty()) {
// Make a keyframe appear as early as possible in the logs, to give actually
// decodable output.
- vie_encoder_->SendKeyFrame();
+ video_stream_encoder_->SendKeyFrame();
}
}
diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h
index 59cb797..db34539 100644
--- a/webrtc/video/video_send_stream.h
+++ b/webrtc/video/video_send_stream.h
@@ -24,7 +24,7 @@
#include "webrtc/video/encoder_rtcp_feedback.h"
#include "webrtc/video/send_delay_stats.h"
#include "webrtc/video/send_statistics_proxy.h"
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
@@ -44,7 +44,8 @@
// VideoSendStream implements webrtc::VideoSendStream.
// Internally, it delegates all public methods to VideoSendStreamImpl and / or
-// VieEncoder. VideoSendStreamInternal is created and deleted on |worker_queue|.
+// VideoStreamEncoder. VideoSendStreamInternal is created and deleted on
+// |worker_queue|.
class VideoSendStream : public webrtc::VideoSendStream {
public:
VideoSendStream(int num_cpu_cores,
@@ -102,7 +103,7 @@
const VideoSendStream::Config config_;
const VideoEncoderConfig::ContentType content_type_;
std::unique_ptr<VideoSendStreamImpl> send_stream_;
- std::unique_ptr<ViEEncoder> vie_encoder_;
+ std::unique_ptr<VideoStreamEncoder> video_stream_encoder_;
};
} // namespace internal
diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc
index 94b57e3..8352d4f 100644
--- a/webrtc/video/video_send_stream_tests.cc
+++ b/webrtc/video/video_send_stream_tests.cc
@@ -2371,7 +2371,7 @@
// Set expected temporal layers as they should have been set when
// reconfiguring the encoder and not match the set config. Also copy the
- // TemporalLayersFactory pointer that has been injected by ViEEncoder.
+ // TemporalLayersFactory pointer that has been injected by VideoStreamEncoder.
VideoCodecVP8 encoder_settings = encoder_settings_;
encoder_settings.numberOfTemporalLayers =
kVideoCodecConfigObserverNumberOfTemporalLayers;
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/video_stream_encoder.cc
similarity index 86%
rename from webrtc/video/vie_encoder.cc
rename to webrtc/video/video_stream_encoder.cc
index c49b76b..51fb1d4 100644
--- a/webrtc/video/vie_encoder.cc
+++ b/webrtc/video/video_stream_encoder.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
#include <algorithm>
#include <limits>
@@ -103,83 +103,85 @@
} // namespace
-class ViEEncoder::ConfigureEncoderTask : public rtc::QueuedTask {
+class VideoStreamEncoder::ConfigureEncoderTask : public rtc::QueuedTask {
public:
- ConfigureEncoderTask(ViEEncoder* vie_encoder,
+ ConfigureEncoderTask(VideoStreamEncoder* video_stream_encoder,
VideoEncoderConfig config,
size_t max_data_payload_length,
bool nack_enabled)
- : vie_encoder_(vie_encoder),
+ : video_stream_encoder_(video_stream_encoder),
config_(std::move(config)),
max_data_payload_length_(max_data_payload_length),
nack_enabled_(nack_enabled) {}
private:
bool Run() override {
- vie_encoder_->ConfigureEncoderOnTaskQueue(
+ video_stream_encoder_->ConfigureEncoderOnTaskQueue(
std::move(config_), max_data_payload_length_, nack_enabled_);
return true;
}
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
VideoEncoderConfig config_;
size_t max_data_payload_length_;
bool nack_enabled_;
};
-class ViEEncoder::EncodeTask : public rtc::QueuedTask {
+class VideoStreamEncoder::EncodeTask : public rtc::QueuedTask {
public:
EncodeTask(const VideoFrame& frame,
- ViEEncoder* vie_encoder,
+ VideoStreamEncoder* video_stream_encoder,
int64_t time_when_posted_us,
bool log_stats)
: frame_(frame),
- vie_encoder_(vie_encoder),
+ video_stream_encoder_(video_stream_encoder),
time_when_posted_us_(time_when_posted_us),
log_stats_(log_stats) {
- ++vie_encoder_->posted_frames_waiting_for_encode_;
+ ++video_stream_encoder_->posted_frames_waiting_for_encode_;
}
private:
bool Run() override {
- RTC_DCHECK_RUN_ON(&vie_encoder_->encoder_queue_);
- RTC_DCHECK_GT(vie_encoder_->posted_frames_waiting_for_encode_.Value(), 0);
- vie_encoder_->stats_proxy_->OnIncomingFrame(frame_.width(),
- frame_.height());
- ++vie_encoder_->captured_frame_count_;
- if (--vie_encoder_->posted_frames_waiting_for_encode_ == 0) {
- vie_encoder_->EncodeVideoFrame(frame_, time_when_posted_us_);
+ RTC_DCHECK_RUN_ON(&video_stream_encoder_->encoder_queue_);
+ RTC_DCHECK_GT(
+ video_stream_encoder_->posted_frames_waiting_for_encode_.Value(), 0);
+ video_stream_encoder_->stats_proxy_->OnIncomingFrame(frame_.width(),
+ frame_.height());
+ ++video_stream_encoder_->captured_frame_count_;
+ if (--video_stream_encoder_->posted_frames_waiting_for_encode_ == 0) {
+ video_stream_encoder_->EncodeVideoFrame(frame_, time_when_posted_us_);
} else {
// There is a newer frame in flight. Do not encode this frame.
LOG(LS_VERBOSE)
<< "Incoming frame dropped due to that the encoder is blocked.";
- ++vie_encoder_->dropped_frame_count_;
+ ++video_stream_encoder_->dropped_frame_count_;
}
if (log_stats_) {
LOG(LS_INFO) << "Number of frames: captured "
- << vie_encoder_->captured_frame_count_
+ << video_stream_encoder_->captured_frame_count_
<< ", dropped (due to encoder blocked) "
- << vie_encoder_->dropped_frame_count_ << ", interval_ms "
+ << video_stream_encoder_->dropped_frame_count_
+ << ", interval_ms "
<< kFrameLogIntervalMs;
- vie_encoder_->captured_frame_count_ = 0;
- vie_encoder_->dropped_frame_count_ = 0;
+ video_stream_encoder_->captured_frame_count_ = 0;
+ video_stream_encoder_->dropped_frame_count_ = 0;
}
return true;
}
VideoFrame frame_;
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
const int64_t time_when_posted_us_;
const bool log_stats_;
};
// VideoSourceProxy is responsible ensuring thread safety between calls to
-// ViEEncoder::SetSource that will happen on libjingle's worker thread when a
-// video capturer is connected to the encoder and the encoder task queue
+// VideoStreamEncoder::SetSource that will happen on libjingle's worker thread
+// when a video capturer is connected to the encoder and the encoder task queue
// (encoder_queue_) where the encoder reports its VideoSinkWants.
-class ViEEncoder::VideoSourceProxy {
+class VideoStreamEncoder::VideoSourceProxy {
public:
- explicit VideoSourceProxy(ViEEncoder* vie_encoder)
- : vie_encoder_(vie_encoder),
+ explicit VideoSourceProxy(VideoStreamEncoder* video_stream_encoder)
+ : video_stream_encoder_(video_stream_encoder),
degradation_preference_(
VideoSendStream::DegradationPreference::kDegradationDisabled),
source_(nullptr) {}
@@ -200,21 +202,21 @@
}
if (old_source != source && old_source != nullptr) {
- old_source->RemoveSink(vie_encoder_);
+ old_source->RemoveSink(video_stream_encoder_);
}
if (!source) {
return;
}
- source->AddOrUpdateSink(vie_encoder_, wants);
+ source->AddOrUpdateSink(video_stream_encoder_, wants);
}
void SetWantsRotationApplied(bool rotation_applied) {
rtc::CritScope lock(&crit_);
sink_wants_.rotation_applied = rotation_applied;
if (source_)
- source_->AddOrUpdateSink(vie_encoder_, sink_wants_);
+ source_->AddOrUpdateSink(video_stream_encoder_, sink_wants_);
}
rtc::VideoSinkWants GetActiveSinkWants() {
@@ -228,7 +230,7 @@
sink_wants_.target_pixel_count.reset();
sink_wants_.max_framerate_fps = std::numeric_limits<int>::max();
if (source_)
- source_->AddOrUpdateSink(vie_encoder_, sink_wants_);
+ source_->AddOrUpdateSink(video_stream_encoder_, sink_wants_);
}
bool RequestResolutionLowerThan(int pixel_count) {
@@ -249,7 +251,8 @@
LOG(LS_INFO) << "Scaling down resolution, max pixels: " << pixels_wanted;
sink_wants_.max_pixel_count = pixels_wanted;
sink_wants_.target_pixel_count = rtc::Optional<int>();
- source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
+ source_->AddOrUpdateSink(video_stream_encoder_,
+ GetActiveSinkWantsInternal());
return true;
}
@@ -290,7 +293,8 @@
rtc::Optional<int>((pixel_count * 5) / 3);
}
LOG(LS_INFO) << "Scaling up resolution, max pixels: " << max_pixels_wanted;
- source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
+ source_->AddOrUpdateSink(video_stream_encoder_,
+ GetActiveSinkWantsInternal());
return true;
}
@@ -320,7 +324,8 @@
LOG(LS_INFO) << "Scaling down framerate: " << fps_wanted;
sink_wants_.max_framerate_fps = fps_wanted;
- source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
+ source_->AddOrUpdateSink(video_stream_encoder_,
+ GetActiveSinkWantsInternal());
return true;
}
@@ -336,7 +341,8 @@
LOG(LS_INFO) << "Scaling up framerate: " << fps_wanted;
sink_wants_.max_framerate_fps = fps_wanted;
- source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
+ source_->AddOrUpdateSink(video_stream_encoder_,
+ GetActiveSinkWantsInternal());
return true;
}
@@ -366,7 +372,7 @@
rtc::CriticalSection crit_;
rtc::SequencedTaskChecker main_checker_;
- ViEEncoder* const vie_encoder_;
+ VideoStreamEncoder* const video_stream_encoder_;
rtc::VideoSinkWants sink_wants_ GUARDED_BY(&crit_);
VideoSendStream::DegradationPreference degradation_preference_
GUARDED_BY(&crit_);
@@ -375,7 +381,7 @@
RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy);
};
-ViEEncoder::ViEEncoder(uint32_t number_of_cores,
+VideoStreamEncoder::VideoStreamEncoder(uint32_t number_of_cores,
SendStatisticsProxy* stats_proxy,
const VideoSendStream::Config::EncoderSettings& settings,
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
@@ -428,7 +434,7 @@
});
}
-ViEEncoder::~ViEEncoder() {
+VideoStreamEncoder::~VideoStreamEncoder() {
RTC_DCHECK_RUN_ON(&thread_checker_);
RTC_DCHECK(shutdown_event_.Wait(0))
<< "Must call ::Stop() before destruction.";
@@ -438,7 +444,8 @@
// pipelining encoders better (multiple input frames before something comes
// out). This should effectively turn off CPU adaptations for systems that
// remotely cope with the load right now.
-CpuOveruseOptions ViEEncoder::GetCpuOveruseOptions(bool full_overuse_time) {
+CpuOveruseOptions VideoStreamEncoder::GetCpuOveruseOptions(
+ bool full_overuse_time) {
CpuOveruseOptions options;
if (full_overuse_time) {
options.low_encode_usage_threshold_percent = 150;
@@ -447,7 +454,7 @@
return options;
}
-void ViEEncoder::Stop() {
+void VideoStreamEncoder::Stop() {
RTC_DCHECK_RUN_ON(&thread_checker_);
source_proxy_->SetSource(nullptr, VideoSendStream::DegradationPreference());
encoder_queue_.PostTask([this] {
@@ -464,7 +471,8 @@
shutdown_event_.Wait(rtc::Event::kForever);
}
-void ViEEncoder::RegisterProcessThread(ProcessThread* module_process_thread) {
+void VideoStreamEncoder::RegisterProcessThread(
+ ProcessThread* module_process_thread) {
RTC_DCHECK_RUN_ON(&thread_checker_);
RTC_DCHECK(!module_process_thread_);
module_process_thread_ = module_process_thread;
@@ -472,12 +480,12 @@
module_process_thread_checker_.DetachFromThread();
}
-void ViEEncoder::DeRegisterProcessThread() {
+void VideoStreamEncoder::DeRegisterProcessThread() {
RTC_DCHECK_RUN_ON(&thread_checker_);
module_process_thread_->DeRegisterModule(&video_sender_);
}
-void ViEEncoder::SetBitrateObserver(
+void VideoStreamEncoder::SetBitrateObserver(
VideoBitrateAllocationObserver* bitrate_observer) {
RTC_DCHECK_RUN_ON(&thread_checker_);
encoder_queue_.PostTask([this, bitrate_observer] {
@@ -487,7 +495,7 @@
});
}
-void ViEEncoder::SetSource(
+void VideoStreamEncoder::SetSource(
rtc::VideoSourceInterface<VideoFrame>* source,
const VideoSendStream::DegradationPreference& degradation_preference) {
RTC_DCHECK_RUN_ON(&thread_checker_);
@@ -521,7 +529,7 @@
});
}
-void ViEEncoder::SetSink(EncoderSink* sink, bool rotation_applied) {
+void VideoStreamEncoder::SetSink(EncoderSink* sink, bool rotation_applied) {
source_proxy_->SetWantsRotationApplied(rotation_applied);
encoder_queue_.PostTask([this, sink] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
@@ -529,24 +537,25 @@
});
}
-void ViEEncoder::SetStartBitrate(int start_bitrate_bps) {
+void VideoStreamEncoder::SetStartBitrate(int start_bitrate_bps) {
encoder_queue_.PostTask([this, start_bitrate_bps] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
encoder_start_bitrate_bps_ = start_bitrate_bps;
});
}
-void ViEEncoder::ConfigureEncoder(VideoEncoderConfig config,
- size_t max_data_payload_length,
- bool nack_enabled) {
+void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config,
+ size_t max_data_payload_length,
+ bool nack_enabled) {
encoder_queue_.PostTask(
std::unique_ptr<rtc::QueuedTask>(new ConfigureEncoderTask(
this, std::move(config), max_data_payload_length, nack_enabled)));
}
-void ViEEncoder::ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
- size_t max_data_payload_length,
- bool nack_enabled) {
+void VideoStreamEncoder::ConfigureEncoderOnTaskQueue(
+ VideoEncoderConfig config,
+ size_t max_data_payload_length,
+ bool nack_enabled) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
RTC_DCHECK(sink_);
LOG(LS_INFO) << "ConfigureEncoder requested.";
@@ -569,7 +578,7 @@
}
}
-void ViEEncoder::ReconfigureEncoder() {
+void VideoStreamEncoder::ReconfigureEncoder() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
RTC_DCHECK(pending_encoder_reconfiguration_);
std::vector<VideoStream> streams =
@@ -643,7 +652,7 @@
ConfigureQualityScaler();
}
-void ViEEncoder::ConfigureQualityScaler() {
+void VideoStreamEncoder::ConfigureQualityScaler() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
const auto scaling_settings = settings_.encoder->GetScalingSettings();
const bool quality_scaling_allowed =
@@ -670,7 +679,7 @@
GetActiveCounts(kQuality));
}
-void ViEEncoder::OnFrame(const VideoFrame& video_frame) {
+void VideoStreamEncoder::OnFrame(const VideoFrame& video_frame) {
RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_);
VideoFrame incoming_frame = video_frame;
@@ -720,7 +729,7 @@
incoming_frame, this, rtc::TimeMicros(), log_stats)));
}
-bool ViEEncoder::EncoderPaused() const {
+bool VideoStreamEncoder::EncoderPaused() const {
RTC_DCHECK_RUN_ON(&encoder_queue_);
// Pause video if paused by caller or as long as the network is down or the
// pacer queue has grown too large in buffered mode.
@@ -729,7 +738,7 @@
return last_observed_bitrate_bps_ == 0;
}
-void ViEEncoder::TraceFrameDropStart() {
+void VideoStreamEncoder::TraceFrameDropStart() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
// Start trace event only on the first frame after encoder is paused.
if (!encoder_paused_and_dropped_frame_) {
@@ -738,7 +747,7 @@
encoder_paused_and_dropped_frame_ = true;
}
-void ViEEncoder::TraceFrameDropEnd() {
+void VideoStreamEncoder::TraceFrameDropEnd() {
RTC_DCHECK_RUN_ON(&encoder_queue_);
// End trace event on first frame after encoder resumes, if frame was dropped.
if (encoder_paused_and_dropped_frame_) {
@@ -747,8 +756,8 @@
encoder_paused_and_dropped_frame_ = false;
}
-void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
- int64_t time_when_posted_us) {
+void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
+ int64_t time_when_posted_us) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
if (pre_encode_callback_)
@@ -824,7 +833,7 @@
video_sender_.AddVideoFrame(out_frame, nullptr);
}
-void ViEEncoder::SendKeyFrame() {
+void VideoStreamEncoder::SendKeyFrame() {
if (!encoder_queue_.IsCurrent()) {
encoder_queue_.PostTask([this] { SendKeyFrame(); });
return;
@@ -833,7 +842,7 @@
video_sender_.IntraFrameRequest(0);
}
-EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
+EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage(
const EncodedImage& encoded_image,
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation) {
@@ -858,7 +867,7 @@
return result;
}
-void ViEEncoder::OnDroppedFrame() {
+void VideoStreamEncoder::OnDroppedFrame() {
encoder_queue_.PostTask([this] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
if (quality_scaler_)
@@ -866,12 +875,13 @@
});
}
-void ViEEncoder::SendStatistics(uint32_t bit_rate, uint32_t frame_rate) {
+void VideoStreamEncoder::SendStatistics(uint32_t bit_rate,
+ uint32_t frame_rate) {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate);
}
-void ViEEncoder::OnReceivedIntraFrameRequest(size_t stream_index) {
+void VideoStreamEncoder::OnReceivedIntraFrameRequest(size_t stream_index) {
if (!encoder_queue_.IsCurrent()) {
encoder_queue_.PostTask(
[this, stream_index] { OnReceivedIntraFrameRequest(stream_index); });
@@ -883,9 +893,9 @@
video_sender_.IntraFrameRequest(stream_index);
}
-void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
- uint8_t fraction_lost,
- int64_t round_trip_time_ms) {
+void VideoStreamEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
+ uint8_t fraction_lost,
+ int64_t round_trip_time_ms) {
if (!encoder_queue_.IsCurrent()) {
encoder_queue_.PostTask(
[this, bitrate_bps, fraction_lost, round_trip_time_ms] {
@@ -917,7 +927,7 @@
}
}
-void ViEEncoder::AdaptDown(AdaptReason reason) {
+void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
AdaptationRequest adaptation_request = {
last_frame_info_->pixel_count(),
@@ -1008,7 +1018,7 @@
LOG(LS_INFO) << GetConstAdaptCounter().ToString();
}
-void ViEEncoder::AdaptUp(AdaptReason reason) {
+void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
const AdaptCounter& adapt_counter = GetConstAdaptCounter();
@@ -1096,7 +1106,7 @@
LOG(LS_INFO) << adapt_counter.ToString();
}
-void ViEEncoder::UpdateAdaptationStats(AdaptReason reason) {
+void VideoStreamEncoder::UpdateAdaptationStats(AdaptReason reason) {
switch (reason) {
case kCpu:
stats_proxy_->OnCpuAdaptationChanged(GetActiveCounts(kCpu),
@@ -1109,8 +1119,10 @@
}
}
-ViEEncoder::AdaptCounts ViEEncoder::GetActiveCounts(AdaptReason reason) {
- ViEEncoder::AdaptCounts counts = GetConstAdaptCounter().Counts(reason);
+VideoStreamEncoder::AdaptCounts VideoStreamEncoder::GetActiveCounts(
+ AdaptReason reason) {
+ VideoStreamEncoder::AdaptCounts counts =
+ GetConstAdaptCounter().Counts(reason);
switch (reason) {
case kCpu:
if (!IsFramerateScalingEnabled(degradation_preference_))
@@ -1132,46 +1144,48 @@
return counts;
}
-ViEEncoder::AdaptCounter& ViEEncoder::GetAdaptCounter() {
+VideoStreamEncoder::AdaptCounter& VideoStreamEncoder::GetAdaptCounter() {
return adapt_counters_[degradation_preference_];
}
-const ViEEncoder::AdaptCounter& ViEEncoder::GetConstAdaptCounter() {
+const VideoStreamEncoder::AdaptCounter&
+VideoStreamEncoder::GetConstAdaptCounter() {
return adapt_counters_[degradation_preference_];
}
// Class holding adaptation information.
-ViEEncoder::AdaptCounter::AdaptCounter() {
+VideoStreamEncoder::AdaptCounter::AdaptCounter() {
fps_counters_.resize(kScaleReasonSize);
resolution_counters_.resize(kScaleReasonSize);
static_assert(kScaleReasonSize == 2, "Update MoveCount.");
}
-ViEEncoder::AdaptCounter::~AdaptCounter() {}
+VideoStreamEncoder::AdaptCounter::~AdaptCounter() {}
-std::string ViEEncoder::AdaptCounter::ToString() const {
+std::string VideoStreamEncoder::AdaptCounter::ToString() const {
std::stringstream ss;
ss << "Downgrade counts: fps: {" << ToString(fps_counters_);
ss << "}, resolution: {" << ToString(resolution_counters_) << "}";
return ss.str();
}
-ViEEncoder::AdaptCounts ViEEncoder::AdaptCounter::Counts(int reason) const {
+VideoStreamEncoder::AdaptCounts VideoStreamEncoder::AdaptCounter::Counts(
+ int reason) const {
AdaptCounts counts;
counts.fps = fps_counters_[reason];
counts.resolution = resolution_counters_[reason];
return counts;
}
-void ViEEncoder::AdaptCounter::IncrementFramerate(int reason) {
+void VideoStreamEncoder::AdaptCounter::IncrementFramerate(int reason) {
++(fps_counters_[reason]);
}
-void ViEEncoder::AdaptCounter::IncrementResolution(int reason) {
+void VideoStreamEncoder::AdaptCounter::IncrementResolution(int reason) {
++(resolution_counters_[reason]);
}
-void ViEEncoder::AdaptCounter::DecrementFramerate(int reason) {
+void VideoStreamEncoder::AdaptCounter::DecrementFramerate(int reason) {
if (fps_counters_[reason] == 0) {
// Balanced mode: Adapt up is in a different order, switch reason.
// E.g. framerate adapt down: quality (2), framerate adapt up: cpu (3).
@@ -1188,7 +1202,7 @@
RTC_DCHECK_GE(fps_counters_[reason], 0);
}
-void ViEEncoder::AdaptCounter::DecrementResolution(int reason) {
+void VideoStreamEncoder::AdaptCounter::DecrementResolution(int reason) {
if (resolution_counters_[reason] == 0) {
// Balanced mode: Adapt up is in a different order, switch reason.
RTC_DCHECK_GT(TotalCount(reason), 0) << "No downgrade for reason.";
@@ -1200,45 +1214,47 @@
RTC_DCHECK_GE(resolution_counters_[reason], 0);
}
-void ViEEncoder::AdaptCounter::DecrementFramerate(int reason, int cur_fps) {
+void VideoStreamEncoder::AdaptCounter::DecrementFramerate(int reason,
+ int cur_fps) {
DecrementFramerate(reason);
// Reset if at max fps (i.e. in case of fewer steps up than down).
if (cur_fps == std::numeric_limits<int>::max())
std::fill(fps_counters_.begin(), fps_counters_.end(), 0);
}
-int ViEEncoder::AdaptCounter::FramerateCount() const {
+int VideoStreamEncoder::AdaptCounter::FramerateCount() const {
return Count(fps_counters_);
}
-int ViEEncoder::AdaptCounter::ResolutionCount() const {
+int VideoStreamEncoder::AdaptCounter::ResolutionCount() const {
return Count(resolution_counters_);
}
-int ViEEncoder::AdaptCounter::FramerateCount(int reason) const {
+int VideoStreamEncoder::AdaptCounter::FramerateCount(int reason) const {
return fps_counters_[reason];
}
-int ViEEncoder::AdaptCounter::ResolutionCount(int reason) const {
+int VideoStreamEncoder::AdaptCounter::ResolutionCount(int reason) const {
return resolution_counters_[reason];
}
-int ViEEncoder::AdaptCounter::TotalCount(int reason) const {
+int VideoStreamEncoder::AdaptCounter::TotalCount(int reason) const {
return FramerateCount(reason) + ResolutionCount(reason);
}
-int ViEEncoder::AdaptCounter::Count(const std::vector<int>& counters) const {
+int VideoStreamEncoder::AdaptCounter::Count(
+ const std::vector<int>& counters) const {
return std::accumulate(counters.begin(), counters.end(), 0);
}
-void ViEEncoder::AdaptCounter::MoveCount(std::vector<int>* counters,
- int from_reason) {
+void VideoStreamEncoder::AdaptCounter::MoveCount(std::vector<int>* counters,
+ int from_reason) {
int to_reason = (from_reason + 1) % kScaleReasonSize;
++((*counters)[to_reason]);
--((*counters)[from_reason]);
}
-std::string ViEEncoder::AdaptCounter::ToString(
+std::string VideoStreamEncoder::AdaptCounter::ToString(
const std::vector<int>& counters) const {
std::stringstream ss;
for (size_t reason = 0; reason < kScaleReasonSize; ++reason) {
diff --git a/webrtc/video/vie_encoder.h b/webrtc/video/video_stream_encoder.h
similarity index 91%
rename from webrtc/video/vie_encoder.h
rename to webrtc/video/video_stream_encoder.h
index 6e9234f..c554e11 100644
--- a/webrtc/video/vie_encoder.h
+++ b/webrtc/video/video_stream_encoder.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_VIDEO_VIE_ENCODER_H_
-#define WEBRTC_VIDEO_VIE_ENCODER_H_
+#ifndef WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
+#define WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
#include <map>
#include <memory>
@@ -40,18 +40,18 @@
class SendStatisticsProxy;
class VideoBitrateAllocationObserver;
-// VieEncoder represent a video encoder that accepts raw video frames as input
-// and produces an encoded bit stream.
+// VideoStreamEncoder represent a video encoder that accepts raw video frames as
+// input and produces an encoded bit stream.
// Usage:
// Instantiate.
// Call SetSink.
// Call SetSource.
// Call ConfigureEncoder with the codec settings.
// Call Stop() when done.
-class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
- public EncodedImageCallback,
- public VCMSendStatisticsCallback,
- public AdaptationObserverInterface {
+class VideoStreamEncoder : public rtc::VideoSinkInterface<VideoFrame>,
+ public EncodedImageCallback,
+ public VCMSendStatisticsCallback,
+ public AdaptationObserverInterface {
public:
// Interface for receiving encoded video frames and notifications about
// configuration changes.
@@ -73,13 +73,13 @@
// Downscale framerate at most 4 times.
static const int kMaxCpuFramerateDowngrades = 4;
- ViEEncoder(uint32_t number_of_cores,
- SendStatisticsProxy* stats_proxy,
- const VideoSendStream::Config::EncoderSettings& settings,
- rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
- EncodedFrameObserver* encoder_timing,
- std::unique_ptr<OveruseFrameDetector> overuse_detector);
- ~ViEEncoder();
+ VideoStreamEncoder(uint32_t number_of_cores,
+ SendStatisticsProxy* stats_proxy,
+ const VideoSendStream::Config::EncoderSettings& settings,
+ rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
+ EncodedFrameObserver* encoder_timing,
+ std::unique_ptr<OveruseFrameDetector> overuse_detector);
+ ~VideoStreamEncoder();
// RegisterProcessThread register |module_process_thread| with those objects
// that use it. Registration has to happen on the thread where
// |module_process_thread| was created (libjingle's worker thread).
@@ -243,7 +243,7 @@
ProcessThread* module_process_thread_;
rtc::ThreadChecker module_process_thread_checker_;
// |thread_checker_| checks that public methods that are related to lifetime
- // of ViEEncoder are called on the same thread.
+ // of VideoStreamEncoder are called on the same thread.
rtc::ThreadChecker thread_checker_;
VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
@@ -308,9 +308,9 @@
// destroyed first to make sure no tasks are run that use other members.
rtc::TaskQueue encoder_queue_;
- RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
+ RTC_DISALLOW_COPY_AND_ASSIGN(VideoStreamEncoder);
};
} // namespace webrtc
-#endif // WEBRTC_VIDEO_VIE_ENCODER_H_
+#endif // WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/video_stream_encoder_unittest.cc
similarity index 82%
rename from webrtc/video/vie_encoder_unittest.cc
rename to webrtc/video/video_stream_encoder_unittest.cc
index 09ac4c9..d7d09db 100644
--- a/webrtc/video/vie_encoder_unittest.cc
+++ b/webrtc/video/video_stream_encoder_unittest.cc
@@ -26,7 +26,7 @@
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
#include "webrtc/video/send_statistics_proxy.h"
-#include "webrtc/video/vie_encoder.h"
+#include "webrtc/video/video_stream_encoder.h"
namespace {
// TODO(kthelgason): Lower this limit when better testing
@@ -93,21 +93,22 @@
int last_target_framerate_fps_ GUARDED_BY(lock_);
};
-class ViEEncoderUnderTest : public ViEEncoder {
+class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
public:
- ViEEncoderUnderTest(SendStatisticsProxy* stats_proxy,
+ VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy,
const VideoSendStream::Config::EncoderSettings& settings)
- : ViEEncoder(1 /* number_of_cores */,
- stats_proxy,
- settings,
- nullptr /* pre_encode_callback */,
- nullptr /* encoder_timing */,
- std::unique_ptr<OveruseFrameDetector>(
- overuse_detector_proxy_ = new CpuOveruseDetectorProxy(
- GetCpuOveruseOptions(settings.full_overuse_time),
- this,
- nullptr,
- stats_proxy))) {}
+ : VideoStreamEncoder(
+ 1 /* number_of_cores */,
+ stats_proxy,
+ settings,
+ nullptr /* pre_encode_callback */,
+ nullptr /* encoder_timing */,
+ std::unique_ptr<OveruseFrameDetector>(
+ overuse_detector_proxy_ = new CpuOveruseDetectorProxy(
+ GetCpuOveruseOptions(settings.full_overuse_time),
+ this,
+ nullptr,
+ stats_proxy))) {}
void PostTaskAndWait(bool down, AdaptReason reason) {
rtc::Event event(false, false);
@@ -258,11 +259,11 @@
} // namespace
-class ViEEncoderTest : public ::testing::Test {
+class VideoStreamEncoderTest : public ::testing::Test {
public:
static const int kDefaultTimeoutMs = 30 * 1000;
- ViEEncoderTest()
+ VideoStreamEncoderTest()
: video_send_config_(VideoSendStream::Config(nullptr)),
codec_width_(320),
codec_height_(240),
@@ -299,18 +300,18 @@
void ConfigureEncoder(VideoEncoderConfig video_encoder_config,
bool nack_enabled) {
- if (vie_encoder_)
- vie_encoder_->Stop();
- vie_encoder_.reset(new ViEEncoderUnderTest(
+ if (video_stream_encoder_)
+ video_stream_encoder_->Stop();
+ video_stream_encoder_.reset(new VideoStreamEncoderUnderTest(
stats_proxy_.get(), video_send_config_.encoder_settings));
- vie_encoder_->SetSink(&sink_, false /* rotation_applied */);
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */);
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainFramerate);
- vie_encoder_->SetStartBitrate(kTargetBitrateBps);
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, nack_enabled);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->SetStartBitrate(kTargetBitrateBps);
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, nack_enabled);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
}
void ResetEncoder(const std::string& payload_name,
@@ -555,7 +556,7 @@
bool force_init_encode_failed_ GUARDED_BY(local_crit_sect_) = false;
};
- class TestSink : public ViEEncoder::EncoderSink {
+ class TestSink : public VideoStreamEncoder::EncoderSink {
public:
explicit TestSink(TestEncoder* test_encoder)
: test_encoder_(test_encoder), encoded_frame_event_(false, false) {}
@@ -659,49 +660,49 @@
std::unique_ptr<MockableSendStatisticsProxy> stats_proxy_;
TestSink sink_;
AdaptingFrameForwarder video_source_;
- std::unique_ptr<ViEEncoderUnderTest> vie_encoder_;
+ std::unique_ptr<VideoStreamEncoderUnderTest> video_stream_encoder_;
rtc::ScopedFakeClock fake_clock_;
};
-TEST_F(ViEEncoderTest, EncodeOneFrame) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, EncodeOneFrame) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
rtc::Event frame_destroyed_event(false, false);
video_source_.IncomingCapturedFrame(CreateFrame(1, &frame_destroyed_event));
WaitForEncodedFrame(1);
EXPECT_TRUE(frame_destroyed_event.Wait(kDefaultTimeoutMs));
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DropsFramesBeforeFirstOnBitrateUpdated) {
+TEST_F(VideoStreamEncoderTest, DropsFramesBeforeFirstOnBitrateUpdated) {
// Dropped since no target bitrate has been set.
rtc::Event frame_destroyed_event(false, false);
video_source_.IncomingCapturedFrame(CreateFrame(1, &frame_destroyed_event));
EXPECT_TRUE(frame_destroyed_event.Wait(kDefaultTimeoutMs));
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
WaitForEncodedFrame(2);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DropsFramesWhenRateSetToZero) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, DropsFramesWhenRateSetToZero) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
WaitForEncodedFrame(1);
- vie_encoder_->OnBitrateUpdated(0, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(0, 0, 0);
// Dropped since bitrate is zero.
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(3, nullptr));
WaitForEncodedFrame(3);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DropsFramesWithSameOrOldNtpTimestamp) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, DropsFramesWithSameOrOldNtpTimestamp) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
WaitForEncodedFrame(1);
@@ -710,24 +711,24 @@
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
WaitForEncodedFrame(2);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DropsFrameAfterStop) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, DropsFrameAfterStop) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
WaitForEncodedFrame(1);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
sink_.SetExpectNoFrames();
rtc::Event frame_destroyed_event(false, false);
video_source_.IncomingCapturedFrame(CreateFrame(2, &frame_destroyed_event));
EXPECT_TRUE(frame_destroyed_event.Wait(kDefaultTimeoutMs));
}
-TEST_F(ViEEncoderTest, DropsPendingFramesOnSlowEncode) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, DropsPendingFramesOnSlowEncode) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
fake_encoder_.BlockNextEncode();
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -739,11 +740,12 @@
fake_encoder_.ContinueEncode();
WaitForEncodedFrame(3);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, ConfigureEncoderTriggersOnEncoderConfigurationChanged) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest,
+ ConfigureEncoderTriggersOnEncoderConfigurationChanged) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
EXPECT_EQ(0, sink_.number_of_reconfigurations());
// Capture a frame and wait for it to synchronize with the encoder thread.
@@ -756,8 +758,9 @@
VideoEncoderConfig video_encoder_config;
test::FillEncoderConfiguration(1, &video_encoder_config);
video_encoder_config.min_transmit_bitrate_bps = 9999;
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, true /* nack_enabled */);
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength,
+ true /* nack_enabled */);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
@@ -765,11 +768,11 @@
EXPECT_EQ(2, sink_.number_of_reconfigurations());
EXPECT_EQ(9999, sink_.last_min_transmit_bitrate());
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, FrameResolutionChangeReconfigureEncoder) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, FrameResolutionChangeReconfigureEncoder) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -789,15 +792,15 @@
EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height);
EXPECT_EQ(2, sink_.number_of_reconfigurations());
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, Vp8ResilienceIsOffFor1S1TLWithNackEnabled) {
+TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor1S1TLWithNackEnabled) {
const bool kNackEnabled = true;
const size_t kNumStreams = 1;
const size_t kNumTl = 1;
ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -809,15 +812,15 @@
EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers);
// Resilience is off for no temporal layers with nack on.
EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, Vp8ResilienceIsOffFor2S1TlWithNackEnabled) {
+TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor2S1TlWithNackEnabled) {
const bool kNackEnabled = true;
const size_t kNumStreams = 2;
const size_t kNumTl = 1;
ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -829,15 +832,15 @@
EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers);
// Resilience is off for no temporal layers and >1 streams with nack on.
EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, Vp8ResilienceIsOnFor1S1TLWithNackDisabled) {
+TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S1TLWithNackDisabled) {
const bool kNackEnabled = false;
const size_t kNumStreams = 1;
const size_t kNumTl = 1;
ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -849,15 +852,15 @@
EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers);
// Resilience is on for no temporal layers with nack off.
EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, Vp8ResilienceIsOnFor1S2TlWithNackEnabled) {
+TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S2TlWithNackEnabled) {
const bool kNackEnabled = true;
const size_t kNumStreams = 1;
const size_t kNumTl = 2;
ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Capture a frame and wait for it to synchronize with the encoder thread.
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
@@ -869,45 +872,45 @@
EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers);
// Resilience is on for temporal layers.
EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SwitchSourceDeregisterEncoderAsSink) {
+TEST_F(VideoStreamEncoderTest, SwitchSourceDeregisterEncoderAsSink) {
EXPECT_TRUE(video_source_.has_sinks());
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
EXPECT_FALSE(video_source_.has_sinks());
EXPECT_TRUE(new_video_source.has_sinks());
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SinkWantsRotationApplied) {
+TEST_F(VideoStreamEncoderTest, SinkWantsRotationApplied) {
EXPECT_FALSE(video_source_.sink_wants().rotation_applied);
- vie_encoder_->SetSink(&sink_, true /*rotation_applied*/);
+ video_stream_encoder_->SetSink(&sink_, true /*rotation_applied*/);
EXPECT_TRUE(video_source_.sink_wants().rotation_applied);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SinkWantsFromOveruseDetector) {
- const int kMaxDowngrades = ViEEncoder::kMaxCpuResolutionDowngrades;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, SinkWantsFromOveruseDetector) {
+ const int kMaxDowngrades = VideoStreamEncoder::kMaxCpuResolutionDowngrades;
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
VerifyNoLimitation(video_source_.sink_wants());
int frame_width = 1280;
int frame_height = 720;
- // Trigger CPU overuse kMaxCpuDowngrades times. Every time, ViEEncoder should
- // request lower resolution.
+ // Trigger CPU overuse kMaxCpuDowngrades times. Every time, VideoStreamEncoder
+ // should request lower resolution.
for (int i = 1; i <= kMaxDowngrades; ++i) {
video_source_.IncomingCapturedFrame(
CreateFrame(i, frame_width, frame_height));
WaitForEncodedFrame(i);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
EXPECT_LT(video_source_.sink_wants().max_pixel_count,
@@ -925,7 +928,7 @@
video_source_.IncomingCapturedFrame(
CreateFrame(kMaxDowngrades + 1, frame_width, frame_height));
WaitForEncodedFrame(kMaxDowngrades + 1);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
EXPECT_EQ(video_source_.sink_wants().target_pixel_count,
current_wants.target_pixel_count);
EXPECT_EQ(video_source_.sink_wants().max_pixel_count,
@@ -935,7 +938,7 @@
stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger CPU normal use.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
EXPECT_EQ(frame_width * frame_height * 5 / 3,
video_source_.sink_wants().target_pixel_count.value_or(0));
EXPECT_EQ(frame_width * frame_height * 4,
@@ -944,20 +947,22 @@
EXPECT_EQ(kMaxDowngrades + 1,
stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, TestMaxCpuResolutionDowngrades_BalancedMode_NoFpsLimit) {
- const int kMaxDowngrades = ViEEncoder::kMaxCpuResolutionDowngrades;
+TEST_F(VideoStreamEncoderTest,
+ TestMaxCpuResolutionDowngrades_BalancedMode_NoFpsLimit) {
+ const int kMaxDowngrades = VideoStreamEncoder::kMaxCpuResolutionDowngrades;
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
@@ -967,7 +972,7 @@
for (int i = 1; i <= kMaxDowngrades; ++i) {
source.IncomingCapturedFrame(CreateFrame(t, kWidth, kHeight));
sink_.WaitForEncodedFrame(t++);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
VerifyFpsMaxResolutionLt(source.sink_wants(), source.last_wants());
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(i, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
@@ -977,7 +982,7 @@
rtc::VideoSinkWants last_wants = source.sink_wants();
source.IncomingCapturedFrame(CreateFrame(t, kWidth, kHeight));
sink_.WaitForEncodedFrame(t++);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
VerifyFpsEqResolutionEq(source.sink_wants(), last_wants);
EXPECT_EQ(last_wants.max_pixel_count, source.sink_wants().max_pixel_count);
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
@@ -988,7 +993,7 @@
for (int i = 1; i <= kMaxDowngrades; ++i) {
source.IncomingCapturedFrame(CreateFrame(t, kWidth, kHeight));
sink_.WaitForEncodedFrame(t++);
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
EXPECT_GT(source.sink_wants().max_pixel_count, last_wants.max_pixel_count);
EXPECT_EQ(kMaxDowngrades + i,
@@ -998,10 +1003,10 @@
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SinkWantsStoredByDegradationPreference) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
VerifyNoLimitation(video_source_.sink_wants());
const int kFrameWidth = 1280;
@@ -1016,7 +1021,7 @@
frame_timestamp += kFrameIntervalMs;
// Trigger CPU overuse.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(
CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(frame_timestamp);
@@ -1032,7 +1037,7 @@
// Set new source, switch to maintain-resolution.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
@@ -1046,7 +1051,7 @@
stats.input_frame_rate = kInputFps;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
new_video_source.IncomingCapturedFrame(
CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(frame_timestamp);
@@ -1059,12 +1064,12 @@
EXPECT_LT(new_video_source.sink_wants().max_framerate_fps, kInputFps);
// Turn off degradation completely.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
VerifyNoLimitation(new_video_source.sink_wants());
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
new_video_source.IncomingCapturedFrame(
CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(frame_timestamp);
@@ -1074,7 +1079,7 @@
VerifyNoLimitation(new_video_source.sink_wants());
// Calling SetSource with resolution scaling enabled apply the old SinkWants.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
EXPECT_LT(new_video_source.sink_wants().max_pixel_count,
@@ -1084,7 +1089,7 @@
new_video_source.sink_wants().max_framerate_fps);
// Calling SetSource with framerate scaling enabled apply the old SinkWants.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
@@ -1092,11 +1097,11 @@
new_video_source.sink_wants().max_pixel_count);
EXPECT_LT(new_video_source.sink_wants().max_framerate_fps, kInputFps);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, StatsTracksQualityAdaptationStats) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, StatsTracksQualityAdaptationStats) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1107,7 +1112,7 @@
EXPECT_EQ(0, stats.number_of_quality_adapt_changes);
// Trigger adapt down.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
@@ -1116,7 +1121,7 @@
EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
// Trigger adapt up.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
@@ -1125,11 +1130,11 @@
EXPECT_EQ(2, stats.number_of_quality_adapt_changes);
EXPECT_EQ(0, stats.number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, StatsTracksCpuAdaptationStats) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, StatsTracksCpuAdaptationStats) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1140,7 +1145,7 @@
EXPECT_EQ(0, stats.number_of_cpu_adapt_changes);
// Trigger CPU overuse.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
@@ -1149,7 +1154,7 @@
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Trigger CPU normal use.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
@@ -1158,11 +1163,11 @@
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
EXPECT_EQ(0, stats.number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1174,7 +1179,7 @@
EXPECT_EQ(0, stats.number_of_cpu_adapt_changes);
// Trigger CPU overuse.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
stats = stats_proxy_->GetStats();
@@ -1184,7 +1189,7 @@
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
@@ -1196,7 +1201,7 @@
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Set adaptation disabled.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
@@ -1208,7 +1213,7 @@
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Set adaptation back to enabled.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
@@ -1220,7 +1225,7 @@
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Trigger CPU normal use.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
new_video_source.IncomingCapturedFrame(CreateFrame(6, kWidth, kHeight));
WaitForEncodedFrame(6);
stats = stats_proxy_->GetStats();
@@ -1229,11 +1234,11 @@
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
EXPECT_EQ(0, stats.number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1246,8 +1251,9 @@
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(&new_video_source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &new_video_source,
+ VideoSendStream::DegradationPreference::kBalanced);
new_video_source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
@@ -1257,7 +1263,7 @@
EXPECT_EQ(0, stats.number_of_quality_adapt_changes);
// Trigger adapt down.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
stats = stats_proxy_->GetStats();
@@ -1266,8 +1272,9 @@
EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
// Set new source with adaptation still enabled.
- vie_encoder_->SetSource(&new_video_source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &new_video_source,
+ VideoSendStream::DegradationPreference::kBalanced);
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
@@ -1277,7 +1284,7 @@
EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
// Disable resolution scaling.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
@@ -1289,11 +1296,12 @@
EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
EXPECT_EQ(0, stats.number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, QualityAdaptationStatsAreResetWhenScalerIsDisabled) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest,
+ QualityAdaptationStatsAreResetWhenScalerIsDisabled) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1305,7 +1313,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt down.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
@@ -1313,7 +1321,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger overuse.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
@@ -1322,7 +1330,7 @@
// Set source with adaptation still enabled but quality scaler is off.
fake_encoder_.SetQualityScaling(false);
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainFramerate);
@@ -1332,11 +1340,12 @@
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, StatsTracksCpuAdaptationStatsWhenSwitchingSource) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest,
+ StatsTracksCpuAdaptationStatsWhenSwitchingSource) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1350,7 +1359,7 @@
EXPECT_EQ(0, stats.number_of_cpu_adapt_changes);
// Trigger CPU overuse, should now adapt down.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
stats = stats_proxy_->GetStats();
@@ -1360,7 +1369,7 @@
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
@@ -1373,7 +1382,7 @@
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Set cpu adaptation by frame dropping.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
new_video_source.IncomingCapturedFrame(
@@ -1390,7 +1399,7 @@
VideoSendStream::Stats mock_stats = stats_proxy_->GetStats();
mock_stats.input_frame_rate = 30;
stats_proxy_->SetMockStats(mock_stats);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
stats_proxy_->ResetMockStats();
new_video_source.IncomingCapturedFrame(
@@ -1404,7 +1413,7 @@
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
// Disable CPU adaptation.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
new_video_source.IncomingCapturedFrame(
@@ -1418,7 +1427,7 @@
// Try to trigger overuse. Should not succeed.
stats_proxy_->SetMockStats(mock_stats);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
stats_proxy_->ResetMockStats();
stats = stats_proxy_->GetStats();
@@ -1427,7 +1436,7 @@
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
// Switch back the source with resolution adaptation enabled.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainFramerate);
video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight));
@@ -1438,7 +1447,7 @@
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
// Trigger CPU normal usage.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
stats = stats_proxy_->GetStats();
@@ -1447,7 +1456,7 @@
EXPECT_EQ(3, stats.number_of_cpu_adapt_changes);
// Back to the source with adaptation off, set it back to maintain-resolution.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
new_video_source.IncomingCapturedFrame(
@@ -1460,7 +1469,7 @@
EXPECT_EQ(3, stats.number_of_cpu_adapt_changes);
// Trigger CPU normal usage.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
@@ -1470,11 +1479,11 @@
EXPECT_EQ(4, stats.number_of_cpu_adapt_changes);
EXPECT_EQ(0, stats.number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, StatsTracksPreferredBitrate) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest, StatsTracksPreferredBitrate) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 1280;
const int kHeight = 720;
@@ -1485,13 +1494,14 @@
EXPECT_EQ(video_encoder_config_.max_bitrate_bps,
stats.preferred_media_bitrate_bps);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
+TEST_F(VideoStreamEncoderTest,
+ ScalingUpAndDownDoesNothingWithMaintainResolution) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Expect no scaling to begin with.
VerifyNoLimitation(video_source_.sink_wants());
@@ -1500,7 +1510,7 @@
WaitForEncodedFrame(1);
// Trigger scale down.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
@@ -1511,12 +1521,12 @@
// Set resolution scaling disabled.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
// Trigger scale down.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
@@ -1525,7 +1535,7 @@
new_video_source.sink_wants().max_pixel_count);
// Trigger scale up.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
@@ -1533,17 +1543,18 @@
EXPECT_EQ(std::numeric_limits<int>::max(),
new_video_source.sink_wants().max_pixel_count);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SkipsSameAdaptDownRequest_MaintainFramerateMode) {
+TEST_F(VideoStreamEncoderTest,
+ SkipsSameAdaptDownRequest_MaintainFramerateMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1553,36 +1564,37 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
const int kLastMaxPixelCount = source.sink_wants().max_pixel_count;
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt down for same input resolution, expect no change.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
EXPECT_EQ(kLastMaxPixelCount, source.sink_wants().max_pixel_count);
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
+TEST_F(VideoStreamEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(1);
VerifyNoLimitation(source.sink_wants());
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
@@ -1591,7 +1603,7 @@
// Trigger adapt down for same input resolution, expect no change.
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
sink_.WaitForEncodedFrame(2);
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
EXPECT_EQ(kLastMaxPixelCount, source.sink_wants().max_pixel_count);
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
@@ -1599,22 +1611,23 @@
// Trigger adapt down for larger input resolution, expect no change.
source.IncomingCapturedFrame(CreateFrame(3, kWidth + 1, kHeight + 1));
sink_.WaitForEncodedFrame(3);
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
EXPECT_EQ(kLastMaxPixelCount, source.sink_wants().max_pixel_count);
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, NoChangeForInitialNormalUsage_MaintainFramerateMode) {
+TEST_F(VideoStreamEncoderTest,
+ NoChangeForInitialNormalUsage_MaintainFramerateMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1624,22 +1637,23 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, NoChangeForInitialNormalUsage_MaintainResolutionMode) {
+TEST_F(VideoStreamEncoderTest,
+ NoChangeForInitialNormalUsage_MaintainResolutionMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainResolution preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1649,23 +1663,24 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
+TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
@@ -1675,23 +1690,23 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
+TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kDegradationDisabled preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kDegradationDisabled);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1702,24 +1717,25 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptsResolutionForLowQuality_MaintainFramerateMode) {
+TEST_F(VideoStreamEncoderTest,
+ AdaptsResolutionForLowQuality_MaintainFramerateMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1729,7 +1745,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1737,20 +1753,21 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptsFramerateForLowQuality_MaintainResolutionMode) {
+TEST_F(VideoStreamEncoderTest,
+ AdaptsFramerateForLowQuality_MaintainResolutionMode) {
const int kWidth = 1280;
const int kHeight = 720;
const int kInputFps = 30;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
VideoSendStream::Stats stats = stats_proxy_->GetStats();
stats.input_frame_rate = kInputFps;
@@ -1762,37 +1779,37 @@
VerifyNoLimitation(video_source_.sink_wants());
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
sink_.WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(video_source_.sink_wants(), kWidth * kHeight);
// Enable kMaintainResolution preference.
test::FrameForwarder new_video_source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
VerifyNoLimitation(new_video_source.sink_wants());
// Trigger adapt down, expect reduced framerate.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
sink_.WaitForEncodedFrame(3);
VerifyFpsLtResolutionMax(new_video_source.sink_wants(), kInputFps);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(new_video_source.sink_wants());
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DoesNotScaleBelowSetResolutionLimit) {
+TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) {
const int kWidth = 1280;
const int kHeight = 720;
const size_t kNumFrames = 10;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable adapter, expected input resolutions when downscaling:
// 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (min resolution limit)
@@ -1808,7 +1825,7 @@
// Trigger scale down.
rtc::VideoSinkWants last_wants = video_source_.sink_wants();
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
EXPECT_GE(video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame);
if (video_source_.sink_wants().max_pixel_count < last_wants.max_pixel_count)
@@ -1819,19 +1836,19 @@
stats_proxy_->GetStats().number_of_quality_adapt_changes);
EXPECT_GT(downscales, 0);
}
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest,
+TEST_F(VideoStreamEncoderTest,
AdaptsResolutionUpAndDownTwiceOnOveruse_MaintainFramerateMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1841,7 +1858,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1849,7 +1866,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
VerifyNoLimitation(source.sink_wants());
@@ -1857,7 +1874,7 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1865,27 +1882,28 @@
EXPECT_EQ(3, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest,
+TEST_F(VideoStreamEncoderTest,
AdaptsResolutionUpAndDownTwiceForLowQuality_BalancedMode_NoFpsLimit) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
@@ -1894,7 +1912,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
sink_.WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1902,7 +1920,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
VerifyNoLimitation(source.sink_wants());
@@ -1910,7 +1928,7 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
sink_.WaitForEncodedFrame(4);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1918,26 +1936,26 @@
EXPECT_EQ(3, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no restriction.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest,
+TEST_F(VideoStreamEncoderTest,
AdaptsResolutionOnOveruseAndLowQuality_MaintainFramerateMode) {
const int kWidth = 1280;
const int kHeight = 720;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
@@ -1949,7 +1967,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, expect scaled down resolution (960x540).
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
@@ -1959,7 +1977,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, expect scaled down resolution (640x360).
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
VerifyFpsMaxResolutionLt(source.sink_wants(), source.last_wants());
@@ -1970,7 +1988,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, max cpu downgrades reached, expect no change.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
VerifyFpsEqResolutionEq(source.sink_wants(), last_wants);
@@ -1980,7 +1998,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt down, expect scaled down resolution (480x270).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
WaitForEncodedFrame(5);
VerifyFpsMaxResolutionLt(source.sink_wants(), source.last_wants());
@@ -1990,7 +2008,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, expect upscaled resolution (640x360).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
source.IncomingCapturedFrame(CreateFrame(6, kWidth, kHeight));
WaitForEncodedFrame(6);
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
@@ -2000,7 +2018,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, expect upscaled resolution (960x540).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
source.IncomingCapturedFrame(CreateFrame(7, kWidth, kHeight));
WaitForEncodedFrame(7);
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
@@ -2011,7 +2029,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, no cpu downgrades, expect no change (960x540).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
source.IncomingCapturedFrame(CreateFrame(8, kWidth, kHeight));
WaitForEncodedFrame(8);
VerifyFpsEqResolutionEq(source.sink_wants(), last_wants);
@@ -2021,7 +2039,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt up, expect no restriction (1280x720).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
source.IncomingCapturedFrame(CreateFrame(9, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
@@ -2031,29 +2049,29 @@
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, CpuLimitedHistogramIsReported) {
+TEST_F(VideoStreamEncoderTest, CpuLimitedHistogramIsReported) {
const int kWidth = 640;
const int kHeight = 360;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
WaitForEncodedFrame(i);
}
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
video_source_.IncomingCapturedFrame(CreateFrame(
SendStatisticsProxy::kMinRequiredMetricsSamples + i, kWidth, kHeight));
WaitForEncodedFrame(SendStatisticsProxy::kMinRequiredMetricsSamples + i);
}
- vie_encoder_->Stop();
- vie_encoder_.reset();
+ video_stream_encoder_->Stop();
+ video_stream_encoder_.reset();
stats_proxy_.reset();
EXPECT_EQ(1,
@@ -2062,12 +2080,13 @@
1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50));
}
-TEST_F(ViEEncoderTest, CpuLimitedHistogramIsNotReportedForDisabledDegradation) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest,
+ CpuLimitedHistogramIsNotReportedForDisabledDegradation) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kWidth = 640;
const int kHeight = 360;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kDegradationDisabled);
@@ -2076,17 +2095,17 @@
WaitForEncodedFrame(i);
}
- vie_encoder_->Stop();
- vie_encoder_.reset();
+ video_stream_encoder_->Stop();
+ video_stream_encoder_.reset();
stats_proxy_.reset();
EXPECT_EQ(0,
metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent"));
}
-TEST_F(ViEEncoderTest, CallsBitrateObserver) {
+TEST_F(VideoStreamEncoderTest, CallsBitrateObserver) {
MockBitrateObserver bitrate_observer;
- vie_encoder_->SetBitrateObserver(&bitrate_observer);
+ video_stream_encoder_->SetBitrateObserver(&bitrate_observer);
const int kDefaultFps = 30;
const BitrateAllocation expected_bitrate =
@@ -2096,7 +2115,7 @@
// First called on bitrate updated, then again on first frame.
EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(expected_bitrate))
.Times(2);
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
const int64_t kStartTimeMs = 1;
video_source_.IncomingCapturedFrame(
@@ -2121,25 +2140,26 @@
kStartTimeMs + kProcessIntervalMs, codec_width_, codec_height_));
WaitForEncodedFrame(kStartTimeMs + kProcessIntervalMs);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, OveruseDetectorUpdatedOnReconfigureAndAdaption) {
+TEST_F(VideoStreamEncoderTest, OveruseDetectorUpdatedOnReconfigureAndAdaption) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
const int kFramerate = 24;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
// Insert a single frame, triggering initial configuration.
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kDefaultFramerate);
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kDefaultFramerate);
// Trigger reconfigure encoder (without resetting the entire instance).
VideoEncoderConfig video_encoder_config;
@@ -2147,22 +2167,23 @@
video_encoder_config.number_of_streams = 1;
video_encoder_config.video_stream_factory =
new rtc::RefCountedObject<VideoStreamFactory>(1, kFramerate);
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, false);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
// Detector should be updated with fps limit from codec config.
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kFramerate);
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kFramerate);
// Trigger overuse, max framerate should be reduced.
VideoSendStream::Stats stats = stats_proxy_->GetStats();
stats.input_frame_rate = kFramerate;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuOveruse();
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
int adapted_framerate =
- vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
EXPECT_LT(adapted_framerate, kFramerate);
// Trigger underuse, max framerate should go back to codec configured fps.
@@ -2170,23 +2191,25 @@
stats = stats_proxy_->GetStats();
stats.input_frame_rate = adapted_framerate / 2;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuNormalUsage();
- vie_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kFramerate);
+ video_stream_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kFramerate);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, OveruseDetectorUpdatedRespectsFramerateAfterUnderuse) {
+TEST_F(VideoStreamEncoderTest,
+ OveruseDetectorUpdatedRespectsFramerateAfterUnderuse) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
const int kLowFramerate = 15;
const int kHighFramerate = 25;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
// Trigger initial configuration.
@@ -2196,21 +2219,22 @@
video_encoder_config.video_stream_factory =
new rtc::RefCountedObject<VideoStreamFactory>(1, kLowFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, false);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kLowFramerate);
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kLowFramerate);
// Trigger overuse, max framerate should be reduced.
VideoSendStream::Stats stats = stats_proxy_->GetStats();
stats.input_frame_rate = kLowFramerate;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuOveruse();
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
int adapted_framerate =
- vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
EXPECT_LT(adapted_framerate, kLowFramerate);
// Reconfigure the encoder with a new (higher max framerate), max fps should
@@ -2218,33 +2242,36 @@
video_encoder_config.video_stream_factory =
new rtc::RefCountedObject<VideoStreamFactory>(1, kHighFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, false);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- adapted_framerate);
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ adapted_framerate);
// Trigger underuse, max framerate should go back to codec configured fps.
stats = stats_proxy_->GetStats();
stats.input_frame_rate = adapted_framerate;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuNormalUsage();
- vie_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kHighFramerate);
+ video_stream_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kHighFramerate);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, OveruseDetectorUpdatedOnDegradationPreferenceChange) {
+TEST_F(VideoStreamEncoderTest,
+ OveruseDetectorUpdatedOnDegradationPreferenceChange) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
const int kFramerate = 24;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
// Trigger initial configuration.
@@ -2254,37 +2281,39 @@
video_encoder_config.video_stream_factory =
new rtc::RefCountedObject<VideoStreamFactory>(1, kFramerate);
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, false);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kFramerate);
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kFramerate);
// Trigger overuse, max framerate should be reduced.
VideoSendStream::Stats stats = stats_proxy_->GetStats();
stats.input_frame_rate = kFramerate;
stats_proxy_->SetMockStats(stats);
- vie_encoder_->TriggerCpuOveruse();
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
int adapted_framerate =
- vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate();
EXPECT_LT(adapted_framerate, kFramerate);
// Change degradation preference to not enable framerate scaling. Target
// framerate should be changed to codec defined limit.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
- EXPECT_EQ(vie_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
- kFramerate);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
+ EXPECT_EQ(
+ video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
+ kFramerate);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DropsFramesAndScalesWhenBitrateIsTooLow) {
+TEST_F(VideoStreamEncoderTest, DropsFramesAndScalesWhenBitrateIsTooLow) {
const int kTooLowBitrateForFrameSizeBps = 10000;
- vie_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
const int kWidth = 640;
const int kHeight = 360;
@@ -2307,12 +2336,13 @@
EXPECT_LT(video_source_.sink_wants().max_pixel_count, last_pixel_count);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, NumberOfDroppedFramesLimitedWhenBitrateIsTooLow) {
+TEST_F(VideoStreamEncoderTest,
+ NumberOfDroppedFramesLimitedWhenBitrateIsTooLow) {
const int kTooLowBitrateForFrameSizeBps = 10000;
- vie_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
const int kWidth = 640;
const int kHeight = 360;
@@ -2329,16 +2359,17 @@
// Expect the sink_wants to specify a scaled frame.
EXPECT_LT(video_source_.sink_wants().max_pixel_count, kWidth * kHeight);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) {
+TEST_F(VideoStreamEncoderTest,
+ InitialFrameDropOffWithMaintainResolutionPreference) {
const int kWidth = 640;
const int kHeight = 360;
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
// Set degradation preference.
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
@@ -2346,36 +2377,37 @@
// Frame should not be dropped, even if it's too large.
WaitForEncodedFrame(1);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) {
+TEST_F(VideoStreamEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) {
const int kWidth = 640;
const int kHeight = 360;
fake_encoder_.SetQualityScaling(false);
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
// Force quality scaler reconfiguration by resetting the source.
- vie_encoder_->SetSource(&video_source_,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &video_source_,
+ VideoSendStream::DegradationPreference::kBalanced);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// Frame should not be dropped, even if it's too large.
WaitForEncodedFrame(1);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
fake_encoder_.SetQualityScaling(true);
}
-TEST_F(ViEEncoderTest,
+TEST_F(VideoStreamEncoderTest,
ResolutionNotAdaptedForTooSmallFrame_MaintainFramerateMode) {
const int kTooSmallWidth = 10;
const int kTooSmallHeight = 10;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(
+ video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
@@ -2383,24 +2415,26 @@
// Trigger adapt down, too small frame, expect no change.
source.IncomingCapturedFrame(CreateFrame(1, kTooSmallWidth, kTooSmallHeight));
WaitForEncodedFrame(1);
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, ResolutionNotAdaptedForTooSmallFrame_BalancedMode) {
+TEST_F(VideoStreamEncoderTest,
+ ResolutionNotAdaptedForTooSmallFrame_BalancedMode) {
const int kTooSmallWidth = 10;
const int kTooSmallHeight = 10;
const int kFpsLimit = 7;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
test::FrameForwarder source;
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
@@ -2408,7 +2442,7 @@
// Trigger adapt down, expect limited framerate.
source.IncomingCapturedFrame(CreateFrame(1, kTooSmallWidth, kTooSmallHeight));
WaitForEncodedFrame(1);
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
VerifyFpsEqResolutionMax(source.sink_wants(), kFpsLimit);
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate);
@@ -2417,35 +2451,37 @@
// Trigger adapt down, too small frame, expect no change.
source.IncomingCapturedFrame(CreateFrame(2, kTooSmallWidth, kTooSmallHeight));
WaitForEncodedFrame(2);
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
VerifyFpsEqResolutionMax(source.sink_wants(), kFpsLimit);
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate);
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, FailingInitEncodeDoesntCauseCrash) {
+TEST_F(VideoStreamEncoderTest, FailingInitEncodeDoesntCauseCrash) {
fake_encoder_.ForceInitEncodeFailure(true);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
ResetEncoder("VP8", 2, 1, true, false);
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
video_source_.IncomingCapturedFrame(
CreateFrame(1, kFrameWidth, kFrameHeight));
ExpectDroppedFrame();
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
// TODO(sprang): Extend this with fps throttling and any "balanced" extensions.
-TEST_F(ViEEncoderTest, AdaptsResolutionOnOveruse_MaintainFramerateMode) {
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+TEST_F(VideoStreamEncoderTest,
+ AdaptsResolutionOnOveruse_MaintainFramerateMode) {
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
// Enabled default VideoAdapter downscaling. First step is 3/4, not 3/5 as
- // requested by ViEEncoder::VideoSourceProxy::RequestResolutionLowerThan().
+ // requested by
+ // VideoStreamEncoder::VideoSourceProxy::RequestResolutionLowerThan().
video_source_.set_adaptation_enabled(true);
video_source_.IncomingCapturedFrame(
@@ -2453,27 +2489,28 @@
WaitForEncodedFrame(kFrameWidth, kFrameHeight);
// Trigger CPU overuse, downscale by 3/4.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(
CreateFrame(2, kFrameWidth, kFrameHeight));
WaitForEncodedFrame((kFrameWidth * 3) / 4, (kFrameHeight * 3) / 4);
// Trigger CPU normal use, return to original resolution.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
video_source_.IncomingCapturedFrame(
CreateFrame(3, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(kFrameWidth, kFrameHeight);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptsFramerateOnOveruse_MaintainResolutionMode) {
+TEST_F(VideoStreamEncoderTest,
+ AdaptsFramerateOnOveruse_MaintainResolutionMode) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
int kFrameIntervalMs = rtc::kNumMillisecsPerSec / max_framerate_;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
- vie_encoder_->SetSource(
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
video_source_.set_adaptation_enabled(true);
@@ -2485,7 +2522,7 @@
WaitForEncodedFrame(timestamp_ms);
// Try to trigger overuse. No fps estimate available => no effect.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
// Insert frames for one second to get a stable estimate.
for (int i = 0; i < max_framerate_; ++i) {
@@ -2496,7 +2533,7 @@
}
// Trigger CPU overuse, reduce framerate by 2/3.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
int num_frames_dropped = 0;
for (int i = 0; i < max_framerate_; ++i) {
timestamp_ms += kFrameIntervalMs;
@@ -2515,7 +2552,7 @@
kErrorMargin);
// Trigger CPU overuse, reduce framerate by 2/3 again.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
num_frames_dropped = 0;
for (int i = 0; i < max_framerate_; ++i) {
timestamp_ms += kFrameIntervalMs;
@@ -2531,7 +2568,7 @@
kErrorMargin);
// Go back up one step.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
num_frames_dropped = 0;
for (int i = 0; i < max_framerate_; ++i) {
timestamp_ms += kFrameIntervalMs;
@@ -2547,7 +2584,7 @@
kErrorMargin);
// Go back up to original mode.
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
num_frames_dropped = 0;
for (int i = 0; i < max_framerate_; ++i) {
timestamp_ms += kFrameIntervalMs;
@@ -2561,10 +2598,10 @@
}
EXPECT_NEAR(num_frames_dropped, 0, kErrorMargin);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DoesntAdaptDownPastMinFramerate) {
+TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) {
const int kFramerateFps = 5;
const int kFrameIntervalMs = rtc::kNumMillisecsPerSec / kFramerateFps;
const int kMinFpsFrameInterval = rtc::kNumMillisecsPerSec / kMinFramerateFps;
@@ -2575,8 +2612,8 @@
// disable frame dropping and make testing easier.
ResetEncoder("VP8", 1, 2, true, true);
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
- vie_encoder_->SetSource(
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
video_source_.set_adaptation_enabled(true);
@@ -2584,7 +2621,7 @@
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
// Trigger overuse as much as we can.
- for (int i = 0; i < ViEEncoder::kMaxCpuResolutionDowngrades; ++i) {
+ for (int i = 0; i < VideoStreamEncoder::kMaxCpuResolutionDowngrades; ++i) {
// Insert frames to get a new fps estimate...
for (int j = 0; j < kFramerateFps; ++j) {
video_source_.IncomingCapturedFrame(
@@ -2592,7 +2629,7 @@
timestamp_ms += kFrameIntervalMs;
}
// ...and then try to adapt again.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
}
// Drain any frame in the pipeline.
@@ -2606,21 +2643,23 @@
WaitForEncodedFrame(timestamp_ms);
}
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptsResolutionAndFramerateForLowQuality_BalancedMode) {
+TEST_F(VideoStreamEncoderTest,
+ AdaptsResolutionAndFramerateForLowQuality_BalancedMode) {
const int kWidth = 1280;
const int kHeight = 720;
const int64_t kFrameIntervalMs = 150;
int64_t timestamp_ms = kFrameIntervalMs;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@@ -2630,7 +2669,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution (960x540@30fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2640,7 +2679,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution (640x360@30fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2650,7 +2689,7 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect reduced fps (640x360@15fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2660,7 +2699,7 @@
EXPECT_EQ(3, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution (480x270@15fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2670,7 +2709,7 @@
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Restrict bitrate, trigger adapt down, expect reduced fps (480x270@10fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2680,7 +2719,7 @@
EXPECT_EQ(5, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect scaled down resolution (320x180@10fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2690,7 +2729,7 @@
EXPECT_EQ(6, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect reduced fps (320x180@7fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2701,7 +2740,7 @@
EXPECT_EQ(7, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, min resolution reached, expect no change.
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2711,7 +2750,7 @@
EXPECT_EQ(7, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt down, expect expect increased fps (320x180@10fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2721,7 +2760,7 @@
EXPECT_EQ(8, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect upscaled resolution (480x270@10fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2731,7 +2770,7 @@
EXPECT_EQ(9, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Increase bitrate, trigger adapt up, expect increased fps (480x270@15fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2741,7 +2780,7 @@
EXPECT_EQ(10, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect upscaled resolution (640x360@15fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2751,7 +2790,7 @@
EXPECT_EQ(11, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect increased fps (640x360@30fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2761,7 +2800,7 @@
EXPECT_EQ(12, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect upscaled resolution (960x540@30fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2771,7 +2810,7 @@
EXPECT_EQ(13, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no restriction (1280x720fps@30fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@@ -2782,25 +2821,26 @@
EXPECT_EQ(14, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_EQ(14, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
+TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
const int kWidth = 1280;
const int kHeight = 720;
const int64_t kFrameIntervalMs = 150;
int64_t timestamp_ms = kFrameIntervalMs;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@@ -2813,7 +2853,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, expect scaled down resolution (960x540@30fps).
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2826,7 +2866,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, expect scaled down resolution (640x360@30fps).
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2839,7 +2879,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt down, expect reduced fps (640x360@15fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2852,7 +2892,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, expect increased fps (640x360@30fps).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2865,7 +2905,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt up, expect upscaled resolution (960x540@30fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2878,7 +2918,7 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, expect no restriction (1280x720fps@30fps).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@@ -2892,27 +2932,29 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Resolution) {
+TEST_F(VideoStreamEncoderTest,
+ AdaptWithTwoReasonsAndDifferentOrder_Resolution) {
const int kWidth = 640;
const int kHeight = 360;
const int kFpsLimit = 15;
const int64_t kFrameIntervalMs = 150;
int64_t timestamp_ms = kFrameIntervalMs;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
- vie_encoder_->SetSource(&source,
- VideoSendStream::DegradationPreference::kBalanced);
+ video_stream_encoder_->SetSource(
+ &source,
+ VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@@ -2925,7 +2967,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt down, expect scaled down framerate (640x360@15fps).
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2938,7 +2980,7 @@
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt down, expect scaled down resolution (480x270@15fps).
- vie_encoder_->TriggerQualityLow();
+ video_stream_encoder_->TriggerQualityLow();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2951,7 +2993,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger cpu adapt up, expect upscaled resolution (640x360@15fps).
- vie_encoder_->TriggerCpuNormalUsage();
+ video_stream_encoder_->TriggerCpuNormalUsage();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2964,7 +3006,7 @@
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger quality adapt up, expect increased fps (640x360@30fps).
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -2977,15 +3019,15 @@
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
// Trigger adapt up, expect no change.
- vie_encoder_->TriggerQualityHigh();
+ video_stream_encoder_->TriggerQualityHigh();
VerifyNoLimitation(source.sink_wants());
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) {
+TEST_F(VideoStreamEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) {
// Simulates simulcast behavior and makes highest stream resolutions divisible
// by 4.
class CroppingVideoStreamFactory
@@ -3025,16 +3067,16 @@
const int kAdaptedFrameHeight = 808;
const int kFramerate = 24;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Trigger reconfigure encoder (without resetting the entire instance).
VideoEncoderConfig video_encoder_config;
video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
video_encoder_config.number_of_streams = 1;
video_encoder_config.video_stream_factory =
new rtc::RefCountedObject<CroppingVideoStreamFactory>(1, kFramerate);
- vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
- kMaxPayloadLength, false);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
video_source_.set_adaptation_enabled(true);
@@ -3043,21 +3085,21 @@
WaitForEncodedFrame(kFrameWidth, kFrameHeight);
// Trigger CPU overuse, downscale by 3/4.
- vie_encoder_->TriggerCpuOveruse();
+ video_stream_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(
CreateFrame(2, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(kAdaptedFrameWidth, kAdaptedFrameHeight);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, PeriodicallyUpdatesChannelParameters) {
+TEST_F(VideoStreamEncoderTest, PeriodicallyUpdatesChannelParameters) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
const int kLowFps = 2;
const int kHighFps = 30;
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
max_framerate_ = kLowFps;
@@ -3071,7 +3113,7 @@
}
// Make sure encoder is updated with new target.
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_source_.IncomingCapturedFrame(
CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
WaitForEncodedFrame(timestamp_ms);
@@ -3099,21 +3141,21 @@
// before.
EXPECT_GT(fake_encoder_.GetConfiguredInputFramerate(), kLowFps);
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, DoesNotUpdateBitrateAllocationWhenSuspended) {
+TEST_F(VideoStreamEncoderTest, DoesNotUpdateBitrateAllocationWhenSuspended) {
const int kFrameWidth = 1280;
const int kFrameHeight = 720;
const int kTargetBitrateBps = 1000000;
MockBitrateObserver bitrate_observer;
- vie_encoder_->SetBitrateObserver(&bitrate_observer);
+ video_stream_encoder_->SetBitrateObserver(&bitrate_observer);
EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(1);
// Initial bitrate update.
- vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
- vie_encoder_->WaitUntilTaskQueueIsIdle();
+ video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ video_stream_encoder_->WaitUntilTaskQueueIsIdle();
// Insert a first video frame, causes another bitrate update.
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
@@ -3123,7 +3165,7 @@
WaitForEncodedFrame(timestamp_ms);
// Next, simulate video suspension due to pacer queue overrun.
- vie_encoder_->OnBitrateUpdated(0, 0, 1);
+ video_stream_encoder_->OnBitrateUpdated(0, 0, 1);
// Skip ahead until a new periodic parameter update should have occured.
timestamp_ms += vcm::VCMProcessTimer::kDefaultProcessIntervalMs;
@@ -3137,7 +3179,7 @@
CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
ExpectDroppedFrame();
- vie_encoder_->Stop();
+ video_stream_encoder_->Stop();
}
} // namespace webrtc