Skip to content

Commit ba13ab6

Browse files
authored
Merge branch 'gh-pages' into video-replay
2 parents 3ea8e60 + 6af9706 commit ba13ab6

File tree

1 file changed

+55
-8
lines changed
  • src/content/extensions/svc/js

1 file changed

+55
-8
lines changed

src/content/extensions/svc/js/main.js

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ const scalabilityMode = document.querySelector('#scalabilityMode');
4545
const supportsSetCodecPreferences = window.RTCRtpTransceiver &&
4646
'setCodecPreferences' in window.RTCRtpTransceiver.prototype;
4747

48+
const scalabilityModes = [
49+
'L1T1',
50+
'L1T2',
51+
'L1T3',
52+
'L2T1',
53+
'L2T2',
54+
'L2T3',
55+
'L3T1',
56+
'L3T2',
57+
'L3T3',
58+
'L2T1h',
59+
'L2T2h',
60+
'L2T3h',
61+
'S2T1',
62+
'S2T2',
63+
'S2T3',
64+
'S2T1h',
65+
'S2T2h',
66+
'S2T3h',
67+
'S3T1',
68+
'S3T2',
69+
'S3T3',
70+
'S3T1h',
71+
'S3T2h',
72+
'S3T3h',
73+
'L2T2_KEY',
74+
'L2T3_KEY',
75+
'L3T2_KEY',
76+
'L3T3_KEY'
77+
];
78+
4879
let localStream;
4980
let pc1;
5081
let pc2;
@@ -94,24 +125,40 @@ async function start() {
94125
option.innerText = option.value;
95126
codecPreferences.appendChild(option);
96127
});
97-
codecPreferences.addEventListener('change', (event) => {
98-
const [mimeType, sdpFmtpLine] = event.target.value.split(' ');
99-
const selectedCodecIndex = codecs.findIndex(c => c.mimeType === mimeType && c.sdpFmtpLine === sdpFmtpLine);
100-
const selectedCodec = codecs[selectedCodecIndex];
128+
codecPreferences.addEventListener('change', async (event) => {
129+
const [mimeType] = event.target.value.split(' ');
101130
while (scalabilityMode.firstChild) {
102131
scalabilityMode.firstChild.remove();
103132
}
104133
const option = document.createElement('option');
105134
option.value = '';
106135
option.innerText = 'NONE';
107136
scalabilityMode.appendChild(option);
108-
if (selectedCodec.scalabilityModes) {
109-
for (const mode of selectedCodec.scalabilityModes) {
137+
138+
const capabilityPromises = [];
139+
for (const mode of scalabilityModes) {
140+
capabilityPromises.push(navigator.mediaCapabilities.encodingInfo({
141+
type: 'webrtc',
142+
video: {
143+
contentType: mimeType,
144+
width: 640,
145+
height: 480,
146+
bitrate: 10000,
147+
framerate: 29.97,
148+
scalabilityMode: mode
149+
}}));
150+
}
151+
const capabilityResults = await Promise.all(capabilityPromises);
152+
for (let i = 0; i < scalabilityModes.length; ++i) {
153+
if (capabilityResults[i].supported) {
110154
const option = document.createElement('option');
111-
option.value = mode;
112-
option.innerText = mode;
155+
option.value = scalabilityModes[i];
156+
option.innerText = scalabilityModes[i];
113157
scalabilityMode.appendChild(option);
114158
}
159+
}
160+
161+
if (scalabilityMode.childElementCount > 1) {
115162
scalabilityMode.disabled = false;
116163
} else {
117164
scalabilityMode.disabled = true;

0 commit comments

Comments
 (0)