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

Side by Side Diff: ppapi/examples/video_effects/video_effects.html

Issue 2365883002: Expose the MediaStream interface (Closed)
Patch Set: drop TODO Created 4 years, 2 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
« no previous file with comments | « content/test/data/media/peerconnection-call.html ('k') | ppapi/tests/test_video_destination.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <!-- 3 <!--
4 Copyright (c) 2013 The Chromium Authors. All rights reserved. 4 Copyright (c) 2013 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be 5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file. 6 found in the LICENSE file.
7 --> 7 -->
8 <head> 8 <head>
9 <title>Video Effects Demo</title> 9 <title>Video Effects Demo</title>
10 <style> 10 <style>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 callButton.disabled = false; 85 callButton.disabled = false;
86 initEffect(); 86 initEffect();
87 } 87 }
88 88
89 function start() { 89 function start() {
90 trace("Requesting local stream"); 90 trace("Requesting local stream");
91 startButton.disabled = true; 91 startButton.disabled = true;
92 // Call into getUserMedia via the polyfill (adapter.js). 92 // Call into getUserMedia via the polyfill (adapter.js).
93 getUserMedia({audio:false, video:true}, 93 getUserMedia({audio:false, video:true},
94 gotStream, function() {}); 94 gotStream, function() {});
95 } 95 }
96 96
97 function onRegisterStreamDone() { 97 function onRegisterStreamDone() {
98 vidprocessedlocal.src = URL.createObjectURL(processedLocalstream); 98 vidprocessedlocal.src = URL.createObjectURL(processedLocalstream);
99 toggleEffectButton.disabled = false; 99 toggleEffectButton.disabled = false;
100 } 100 }
101 101
102 function HandleMessage(message_event) { 102 function HandleMessage(message_event) {
103 if (message_event.data) { 103 if (message_event.data) {
104 if (message_event.data == 'DoneRegistering') { 104 if (message_event.data == 'DoneRegistering') {
105 onRegisterStreamDone(); 105 onRegisterStreamDone();
106 } else { 106 } else {
107 trace(message_event.data); 107 trace(message_event.data);
108 } 108 }
109 } 109 }
110 } 110 }
111 111
112 function initEffect() { 112 function initEffect() {
113 var url = URL.createObjectURL(localstream); 113 var url = URL.createObjectURL(localstream);
114 processedLocalstream = new webkitMediaStream([]); 114 processedLocalstream = new MediaStream([]);
115 var processedStreamUrl = URL.createObjectURL(processedLocalstream); 115 var processedStreamUrl = URL.createObjectURL(processedLocalstream);
116 effectsPlugin.postMessage( 116 effectsPlugin.postMessage(
117 'registerStream' + ' ' + url + ' ' + processedStreamUrl); 117 'registerStream' + ' ' + url + ' ' + processedStreamUrl);
118 } 118 }
119 119
120 function toggleEffect() { 120 function toggleEffect() {
121 effectsEnabled = !effectsEnabled; 121 effectsEnabled = !effectsEnabled;
122 if (effectsEnabled) { 122 if (effectsEnabled) {
123 toggleEffectButton.innerHTML = 'Disable Effect'; 123 toggleEffectButton.innerHTML = 'Disable Effect';
124 effectsPlugin.postMessage('effectOn'); 124 effectsPlugin.postMessage('effectOn');
125 } else { 125 } else {
126 toggleEffectButton.innerHTML = 'Enable Effect'; 126 toggleEffectButton.innerHTML = 'Enable Effect';
127 effectsPlugin.postMessage('effectOff'); 127 effectsPlugin.postMessage('effectOff');
128 } 128 }
129 } 129 }
130 130
131 function call() { 131 function call() {
132 callButton.disabled = true; 132 callButton.disabled = true;
133 hangupButton.disabled = false; 133 hangupButton.disabled = false;
134 trace("Starting call"); 134 trace("Starting call");
135 var servers = null; 135 var servers = null;
136 pc1 = new RTCPeerConnection(servers); 136 pc1 = new RTCPeerConnection(servers);
137 trace("Created local peer connection object pc1"); 137 trace("Created local peer connection object pc1");
138 pc1.onicecandidate = iceCallback1; 138 pc1.onicecandidate = iceCallback1;
139 pc2 = new RTCPeerConnection(servers); 139 pc2 = new RTCPeerConnection(servers);
140 trace("Created remote peer connection object pc2"); 140 trace("Created remote peer connection object pc2");
141 pc2.onicecandidate = iceCallback2; 141 pc2.onicecandidate = iceCallback2;
142 pc2.onaddstream = gotRemoteStream; 142 pc2.onaddstream = gotRemoteStream;
143 143
144 pc1.addStream(processedLocalstream); 144 pc1.addStream(processedLocalstream);
145 trace("Adding Local Stream to peer connection"); 145 trace("Adding Local Stream to peer connection");
146 146
147 pc1.createOffer(gotDescription1); 147 pc1.createOffer(gotDescription1);
148 } 148 }
149 149
150 function gotDescription1(desc){ 150 function gotDescription1(desc){
151 pc1.setLocalDescription(desc); 151 pc1.setLocalDescription(desc);
152 trace("Offer from pc1 \n" + desc.sdp); 152 trace("Offer from pc1 \n" + desc.sdp);
153 pc2.setRemoteDescription(desc); 153 pc2.setRemoteDescription(desc);
154 // Since the "remote" side has no media stream we need 154 // Since the "remote" side has no media stream we need
155 // to pass in the right constraints in order for it to 155 // to pass in the right constraints in order for it to
156 // accept the incoming offer of audio and video. 156 // accept the incoming offer of audio and video.
157 var sdpConstraints = {'mandatory': { 157 var sdpConstraints = {'mandatory': {
158 'OfferToReceiveAudio':true, 158 'OfferToReceiveAudio':true,
159 'OfferToReceiveVideo':true }}; 159 'OfferToReceiveVideo':true }};
160 pc2.createAnswer(gotDescription2, null, sdpConstraints); 160 pc2.createAnswer(gotDescription2, null, sdpConstraints);
161 } 161 }
162 162
163 function gotDescription2(desc){ 163 function gotDescription2(desc){
164 pc2.setLocalDescription(desc); 164 pc2.setLocalDescription(desc);
165 trace("Answer from pc2 \n" + desc.sdp); 165 trace("Answer from pc2 \n" + desc.sdp);
166 pc1.setRemoteDescription(desc); 166 pc1.setRemoteDescription(desc);
167 } 167 }
168 168
169 function hangup() { 169 function hangup() {
170 trace("Ending call"); 170 trace("Ending call");
171 pc1.close(); 171 pc1.close();
172 pc2.close(); 172 pc2.close();
173 pc1 = null; 173 pc1 = null;
174 pc2 = null; 174 pc2 = null;
175 hangupButton.disabled = true; 175 hangupButton.disabled = true;
176 callButton.disabled = false; 176 callButton.disabled = false;
177 } 177 }
178 178
179 function gotRemoteStream(e){ 179 function gotRemoteStream(e){
180 vidremote.src = URL.createObjectURL(e.stream); 180 vidremote.src = URL.createObjectURL(e.stream);
181 trace("Received remote stream"); 181 trace("Received remote stream");
182 } 182 }
183 183
184 function iceCallback1(event){ 184 function iceCallback1(event){
185 if (event.candidate) { 185 if (event.candidate) {
186 pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); 186 pc2.addIceCandidate(new RTCIceCandidate(event.candidate));
187 trace("Local ICE candidate: \n" + event.candidate.candidate); 187 trace("Local ICE candidate: \n" + event.candidate.candidate);
188 } 188 }
189 } 189 }
190 190
191 function iceCallback2(event){ 191 function iceCallback2(event){
192 if (event.candidate) { 192 if (event.candidate) {
193 pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); 193 pc1.addIceCandidate(new RTCIceCandidate(event.candidate));
194 trace("Remote ICE candidate: \n " + event.candidate.candidate); 194 trace("Remote ICE candidate: \n " + event.candidate.candidate);
195 } 195 }
196 } 196 }
197 197
198 function InitializePlugin() { 198 function InitializePlugin() {
199 effectsPlugin = document.getElementById('plugin'); 199 effectsPlugin = document.getElementById('plugin');
200 effectsPlugin.addEventListener('message', HandleMessage, false); 200 effectsPlugin.addEventListener('message', HandleMessage, false);
201 } 201 }
202 202
203 document.addEventListener('DOMContentLoaded', InitializePlugin, false); 203 document.addEventListener('DOMContentLoaded', InitializePlugin, false);
204 </script> 204 </script>
205 </body> 205 </body>
206 </html> 206 </html>
207
208
OLDNEW
« no previous file with comments | « content/test/data/media/peerconnection-call.html ('k') | ppapi/tests/test_video_destination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698