Skip to content
Snippets Groups Projects
Commit f1bcc146 authored by Byron Campen's avatar Byron Campen
Browse files

Bug 1676855: Support RTCRtpEncodingParameters.active r=jib,mjf

parent e1da52d8
No related branches found
No related tags found
No related merge requests found
......@@ -859,6 +859,7 @@ bool operator==(const RTCRtpEncodingParameters& a1,
void RTCRtpSender::ApplyJsEncodingToConduitEncoding(
const RTCRtpEncodingParameters& aJsEncoding,
VideoCodecConfig::Encoding* aConduitEncoding) {
aConduitEncoding->active = aJsEncoding.mActive;
if (aJsEncoding.mMaxBitrate.WasPassed()) {
aConduitEncoding->constraints.maxBr = aJsEncoding.mMaxBitrate.Value();
}
......
......@@ -121,8 +121,11 @@ class VideoCodecConfig {
struct Encoding {
std::string rid;
EncodingConstraints constraints;
bool active = true;
// TODO(bug 1744116): Use = default here
bool operator==(const Encoding& aOther) const {
return rid == aOther.rid && constraints == aOther.constraints;
return rid == aOther.rid && constraints == aOther.constraints &&
active == aOther.active;
}
};
std::vector<Encoding> mEncodings;
......@@ -133,6 +136,7 @@ class VideoCodecConfig {
uint8_t mPacketizationMode;
// TODO: add external negotiated SPS/PPS
// TODO(bug 1744116): Use = default here
bool operator==(const VideoCodecConfig& aRhs) const {
return mType == aRhs.mType && mName == aRhs.mName &&
mAckFbTypes == aRhs.mAckFbTypes &&
......
......@@ -1309,6 +1309,22 @@ MediaConduitErrorCode WebrtcVideoConduit::SendVideoFrame(
__FUNCTION__);
return kMediaConduitNoError;
}
// Workaround for bug in libwebrtc where all encodings are transmitted
// if they are all inactive.
bool anyActive = false;
for (const auto& encoding : mCurSendCodecConfig->mEncodings) {
if (encoding.active) {
anyActive = true;
break;
}
}
if (!anyActive) {
CSFLogVerbose(LOGTAG, "WebrtcVideoConduit %p %s No active encodings",
this, __FUNCTION__);
return kMediaConduitNoError;
}
CSFLogVerbose(LOGTAG, "WebrtcVideoConduit %p %s (send SSRC %u (0x%x))",
this, __FUNCTION__, mSendStreamConfig.rtp.ssrcs.front(),
mSendStreamConfig.rtp.ssrcs.front());
......
......@@ -150,6 +150,7 @@ std::vector<webrtc::VideoStream> VideoStreamFactory::CreateEncoderStreams(
for (int idx = streamCount - 1; idx >= 0; --idx) {
webrtc::VideoStream video_stream;
auto& encoding = mCodecConfig.mEncodings[idx];
video_stream.active = encoding.active;
MOZ_ASSERT(encoding.constraints.scaleDownBy >= 1.0);
gfx::IntSize newSize(0, 0);
......
[setParameters-active.https.html]
expected:
if (os == "android") and fission: [TIMEOUT, OK]
expected: [OK, TIMEOUT]
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1787474
[Simulcast setParameters active=false on first encoding stops sending frames for that encoding]
expected: [PASS, TIMEOUT]
[Simulcast setParameters active=false on second encoding stops sending frames for that encoding]
expected: [PASS, TIMEOUT, NOTRUN]
[Simulcast setParameters active=false stops sending frames]
expected: FAIL
expected: [PASS, TIMEOUT, NOTRUN]
......@@ -24,6 +24,56 @@ async function queryReceiverStats(pc) {
return inboundStats.map(s => s.framesDecoded);
}
promise_test(async t => {
const rids = [0, 1];
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
// Deactivate first sender.
const parameters = pc1.getSenders()[0].getParameters();
parameters.encodings[0].active = false;
await pc1.getSenders()[0].setParameters(parameters);
// Assert (almost) no new frames are received on the first encoding.
// Without any action we would expect to have received around 30fps.
await new Promise(resolve => t.step_timeout(resolve, 100)); // Wait a bit.
const initialStats = await queryReceiverStats(pc2);
await new Promise(resolve => t.step_timeout(resolve, 1000)); // Wait more.
const subsequentStats = await queryReceiverStats(pc2);
assert_equals(subsequentStats[0], initialStats[0]);
assert_greater_than(subsequentStats[1], initialStats[1]);
}, 'Simulcast setParameters active=false on first encoding stops sending frames for that encoding');
promise_test(async t => {
const rids = [0, 1];
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
await negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2);
// Deactivate second sender.
const parameters = pc1.getSenders()[0].getParameters();
parameters.encodings[1].active = false;
await pc1.getSenders()[0].setParameters(parameters);
// Assert (almost) no new frames are received on the second encoding.
// Without any action we would expect to have received around 30fps.
await new Promise(resolve => t.step_timeout(resolve, 100)); // Wait a bit.
const initialStats = await queryReceiverStats(pc2);
await new Promise(resolve => t.step_timeout(resolve, 1000)); // Wait more.
const subsequentStats = await queryReceiverStats(pc2);
assert_equals(subsequentStats[1], initialStats[1]);
assert_greater_than(subsequentStats[0], initialStats[0]);
}, 'Simulcast setParameters active=false on second encoding stops sending frames for that encoding');
promise_test(async t => {
const rids = [0, 1];
const pc1 = new RTCPeerConnection();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment