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}
This commit is contained in:
parent
8435e5518d
commit
cc3d442469
@ -499,8 +499,8 @@ TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
|
|||||||
switch (test_phase_) {
|
switch (test_phase_) {
|
||||||
case TestPhase::kStart:
|
case TestPhase::kStart:
|
||||||
if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
|
if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
|
||||||
// On adapting down, ViEEncoder::VideoSourceProxy will set only the
|
// On adapting down, VideoStreamEncoder::VideoSourceProxy will set
|
||||||
// max pixel count, leaving the target unset.
|
// only the max pixel count, leaving the target unset.
|
||||||
test_phase_ = TestPhase::kAdaptedDown;
|
test_phase_ = TestPhase::kAdaptedDown;
|
||||||
} else {
|
} else {
|
||||||
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
ADD_FAILURE() << "Got unexpected adaptation request, max res = "
|
||||||
|
|||||||
@ -2272,7 +2272,7 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) {
|
|||||||
send_stream = fake_call_->GetVideoSendStreams().front();
|
send_stream = fake_call_->GetVideoSendStreams().front();
|
||||||
// We have a new fake send stream, so it doesn't remember the old sink wants.
|
// We have a new fake send stream, so it doesn't remember the old sink wants.
|
||||||
// In practice, it will be populated from
|
// 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);
|
send_stream->InjectVideoSinkWants(wants);
|
||||||
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
|
EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
|
||||||
ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams());
|
ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams());
|
||||||
|
|||||||
@ -102,7 +102,7 @@ class DelayedEncoder : public test::FakeEncoder {
|
|||||||
// This class implements a multi-threaded fake encoder by posting
|
// This class implements a multi-threaded fake encoder by posting
|
||||||
// FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
|
// FakeH264Encoder::Encode(.) tasks to |queue1_| and |queue2_|, in an
|
||||||
// alternating fashion. The class itself does not need to be thread safe,
|
// 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 {
|
class MultithreadedFakeH264Encoder : public test::FakeH264Encoder {
|
||||||
public:
|
public:
|
||||||
explicit MultithreadedFakeH264Encoder(Clock* clock);
|
explicit MultithreadedFakeH264Encoder(Clock* clock);
|
||||||
|
|||||||
@ -44,8 +44,8 @@ rtc_static_library("video") {
|
|||||||
"video_send_stream.h",
|
"video_send_stream.h",
|
||||||
"video_stream_decoder.cc",
|
"video_stream_decoder.cc",
|
||||||
"video_stream_decoder.h",
|
"video_stream_decoder.h",
|
||||||
"vie_encoder.cc",
|
"video_stream_encoder.cc",
|
||||||
"vie_encoder.h",
|
"video_stream_encoder.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (!build_with_chromium && is_clang) {
|
if (!build_with_chromium && is_clang) {
|
||||||
@ -257,7 +257,7 @@ if (rtc_include_tests) {
|
|||||||
"stream_synchronization_unittest.cc",
|
"stream_synchronization_unittest.cc",
|
||||||
"video_receive_stream_unittest.cc",
|
"video_receive_stream_unittest.cc",
|
||||||
"video_send_stream_tests.cc",
|
"video_send_stream_tests.cc",
|
||||||
"vie_encoder_unittest.cc",
|
"video_stream_encoder_unittest.cc",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":video",
|
":video",
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#include "webrtc/video/encoder_rtcp_feedback.h"
|
#include "webrtc/video/encoder_rtcp_feedback.h"
|
||||||
|
|
||||||
#include "webrtc/rtc_base/checks.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;
|
static const int kMinKeyFrameRequestIntervalMs = 300;
|
||||||
|
|
||||||
@ -19,10 +19,10 @@ namespace webrtc {
|
|||||||
|
|
||||||
EncoderRtcpFeedback::EncoderRtcpFeedback(Clock* clock,
|
EncoderRtcpFeedback::EncoderRtcpFeedback(Clock* clock,
|
||||||
const std::vector<uint32_t>& ssrcs,
|
const std::vector<uint32_t>& ssrcs,
|
||||||
ViEEncoder* encoder)
|
VideoStreamEncoder* encoder)
|
||||||
: clock_(clock),
|
: clock_(clock),
|
||||||
ssrcs_(ssrcs),
|
ssrcs_(ssrcs),
|
||||||
vie_encoder_(encoder),
|
video_stream_encoder_(encoder),
|
||||||
time_last_intra_request_ms_(ssrcs.size(), -1) {
|
time_last_intra_request_ms_(ssrcs.size(), -1) {
|
||||||
RTC_DCHECK(!ssrcs.empty());
|
RTC_DCHECK(!ssrcs.empty());
|
||||||
}
|
}
|
||||||
@ -49,8 +49,8 @@ void EncoderRtcpFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
|||||||
RTC_DCHECK(HasSsrc(ssrc));
|
RTC_DCHECK(HasSsrc(ssrc));
|
||||||
size_t index = GetStreamIndex(ssrc);
|
size_t index = GetStreamIndex(ssrc);
|
||||||
{
|
{
|
||||||
// TODO(mflodman): Move to ViEEncoder after some more changes making it
|
// TODO(mflodman): Move to VideoStreamEncoder after some more changes making
|
||||||
// easier to test there.
|
// it easier to test there.
|
||||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
if (time_last_intra_request_ms_[index] + kMinKeyFrameRequestIntervalMs >
|
if (time_last_intra_request_ms_[index] + kMinKeyFrameRequestIntervalMs >
|
||||||
@ -60,7 +60,7 @@ void EncoderRtcpFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
|||||||
time_last_intra_request_ms_[index] = now_ms;
|
time_last_intra_request_ms_[index] = now_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
vie_encoder_->OnReceivedIntraFrameRequest(index);
|
video_stream_encoder_->OnReceivedIntraFrameRequest(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ViEEncoder;
|
class VideoStreamEncoder;
|
||||||
|
|
||||||
class EncoderRtcpFeedback : public RtcpIntraFrameObserver {
|
class EncoderRtcpFeedback : public RtcpIntraFrameObserver {
|
||||||
public:
|
public:
|
||||||
EncoderRtcpFeedback(Clock* clock,
|
EncoderRtcpFeedback(Clock* clock,
|
||||||
const std::vector<uint32_t>& ssrcs,
|
const std::vector<uint32_t>& ssrcs,
|
||||||
ViEEncoder* encoder);
|
VideoStreamEncoder* encoder);
|
||||||
void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
|
void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -34,7 +34,7 @@ class EncoderRtcpFeedback : public RtcpIntraFrameObserver {
|
|||||||
|
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
const std::vector<uint32_t> ssrcs_;
|
const std::vector<uint32_t> ssrcs_;
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
|
|
||||||
rtc::CriticalSection crit_;
|
rtc::CriticalSection crit_;
|
||||||
std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(crit_);
|
std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(crit_);
|
||||||
|
|||||||
@ -16,22 +16,23 @@
|
|||||||
#include "webrtc/test/gmock.h"
|
#include "webrtc/test/gmock.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
#include "webrtc/video/send_statistics_proxy.h"
|
#include "webrtc/video/send_statistics_proxy.h"
|
||||||
#include "webrtc/video/vie_encoder.h"
|
#include "webrtc/video/video_stream_encoder.h"
|
||||||
|
|
||||||
using ::testing::NiceMock;
|
using ::testing::NiceMock;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class MockVieEncoder : public ViEEncoder {
|
class MockVideoStreamEncoder : public VideoStreamEncoder {
|
||||||
public:
|
public:
|
||||||
explicit MockVieEncoder(SendStatisticsProxy* send_stats_proxy)
|
explicit MockVideoStreamEncoder(SendStatisticsProxy* send_stats_proxy)
|
||||||
: ViEEncoder(1,
|
: VideoStreamEncoder(1,
|
||||||
send_stats_proxy,
|
send_stats_proxy,
|
||||||
VideoSendStream::Config::EncoderSettings("fake", 0, nullptr),
|
VideoSendStream::Config::EncoderSettings("fake", 0,
|
||||||
|
nullptr),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
std::unique_ptr<OveruseFrameDetector>()) {}
|
std::unique_ptr<OveruseFrameDetector>()) {}
|
||||||
~MockVieEncoder() { Stop(); }
|
~MockVideoStreamEncoder() { Stop(); }
|
||||||
|
|
||||||
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
|
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
|
||||||
};
|
};
|
||||||
@ -54,7 +55,7 @@ class VieKeyRequestTest : public ::testing::Test {
|
|||||||
|
|
||||||
SimulatedClock simulated_clock_;
|
SimulatedClock simulated_clock_;
|
||||||
SendStatisticsProxy send_stats_proxy_;
|
SendStatisticsProxy send_stats_proxy_;
|
||||||
MockVieEncoder encoder_;
|
MockVideoStreamEncoder encoder_;
|
||||||
EncoderRtcpFeedback encoder_rtcp_feedback_;
|
EncoderRtcpFeedback encoder_rtcp_feedback_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -717,8 +717,8 @@ void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::SetAdaptationStats(
|
void SendStatisticsProxy::SetAdaptationStats(
|
||||||
const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
const ViEEncoder::AdaptCounts& quality_counts) {
|
const VideoStreamEncoder::AdaptCounts& quality_counts) {
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_);
|
SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_);
|
||||||
SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_);
|
SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_);
|
||||||
@ -726,24 +726,24 @@ void SendStatisticsProxy::SetAdaptationStats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::OnCpuAdaptationChanged(
|
void SendStatisticsProxy::OnCpuAdaptationChanged(
|
||||||
const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
const ViEEncoder::AdaptCounts& quality_counts) {
|
const VideoStreamEncoder::AdaptCounts& quality_counts) {
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
++stats_.number_of_cpu_adapt_changes;
|
++stats_.number_of_cpu_adapt_changes;
|
||||||
UpdateAdaptationStats(cpu_counts, quality_counts);
|
UpdateAdaptationStats(cpu_counts, quality_counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::OnQualityAdaptationChanged(
|
void SendStatisticsProxy::OnQualityAdaptationChanged(
|
||||||
const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
const ViEEncoder::AdaptCounts& quality_counts) {
|
const VideoStreamEncoder::AdaptCounts& quality_counts) {
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
++stats_.number_of_quality_adapt_changes;
|
++stats_.number_of_quality_adapt_changes;
|
||||||
UpdateAdaptationStats(cpu_counts, quality_counts);
|
UpdateAdaptationStats(cpu_counts, quality_counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::UpdateAdaptationStats(
|
void SendStatisticsProxy::UpdateAdaptationStats(
|
||||||
const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
const ViEEncoder::AdaptCounts& quality_counts) {
|
const VideoStreamEncoder::AdaptCounts& quality_counts) {
|
||||||
cpu_downscales_ = cpu_counts.resolution;
|
cpu_downscales_ = cpu_counts.resolution;
|
||||||
quality_downscales_ = quality_counts.resolution;
|
quality_downscales_ = quality_counts.resolution;
|
||||||
|
|
||||||
@ -753,7 +753,8 @@ void SendStatisticsProxy::UpdateAdaptationStats(
|
|||||||
stats_.bw_limited_framerate = quality_counts.fps > 0;
|
stats_.bw_limited_framerate = quality_counts.fps > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendStatisticsProxy::SetAdaptTimer(const ViEEncoder::AdaptCounts& counts,
|
void SendStatisticsProxy::SetAdaptTimer(
|
||||||
|
const VideoStreamEncoder::AdaptCounts& counts,
|
||||||
StatsTimer* timer) {
|
StatsTimer* timer) {
|
||||||
if (counts.resolution >= 0 || counts.fps >= 0) {
|
if (counts.resolution >= 0 || counts.fps >= 0) {
|
||||||
// Adaptation enabled.
|
// Adaptation enabled.
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
#include "webrtc/video/overuse_frame_detector.h"
|
#include "webrtc/video/overuse_frame_detector.h"
|
||||||
#include "webrtc/video/report_block_stats.h"
|
#include "webrtc/video/report_block_stats.h"
|
||||||
#include "webrtc/video/stats_counter.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"
|
#include "webrtc/video_send_stream.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -58,13 +58,15 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
|
|||||||
void OnIncomingFrame(int width, int height);
|
void OnIncomingFrame(int width, int height);
|
||||||
|
|
||||||
// Adaptation stats.
|
// Adaptation stats.
|
||||||
void SetAdaptationStats(const ViEEncoder::AdaptCounts& cpu_counts,
|
void SetAdaptationStats(
|
||||||
const ViEEncoder::AdaptCounts& quality_counts);
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
void OnCpuAdaptationChanged(const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& quality_counts);
|
||||||
const ViEEncoder::AdaptCounts& quality_counts);
|
void OnCpuAdaptationChanged(
|
||||||
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
|
const VideoStreamEncoder::AdaptCounts& quality_counts);
|
||||||
void OnQualityAdaptationChanged(
|
void OnQualityAdaptationChanged(
|
||||||
const ViEEncoder::AdaptCounts& cpu_counts,
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
const ViEEncoder::AdaptCounts& quality_counts);
|
const VideoStreamEncoder::AdaptCounts& quality_counts);
|
||||||
|
|
||||||
void OnEncoderStatsUpdate(uint32_t framerate, uint32_t bitrate);
|
void OnEncoderStatsUpdate(uint32_t framerate, uint32_t bitrate);
|
||||||
void OnSuspendChange(bool is_suspended);
|
void OnSuspendChange(bool is_suspended);
|
||||||
@ -164,10 +166,12 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
|
|||||||
VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
|
VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||||
|
|
||||||
void SetAdaptTimer(const ViEEncoder::AdaptCounts& counts, StatsTimer* timer)
|
void SetAdaptTimer(const VideoStreamEncoder::AdaptCounts& counts,
|
||||||
|
StatsTimer* timer)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||||
void UpdateAdaptationStats(const ViEEncoder::AdaptCounts& cpu_counts,
|
void UpdateAdaptationStats(
|
||||||
const ViEEncoder::AdaptCounts& quality_counts)
|
const VideoStreamEncoder::AdaptCounts& cpu_counts,
|
||||||
|
const VideoStreamEncoder::AdaptCounts& quality_counts)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||||
|
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
|
|||||||
@ -368,8 +368,8 @@ TEST_F(SendStatisticsProxyTest, OnSendEncodedImageWithoutQpQpSumWontExist) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) {
|
TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_framerate);
|
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_framerate);
|
||||||
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_resolution);
|
EXPECT_FALSE(statistics_proxy_->GetStats().cpu_limited_resolution);
|
||||||
cpu_counts.fps = 1;
|
cpu_counts.fps = 1;
|
||||||
@ -395,8 +395,8 @@ TEST_F(SendStatisticsProxyTest, GetCpuAdaptationStats) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, GetQualityAdaptationStats) {
|
TEST_F(SendStatisticsProxyTest, GetQualityAdaptationStats) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_framerate);
|
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_framerate);
|
||||||
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
|
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
|
||||||
quality_counts.fps = 1;
|
quality_counts.fps = 1;
|
||||||
@ -422,8 +422,8 @@ TEST_F(SendStatisticsProxyTest, GetQualityAdaptationStats) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, GetStatsReportsCpuAdaptChanges) {
|
TEST_F(SendStatisticsProxyTest, GetStatsReportsCpuAdaptChanges) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_cpu_adapt_changes);
|
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||||
|
|
||||||
cpu_counts.resolution = 1;
|
cpu_counts.resolution = 1;
|
||||||
@ -441,8 +441,8 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsCpuAdaptChanges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, GetStatsReportsQualityAdaptChanges) {
|
TEST_F(SendStatisticsProxyTest, GetStatsReportsQualityAdaptChanges) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_quality_adapt_changes);
|
EXPECT_EQ(0, statistics_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||||
|
|
||||||
quality_counts.fps = 1;
|
quality_counts.fps = 1;
|
||||||
@ -474,8 +474,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesNotReported_MinRuntimeNotPassed) {
|
|||||||
// First RTP packet sent.
|
// First RTP packet sent.
|
||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
// Enable adaptation.
|
// Enable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
// Min runtime has not passed.
|
// Min runtime has not passed.
|
||||||
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1);
|
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1);
|
||||||
@ -489,8 +489,8 @@ TEST_F(SendStatisticsProxyTest, ZeroAdaptChangesReported) {
|
|||||||
// First RTP packet sent.
|
// First RTP packet sent.
|
||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
// Enable adaptation.
|
// Enable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
// Min runtime has passed.
|
// Min runtime has passed.
|
||||||
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
|
fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
|
||||||
@ -507,8 +507,8 @@ TEST_F(SendStatisticsProxyTest, CpuAdaptChangesReported) {
|
|||||||
// First RTP packet sent.
|
// First RTP packet sent.
|
||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
// Enable adaptation.
|
// Enable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
// Adapt changes: 1, elapsed time: 10 sec => 6 per minute.
|
// Adapt changes: 1, elapsed time: 10 sec => 6 per minute.
|
||||||
statistics_proxy_->OnCpuAdaptationChanged(cpu_counts, quality_counts);
|
statistics_proxy_->OnCpuAdaptationChanged(cpu_counts, quality_counts);
|
||||||
@ -523,8 +523,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesStatsExcludesDisabledTime) {
|
|||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
|
|
||||||
// Disable quality adaptation.
|
// Disable quality adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.fps = -1;
|
quality_counts.fps = -1;
|
||||||
quality_counts.resolution = -1;
|
quality_counts.resolution = -1;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
@ -591,8 +591,8 @@ TEST_F(SendStatisticsProxyTest, QualityAdaptChangesStatsExcludesSuspendedTime) {
|
|||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
|
|
||||||
// Enable adaptation.
|
// Enable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
// Adapt changes: 2, elapsed time: 20 sec.
|
// Adapt changes: 2, elapsed time: 20 sec.
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(20000);
|
fake_clock_.AdvanceTimeMilliseconds(20000);
|
||||||
@ -625,8 +625,8 @@ TEST_F(SendStatisticsProxyTest, CpuAdaptChangesStatsExcludesSuspendedTime) {
|
|||||||
fake_clock_.AdvanceTimeMilliseconds(30000);
|
fake_clock_.AdvanceTimeMilliseconds(30000);
|
||||||
|
|
||||||
// Enable adaptation.
|
// Enable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
// Adapt changes: 1, elapsed time: 20 sec.
|
// Adapt changes: 1, elapsed time: 20 sec.
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(10000);
|
fake_clock_.AdvanceTimeMilliseconds(10000);
|
||||||
@ -670,8 +670,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesStatsNotStartedIfVideoSuspended) {
|
|||||||
statistics_proxy_->OnSuspendChange(true);
|
statistics_proxy_->OnSuspendChange(true);
|
||||||
|
|
||||||
// Enable adaptation, stats time not started when suspended.
|
// Enable adaptation, stats time not started when suspended.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(10000);
|
fake_clock_.AdvanceTimeMilliseconds(10000);
|
||||||
|
|
||||||
@ -690,8 +690,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesStatsNotStartedIfVideoSuspended) {
|
|||||||
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsRestartsOnFirstSentPacket) {
|
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsRestartsOnFirstSentPacket) {
|
||||||
// Send first packet, adaptation enabled.
|
// Send first packet, adaptation enabled.
|
||||||
// Elapsed time before first packet is sent should be excluded.
|
// Elapsed time before first packet is sent should be excluded.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(10000);
|
fake_clock_.AdvanceTimeMilliseconds(10000);
|
||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
@ -711,8 +711,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesStatsRestartsOnFirstSentPacket) {
|
|||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsStartedAfterFirstSentPacket) {
|
TEST_F(SendStatisticsProxyTest, AdaptChangesStatsStartedAfterFirstSentPacket) {
|
||||||
// Enable and disable adaptation.
|
// Enable and disable adaptation.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(60000);
|
fake_clock_.AdvanceTimeMilliseconds(60000);
|
||||||
cpu_counts.fps = -1;
|
cpu_counts.fps = -1;
|
||||||
@ -743,8 +743,8 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesStatsStartedAfterFirstSentPacket) {
|
|||||||
TEST_F(SendStatisticsProxyTest, AdaptChangesReportedAfterContentSwitch) {
|
TEST_F(SendStatisticsProxyTest, AdaptChangesReportedAfterContentSwitch) {
|
||||||
// First RTP packet sent, cpu adaptation enabled.
|
// First RTP packet sent, cpu adaptation enabled.
|
||||||
UpdateDataCounters(kFirstSsrc);
|
UpdateDataCounters(kFirstSsrc);
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.fps = -1;
|
quality_counts.fps = -1;
|
||||||
quality_counts.resolution = -1;
|
quality_counts.resolution = -1;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
@ -904,8 +904,8 @@ TEST_F(SendStatisticsProxyTest, SentFpsHistogramExcludesSuspendedTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) {
|
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
cpu_counts.resolution = -1;
|
cpu_counts.resolution = -1;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
|
|
||||||
@ -918,8 +918,8 @@ TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramUpdated) {
|
TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramUpdated) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
cpu_counts.resolution = 0;
|
cpu_counts.resolution = 0;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
|
|
||||||
@ -1216,8 +1216,8 @@ TEST_F(SendStatisticsProxyTest,
|
|||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest,
|
TEST_F(SendStatisticsProxyTest,
|
||||||
QualityLimitedHistogramsNotUpdatedWhenDisabled) {
|
QualityLimitedHistogramsNotUpdatedWhenDisabled) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.resolution = -1;
|
quality_counts.resolution = -1;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
EncodedImage encoded_image;
|
EncodedImage encoded_image;
|
||||||
@ -1234,8 +1234,8 @@ TEST_F(SendStatisticsProxyTest,
|
|||||||
|
|
||||||
TEST_F(SendStatisticsProxyTest,
|
TEST_F(SendStatisticsProxyTest,
|
||||||
QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
|
QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.resolution = 0;
|
quality_counts.resolution = 0;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
EncodedImage encoded_image;
|
EncodedImage encoded_image;
|
||||||
@ -1256,8 +1256,8 @@ TEST_F(SendStatisticsProxyTest,
|
|||||||
TEST_F(SendStatisticsProxyTest,
|
TEST_F(SendStatisticsProxyTest,
|
||||||
QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
|
QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
|
||||||
const int kDownscales = 2;
|
const int kDownscales = 2;
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.resolution = kDownscales;
|
quality_counts.resolution = kDownscales;
|
||||||
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
statistics_proxy_->SetAdaptationStats(cpu_counts, quality_counts);
|
||||||
EncodedImage encoded_image;
|
EncodedImage encoded_image;
|
||||||
@ -1295,8 +1295,8 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) {
|
|||||||
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
|
EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
|
||||||
|
|
||||||
// Resolution scaled due to quality.
|
// Resolution scaled due to quality.
|
||||||
ViEEncoder::AdaptCounts cpu_counts;
|
VideoStreamEncoder::AdaptCounts cpu_counts;
|
||||||
ViEEncoder::AdaptCounts quality_counts;
|
VideoStreamEncoder::AdaptCounts quality_counts;
|
||||||
quality_counts.resolution = 1;
|
quality_counts.resolution = 1;
|
||||||
statistics_proxy_->OnQualityAdaptationChanged(cpu_counts, quality_counts);
|
statistics_proxy_->OnQualityAdaptationChanged(cpu_counts, quality_counts);
|
||||||
statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
|
statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
|
||||||
|
|||||||
@ -333,7 +333,7 @@ namespace internal {
|
|||||||
class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
|
class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
|
||||||
public webrtc::OverheadObserver,
|
public webrtc::OverheadObserver,
|
||||||
public webrtc::VCMProtectionCallback,
|
public webrtc::VCMProtectionCallback,
|
||||||
public ViEEncoder::EncoderSink,
|
public VideoStreamEncoder::EncoderSink,
|
||||||
public VideoBitrateAllocationObserver {
|
public VideoBitrateAllocationObserver {
|
||||||
public:
|
public:
|
||||||
VideoSendStreamImpl(SendStatisticsProxy* stats_proxy,
|
VideoSendStreamImpl(SendStatisticsProxy* stats_proxy,
|
||||||
@ -342,7 +342,7 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
|
|||||||
RtpTransportControllerSendInterface* transport,
|
RtpTransportControllerSendInterface* transport,
|
||||||
BitrateAllocator* bitrate_allocator,
|
BitrateAllocator* bitrate_allocator,
|
||||||
SendDelayStats* send_delay_stats,
|
SendDelayStats* send_delay_stats,
|
||||||
ViEEncoder* vie_encoder,
|
VideoStreamEncoder* video_stream_encoder,
|
||||||
RtcEventLog* event_log,
|
RtcEventLog* event_log,
|
||||||
const VideoSendStream::Config* config,
|
const VideoSendStream::Config* config,
|
||||||
int initial_encoder_max_bitrate,
|
int initial_encoder_max_bitrate,
|
||||||
@ -440,7 +440,7 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
|
|||||||
uint32_t encoder_max_bitrate_bps_;
|
uint32_t encoder_max_bitrate_bps_;
|
||||||
uint32_t encoder_target_rate_bps_;
|
uint32_t encoder_target_rate_bps_;
|
||||||
|
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
EncoderRtcpFeedback encoder_feedback_;
|
EncoderRtcpFeedback encoder_feedback_;
|
||||||
ProtectionBitrateCalculator protection_bitrate_calculator_;
|
ProtectionBitrateCalculator protection_bitrate_calculator_;
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ class VideoSendStream::ConstructionTask : public rtc::QueuedTask {
|
|||||||
ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream,
|
ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream,
|
||||||
rtc::Event* done_event,
|
rtc::Event* done_event,
|
||||||
SendStatisticsProxy* stats_proxy,
|
SendStatisticsProxy* stats_proxy,
|
||||||
ViEEncoder* vie_encoder,
|
VideoStreamEncoder* video_stream_encoder,
|
||||||
ProcessThread* module_process_thread,
|
ProcessThread* module_process_thread,
|
||||||
CallStats* call_stats,
|
CallStats* call_stats,
|
||||||
RtpTransportControllerSendInterface* transport,
|
RtpTransportControllerSendInterface* transport,
|
||||||
@ -484,7 +484,7 @@ class VideoSendStream::ConstructionTask : public rtc::QueuedTask {
|
|||||||
: send_stream_(send_stream),
|
: send_stream_(send_stream),
|
||||||
done_event_(done_event),
|
done_event_(done_event),
|
||||||
stats_proxy_(stats_proxy),
|
stats_proxy_(stats_proxy),
|
||||||
vie_encoder_(vie_encoder),
|
video_stream_encoder_(video_stream_encoder),
|
||||||
call_stats_(call_stats),
|
call_stats_(call_stats),
|
||||||
transport_(transport),
|
transport_(transport),
|
||||||
bitrate_allocator_(bitrate_allocator),
|
bitrate_allocator_(bitrate_allocator),
|
||||||
@ -502,16 +502,16 @@ class VideoSendStream::ConstructionTask : public rtc::QueuedTask {
|
|||||||
bool Run() override {
|
bool Run() override {
|
||||||
send_stream_->reset(new VideoSendStreamImpl(
|
send_stream_->reset(new VideoSendStreamImpl(
|
||||||
stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_,
|
stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_,
|
||||||
bitrate_allocator_, send_delay_stats_, vie_encoder_, event_log_,
|
bitrate_allocator_, send_delay_stats_, video_stream_encoder_,
|
||||||
config_, initial_encoder_max_bitrate_, std::move(suspended_ssrcs_),
|
event_log_, config_, initial_encoder_max_bitrate_,
|
||||||
content_type_, keepalive_config_));
|
std::move(suspended_ssrcs_), content_type_, keepalive_config_));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<VideoSendStreamImpl>* const send_stream_;
|
std::unique_ptr<VideoSendStreamImpl>* const send_stream_;
|
||||||
rtc::Event* const done_event_;
|
rtc::Event* const done_event_;
|
||||||
SendStatisticsProxy* const stats_proxy_;
|
SendStatisticsProxy* const stats_proxy_;
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
CallStats* const call_stats_;
|
CallStats* const call_stats_;
|
||||||
RtpTransportControllerSendInterface* const transport_;
|
RtpTransportControllerSendInterface* const transport_;
|
||||||
BitrateAllocator* const bitrate_allocator_;
|
BitrateAllocator* const bitrate_allocator_;
|
||||||
@ -643,15 +643,18 @@ VideoSendStream::VideoSendStream(
|
|||||||
encoder_config.content_type),
|
encoder_config.content_type),
|
||||||
config_(std::move(config)),
|
config_(std::move(config)),
|
||||||
content_type_(encoder_config.content_type) {
|
content_type_(encoder_config.content_type) {
|
||||||
vie_encoder_.reset(
|
video_stream_encoder_.reset(
|
||||||
new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings,
|
new VideoStreamEncoder(num_cpu_cores, &stats_proxy_,
|
||||||
config_.pre_encode_callback, config_.post_encode_callback,
|
config_.encoder_settings,
|
||||||
|
config_.pre_encode_callback,
|
||||||
|
config_.post_encode_callback,
|
||||||
std::unique_ptr<OveruseFrameDetector>()));
|
std::unique_ptr<OveruseFrameDetector>()));
|
||||||
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
|
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
|
||||||
&send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(),
|
&send_stream_, &thread_sync_event_, &stats_proxy_,
|
||||||
module_process_thread, call_stats, transport, bitrate_allocator,
|
video_stream_encoder_.get(), module_process_thread, call_stats, transport,
|
||||||
send_delay_stats, event_log, &config_, encoder_config.max_bitrate_bps,
|
bitrate_allocator, send_delay_stats, event_log, &config_,
|
||||||
suspended_ssrcs, encoder_config.content_type, keepalive_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.
|
// Wait for ConstructionTask to complete so that |send_stream_| can be used.
|
||||||
// |module_process_thread| must be registered and deregistered on the thread
|
// |module_process_thread| must be registered and deregistered on the thread
|
||||||
@ -661,9 +664,9 @@ VideoSendStream::VideoSendStream(
|
|||||||
// TODO(sprang): Enable this also for regular video calls if it works well.
|
// TODO(sprang): Enable this also for regular video calls if it works well.
|
||||||
if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) {
|
if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) {
|
||||||
// Only signal target bitrate for screenshare streams, for now.
|
// 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));
|
ReconfigureVideoEncoder(std::move(encoder_config));
|
||||||
}
|
}
|
||||||
@ -683,8 +686,8 @@ void VideoSendStream::Start() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// It is expected that after VideoSendStream::Start has been called, incoming
|
// It is expected that after VideoSendStream::Start has been called, incoming
|
||||||
// frames are not dropped in ViEEncoder. To ensure this, Start has to be
|
// frames are not dropped in VideoStreamEncoder. To ensure this, Start has to
|
||||||
// synchronized.
|
// be synchronized.
|
||||||
thread_sync_event_.Wait(rtc::Event::kForever);
|
thread_sync_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +702,7 @@ void VideoSendStream::SetSource(
|
|||||||
rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
|
rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
|
||||||
const DegradationPreference& degradation_preference) {
|
const DegradationPreference& degradation_preference) {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
vie_encoder_->SetSource(source, degradation_preference);
|
video_stream_encoder_->SetSource(source, degradation_preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
|
void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
|
||||||
@ -707,7 +710,8 @@ void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
|
|||||||
// ReconfigureVideoEncoder from the network thread.
|
// ReconfigureVideoEncoder from the network thread.
|
||||||
// RTC_DCHECK_RUN_ON(&thread_checker_);
|
// RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
RTC_DCHECK(content_type_ == config.content_type);
|
RTC_DCHECK(content_type_ == config.content_type);
|
||||||
vie_encoder_->ConfigureEncoder(std::move(config), config_.rtp.max_packet_size,
|
video_stream_encoder_->ConfigureEncoder(std::move(config),
|
||||||
|
config_.rtp.max_packet_size,
|
||||||
config_.rtp.nack.rtp_history_ms > 0);
|
config_.rtp.nack.rtp_history_ms > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,8 +731,8 @@ void VideoSendStream::SignalNetworkState(NetworkState state) {
|
|||||||
|
|
||||||
VideoSendStream::RtpStateMap VideoSendStream::StopPermanentlyAndGetRtpStates() {
|
VideoSendStream::RtpStateMap VideoSendStream::StopPermanentlyAndGetRtpStates() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
vie_encoder_->Stop();
|
video_stream_encoder_->Stop();
|
||||||
vie_encoder_->DeRegisterProcessThread();
|
video_stream_encoder_->DeRegisterProcessThread();
|
||||||
VideoSendStream::RtpStateMap state_map;
|
VideoSendStream::RtpStateMap state_map;
|
||||||
send_stream_->DeRegisterProcessThread();
|
send_stream_->DeRegisterProcessThread();
|
||||||
worker_queue_->PostTask(
|
worker_queue_->PostTask(
|
||||||
@ -765,7 +769,7 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
|||||||
RtpTransportControllerSendInterface* transport,
|
RtpTransportControllerSendInterface* transport,
|
||||||
BitrateAllocator* bitrate_allocator,
|
BitrateAllocator* bitrate_allocator,
|
||||||
SendDelayStats* send_delay_stats,
|
SendDelayStats* send_delay_stats,
|
||||||
ViEEncoder* vie_encoder,
|
VideoStreamEncoder* video_stream_encoder,
|
||||||
RtcEventLog* event_log,
|
RtcEventLog* event_log,
|
||||||
const VideoSendStream::Config* config,
|
const VideoSendStream::Config* config,
|
||||||
int initial_encoder_max_bitrate,
|
int initial_encoder_max_bitrate,
|
||||||
@ -788,10 +792,10 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
|||||||
encoder_min_bitrate_bps_(0),
|
encoder_min_bitrate_bps_(0),
|
||||||
encoder_max_bitrate_bps_(initial_encoder_max_bitrate),
|
encoder_max_bitrate_bps_(initial_encoder_max_bitrate),
|
||||||
encoder_target_rate_bps_(0),
|
encoder_target_rate_bps_(0),
|
||||||
vie_encoder_(vie_encoder),
|
video_stream_encoder_(video_stream_encoder),
|
||||||
encoder_feedback_(Clock::GetRealTimeClock(),
|
encoder_feedback_(Clock::GetRealTimeClock(),
|
||||||
config_->rtp.ssrcs,
|
config_->rtp.ssrcs,
|
||||||
vie_encoder),
|
video_stream_encoder),
|
||||||
protection_bitrate_calculator_(Clock::GetRealTimeClock(), this),
|
protection_bitrate_calculator_(Clock::GetRealTimeClock(), this),
|
||||||
bandwidth_observer_(transport->send_side_cc()
|
bandwidth_observer_(transport->send_side_cc()
|
||||||
->GetBitrateController()
|
->GetBitrateController()
|
||||||
@ -887,7 +891,8 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
|||||||
RTC_DCHECK_GE(config_->encoder_settings.payload_type, 0);
|
RTC_DCHECK_GE(config_->encoder_settings.payload_type, 0);
|
||||||
RTC_DCHECK_LE(config_->encoder_settings.payload_type, 127);
|
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
|
// 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
|
// side doesn't support the rotation extension. This allows us to prepare the
|
||||||
@ -900,7 +905,7 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
|||||||
return extension.uri == RtpExtension::kVideoRotationUri;
|
return extension.uri == RtpExtension::kVideoRotationUri;
|
||||||
}) == config_->rtp.extensions.end();
|
}) == config_->rtp.extensions.end();
|
||||||
|
|
||||||
vie_encoder_->SetSink(this, rotation_applied);
|
video_stream_encoder_->SetSink(this, rotation_applied);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSendStreamImpl::RegisterProcessThread(
|
void VideoSendStreamImpl::RegisterProcessThread(
|
||||||
@ -961,7 +966,7 @@ void VideoSendStreamImpl::Start() {
|
|||||||
CheckEncoderActivityTask::kEncoderTimeOutMs);
|
CheckEncoderActivityTask::kEncoderTimeOutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
vie_encoder_->SendKeyFrame();
|
video_stream_encoder_->SendKeyFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSendStreamImpl::Stop() {
|
void VideoSendStreamImpl::Stop() {
|
||||||
@ -977,7 +982,7 @@ void VideoSendStreamImpl::Stop() {
|
|||||||
check_encoder_activity_task_->Stop();
|
check_encoder_activity_task_->Stop();
|
||||||
check_encoder_activity_task_ = nullptr;
|
check_encoder_activity_task_ = nullptr;
|
||||||
}
|
}
|
||||||
vie_encoder_->OnBitrateUpdated(0, 0, 0);
|
video_stream_encoder_->OnBitrateUpdated(0, 0, 0);
|
||||||
stats_proxy_->OnSetEncoderTargetRate(0);
|
stats_proxy_->OnSetEncoderTargetRate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1298,7 +1303,8 @@ uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps,
|
|||||||
|
|
||||||
encoder_target_rate_bps_ =
|
encoder_target_rate_bps_ =
|
||||||
std::min(encoder_max_bitrate_bps_, 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_);
|
stats_proxy_->OnSetEncoderTargetRate(encoder_target_rate_bps_);
|
||||||
return protection_bitrate;
|
return protection_bitrate;
|
||||||
}
|
}
|
||||||
@ -1320,7 +1326,7 @@ void VideoSendStreamImpl::EnableEncodedFrameRecording(
|
|||||||
if (!files.empty()) {
|
if (!files.empty()) {
|
||||||
// Make a keyframe appear as early as possible in the logs, to give actually
|
// Make a keyframe appear as early as possible in the logs, to give actually
|
||||||
// decodable output.
|
// decodable output.
|
||||||
vie_encoder_->SendKeyFrame();
|
video_stream_encoder_->SendKeyFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
#include "webrtc/video/encoder_rtcp_feedback.h"
|
#include "webrtc/video/encoder_rtcp_feedback.h"
|
||||||
#include "webrtc/video/send_delay_stats.h"
|
#include "webrtc/video/send_delay_stats.h"
|
||||||
#include "webrtc/video/send_statistics_proxy.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_receive_stream.h"
|
||||||
#include "webrtc/video_send_stream.h"
|
#include "webrtc/video_send_stream.h"
|
||||||
|
|
||||||
@ -44,7 +44,8 @@ class VideoSendStreamImpl;
|
|||||||
|
|
||||||
// VideoSendStream implements webrtc::VideoSendStream.
|
// VideoSendStream implements webrtc::VideoSendStream.
|
||||||
// Internally, it delegates all public methods to VideoSendStreamImpl and / or
|
// 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 {
|
class VideoSendStream : public webrtc::VideoSendStream {
|
||||||
public:
|
public:
|
||||||
VideoSendStream(int num_cpu_cores,
|
VideoSendStream(int num_cpu_cores,
|
||||||
@ -102,7 +103,7 @@ class VideoSendStream : public webrtc::VideoSendStream {
|
|||||||
const VideoSendStream::Config config_;
|
const VideoSendStream::Config config_;
|
||||||
const VideoEncoderConfig::ContentType content_type_;
|
const VideoEncoderConfig::ContentType content_type_;
|
||||||
std::unique_ptr<VideoSendStreamImpl> send_stream_;
|
std::unique_ptr<VideoSendStreamImpl> send_stream_;
|
||||||
std::unique_ptr<ViEEncoder> vie_encoder_;
|
std::unique_ptr<VideoStreamEncoder> video_stream_encoder_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|||||||
@ -2371,7 +2371,7 @@ void VideoCodecConfigObserver<VideoCodecVP8>::VerifyCodecSpecifics(
|
|||||||
|
|
||||||
// Set expected temporal layers as they should have been set when
|
// Set expected temporal layers as they should have been set when
|
||||||
// reconfiguring the encoder and not match the set config. Also copy the
|
// 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_;
|
VideoCodecVP8 encoder_settings = encoder_settings_;
|
||||||
encoder_settings.numberOfTemporalLayers =
|
encoder_settings.numberOfTemporalLayers =
|
||||||
kVideoCodecConfigObserverNumberOfTemporalLayers;
|
kVideoCodecConfigObserverNumberOfTemporalLayers;
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* 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 <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -103,83 +103,85 @@ bool IsFramerateScalingEnabled(
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class ViEEncoder::ConfigureEncoderTask : public rtc::QueuedTask {
|
class VideoStreamEncoder::ConfigureEncoderTask : public rtc::QueuedTask {
|
||||||
public:
|
public:
|
||||||
ConfigureEncoderTask(ViEEncoder* vie_encoder,
|
ConfigureEncoderTask(VideoStreamEncoder* video_stream_encoder,
|
||||||
VideoEncoderConfig config,
|
VideoEncoderConfig config,
|
||||||
size_t max_data_payload_length,
|
size_t max_data_payload_length,
|
||||||
bool nack_enabled)
|
bool nack_enabled)
|
||||||
: vie_encoder_(vie_encoder),
|
: video_stream_encoder_(video_stream_encoder),
|
||||||
config_(std::move(config)),
|
config_(std::move(config)),
|
||||||
max_data_payload_length_(max_data_payload_length),
|
max_data_payload_length_(max_data_payload_length),
|
||||||
nack_enabled_(nack_enabled) {}
|
nack_enabled_(nack_enabled) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Run() override {
|
bool Run() override {
|
||||||
vie_encoder_->ConfigureEncoderOnTaskQueue(
|
video_stream_encoder_->ConfigureEncoderOnTaskQueue(
|
||||||
std::move(config_), max_data_payload_length_, nack_enabled_);
|
std::move(config_), max_data_payload_length_, nack_enabled_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
VideoEncoderConfig config_;
|
VideoEncoderConfig config_;
|
||||||
size_t max_data_payload_length_;
|
size_t max_data_payload_length_;
|
||||||
bool nack_enabled_;
|
bool nack_enabled_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ViEEncoder::EncodeTask : public rtc::QueuedTask {
|
class VideoStreamEncoder::EncodeTask : public rtc::QueuedTask {
|
||||||
public:
|
public:
|
||||||
EncodeTask(const VideoFrame& frame,
|
EncodeTask(const VideoFrame& frame,
|
||||||
ViEEncoder* vie_encoder,
|
VideoStreamEncoder* video_stream_encoder,
|
||||||
int64_t time_when_posted_us,
|
int64_t time_when_posted_us,
|
||||||
bool log_stats)
|
bool log_stats)
|
||||||
: frame_(frame),
|
: frame_(frame),
|
||||||
vie_encoder_(vie_encoder),
|
video_stream_encoder_(video_stream_encoder),
|
||||||
time_when_posted_us_(time_when_posted_us),
|
time_when_posted_us_(time_when_posted_us),
|
||||||
log_stats_(log_stats) {
|
log_stats_(log_stats) {
|
||||||
++vie_encoder_->posted_frames_waiting_for_encode_;
|
++video_stream_encoder_->posted_frames_waiting_for_encode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Run() override {
|
bool Run() override {
|
||||||
RTC_DCHECK_RUN_ON(&vie_encoder_->encoder_queue_);
|
RTC_DCHECK_RUN_ON(&video_stream_encoder_->encoder_queue_);
|
||||||
RTC_DCHECK_GT(vie_encoder_->posted_frames_waiting_for_encode_.Value(), 0);
|
RTC_DCHECK_GT(
|
||||||
vie_encoder_->stats_proxy_->OnIncomingFrame(frame_.width(),
|
video_stream_encoder_->posted_frames_waiting_for_encode_.Value(), 0);
|
||||||
|
video_stream_encoder_->stats_proxy_->OnIncomingFrame(frame_.width(),
|
||||||
frame_.height());
|
frame_.height());
|
||||||
++vie_encoder_->captured_frame_count_;
|
++video_stream_encoder_->captured_frame_count_;
|
||||||
if (--vie_encoder_->posted_frames_waiting_for_encode_ == 0) {
|
if (--video_stream_encoder_->posted_frames_waiting_for_encode_ == 0) {
|
||||||
vie_encoder_->EncodeVideoFrame(frame_, time_when_posted_us_);
|
video_stream_encoder_->EncodeVideoFrame(frame_, time_when_posted_us_);
|
||||||
} else {
|
} else {
|
||||||
// There is a newer frame in flight. Do not encode this frame.
|
// There is a newer frame in flight. Do not encode this frame.
|
||||||
LOG(LS_VERBOSE)
|
LOG(LS_VERBOSE)
|
||||||
<< "Incoming frame dropped due to that the encoder is blocked.";
|
<< "Incoming frame dropped due to that the encoder is blocked.";
|
||||||
++vie_encoder_->dropped_frame_count_;
|
++video_stream_encoder_->dropped_frame_count_;
|
||||||
}
|
}
|
||||||
if (log_stats_) {
|
if (log_stats_) {
|
||||||
LOG(LS_INFO) << "Number of frames: captured "
|
LOG(LS_INFO) << "Number of frames: captured "
|
||||||
<< vie_encoder_->captured_frame_count_
|
<< video_stream_encoder_->captured_frame_count_
|
||||||
<< ", dropped (due to encoder blocked) "
|
<< ", dropped (due to encoder blocked) "
|
||||||
<< vie_encoder_->dropped_frame_count_ << ", interval_ms "
|
<< video_stream_encoder_->dropped_frame_count_
|
||||||
|
<< ", interval_ms "
|
||||||
<< kFrameLogIntervalMs;
|
<< kFrameLogIntervalMs;
|
||||||
vie_encoder_->captured_frame_count_ = 0;
|
video_stream_encoder_->captured_frame_count_ = 0;
|
||||||
vie_encoder_->dropped_frame_count_ = 0;
|
video_stream_encoder_->dropped_frame_count_ = 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
VideoFrame frame_;
|
VideoFrame frame_;
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
const int64_t time_when_posted_us_;
|
const int64_t time_when_posted_us_;
|
||||||
const bool log_stats_;
|
const bool log_stats_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// VideoSourceProxy is responsible ensuring thread safety between calls to
|
// VideoSourceProxy is responsible ensuring thread safety between calls to
|
||||||
// ViEEncoder::SetSource that will happen on libjingle's worker thread when a
|
// VideoStreamEncoder::SetSource that will happen on libjingle's worker thread
|
||||||
// video capturer is connected to the encoder and the encoder task queue
|
// when a video capturer is connected to the encoder and the encoder task queue
|
||||||
// (encoder_queue_) where the encoder reports its VideoSinkWants.
|
// (encoder_queue_) where the encoder reports its VideoSinkWants.
|
||||||
class ViEEncoder::VideoSourceProxy {
|
class VideoStreamEncoder::VideoSourceProxy {
|
||||||
public:
|
public:
|
||||||
explicit VideoSourceProxy(ViEEncoder* vie_encoder)
|
explicit VideoSourceProxy(VideoStreamEncoder* video_stream_encoder)
|
||||||
: vie_encoder_(vie_encoder),
|
: video_stream_encoder_(video_stream_encoder),
|
||||||
degradation_preference_(
|
degradation_preference_(
|
||||||
VideoSendStream::DegradationPreference::kDegradationDisabled),
|
VideoSendStream::DegradationPreference::kDegradationDisabled),
|
||||||
source_(nullptr) {}
|
source_(nullptr) {}
|
||||||
@ -200,21 +202,21 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old_source != source && old_source != nullptr) {
|
if (old_source != source && old_source != nullptr) {
|
||||||
old_source->RemoveSink(vie_encoder_);
|
old_source->RemoveSink(video_stream_encoder_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!source) {
|
if (!source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
source->AddOrUpdateSink(vie_encoder_, wants);
|
source->AddOrUpdateSink(video_stream_encoder_, wants);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWantsRotationApplied(bool rotation_applied) {
|
void SetWantsRotationApplied(bool rotation_applied) {
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
sink_wants_.rotation_applied = rotation_applied;
|
sink_wants_.rotation_applied = rotation_applied;
|
||||||
if (source_)
|
if (source_)
|
||||||
source_->AddOrUpdateSink(vie_encoder_, sink_wants_);
|
source_->AddOrUpdateSink(video_stream_encoder_, sink_wants_);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc::VideoSinkWants GetActiveSinkWants() {
|
rtc::VideoSinkWants GetActiveSinkWants() {
|
||||||
@ -228,7 +230,7 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
sink_wants_.target_pixel_count.reset();
|
sink_wants_.target_pixel_count.reset();
|
||||||
sink_wants_.max_framerate_fps = std::numeric_limits<int>::max();
|
sink_wants_.max_framerate_fps = std::numeric_limits<int>::max();
|
||||||
if (source_)
|
if (source_)
|
||||||
source_->AddOrUpdateSink(vie_encoder_, sink_wants_);
|
source_->AddOrUpdateSink(video_stream_encoder_, sink_wants_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RequestResolutionLowerThan(int pixel_count) {
|
bool RequestResolutionLowerThan(int pixel_count) {
|
||||||
@ -249,7 +251,8 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
LOG(LS_INFO) << "Scaling down resolution, max pixels: " << pixels_wanted;
|
LOG(LS_INFO) << "Scaling down resolution, max pixels: " << pixels_wanted;
|
||||||
sink_wants_.max_pixel_count = pixels_wanted;
|
sink_wants_.max_pixel_count = pixels_wanted;
|
||||||
sink_wants_.target_pixel_count = rtc::Optional<int>();
|
sink_wants_.target_pixel_count = rtc::Optional<int>();
|
||||||
source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
|
source_->AddOrUpdateSink(video_stream_encoder_,
|
||||||
|
GetActiveSinkWantsInternal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +293,8 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
rtc::Optional<int>((pixel_count * 5) / 3);
|
rtc::Optional<int>((pixel_count * 5) / 3);
|
||||||
}
|
}
|
||||||
LOG(LS_INFO) << "Scaling up resolution, max pixels: " << max_pixels_wanted;
|
LOG(LS_INFO) << "Scaling up resolution, max pixels: " << max_pixels_wanted;
|
||||||
source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
|
source_->AddOrUpdateSink(video_stream_encoder_,
|
||||||
|
GetActiveSinkWantsInternal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +324,8 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
|
|
||||||
LOG(LS_INFO) << "Scaling down framerate: " << fps_wanted;
|
LOG(LS_INFO) << "Scaling down framerate: " << fps_wanted;
|
||||||
sink_wants_.max_framerate_fps = fps_wanted;
|
sink_wants_.max_framerate_fps = fps_wanted;
|
||||||
source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
|
source_->AddOrUpdateSink(video_stream_encoder_,
|
||||||
|
GetActiveSinkWantsInternal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +341,8 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
|
|
||||||
LOG(LS_INFO) << "Scaling up framerate: " << fps_wanted;
|
LOG(LS_INFO) << "Scaling up framerate: " << fps_wanted;
|
||||||
sink_wants_.max_framerate_fps = fps_wanted;
|
sink_wants_.max_framerate_fps = fps_wanted;
|
||||||
source_->AddOrUpdateSink(vie_encoder_, GetActiveSinkWantsInternal());
|
source_->AddOrUpdateSink(video_stream_encoder_,
|
||||||
|
GetActiveSinkWantsInternal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +372,7 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
|
|
||||||
rtc::CriticalSection crit_;
|
rtc::CriticalSection crit_;
|
||||||
rtc::SequencedTaskChecker main_checker_;
|
rtc::SequencedTaskChecker main_checker_;
|
||||||
ViEEncoder* const vie_encoder_;
|
VideoStreamEncoder* const video_stream_encoder_;
|
||||||
rtc::VideoSinkWants sink_wants_ GUARDED_BY(&crit_);
|
rtc::VideoSinkWants sink_wants_ GUARDED_BY(&crit_);
|
||||||
VideoSendStream::DegradationPreference degradation_preference_
|
VideoSendStream::DegradationPreference degradation_preference_
|
||||||
GUARDED_BY(&crit_);
|
GUARDED_BY(&crit_);
|
||||||
@ -375,7 +381,7 @@ class ViEEncoder::VideoSourceProxy {
|
|||||||
RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy);
|
RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy);
|
||||||
};
|
};
|
||||||
|
|
||||||
ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
VideoStreamEncoder::VideoStreamEncoder(uint32_t number_of_cores,
|
||||||
SendStatisticsProxy* stats_proxy,
|
SendStatisticsProxy* stats_proxy,
|
||||||
const VideoSendStream::Config::EncoderSettings& settings,
|
const VideoSendStream::Config::EncoderSettings& settings,
|
||||||
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
|
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
|
||||||
@ -428,7 +434,7 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEEncoder::~ViEEncoder() {
|
VideoStreamEncoder::~VideoStreamEncoder() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
RTC_DCHECK(shutdown_event_.Wait(0))
|
RTC_DCHECK(shutdown_event_.Wait(0))
|
||||||
<< "Must call ::Stop() before destruction.";
|
<< "Must call ::Stop() before destruction.";
|
||||||
@ -438,7 +444,8 @@ ViEEncoder::~ViEEncoder() {
|
|||||||
// pipelining encoders better (multiple input frames before something comes
|
// pipelining encoders better (multiple input frames before something comes
|
||||||
// out). This should effectively turn off CPU adaptations for systems that
|
// out). This should effectively turn off CPU adaptations for systems that
|
||||||
// remotely cope with the load right now.
|
// remotely cope with the load right now.
|
||||||
CpuOveruseOptions ViEEncoder::GetCpuOveruseOptions(bool full_overuse_time) {
|
CpuOveruseOptions VideoStreamEncoder::GetCpuOveruseOptions(
|
||||||
|
bool full_overuse_time) {
|
||||||
CpuOveruseOptions options;
|
CpuOveruseOptions options;
|
||||||
if (full_overuse_time) {
|
if (full_overuse_time) {
|
||||||
options.low_encode_usage_threshold_percent = 150;
|
options.low_encode_usage_threshold_percent = 150;
|
||||||
@ -447,7 +454,7 @@ CpuOveruseOptions ViEEncoder::GetCpuOveruseOptions(bool full_overuse_time) {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::Stop() {
|
void VideoStreamEncoder::Stop() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
source_proxy_->SetSource(nullptr, VideoSendStream::DegradationPreference());
|
source_proxy_->SetSource(nullptr, VideoSendStream::DegradationPreference());
|
||||||
encoder_queue_.PostTask([this] {
|
encoder_queue_.PostTask([this] {
|
||||||
@ -464,7 +471,8 @@ void ViEEncoder::Stop() {
|
|||||||
shutdown_event_.Wait(rtc::Event::kForever);
|
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_RUN_ON(&thread_checker_);
|
||||||
RTC_DCHECK(!module_process_thread_);
|
RTC_DCHECK(!module_process_thread_);
|
||||||
module_process_thread_ = module_process_thread;
|
module_process_thread_ = module_process_thread;
|
||||||
@ -472,12 +480,12 @@ void ViEEncoder::RegisterProcessThread(ProcessThread* module_process_thread) {
|
|||||||
module_process_thread_checker_.DetachFromThread();
|
module_process_thread_checker_.DetachFromThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::DeRegisterProcessThread() {
|
void VideoStreamEncoder::DeRegisterProcessThread() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
module_process_thread_->DeRegisterModule(&video_sender_);
|
module_process_thread_->DeRegisterModule(&video_sender_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::SetBitrateObserver(
|
void VideoStreamEncoder::SetBitrateObserver(
|
||||||
VideoBitrateAllocationObserver* bitrate_observer) {
|
VideoBitrateAllocationObserver* bitrate_observer) {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
encoder_queue_.PostTask([this, bitrate_observer] {
|
encoder_queue_.PostTask([this, bitrate_observer] {
|
||||||
@ -487,7 +495,7 @@ void ViEEncoder::SetBitrateObserver(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::SetSource(
|
void VideoStreamEncoder::SetSource(
|
||||||
rtc::VideoSourceInterface<VideoFrame>* source,
|
rtc::VideoSourceInterface<VideoFrame>* source,
|
||||||
const VideoSendStream::DegradationPreference& degradation_preference) {
|
const VideoSendStream::DegradationPreference& degradation_preference) {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
@ -521,7 +529,7 @@ void ViEEncoder::SetSource(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::SetSink(EncoderSink* sink, bool rotation_applied) {
|
void VideoStreamEncoder::SetSink(EncoderSink* sink, bool rotation_applied) {
|
||||||
source_proxy_->SetWantsRotationApplied(rotation_applied);
|
source_proxy_->SetWantsRotationApplied(rotation_applied);
|
||||||
encoder_queue_.PostTask([this, sink] {
|
encoder_queue_.PostTask([this, sink] {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
@ -529,14 +537,14 @@ void ViEEncoder::SetSink(EncoderSink* sink, bool rotation_applied) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::SetStartBitrate(int start_bitrate_bps) {
|
void VideoStreamEncoder::SetStartBitrate(int start_bitrate_bps) {
|
||||||
encoder_queue_.PostTask([this, start_bitrate_bps] {
|
encoder_queue_.PostTask([this, start_bitrate_bps] {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
encoder_start_bitrate_bps_ = start_bitrate_bps;
|
encoder_start_bitrate_bps_ = start_bitrate_bps;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::ConfigureEncoder(VideoEncoderConfig config,
|
void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config,
|
||||||
size_t max_data_payload_length,
|
size_t max_data_payload_length,
|
||||||
bool nack_enabled) {
|
bool nack_enabled) {
|
||||||
encoder_queue_.PostTask(
|
encoder_queue_.PostTask(
|
||||||
@ -544,7 +552,8 @@ void ViEEncoder::ConfigureEncoder(VideoEncoderConfig config,
|
|||||||
this, std::move(config), max_data_payload_length, nack_enabled)));
|
this, std::move(config), max_data_payload_length, nack_enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
|
void VideoStreamEncoder::ConfigureEncoderOnTaskQueue(
|
||||||
|
VideoEncoderConfig config,
|
||||||
size_t max_data_payload_length,
|
size_t max_data_payload_length,
|
||||||
bool nack_enabled) {
|
bool nack_enabled) {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
@ -569,7 +578,7 @@ void ViEEncoder::ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::ReconfigureEncoder() {
|
void VideoStreamEncoder::ReconfigureEncoder() {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
RTC_DCHECK(pending_encoder_reconfiguration_);
|
RTC_DCHECK(pending_encoder_reconfiguration_);
|
||||||
std::vector<VideoStream> streams =
|
std::vector<VideoStream> streams =
|
||||||
@ -643,7 +652,7 @@ void ViEEncoder::ReconfigureEncoder() {
|
|||||||
ConfigureQualityScaler();
|
ConfigureQualityScaler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::ConfigureQualityScaler() {
|
void VideoStreamEncoder::ConfigureQualityScaler() {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
const auto scaling_settings = settings_.encoder->GetScalingSettings();
|
const auto scaling_settings = settings_.encoder->GetScalingSettings();
|
||||||
const bool quality_scaling_allowed =
|
const bool quality_scaling_allowed =
|
||||||
@ -670,7 +679,7 @@ void ViEEncoder::ConfigureQualityScaler() {
|
|||||||
GetActiveCounts(kQuality));
|
GetActiveCounts(kQuality));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::OnFrame(const VideoFrame& video_frame) {
|
void VideoStreamEncoder::OnFrame(const VideoFrame& video_frame) {
|
||||||
RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_);
|
RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_);
|
||||||
VideoFrame incoming_frame = video_frame;
|
VideoFrame incoming_frame = video_frame;
|
||||||
|
|
||||||
@ -720,7 +729,7 @@ void ViEEncoder::OnFrame(const VideoFrame& video_frame) {
|
|||||||
incoming_frame, this, rtc::TimeMicros(), log_stats)));
|
incoming_frame, this, rtc::TimeMicros(), log_stats)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViEEncoder::EncoderPaused() const {
|
bool VideoStreamEncoder::EncoderPaused() const {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
// Pause video if paused by caller or as long as the network is down or the
|
// 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.
|
// pacer queue has grown too large in buffered mode.
|
||||||
@ -729,7 +738,7 @@ bool ViEEncoder::EncoderPaused() const {
|
|||||||
return last_observed_bitrate_bps_ == 0;
|
return last_observed_bitrate_bps_ == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::TraceFrameDropStart() {
|
void VideoStreamEncoder::TraceFrameDropStart() {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
// Start trace event only on the first frame after encoder is paused.
|
// Start trace event only on the first frame after encoder is paused.
|
||||||
if (!encoder_paused_and_dropped_frame_) {
|
if (!encoder_paused_and_dropped_frame_) {
|
||||||
@ -738,7 +747,7 @@ void ViEEncoder::TraceFrameDropStart() {
|
|||||||
encoder_paused_and_dropped_frame_ = true;
|
encoder_paused_and_dropped_frame_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::TraceFrameDropEnd() {
|
void VideoStreamEncoder::TraceFrameDropEnd() {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
// End trace event on first frame after encoder resumes, if frame was dropped.
|
// End trace event on first frame after encoder resumes, if frame was dropped.
|
||||||
if (encoder_paused_and_dropped_frame_) {
|
if (encoder_paused_and_dropped_frame_) {
|
||||||
@ -747,7 +756,7 @@ void ViEEncoder::TraceFrameDropEnd() {
|
|||||||
encoder_paused_and_dropped_frame_ = false;
|
encoder_paused_and_dropped_frame_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
|
void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
|
||||||
int64_t time_when_posted_us) {
|
int64_t time_when_posted_us) {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
|
|
||||||
@ -824,7 +833,7 @@ void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
|
|||||||
video_sender_.AddVideoFrame(out_frame, nullptr);
|
video_sender_.AddVideoFrame(out_frame, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::SendKeyFrame() {
|
void VideoStreamEncoder::SendKeyFrame() {
|
||||||
if (!encoder_queue_.IsCurrent()) {
|
if (!encoder_queue_.IsCurrent()) {
|
||||||
encoder_queue_.PostTask([this] { SendKeyFrame(); });
|
encoder_queue_.PostTask([this] { SendKeyFrame(); });
|
||||||
return;
|
return;
|
||||||
@ -833,7 +842,7 @@ void ViEEncoder::SendKeyFrame() {
|
|||||||
video_sender_.IntraFrameRequest(0);
|
video_sender_.IntraFrameRequest(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
|
EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage(
|
||||||
const EncodedImage& encoded_image,
|
const EncodedImage& encoded_image,
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
const CodecSpecificInfo* codec_specific_info,
|
||||||
const RTPFragmentationHeader* fragmentation) {
|
const RTPFragmentationHeader* fragmentation) {
|
||||||
@ -858,7 +867,7 @@ EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::OnDroppedFrame() {
|
void VideoStreamEncoder::OnDroppedFrame() {
|
||||||
encoder_queue_.PostTask([this] {
|
encoder_queue_.PostTask([this] {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
if (quality_scaler_)
|
if (quality_scaler_)
|
||||||
@ -866,12 +875,13 @@ void ViEEncoder::OnDroppedFrame() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
|
||||||
stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate);
|
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()) {
|
if (!encoder_queue_.IsCurrent()) {
|
||||||
encoder_queue_.PostTask(
|
encoder_queue_.PostTask(
|
||||||
[this, stream_index] { OnReceivedIntraFrameRequest(stream_index); });
|
[this, stream_index] { OnReceivedIntraFrameRequest(stream_index); });
|
||||||
@ -883,7 +893,7 @@ void ViEEncoder::OnReceivedIntraFrameRequest(size_t stream_index) {
|
|||||||
video_sender_.IntraFrameRequest(stream_index);
|
video_sender_.IntraFrameRequest(stream_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
|
void VideoStreamEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
|
||||||
uint8_t fraction_lost,
|
uint8_t fraction_lost,
|
||||||
int64_t round_trip_time_ms) {
|
int64_t round_trip_time_ms) {
|
||||||
if (!encoder_queue_.IsCurrent()) {
|
if (!encoder_queue_.IsCurrent()) {
|
||||||
@ -917,7 +927,7 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptDown(AdaptReason reason) {
|
void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
AdaptationRequest adaptation_request = {
|
AdaptationRequest adaptation_request = {
|
||||||
last_frame_info_->pixel_count(),
|
last_frame_info_->pixel_count(),
|
||||||
@ -1008,7 +1018,7 @@ void ViEEncoder::AdaptDown(AdaptReason reason) {
|
|||||||
LOG(LS_INFO) << GetConstAdaptCounter().ToString();
|
LOG(LS_INFO) << GetConstAdaptCounter().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptUp(AdaptReason reason) {
|
void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
|
||||||
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
RTC_DCHECK_RUN_ON(&encoder_queue_);
|
||||||
|
|
||||||
const AdaptCounter& adapt_counter = GetConstAdaptCounter();
|
const AdaptCounter& adapt_counter = GetConstAdaptCounter();
|
||||||
@ -1096,7 +1106,7 @@ void ViEEncoder::AdaptUp(AdaptReason reason) {
|
|||||||
LOG(LS_INFO) << adapt_counter.ToString();
|
LOG(LS_INFO) << adapt_counter.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::UpdateAdaptationStats(AdaptReason reason) {
|
void VideoStreamEncoder::UpdateAdaptationStats(AdaptReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case kCpu:
|
case kCpu:
|
||||||
stats_proxy_->OnCpuAdaptationChanged(GetActiveCounts(kCpu),
|
stats_proxy_->OnCpuAdaptationChanged(GetActiveCounts(kCpu),
|
||||||
@ -1109,8 +1119,10 @@ void ViEEncoder::UpdateAdaptationStats(AdaptReason reason) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEEncoder::AdaptCounts ViEEncoder::GetActiveCounts(AdaptReason reason) {
|
VideoStreamEncoder::AdaptCounts VideoStreamEncoder::GetActiveCounts(
|
||||||
ViEEncoder::AdaptCounts counts = GetConstAdaptCounter().Counts(reason);
|
AdaptReason reason) {
|
||||||
|
VideoStreamEncoder::AdaptCounts counts =
|
||||||
|
GetConstAdaptCounter().Counts(reason);
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case kCpu:
|
case kCpu:
|
||||||
if (!IsFramerateScalingEnabled(degradation_preference_))
|
if (!IsFramerateScalingEnabled(degradation_preference_))
|
||||||
@ -1132,46 +1144,48 @@ ViEEncoder::AdaptCounts ViEEncoder::GetActiveCounts(AdaptReason reason) {
|
|||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEEncoder::AdaptCounter& ViEEncoder::GetAdaptCounter() {
|
VideoStreamEncoder::AdaptCounter& VideoStreamEncoder::GetAdaptCounter() {
|
||||||
return adapt_counters_[degradation_preference_];
|
return adapt_counters_[degradation_preference_];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViEEncoder::AdaptCounter& ViEEncoder::GetConstAdaptCounter() {
|
const VideoStreamEncoder::AdaptCounter&
|
||||||
|
VideoStreamEncoder::GetConstAdaptCounter() {
|
||||||
return adapt_counters_[degradation_preference_];
|
return adapt_counters_[degradation_preference_];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class holding adaptation information.
|
// Class holding adaptation information.
|
||||||
ViEEncoder::AdaptCounter::AdaptCounter() {
|
VideoStreamEncoder::AdaptCounter::AdaptCounter() {
|
||||||
fps_counters_.resize(kScaleReasonSize);
|
fps_counters_.resize(kScaleReasonSize);
|
||||||
resolution_counters_.resize(kScaleReasonSize);
|
resolution_counters_.resize(kScaleReasonSize);
|
||||||
static_assert(kScaleReasonSize == 2, "Update MoveCount.");
|
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;
|
std::stringstream ss;
|
||||||
ss << "Downgrade counts: fps: {" << ToString(fps_counters_);
|
ss << "Downgrade counts: fps: {" << ToString(fps_counters_);
|
||||||
ss << "}, resolution: {" << ToString(resolution_counters_) << "}";
|
ss << "}, resolution: {" << ToString(resolution_counters_) << "}";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEEncoder::AdaptCounts ViEEncoder::AdaptCounter::Counts(int reason) const {
|
VideoStreamEncoder::AdaptCounts VideoStreamEncoder::AdaptCounter::Counts(
|
||||||
|
int reason) const {
|
||||||
AdaptCounts counts;
|
AdaptCounts counts;
|
||||||
counts.fps = fps_counters_[reason];
|
counts.fps = fps_counters_[reason];
|
||||||
counts.resolution = resolution_counters_[reason];
|
counts.resolution = resolution_counters_[reason];
|
||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptCounter::IncrementFramerate(int reason) {
|
void VideoStreamEncoder::AdaptCounter::IncrementFramerate(int reason) {
|
||||||
++(fps_counters_[reason]);
|
++(fps_counters_[reason]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptCounter::IncrementResolution(int reason) {
|
void VideoStreamEncoder::AdaptCounter::IncrementResolution(int reason) {
|
||||||
++(resolution_counters_[reason]);
|
++(resolution_counters_[reason]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptCounter::DecrementFramerate(int reason) {
|
void VideoStreamEncoder::AdaptCounter::DecrementFramerate(int reason) {
|
||||||
if (fps_counters_[reason] == 0) {
|
if (fps_counters_[reason] == 0) {
|
||||||
// Balanced mode: Adapt up is in a different order, switch reason.
|
// Balanced mode: Adapt up is in a different order, switch reason.
|
||||||
// E.g. framerate adapt down: quality (2), framerate adapt up: cpu (3).
|
// E.g. framerate adapt down: quality (2), framerate adapt up: cpu (3).
|
||||||
@ -1188,7 +1202,7 @@ void ViEEncoder::AdaptCounter::DecrementFramerate(int reason) {
|
|||||||
RTC_DCHECK_GE(fps_counters_[reason], 0);
|
RTC_DCHECK_GE(fps_counters_[reason], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptCounter::DecrementResolution(int reason) {
|
void VideoStreamEncoder::AdaptCounter::DecrementResolution(int reason) {
|
||||||
if (resolution_counters_[reason] == 0) {
|
if (resolution_counters_[reason] == 0) {
|
||||||
// Balanced mode: Adapt up is in a different order, switch reason.
|
// Balanced mode: Adapt up is in a different order, switch reason.
|
||||||
RTC_DCHECK_GT(TotalCount(reason), 0) << "No downgrade for reason.";
|
RTC_DCHECK_GT(TotalCount(reason), 0) << "No downgrade for reason.";
|
||||||
@ -1200,45 +1214,47 @@ void ViEEncoder::AdaptCounter::DecrementResolution(int reason) {
|
|||||||
RTC_DCHECK_GE(resolution_counters_[reason], 0);
|
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);
|
DecrementFramerate(reason);
|
||||||
// Reset if at max fps (i.e. in case of fewer steps up than down).
|
// Reset if at max fps (i.e. in case of fewer steps up than down).
|
||||||
if (cur_fps == std::numeric_limits<int>::max())
|
if (cur_fps == std::numeric_limits<int>::max())
|
||||||
std::fill(fps_counters_.begin(), fps_counters_.end(), 0);
|
std::fill(fps_counters_.begin(), fps_counters_.end(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::AdaptCounter::FramerateCount() const {
|
int VideoStreamEncoder::AdaptCounter::FramerateCount() const {
|
||||||
return Count(fps_counters_);
|
return Count(fps_counters_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::AdaptCounter::ResolutionCount() const {
|
int VideoStreamEncoder::AdaptCounter::ResolutionCount() const {
|
||||||
return Count(resolution_counters_);
|
return Count(resolution_counters_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::AdaptCounter::FramerateCount(int reason) const {
|
int VideoStreamEncoder::AdaptCounter::FramerateCount(int reason) const {
|
||||||
return fps_counters_[reason];
|
return fps_counters_[reason];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::AdaptCounter::ResolutionCount(int reason) const {
|
int VideoStreamEncoder::AdaptCounter::ResolutionCount(int reason) const {
|
||||||
return resolution_counters_[reason];
|
return resolution_counters_[reason];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::AdaptCounter::TotalCount(int reason) const {
|
int VideoStreamEncoder::AdaptCounter::TotalCount(int reason) const {
|
||||||
return FramerateCount(reason) + ResolutionCount(reason);
|
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);
|
return std::accumulate(counters.begin(), counters.end(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViEEncoder::AdaptCounter::MoveCount(std::vector<int>* counters,
|
void VideoStreamEncoder::AdaptCounter::MoveCount(std::vector<int>* counters,
|
||||||
int from_reason) {
|
int from_reason) {
|
||||||
int to_reason = (from_reason + 1) % kScaleReasonSize;
|
int to_reason = (from_reason + 1) % kScaleReasonSize;
|
||||||
++((*counters)[to_reason]);
|
++((*counters)[to_reason]);
|
||||||
--((*counters)[from_reason]);
|
--((*counters)[from_reason]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ViEEncoder::AdaptCounter::ToString(
|
std::string VideoStreamEncoder::AdaptCounter::ToString(
|
||||||
const std::vector<int>& counters) const {
|
const std::vector<int>& counters) const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
for (size_t reason = 0; reason < kScaleReasonSize; ++reason) {
|
for (size_t reason = 0; reason < kScaleReasonSize; ++reason) {
|
||||||
@ -8,8 +8,8 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WEBRTC_VIDEO_VIE_ENCODER_H_
|
#ifndef WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
|
||||||
#define WEBRTC_VIDEO_VIE_ENCODER_H_
|
#define WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -40,15 +40,15 @@ class ProcessThread;
|
|||||||
class SendStatisticsProxy;
|
class SendStatisticsProxy;
|
||||||
class VideoBitrateAllocationObserver;
|
class VideoBitrateAllocationObserver;
|
||||||
|
|
||||||
// VieEncoder represent a video encoder that accepts raw video frames as input
|
// VideoStreamEncoder represent a video encoder that accepts raw video frames as
|
||||||
// and produces an encoded bit stream.
|
// input and produces an encoded bit stream.
|
||||||
// Usage:
|
// Usage:
|
||||||
// Instantiate.
|
// Instantiate.
|
||||||
// Call SetSink.
|
// Call SetSink.
|
||||||
// Call SetSource.
|
// Call SetSource.
|
||||||
// Call ConfigureEncoder with the codec settings.
|
// Call ConfigureEncoder with the codec settings.
|
||||||
// Call Stop() when done.
|
// Call Stop() when done.
|
||||||
class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
class VideoStreamEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
||||||
public EncodedImageCallback,
|
public EncodedImageCallback,
|
||||||
public VCMSendStatisticsCallback,
|
public VCMSendStatisticsCallback,
|
||||||
public AdaptationObserverInterface {
|
public AdaptationObserverInterface {
|
||||||
@ -73,13 +73,13 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
|||||||
// Downscale framerate at most 4 times.
|
// Downscale framerate at most 4 times.
|
||||||
static const int kMaxCpuFramerateDowngrades = 4;
|
static const int kMaxCpuFramerateDowngrades = 4;
|
||||||
|
|
||||||
ViEEncoder(uint32_t number_of_cores,
|
VideoStreamEncoder(uint32_t number_of_cores,
|
||||||
SendStatisticsProxy* stats_proxy,
|
SendStatisticsProxy* stats_proxy,
|
||||||
const VideoSendStream::Config::EncoderSettings& settings,
|
const VideoSendStream::Config::EncoderSettings& settings,
|
||||||
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
|
rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
|
||||||
EncodedFrameObserver* encoder_timing,
|
EncodedFrameObserver* encoder_timing,
|
||||||
std::unique_ptr<OveruseFrameDetector> overuse_detector);
|
std::unique_ptr<OveruseFrameDetector> overuse_detector);
|
||||||
~ViEEncoder();
|
~VideoStreamEncoder();
|
||||||
// RegisterProcessThread register |module_process_thread| with those objects
|
// RegisterProcessThread register |module_process_thread| with those objects
|
||||||
// that use it. Registration has to happen on the thread where
|
// that use it. Registration has to happen on the thread where
|
||||||
// |module_process_thread| was created (libjingle's worker thread).
|
// |module_process_thread| was created (libjingle's worker thread).
|
||||||
@ -243,7 +243,7 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
|||||||
ProcessThread* module_process_thread_;
|
ProcessThread* module_process_thread_;
|
||||||
rtc::ThreadChecker module_process_thread_checker_;
|
rtc::ThreadChecker module_process_thread_checker_;
|
||||||
// |thread_checker_| checks that public methods that are related to lifetime
|
// |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_;
|
rtc::ThreadChecker thread_checker_;
|
||||||
|
|
||||||
VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
|
VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
|
||||||
@ -308,9 +308,9 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
|||||||
// destroyed first to make sure no tasks are run that use other members.
|
// destroyed first to make sure no tasks are run that use other members.
|
||||||
rtc::TaskQueue encoder_queue_;
|
rtc::TaskQueue encoder_queue_;
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
|
RTC_DISALLOW_COPY_AND_ASSIGN(VideoStreamEncoder);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_VIDEO_VIE_ENCODER_H_
|
#endif // WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user