Revert of Add experimental simulcast screen content mode (patchset #5 id:80001 of https://codereview.webrtc.org/2636443002/ )
Reason for revert:
Breaks chromium.
Original issue's description:
> Add experimental simulcast screen content mode
>
> BUG=webrtc:4172
>
> Review-Url: https://codereview.webrtc.org/2636443002
> Cr-Commit-Position: refs/heads/master@{#16135}
> Committed: a28e971e3b
TBR=perkj@webrtc.org,asapersson@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4172
Review-Url: https://codereview.webrtc.org/2643763002
Cr-Commit-Position: refs/heads/master@{#16145}
This commit is contained in:
@ -14,7 +14,6 @@
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/media/base/streamparams.h"
|
||||
#include "webrtc/media/engine/constants.h"
|
||||
#include "webrtc/media/engine/simulcast.h"
|
||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||
|
||||
@ -50,8 +49,6 @@ const SimulcastFormat kSimulcastFormats[] = {
|
||||
{0, 0, 1, 200, 150, 30}
|
||||
};
|
||||
|
||||
const int kDefaultScreenshareSimulcastStreams = 2;
|
||||
|
||||
// Multiway: Number of temporal layers for each simulcast stream, for maximum
|
||||
// possible number of simulcast streams |kMaxSimulcastStreams|. The array
|
||||
// goes from lowest resolution at position 0 to highest resolution.
|
||||
@ -82,8 +79,8 @@ int FindSimulcastFormatIndex(int width, int height) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width * height >=
|
||||
kSimulcastFormats[i].width * kSimulcastFormats[i].height) {
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -94,8 +91,8 @@ int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width * height >=
|
||||
kSimulcastFormats[i].width * kSimulcastFormats[i].height &&
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height &&
|
||||
max_layers == kSimulcastFormats[i].max_layers) {
|
||||
return i;
|
||||
}
|
||||
@ -121,7 +118,7 @@ size_t FindSimulcastMaxLayers(int width, int height) {
|
||||
// TODO(marpan): Investigate if we should return 0 instead of -1 in
|
||||
// FindSimulcast[Max/Target/Min]Bitrate functions below, since the
|
||||
// codec struct max/min/targeBitrates are unsigned.
|
||||
int FindSimulcastMaxBitrateBps(int width, int height) {
|
||||
int FindSimulcastMaxBitrateBps(int width, int height, size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
@ -129,7 +126,9 @@ int FindSimulcastMaxBitrateBps(int width, int height) {
|
||||
return kSimulcastFormats[format_index].max_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastTargetBitrateBps(int width, int height) {
|
||||
int FindSimulcastTargetBitrateBps(int width,
|
||||
int height,
|
||||
size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
@ -137,7 +136,7 @@ int FindSimulcastTargetBitrateBps(int width, int height) {
|
||||
return kSimulcastFormats[format_index].target_bitrate_kbps * 1000;
|
||||
}
|
||||
|
||||
int FindSimulcastMinBitrateBps(int width, int height) {
|
||||
int FindSimulcastMinBitrateBps(int width, int height, size_t max_layers) {
|
||||
const int format_index = FindSimulcastFormatIndex(width, height);
|
||||
if (format_index == -1) {
|
||||
return -1;
|
||||
@ -168,73 +167,52 @@ int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams) {
|
||||
return total_max_bitrate_bps;
|
||||
}
|
||||
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(size_t max_streams,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate,
|
||||
bool is_screencast) {
|
||||
size_t num_simulcast_layers;
|
||||
if (is_screencast) {
|
||||
num_simulcast_layers =
|
||||
UseSimulcastScreenshare() ? kDefaultScreenshareSimulcastStreams : 1;
|
||||
} else {
|
||||
num_simulcast_layers = FindSimulcastMaxLayers(width, height);
|
||||
}
|
||||
|
||||
if (num_simulcast_layers > max_streams) {
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
size_t max_streams,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate) {
|
||||
size_t simulcast_layers = FindSimulcastMaxLayers(width, height);
|
||||
if (simulcast_layers > max_streams) {
|
||||
// If the number of SSRCs in the group differs from our target
|
||||
// number of simulcast streams for current resolution, switch down
|
||||
// to a resolution that matches our number of SSRCs.
|
||||
if (!SlotSimulcastMaxResolution(max_streams, &width, &height)) {
|
||||
return std::vector<webrtc::VideoStream>();
|
||||
}
|
||||
num_simulcast_layers = max_streams;
|
||||
simulcast_layers = max_streams;
|
||||
}
|
||||
std::vector<webrtc::VideoStream> streams;
|
||||
streams.resize(num_simulcast_layers);
|
||||
streams.resize(simulcast_layers);
|
||||
|
||||
if (!is_screencast) {
|
||||
// Format width and height has to be divisible by |2 ^ number_streams - 1|.
|
||||
width = NormalizeSimulcastSize(width, num_simulcast_layers);
|
||||
height = NormalizeSimulcastSize(height, num_simulcast_layers);
|
||||
}
|
||||
// Format width and height has to be divisible by |2 ^ number_streams - 1|.
|
||||
width = NormalizeSimulcastSize(width, simulcast_layers);
|
||||
height = NormalizeSimulcastSize(height, simulcast_layers);
|
||||
|
||||
// Add simulcast sub-streams from lower resolution to higher resolutions.
|
||||
// Add simulcast streams, from highest resolution (|s| = number_streams -1)
|
||||
// to lowest resolution at |s| = 0.
|
||||
for (size_t s = num_simulcast_layers - 1;; --s) {
|
||||
for (size_t s = simulcast_layers - 1;; --s) {
|
||||
streams[s].width = width;
|
||||
streams[s].height = height;
|
||||
// TODO(pbos): Fill actual temporal-layer bitrate thresholds.
|
||||
streams[s].temporal_layer_thresholds_bps.resize(
|
||||
kDefaultConferenceNumberOfTemporalLayers[s] - 1);
|
||||
streams[s].max_bitrate_bps =
|
||||
FindSimulcastMaxBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].target_bitrate_bps =
|
||||
FindSimulcastTargetBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].min_bitrate_bps =
|
||||
FindSimulcastMinBitrateBps(width, height, simulcast_layers);
|
||||
streams[s].max_qp = max_qp;
|
||||
if (is_screencast && s == 0) {
|
||||
ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault();
|
||||
// For legacy screenshare in conference mode, tl0 and tl1 bitrates are
|
||||
// piggybacked on the VideoCodec struct as target and max bitrates,
|
||||
// respectively. See eg. webrtc::VP8EncoderImpl::SetRates().
|
||||
streams[s].min_bitrate_bps = kMinVideoBitrateKbps * 1000;
|
||||
streams[s].target_bitrate_bps = config.tl0_bitrate_kbps * 1000;
|
||||
streams[s].max_bitrate_bps = config.tl1_bitrate_kbps * 1000;
|
||||
streams[s].temporal_layer_thresholds_bps.clear();
|
||||
streams[s].temporal_layer_thresholds_bps.push_back(
|
||||
config.tl0_bitrate_kbps * 1000);
|
||||
streams[s].max_framerate = 5;
|
||||
} else {
|
||||
streams[s].temporal_layer_thresholds_bps.resize(
|
||||
kDefaultConferenceNumberOfTemporalLayers[s] - 1);
|
||||
streams[s].max_bitrate_bps = FindSimulcastMaxBitrateBps(width, height);
|
||||
streams[s].target_bitrate_bps =
|
||||
FindSimulcastTargetBitrateBps(width, height);
|
||||
streams[s].min_bitrate_bps = FindSimulcastMinBitrateBps(width, height);
|
||||
streams[s].max_framerate = max_framerate;
|
||||
}
|
||||
|
||||
streams[s].max_framerate = max_framerate;
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
if (s == 0)
|
||||
if (s == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Spend additional bits to boost the max stream.
|
||||
@ -253,8 +231,6 @@ static const int kScreenshareDefaultTl1BitrateKbps = 1000;
|
||||
|
||||
static const char* kScreencastLayerFieldTrialName =
|
||||
"WebRTC-ScreenshareLayerRates";
|
||||
static const char* kSimulcastScreenshareFieldTrialName =
|
||||
"WebRTC-SimulcastScreenshare";
|
||||
|
||||
ScreenshareLayerConfig::ScreenshareLayerConfig(int tl0_bitrate, int tl1_bitrate)
|
||||
: tl0_bitrate_kbps(tl0_bitrate), tl1_bitrate_kbps(tl1_bitrate) {
|
||||
@ -297,9 +273,4 @@ bool ScreenshareLayerConfig::FromFieldTrialGroup(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UseSimulcastScreenshare() {
|
||||
return webrtc::field_trial::FindFullName(
|
||||
kSimulcastScreenshareFieldTrialName) == "Enabled";
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
namespace cricket {
|
||||
struct StreamParams;
|
||||
|
||||
// TODO(sprang): Remove this, as we're moving away from temporal layer mode.
|
||||
// Config for use with screen cast when temporal layers are enabled.
|
||||
struct ScreenshareLayerConfig {
|
||||
public:
|
||||
@ -46,16 +45,12 @@ int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams);
|
||||
void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs);
|
||||
|
||||
// Get simulcast settings.
|
||||
// TODO(sprang): Remove default parameter when it's not longer referenced.
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(size_t max_streams,
|
||||
int width,
|
||||
int height,
|
||||
int max_bitrate_bps,
|
||||
int max_qp,
|
||||
int max_framerate,
|
||||
bool is_screencast = false);
|
||||
|
||||
bool UseSimulcastScreenshare();
|
||||
int max_framerate);
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
|
||||
@ -301,16 +301,11 @@ class EncoderStreamFactory
|
||||
int width,
|
||||
int height,
|
||||
const webrtc::VideoEncoderConfig& encoder_config) override {
|
||||
if (is_screencast_ &&
|
||||
(!conference_mode_ || !cricket::UseSimulcastScreenshare())) {
|
||||
RTC_DCHECK_EQ(1, encoder_config.number_of_streams);
|
||||
}
|
||||
if (encoder_config.number_of_streams > 1 ||
|
||||
(CodecNamesEq(codec_name_, kVp8CodecName) && is_screencast_ &&
|
||||
conference_mode_)) {
|
||||
RTC_DCHECK(encoder_config.number_of_streams > 1 ? !is_screencast_ : true);
|
||||
if (encoder_config.number_of_streams > 1) {
|
||||
return GetSimulcastConfig(encoder_config.number_of_streams, width, height,
|
||||
encoder_config.max_bitrate_bps, max_qp_,
|
||||
max_framerate_, is_screencast_);
|
||||
max_framerate_);
|
||||
}
|
||||
|
||||
// For unset max bitrates set default bitrate for non-simulcast.
|
||||
@ -327,6 +322,20 @@ class EncoderStreamFactory
|
||||
stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
|
||||
stream.max_qp = max_qp_;
|
||||
|
||||
// Conference mode screencast uses 2 temporal layers split at 100kbit.
|
||||
if (conference_mode_ && is_screencast_) {
|
||||
ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault();
|
||||
// For screenshare in conference mode, tl0 and tl1 bitrates are
|
||||
// piggybacked
|
||||
// on the VideoCodec struct as target and max bitrates, respectively.
|
||||
// See eg. webrtc::VP8EncoderImpl::SetRates().
|
||||
stream.target_bitrate_bps = config.tl0_bitrate_kbps * 1000;
|
||||
stream.max_bitrate_bps = config.tl1_bitrate_kbps * 1000;
|
||||
stream.temporal_layer_thresholds_bps.clear();
|
||||
stream.temporal_layer_thresholds_bps.push_back(config.tl0_bitrate_kbps *
|
||||
1000);
|
||||
}
|
||||
|
||||
if (CodecNamesEq(codec_name_, kVp9CodecName) && !is_screencast_) {
|
||||
stream.temporal_layer_thresholds_bps.resize(
|
||||
GetDefaultVp9TemporalLayers() - 1);
|
||||
@ -1542,7 +1551,6 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
|
||||
enable_cpu_overuse_detection_(enable_cpu_overuse_detection),
|
||||
source_(nullptr),
|
||||
external_encoder_factory_(external_encoder_factory),
|
||||
internal_encoder_factory_(new InternalEncoderFactory()),
|
||||
stream_(nullptr),
|
||||
encoder_sink_(nullptr),
|
||||
parameters_(std::move(config), options, max_bitrate_bps, codec_settings),
|
||||
@ -1670,20 +1678,10 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder(
|
||||
}
|
||||
|
||||
// Try creating internal encoder.
|
||||
if (FindMatchingCodec(internal_encoder_factory_->supported_codecs(), codec)) {
|
||||
if (parameters_.encoder_config.content_type ==
|
||||
webrtc::VideoEncoderConfig::ContentType::kScreen &&
|
||||
parameters_.conference_mode && UseSimulcastScreenshare()) {
|
||||
// TODO(sprang): Remove this adapter once libvpx supports simulcast with
|
||||
// same-resolution substreams.
|
||||
WebRtcSimulcastEncoderFactory adapter_factory(
|
||||
internal_encoder_factory_.get());
|
||||
return AllocatedEncoder(adapter_factory.CreateVideoEncoder(codec), codec,
|
||||
false /* is_external */);
|
||||
}
|
||||
return AllocatedEncoder(
|
||||
internal_encoder_factory_->CreateVideoEncoder(codec), codec,
|
||||
false /* is_external */);
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
if (FindMatchingCodec(internal_encoder_factory.supported_codecs(), codec)) {
|
||||
return AllocatedEncoder(internal_encoder_factory.CreateVideoEncoder(codec),
|
||||
codec, false /* is_external */);
|
||||
}
|
||||
|
||||
// This shouldn't happen, we should not be trying to create something we don't
|
||||
@ -1860,11 +1858,9 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
|
||||
|
||||
// By default, the stream count for the codec configuration should match the
|
||||
// number of negotiated ssrcs. But if the codec is blacklisted for simulcast
|
||||
// or a screencast (and not in simulcast screenshare experiment), only
|
||||
// configure a single stream.
|
||||
// or a screencast, only configure a single stream.
|
||||
encoder_config.number_of_streams = parameters_.config.rtp.ssrcs.size();
|
||||
if (IsCodecBlacklistedForSimulcast(codec.name) ||
|
||||
(is_screencast && !UseSimulcastScreenshare())) {
|
||||
if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) {
|
||||
encoder_config.number_of_streams = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -330,8 +330,6 @@ class WebRtcVideoChannel2 : public VideoMediaChannel, public webrtc::Transport {
|
||||
ACCESS_ON(&thread_checker_);
|
||||
WebRtcVideoEncoderFactory* const external_encoder_factory_
|
||||
ACCESS_ON(&thread_checker_);
|
||||
const std::unique_ptr<WebRtcVideoEncoderFactory> internal_encoder_factory_
|
||||
ACCESS_ON(&thread_checker_);
|
||||
|
||||
webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_);
|
||||
rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
#include "webrtc/media/base/mediaconstants.h"
|
||||
#include "webrtc/media/base/testutils.h"
|
||||
#include "webrtc/media/base/videoengine_unittest.h"
|
||||
#include "webrtc/media/engine/constants.h"
|
||||
#include "webrtc/media/engine/fakewebrtccall.h"
|
||||
#include "webrtc/media/engine/fakewebrtcvideoengine.h"
|
||||
#include "webrtc/media/engine/simulcast.h"
|
||||
@ -3935,7 +3934,7 @@ TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) {
|
||||
class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
public:
|
||||
WebRtcVideoChannel2SimulcastTest()
|
||||
: fake_call_(webrtc::Call::Config(&event_log_)), last_ssrc_(0) {}
|
||||
: fake_call_(webrtc::Call::Config(&event_log_)) {}
|
||||
|
||||
void SetUp() override {
|
||||
engine_.Init();
|
||||
@ -3950,16 +3949,9 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
int capture_width,
|
||||
int capture_height,
|
||||
size_t num_configured_streams,
|
||||
size_t expected_num_streams,
|
||||
bool screenshare,
|
||||
bool conference_mode) {
|
||||
size_t expected_num_streams) {
|
||||
cricket::VideoSendParameters parameters;
|
||||
VideoOptions options;
|
||||
parameters.codecs.push_back(codec);
|
||||
parameters.conference_mode = conference_mode;
|
||||
if (screenshare) {
|
||||
options.is_screencast = rtc::Optional<bool>(screenshare);
|
||||
}
|
||||
ASSERT_TRUE(channel_->SetSendParameters(parameters));
|
||||
|
||||
std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
|
||||
@ -3972,7 +3964,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
// expected simulcast layers.
|
||||
cricket::FakeVideoCapturer capturer;
|
||||
EXPECT_TRUE(
|
||||
channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer));
|
||||
channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
|
||||
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
|
||||
capture_width, capture_height,
|
||||
cricket::VideoFormat::FpsToInterval(30),
|
||||
@ -3983,32 +3975,9 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
|
||||
ASSERT_EQ(expected_num_streams, video_streams.size());
|
||||
|
||||
std::vector<webrtc::VideoStream> expected_streams;
|
||||
if (conference_mode) {
|
||||
expected_streams = GetSimulcastConfig(
|
||||
num_configured_streams, capture_width, capture_height, 0,
|
||||
kDefaultQpMax, kDefaultVideoMaxFramerate, screenshare);
|
||||
} else {
|
||||
webrtc::VideoStream stream;
|
||||
stream.width = capture_width;
|
||||
stream.height = capture_height;
|
||||
stream.max_framerate = kDefaultVideoMaxFramerate;
|
||||
stream.min_bitrate_bps = cricket::kMinVideoBitrateKbps * 1000;
|
||||
int max_bitrate_kbps;
|
||||
if (capture_width * capture_height <= 320 * 240) {
|
||||
max_bitrate_kbps = 600;
|
||||
} else if (capture_width * capture_height <= 640 * 480) {
|
||||
max_bitrate_kbps = 1700;
|
||||
} else if (capture_width * capture_height <= 960 * 540) {
|
||||
max_bitrate_kbps = 2000;
|
||||
} else {
|
||||
max_bitrate_kbps = 2500;
|
||||
}
|
||||
stream.target_bitrate_bps = stream.max_bitrate_bps =
|
||||
max_bitrate_kbps * 1000;
|
||||
stream.max_qp = kDefaultQpMax;
|
||||
expected_streams.push_back(stream);
|
||||
}
|
||||
std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig(
|
||||
num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax,
|
||||
kDefaultVideoMaxFramerate);
|
||||
|
||||
ASSERT_EQ(expected_streams.size(), video_streams.size());
|
||||
|
||||
@ -4037,8 +4006,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
EXPECT_GT(video_streams[i].max_qp, 0);
|
||||
EXPECT_EQ(expected_streams[i].max_qp, video_streams[i].max_qp);
|
||||
|
||||
EXPECT_EQ(!conference_mode,
|
||||
expected_streams[i].temporal_layer_thresholds_bps.empty());
|
||||
EXPECT_FALSE(expected_streams[i].temporal_layer_thresholds_bps.empty());
|
||||
EXPECT_EQ(expected_streams[i].temporal_layer_thresholds_bps,
|
||||
video_streams[i].temporal_layer_thresholds_bps);
|
||||
|
||||
@ -4092,37 +4060,15 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2, false,
|
||||
true);
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3, false,
|
||||
true);
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3);
|
||||
}
|
||||
|
||||
// Test that we normalize send codec format size in simulcast.
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2, false,
|
||||
true);
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForScreenshare) {
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
|
||||
false);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest,
|
||||
SetSendCodecsForConferenceModeScreenshare) {
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) {
|
||||
webrtc::test::ScopedFieldTrials override_field_trials_(
|
||||
"WebRTC-SimulcastScreenshare/Enabled/");
|
||||
VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true,
|
||||
true);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -30,8 +30,6 @@ static const int kQpDeltaThresholdForSync = 8;
|
||||
const double ScreenshareLayers::kMaxTL0FpsReduction = 2.5;
|
||||
const double ScreenshareLayers::kAcceptableTargetOvershoot = 2.0;
|
||||
|
||||
constexpr int ScreenshareLayers::kMaxNumTemporalLayers;
|
||||
|
||||
// Since this is TL0 we only allow updating and predicting from the LAST
|
||||
// reference frame.
|
||||
const int ScreenshareLayers::kTl0Flags =
|
||||
@ -57,14 +55,8 @@ webrtc::TemporalLayers* ScreenshareTemporalLayersFactory::Create(
|
||||
int simulcast_id,
|
||||
int num_temporal_layers,
|
||||
uint8_t initial_tl0_pic_idx) const {
|
||||
webrtc::TemporalLayers* tl;
|
||||
if (simulcast_id == 0) {
|
||||
tl = new webrtc::ScreenshareLayers(num_temporal_layers, rand(),
|
||||
webrtc::Clock::GetRealTimeClock());
|
||||
} else {
|
||||
RealTimeTemporalLayersFactory rt_tl_factory;
|
||||
tl = rt_tl_factory.Create(simulcast_id, num_temporal_layers, rand());
|
||||
}
|
||||
webrtc::TemporalLayers* tl = new webrtc::ScreenshareLayers(
|
||||
num_temporal_layers, rand(), webrtc::Clock::GetRealTimeClock());
|
||||
if (listener_)
|
||||
listener_->OnTemporalLayersCreated(simulcast_id, tl);
|
||||
return tl;
|
||||
@ -74,8 +66,7 @@ ScreenshareLayers::ScreenshareLayers(int num_temporal_layers,
|
||||
uint8_t initial_tl0_pic_idx,
|
||||
Clock* clock)
|
||||
: clock_(clock),
|
||||
number_of_temporal_layers_(
|
||||
std::min(kMaxNumTemporalLayers, num_temporal_layers)),
|
||||
number_of_temporal_layers_(num_temporal_layers),
|
||||
last_base_layer_sync_(false),
|
||||
tl0_pic_idx_(initial_tl0_pic_idx),
|
||||
active_layer_(-1),
|
||||
@ -87,8 +78,8 @@ ScreenshareLayers::ScreenshareLayers(int num_temporal_layers,
|
||||
max_debt_bytes_(0),
|
||||
encode_framerate_(1000.0f, 1000.0f), // 1 second window, second scale.
|
||||
bitrate_updated_(false) {
|
||||
RTC_CHECK_GT(number_of_temporal_layers_, 0);
|
||||
RTC_CHECK_LE(number_of_temporal_layers_, kMaxNumTemporalLayers);
|
||||
RTC_CHECK_GT(num_temporal_layers, 0);
|
||||
RTC_CHECK_LE(num_temporal_layers, 2);
|
||||
}
|
||||
|
||||
ScreenshareLayers::~ScreenshareLayers() {
|
||||
|
||||
@ -84,7 +84,7 @@ class ScreenshareLayers : public TemporalLayers {
|
||||
RateStatistics encode_framerate_;
|
||||
bool bitrate_updated_;
|
||||
|
||||
static constexpr int kMaxNumTemporalLayers = 2;
|
||||
static const int kMaxNumTemporalLayers = 2;
|
||||
struct TemporalLayer {
|
||||
TemporalLayer()
|
||||
: state(State::kNormal),
|
||||
|
||||
@ -38,8 +38,8 @@ bool VideoCodecInitializer::SetupCodec(
|
||||
case kVideoCodecVP8: {
|
||||
if (!codec->VP8()->tl_factory) {
|
||||
if (codec->mode == kScreensharing &&
|
||||
codec->numberOfSimulcastStreams >= 1 &&
|
||||
codec->VP8()->numberOfTemporalLayers >= 1) {
|
||||
codec->numberOfSimulcastStreams == 1 &&
|
||||
codec->VP8()->numberOfTemporalLayers == 2) {
|
||||
// Conference mode temporal layering for screen content.
|
||||
tl_factory.reset(new ScreenshareTemporalLayersFactory());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user