Bug 1654112 - Reinstate usage of mLockScaling in VideoConduit. r=ng

Differential Revision: https://phabricator.services.mozilla.com/D112849
This commit is contained in:
Andreas Pehrson 2021-04-07 09:45:07 +02:00
Родитель 2c32da060a
Коммит e3754e9e2b
2 изменённых файлов: 59 добавлений и 4 удалений

Просмотреть файл

@ -1194,7 +1194,10 @@ void WebrtcVideoConduit::SelectSendResolution(unsigned short width,
ConstrainPreservingAspectRatio(max_width, max_height, &width, &height);
}
int max_fs = mVideoBroadcaster.wants().max_pixel_count;
int max_fs = std::numeric_limits<int>::max();
if (!mLockScaling) {
max_fs = mVideoBroadcaster.wants().max_pixel_count;
}
// Limit resolution to max-fs
if (mCurSendCodecConfig->mEncodingConstraints.maxFs) {
// max-fs is in macroblocks, convert to pixels

Просмотреть файл

@ -43,11 +43,12 @@ class MockVideoSink : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
class VideoConduitTest : public Test {
public:
VideoConduitTest()
VideoConduitTest(
VideoSessionConduit::Options aOptions = VideoSessionConduit::Options())
: mCallWrapper(MockCallWrapper::Create()),
mVideoConduit(MakeRefPtr<WebrtcVideoConduit>(
mCallWrapper, GetCurrentSerialEventTarget(),
VideoSessionConduit::Options(), "")) {
mCallWrapper, GetCurrentSerialEventTarget(), std::move(aOptions),
"")) {
NSS_NoDB_Init(nullptr);
mVideoConduit->SetLocalSSRCs({42}, {43});
@ -729,6 +730,57 @@ TEST_F(VideoConduitTest, TestOnSinkWantsChanged) {
mVideoConduit->StopTransmitting();
}
class VideoConduitTestScalingLocked : public VideoConduitTest {
public:
static VideoSessionConduit::Options CreateOptions() {
VideoSessionConduit::Options options;
options.mLockScaling = true;
return options;
}
VideoConduitTestScalingLocked() : VideoConduitTest(CreateOptions()) {}
};
TEST_F(VideoConduitTestScalingLocked, TestOnSinkWantsChanged) {
UniquePtr<MockVideoSink> sink(new MockVideoSink());
rtc::VideoSinkWants wants;
mVideoConduit->AddOrUpdateSink(sink.get(), wants);
RtpRtcpConfig rtpConf(webrtc::RtcpMode::kCompound);
wants.max_pixel_count = 256000;
EncodingConstraints constraints;
VideoCodecConfig::Encoding encoding;
VideoCodecConfig codecConfig(120, "VP8", constraints);
codecConfig.mEncodings.push_back(encoding);
std::vector<webrtc::VideoStream> videoStreams;
codecConfig.mEncodingConstraints.maxFs = 0;
mVideoConduit->ConfigureSendMediaCodec(&codecConfig, rtpConf);
mVideoConduit->StartTransmitting();
mVideoConduit->AddOrUpdateSink(sink.get(), wants);
SendVideoFrame(1920, 1080, 1);
EXPECT_EQ(sink->mVideoFrame.width(), 1920);
EXPECT_EQ(sink->mVideoFrame.height(), 1080);
videoStreams = Call()->CreateEncoderStreams(sink->mVideoFrame.width(),
sink->mVideoFrame.height());
ASSERT_EQ(videoStreams.size(), 1U);
EXPECT_EQ(videoStreams[0].width, 1920U);
EXPECT_EQ(videoStreams[0].height, 1080U);
codecConfig.mEncodingConstraints.maxFs = 500;
mVideoConduit->ConfigureSendMediaCodec(&codecConfig, rtpConf);
mVideoConduit->AddOrUpdateSink(sink.get(), wants);
SendVideoFrame(1920, 1080, 2);
EXPECT_LE(sink->mVideoFrame.width() * sink->mVideoFrame.height(),
500 * 16 * 16);
videoStreams = Call()->CreateEncoderStreams(sink->mVideoFrame.width(),
sink->mVideoFrame.height());
ASSERT_EQ(videoStreams.size(), 1U);
EXPECT_EQ(videoStreams[0].width, 360U);
EXPECT_EQ(videoStreams[0].height, 201U);
mVideoConduit->StopTransmitting();
}
TEST_F(VideoConduitTest, TestConfigureSendMediaCodecSimulcastOddScreen) {
mVideoConduit->SetLocalSSRCs({42, 43, 44}, {45, 46, 47});
RtpRtcpConfig rtpConf(webrtc::RtcpMode::kCompound);