Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: webrtc/tools/rtcbot/test/three_bots_video_conference.js

Issue 2965593002: Move webrtc/{tools => rtc_tools} (Closed)
Patch Set: Adding back root changes Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 //
9 // A video conference between 3 bots streaming video and audio between
10 // each other.
11 // The test succeeds after establishing the call between the three
12 // devices.
13 //
14 // Note: the source of the video and audio stream is getUserMedia().
15 function testTwoWayVideoStreaming(test, bot1, bot2, bot3) {
16 var answersCount = 0;
17 var statsCollector;
18
19 test.wait([
20 createBotPeerConnectionsWithLocalStream.bind(bot1),
21 createBotPeerConnectionsWithLocalStream.bind(bot2),
22 createBotPeerConnectionsWithLocalStream.bind(bot3)],
23 onPeerConnectionCreated);
24
25 // done() callback is called with list of peers as argument.
26 function createBotPeerConnectionsWithLocalStream(done) {
27 var peerConnections = [];
28
29 this.getUserMedia({video:true, audio:true},
30 onUserMediaSuccess.bind(this), test.fail);
31
32 function onUserMediaSuccess(stream) {
33 test.log("User has granted access to local media.");
34 this.showStream(stream.id, true, true);
35
36 test.createTurnConfig(onTurnConfig.bind(this), test.fail);
37
38 function onTurnConfig(config) {
39 this.createPeerConnection(config, addStream.bind(this),
40 test.fail);
41 this.createPeerConnection(config, addStream.bind(this),
42 test.fail);
43 }
44
45 function addStream(pc) {
46 pc.addStream(stream);
47 pc.addEventListener('addstream', onAddStream.bind(this));
48
49 peerConnections.push(pc);
50 if(peerConnections.length == 2)
51 done(peerConnections);
52 }
53 }
54 }
55
56 function onPeerConnectionCreated(peerConnections1,
57 peerConnections2, peerConnections3) {
58 test.log("RTC Peers created.");
59
60 // Bot1 and Bot2
61 establichCall(peerConnections1[0], peerConnections2[1]);
62 // Bot2 and Bot3
63 establichCall(peerConnections2[0], peerConnections3[1]);
64 // Bot3 and Bot1
65 establichCall(peerConnections3[0], peerConnections1[1]);
66 }
67
68 function establichCall(pc1, pc2) {
69 pc1.addEventListener('icecandidate', onIceCandidate.bind(pc2));
70 pc2.addEventListener('icecandidate', onIceCandidate.bind(pc1));
71
72 createOfferAndAnswer(pc1, pc2);
73 }
74
75 function onAddStream(event) {
76 test.log("On Add stream.");
77 this.showStream(event.stream.id, true, false);
78 }
79
80 function onIceCandidate(event) {
81 if(event.candidate) {
82 this.addIceCandidate(event.candidate,
83 onAddIceCandidateSuccess, test.fail);
84 };
85
86 function onAddIceCandidateSuccess() {
87 test.log("Candidate added successfully");
88 };
89 }
90
91 function createOfferAndAnswer(pc1, pc2) {
92 test.log("Creating offer.");
93 pc1.createOffer(gotOffer, test.fail);
94
95 function gotOffer(offer) {
96 test.log("Got offer");
97 pc1.setLocalDescription(offer, onSetSessionDescriptionSuccess, test.fail);
98 pc2.setRemoteDescription(offer, onSetSessionDescriptionSuccess,
99 test.fail);
100 test.log("Creating answer");
101 pc2.createAnswer(gotAnswer, test.fail);
102 }
103
104 function gotAnswer(answer) {
105 test.log("Got answer");
106 pc2.setLocalDescription(answer, onSetSessionDescriptionSuccess,
107 test.fail);
108 pc1.setRemoteDescription(answer, onSetSessionDescriptionSuccess,
109 test.fail);
110
111 answersCount++;
112 if(answersCount == 3) {
113 // SetTimeout used because creating the three answers will very fast
114 // and test will success and the vm will be closed before establishing
115 // the calls.
116 setTimeout(function() {
117 test.done();
118 }, 5000);
119 }
120 }
121
122 function onSetSessionDescriptionSuccess() {
123 test.log("Set session description success.");
124 }
125 }
126 }
127
128 registerBotTest('threeBotsVideoConference/android+android+chrome',
129 testTwoWayVideoStreaming, ['android-chrome', 'android-chrome',
130 'chrome']);
131 registerBotTest('threeBotsVideoConference/chrome-chrome-chrome',
132 testTwoWayVideoStreaming, ['chrome', 'chrome', 'chrome']);
133 registerBotTest('threeBotsVideoConference/android-android-android',
134 testTwoWayVideoStreaming, ['android-chrome', 'android-chrome',
135 'android-chrome']);
OLDNEW
« no previous file with comments | « webrtc/tools/rtcbot/test/simple_offer_answer.js ('k') | webrtc/tools/rtcbot/test/two_way_video_streaming.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698