OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 <button id="callButton" onclick="call()">Call</button> | 45 <button id="callButton" onclick="call()">Call</button> |
46 <button id="hangupButton" onclick="hangup()">Hang Up</button> | 46 <button id="hangupButton" onclick="hangup()">Hang Up</button> |
47 <br> | 47 <br> |
48 <embed id="plugin" type="application/x-ppapi-example-video-effects" | 48 <embed id="plugin" type="application/x-ppapi-example-video-effects" |
49 width="320" height="240"/> | 49 width="320" height="240"/> |
50 | 50 |
51 <script> | 51 <script> |
52 var RTCPeerConnection = webkitRTCPeerConnection; | 52 var RTCPeerConnection = webkitRTCPeerConnection; |
53 var getUserMedia = navigator.webkitGetUserMedia.bind(navigator); | 53 var getUserMedia = navigator.webkitGetUserMedia.bind(navigator); |
54 var attachMediaStream = function(element, stream) { | 54 var attachMediaStream = function(element, stream) { |
55 element.src = webkitURL.createObjectURL(stream); | 55 element.src = URL.createObjectURL(stream); |
56 }; | 56 }; |
57 var startButton = document.getElementById('startButton'); | 57 var startButton = document.getElementById('startButton'); |
58 var toggleEffectButton = document.getElementById('toggleEffectButton'); | 58 var toggleEffectButton = document.getElementById('toggleEffectButton'); |
59 var callButton = document.getElementById('callButton'); | 59 var callButton = document.getElementById('callButton'); |
60 var hangupButton = document.getElementById('hangupButton'); | 60 var hangupButton = document.getElementById('hangupButton'); |
61 | 61 |
62 callButton.disabled = true; | 62 callButton.disabled = true; |
63 hangupButton.disabled = true; | 63 hangupButton.disabled = true; |
64 toggleEffectButton.disabled = true; | 64 toggleEffectButton.disabled = true; |
65 var pc1 = null; | 65 var pc1 = null; |
(...skipping 22 matching lines...) Expand all Loading... |
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 = webkitURL.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 = webkitURL.createObjectURL(localstream); | 113 var url = URL.createObjectURL(localstream); |
114 processedLocalstream = new webkitMediaStream([]); | 114 processedLocalstream = new webkitMediaStream([]); |
115 var processedStreamUrl = webkitURL.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 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = webkitURL.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 | 207 |
208 | 208 |
OLD | NEW |