1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
content / test / data / media / peerconnection-call.html [blame]
<html>
<head>
<script type="text/javascript" src="webrtc_codec_utils.js"></script>
<script type="text/javascript" src="webrtc_test_utilities.js"></script>
<script type="text/javascript" src="webrtc_test_common.js"></script>
<script type="text/javascript">
$ = function(id) {
return document.getElementById(id);
};
var gFirstConnection = null;
var gSecondConnection = null;
var gLocalStream = null;
var gRemoteStreams = {};
// Test that we can setup a call with an audio and video track (must request
// video in this call since we expect video to be playing).
function call(constraints) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-2')
])
.then(logSuccess);
}
function oldStyleCall() {
createConnections();
return Promise.all([
new Promise((resolve, reject) => {
navigator.webkitGetUserMedia({video: true, audio: true},
resolve, reject);
}).then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-2')
])
.then(logSuccess);
}
// Hang up a call.
function hangup() {
gFirstConnection.close();
gSecondConnection.close();
gFirstConnection = null;
gSecondConnection = null;
gLocalStream.getTracks().forEach(function(track) {
track.stop();
});
gLocalStream = null;
return logSuccess();
}
// Test that we can setup a call with a video track and that the remote peer
// receives black frames if the local video track is disabled.
function callAndDisableLocalVideo(constraints) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1').then(() => {
assertEquals(gLocalStream.getVideoTracks().length, 1);
gLocalStream.getVideoTracks()[0].enabled = false;
return detectBlackVideo('remote-view-1');
}),
])
.then(logSuccess);
}
// Test that we can setup call with an audio and video track and check that
// the video resolution is as expected.
function callAndExpectResolution(constraints,
expected_width,
expected_height,
alignment) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlayingWithExpectedResolution(
'remote-view-1', expected_width, expected_height, alignment),
detectVideoPlayingWithExpectedResolution(
'remote-view-2', expected_width, expected_height, alignment)
])
.then(logSuccess);
}
// First calls without streams on any connections, and then adds a stream
// to peer connection 1 which gets sent to peer connection 2. We must wait
// for the first negotiation to complete before starting the second one, which
// is why we wait until the connection is stable before re-negotiating.
function callEmptyThenAddOneStreamAndRenegotiate(constraints) {
createConnections();
return Promise.all([
negotiate(),
waitForConnectionToStabilize(gFirstConnection).then(() => {
return navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToTheFirstConnectionAndNegotiate);
}).then(() => {
// Only the first connection is sending here.
return detectVideoPlaying('remote-view-2');
}),
])
.then(logSuccess);
}
// The second set of constraints should request video (e.g. video:true) since
// we expect video to be playing after the second renegotiation.
function callAndRenegotiateToVideo(constraints, renegotiationConstraints) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToBothConnectionsAndNegotiate),
waitForConnectionToStabilize(gFirstConnection).then(() => {
gFirstConnection.removeStream(gLocalStream);
gSecondConnection.removeStream(gLocalStream);
}).then(() => {
return navigator.mediaDevices.getUserMedia(renegotiationConstraints)
.then(addStreamToBothConnectionsAndNegotiate);
}).then(() => {
return Promise.all([
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-1')]);
}),
])
.then(logSuccess);
}
// First makes a call between pc1 and pc2 where a stream is sent from pc1 to
// pc2. The stream sent from pc1 to pc2 is cloned from the stream received on
// pc2 to test that cloning of remote video tracks works as intended and is
// sent back to pc1.
function callAndForwardRemoteStream(constraints) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia(constraints)
.then(addStreamToTheFirstConnectionAndNegotiate),
console.log('Initial setup done. Waiting.'),
// Wait for remove video to be playing in pc2. Once video is playing,
// forward the remove stream from pc2 to pc1.
detectVideoPlaying('remote-view-2').then(() => {
// Video has been detected to be playing in pc2. Clone the received
// stream and send it back to pc1.
console.log('callAndForward: Adding return stream');
gSecondConnection.addStream(gRemoteStreams['remote-view-2'].clone());
return Promise.all([
negotiate(),
// Wait for video to be forwarded back to connection 1.
detectVideoPlaying('remote-view-1'),
]);
}),
])
.then(logSuccess);
}
// First makes a call between pc1 and pc2, and then construct a new media
// stream using the remote audio and video tracks, connect the new media
// stream to a video element. These operations should not crash Chrome.
function ConnectChromiumSinkToRemoteAudioTrack() {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-2').then(() => {
// Construct a new media stream with remote tracks.
var newStream = new MediaStream();
newStream.addTrack(
gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]);
newStream.addTrack(
gSecondConnection.getRemoteStreams()[0].getVideoTracks()[0]);
var videoElement = document.createElement('video');
// No crash for this operation.
videoElement.srcObject = newStream;
return detectVideoPlaying('remote-view-2')
}),
])
.then(logSuccess);
}
// Test that we can setup call with an audio and video track and
// simulate that the remote peer don't support MSID.
function callWithoutMsidAndBundle() {
createConnections();
setOfferSdpTransform(removeBundle);
setRemoteSdpTransform(removeMsid);
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-1')
])
.then(logSuccess);
}
// Test that we can't setup a call with an unsupported video codec
function negotiateUnsupportedVideoCodec() {
createConnections();
setOfferSdpTransform(removeVideoCodec);
return navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate)
.then(
() => {
throw new Error('Expected to fail, but succeeded');
},
(error) => {
var expectedMsg = "Failed to set local offer sdp: Failed to set local " +
"video description recv parameters for m-section with mid='1'.";
assertEquals(expectedMsg, error.message);
return logSuccess();
});
}
// Test that we can't setup a call if one peer does not support encryption
function negotiateNonCryptoCall() {
createConnections();
setOfferSdpTransform(removeCrypto);
return navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate)
.then(() => {
throw new Error('Expected to fail, but succeeded');
}, (error) => {
// Per spec, error should be 'InvalidAccessError'
// 4.4.1.5 Set the session description 1.4.5.6
// https://crbug.com/1490510
var expectedError = 'InvalidAccessError';
assertEquals(expectedError, error.name);
return logSuccess();
});
}
// Test that we can negotiate a call with an SDP offer that includes a
// b=AS:XX line to control audio and video bandwidth
function negotiateOfferWithBLine() {
createConnections();
setOfferSdpTransform(addBandwithControl);
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-1')
])
.then(logSuccess);
}
// Test that we can setup call and send DTMF.
function callAndSendDtmf(tones) {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
// Do the DTMF test after we have received video.
detectVideoPlaying('remote-view-2').then(() => {
// Send DTMF tones. Allocate the sender in the window to keep it from
// being garbage collected. https://crbug.com/486654.
var track = gLocalStream.getAudioTracks()[0];
window.sender = gFirstConnection.createDTMFSender(track);
var receivedTones = '';
return new Promise(resolve => {
window.sender.ontonechange = tone => {
receivedTones += tone.tone;
if (receivedTones == tones) {
resolve();
}
};
window.sender.insertDTMF(tones);
});
}),
])
.then(logSuccess);
}
function testCreateOfferOptions() {
createConnections();
var offerOptions = {
'offerToReceiveAudio': false,
'offerToReceiveVideo': true
};
return gFirstConnection.createOffer(offerOptions)
.then(function(offer) {
assertEquals(-1, offer.sdp.search('m=audio'));
assertNotEquals(-1, offer.sdp.search('m=video'));
return logSuccess();
});
}
function enableRemoteVideo(peerConnection, enabled) {
remoteStream = peerConnection.getRemoteStreams()[0];
remoteStream.getVideoTracks()[0].enabled = enabled;
}
function enableRemoteAudio(peerConnection, enabled) {
remoteStream = peerConnection.getRemoteStreams()[0];
remoteStream.getAudioTracks()[0].enabled = enabled;
}
function callAndEnsureVideoTrackMutingWorks() {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-2').then(() => {
// Disable the receiver's remote media stream. Video should stop.
// (Also, ensure muting audio doesn't affect video).
enableRemoteVideo(gSecondConnection, false);
enableRemoteAudio(gSecondConnection, false);
return detectVideoStopped('remote-view-2').then(() => {
// Video has stopped: unmute and succeed if it starts playing again.
enableRemoteVideo(gSecondConnection, true);
return detectVideoPlaying('remote-view-2')
})
}),
])
.then(logSuccess);
}
// Test call with a new Video MediaStream that has been created based on a
// stream generated by getUserMedia.
function callWithNewVideoMediaStream() {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(createNewVideoStreamAndAddToBothConnections),
detectVideoPlaying('remote-view-1'),
detectVideoPlaying('remote-view-1')
])
.then(logSuccess);
}
// Loads this page inside itself using an iframe, and ensures we can make a
// successful getUserMedia + peerconnection call inside the iframe.
function callInsideIframe(constraints) {
return createIframe().then(function(iframe) {
// Run a regular webrtc call inside the iframe.
return iframe.contentWindow.call(constraints);
});
}
function createIframe() {
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
return new Promise(resolve => {
iframe.onload = onIframeLoaded;
iframe.src = window.location;
function onIframeLoaded() {
var iframe = window.document.querySelector('iframe');
resolve(iframe);
}
});
}
// Test call with a stream that has been created by getUserMedia, clone
// the stream to a cloned stream, send them via the same peer connection.
function addTwoMediaStreamsToOneConnection() {
createConnections();
var called = 0;
var remoteAddStreamCalledTwice = new Promise((resolve, reject) => {
gSecondConnection.onaddstream = () => {
called += 1;
if (called == 2)
resolve();
};
});
function verifyHasOneAudioAndVideoTrack(stream) {
assertEquals(1, stream.getAudioTracks().length);
assertEquals(1, stream.getVideoTracks().length);
}
return navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then((localStream) => {
displayAndRemember(localStream);
var clonedStream = null;
if (typeof localStream.clone === "function") {
clonedStream = localStream.clone();
} else {
clonedStream = new MediaStream(localStream);
}
gFirstConnection.addStream(localStream);
gFirstConnection.addStream(clonedStream);
// Verify the local streams are correct.
assertEquals(2, gFirstConnection.getLocalStreams().length);
verifyHasOneAudioAndVideoTrack(gFirstConnection.getLocalStreams()[0]);
verifyHasOneAudioAndVideoTrack(gFirstConnection.getLocalStreams()[1]);
return negotiate();
})
// The remote side should receive two streams after negotiation.
.then(() => { return remoteAddStreamCalledTwice; })
.then(() => {
// Negotiation complete, verify remote streams on the receiving side.
assertEquals(2, gSecondConnection.getRemoteStreams().length);
verifyHasOneAudioAndVideoTrack(
gSecondConnection.getRemoteStreams()[0]);
verifyHasOneAudioAndVideoTrack(
gSecondConnection.getRemoteStreams()[1]);
})
.then(logSuccess);
}
function createConnections() {
gFirstConnection = createConnection('remote-view-1');
assertEquals('stable', gFirstConnection.signalingState);
gSecondConnection = createConnection('remote-view-2');
assertEquals('stable', gSecondConnection.signalingState);
}
function createConnection(remoteView) {
var pc = new RTCPeerConnection();
pc.onaddstream = function(event) {
onRemoteStream(event, remoteView);
}
return pc;
}
function displayAndRemember(localStream) {
$('local-view').srcObject = localStream;
gLocalStream = localStream;
}
// Called if getUserMedia succeeds and we want to send from both connections.
function addStreamToBothConnectionsAndNegotiate(localStream) {
displayAndRemember(localStream);
gFirstConnection.addStream(localStream);
gSecondConnection.addStream(localStream);
return negotiate();
}
// Called if getUserMedia succeeds when we want to send from one connection.
function addStreamToTheFirstConnectionAndNegotiate(localStream) {
displayAndRemember(localStream);
gFirstConnection.addStream(localStream);
negotiate();
}
// A new MediaStream is created with video track from |localStream| and is
// added to both peer connections.
function createNewVideoStreamAndAddToBothConnections(localStream) {
displayAndRemember(localStream);
var newStream = new MediaStream();
newStream.addTrack(localStream.getVideoTracks()[0]);
gFirstConnection.addStream(newStream);
gSecondConnection.addStream(newStream);
return negotiate();
}
function negotiate() {
return negotiateBetween(gFirstConnection, gSecondConnection);
}
function iceCandidateIsLoopback(candidate) {
return candidate.candidate.indexOf("127.0.0.1") > -1 ||
candidate.candidate.indexOf(" ::1 ") > -1;
}
function gatherIceCandidates(pc) {
var candidates = [];
pc.createDataChannel("");
return new Promise((resolve, reject) => {
pc.onicecandidate = function(event) {
// null candidate indicates the gathering has completed.
if (event.candidate == null) {
resolve(candidates);
} else {
candidates.push(event.candidate);
}
}
pc.createOffer(
function(offer) {
pc.setLocalDescription(offer);
},
function(error) { reject(error); }
);
});
}
function callWithDevicePermissionGranted() {
var pc = new RTCPeerConnection();
return gatherIceCandidates(pc)
.then(function(candidates) {
var hasLoopbackCandidate = false;
assertEquals(candidates.length > 0, true);
for (i = 0; i < candidates.length; i++) {
hasLoopbackCandidate |= iceCandidateIsLoopback(candidates[i]);
}
if (hasLoopbackCandidate) {
return logSuccess();
} else {
throw new Error('expect to see non-default host interface');
}
});
}
function callWithNoCandidateExpected() {
var pc = new RTCPeerConnection();
return gatherIceCandidates(pc)
.then(function(candidates) {
assertEquals(candidates.length, 0);
return logSuccess();
});
}
function callAndExpectNonLoopbackCandidates() {
// This one fails if the executing machine has no Internet.
var pc = new RTCPeerConnection();
return gatherIceCandidates(pc)
.then(function(candidates) {
var hasCandidate = false;
assertEquals(candidates.length > 0, true);
for (i = 0; i < candidates.length; i++) {
hasCandidate = true;
assertEquals(iceCandidateIsLoopback(candidates[i]), false);
}
assertTrue(hasCandidate, 'expect to see at least one candidate');
return logSuccess();
});
}
function removeMsid(offerSdp) {
offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, '');
offerSdp = offerSdp.replace('a=mid:audio\r\n', '');
offerSdp = offerSdp.replace('a=mid:video\r\n', '');
offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, '');
return offerSdp;
}
function removeVideoCodec(offerSdp) {
offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
function removeCrypto(offerSdp) {
offerSdp = offerSdp.replace(/a=crypto.*\r\n/g, 'a=Xcrypto\r\n');
offerSdp = offerSdp.replace(/a=fingerprint.*\r\n/g, '');
return offerSdp;
}
function addBandwithControl(offerSdp) {
offerSdp = offerSdp.replace('a=mid:audio\r\n', 'a=mid:audio\r\n'+
'b=AS:16\r\n');
offerSdp = offerSdp.replace('a=mid:video\r\n', 'a=mid:video\r\n'+
'b=AS:512\r\n');
return offerSdp;
}
function removeBundle(sdp) {
return sdp.replace(/a=group:BUNDLE .*\r\n/g, '');
}
function onRemoteStream(e, target) {
console.log("Receiving remote stream...");
gRemoteStreams[target] = e.stream;
var remoteVideo = $(target);
remoteVideo.srcObject = e.stream;
}
// Check that applyConstraints() fails on remote tracks because there is
// currently no mechanism to make their video format known to the track, so
// it is impossible to enforce the user-provided constraints.
// TODO(guidou): Make the video format for remote sources known
// http://crbug.com/772400
function testApplyConstraints() {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1').then(() => {
var track = gFirstConnection.getRemoteStreams()[0].getVideoTracks()[0];
return track.applyConstraints({width: {min: 1000}})
.then(() => {
throw 'applyConstraints should fail for remote tracks';
}, e => {
assertEquals(e.name, 'OverconstrainedError');
});
}),
])
.then(logSuccess);
}
// Makes a call between pc1 and pc2 and check that the remote video tracks
// report values for width and height, but not for frame rate.
function testGetSettingsReportsValuesForRemoteTracks() {
createConnections();
return Promise.all([
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(addStreamToBothConnectionsAndNegotiate),
detectVideoPlaying('remote-view-1').then(() => {
var settings1 = gFirstConnection.getRemoteStreams()[0].getVideoTracks()[0]
.getSettings();
assertTrue(settings1.width != undefined);
assertTrue(settings1.height != undefined);
assertTrue(settings1.frameRate != undefined);
return detectVideoPlaying('remote-view-2').then(() => {
var settings2 = gSecondConnection.getRemoteStreams()[0]
.getVideoTracks()[0].getSettings();
assertTrue(settings2.width != undefined);
assertTrue(settings2.height != undefined);
assertTrue(settings2.frameRate != undefined);
});
}),
])
.then(logSuccess);
}
// TODO(crbug.com/40637961): This test is a temporary replacement for:
// external/wpt/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html
async function testEstablishVideoOnlyCallAndVerifyGetSynchronizationSourcesWorks() {
const startTime = performance.timeOrigin + performance.now();
createConnections();
const stream = await navigator.mediaDevices.getUserMedia({video: true});
await addStreamToBothConnectionsAndNegotiate(stream);
await detectVideoPlaying('remote-view-2');
const peerConnection = gSecondConnection;
const receivers = peerConnection.getReceivers();
assertEquals(receivers.length, 1);
const receiver = receivers[0];
assertEquals(receiver.track.kind, 'video');
const results = receiver.getSynchronizationSources();
assertEquals(results.length, 1);
const result = results[0];
const endTime = performance.timeOrigin + performance.now();
console.log('getSynchronizationSources() = ' + JSON.stringify(result));
// timestamp
assertEquals(typeof result.timestamp, 'number');
assertTrue(result.timestamp >= startTime);
assertTrue(result.timestamp <= endTime);
// source
assertEquals(typeof result.source, 'number');
assertTrue(result.source >= 0);
assertTrue(result.source <= 0xffffffff);
// rtpTimestamp
assertEquals(typeof result.rtpTimestamp, 'number');
assertTrue(result.rtpTimestamp >= 0);
assertTrue(result.rtpTimestamp <= 0xffffffff);
// audioLevel
assertEquals(result.audioLevel, undefined);
// voiceActivityFlag
assertEquals(result.voiceActivityFlag, undefined);
return logSuccess();
}
async function CanSetupH264VideoCallOnSupportedDevice() {
// Setup one way video call, prioritize H264 and verify that it used.
createConnections();
setOfferSdpTransform(maybePreferH264SendCodec);
await Promise.all([
navigator.mediaDevices.getUserMedia({audio: false, video: true})
.then(addStreamToTheFirstConnectionAndNegotiate),
detectVideoPlaying('remote-view-2'),
]);
assertEquals(gLocalStream.getVideoTracks().length, 1);
// Ensure that call uses H264.
return gFirstConnection.getStats(gLocalStream.getVideoTracks()[0])
.then(function(report) {
var numCodecs = 0;
var hasH264 = false;
var supported_codecs = [];
report.forEach(stats => {
if (stats.type == 'codec') {
numCodecs++;
supported_codecs.push(stats.mimeType);
if (stats.mimeType == 'video/H264') {
hasH264 = true;
}
}
});
assertEquals(1, numCodecs);
assertTrue(hasH264, JSON.stringify(supported_codecs));
return logSuccess();
});
}
</script>
</head>
<body>
<table border="0">
<tr>
<td><video width="320" height="240" id="local-view" style="display:none"
autoplay muted></video></td>
<td><video width="320" height="240" id="remote-view-1"
style="display:none" autoplay></video></td>
<td><video width="320" height="240" id="remote-view-2"
style="display:none" autoplay></video></td>
<td><video width="320" height="240" id="remote-view-3"
style="display:none" autoplay></video></td>
<td><video width="320" height="240" id="remote-view-4"
style="display:none" autoplay></video></td>
<!-- Canvases are named after their corresponding video elements. -->
<td><canvas width="320" height="240" id="remote-view-1-canvas"
style="display:none"></canvas></td>
<td><canvas width="320" height="240" id="remote-view-2-canvas"
style="display:none"></canvas></td>
<td><canvas width="320" height="240" id="remote-view-3-canvas"
style="display:none"></canvas></td>
<td><canvas width="320" height="240" id="remote-view-4-canvas"
style="display:none"></canvas></td>
</tr>
</table>
</body>
</html>