1. Updated test pages to include Chrome Frame meta tag

2. Updated test pages to use adapter.js
Review URL: https://webrtc-codereview.appspot.com/1142004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3614 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
elham@webrtc.org 2013-03-05 19:53:01 +00:00
parent 91d11b3cdd
commit 90eb5c84f9
9 changed files with 113 additions and 38 deletions

View File

@ -0,0 +1,51 @@
var RTCPeerConnection = null;
var getUserMedia = null;
var attachMediaStream = null;
if (navigator.mozGetUserMedia) {
console.log("This appears to be Firefox");
// The RTCPeerConnection object.
RTCPeerConnection = mozRTCPeerConnection;
// Get UserMedia (only difference is the prefix).
// Code from Adam Barth.
getUserMedia = navigator.mozGetUserMedia.bind(navigator);
// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
console.log("Attaching media stream");
element.mozSrcObject = stream;
element.play();
};
} else if (navigator.webkitGetUserMedia) {
console.log("This appears to be Chrome");
// The RTCPeerConnection object.
RTCPeerConnection = webkitRTCPeerConnection;
// Get UserMedia (only difference is the prefix).
// Code from Adam Barth.
getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
element.src = webkitURL.createObjectURL(stream);
};
// The representation of tracks in a stream is changed in M26.
// Unify them for earlier Chrome versions in the coexisting period.
if (!webkitMediaStream.prototype.getVideoTracks) {
webkitMediaStream.prototype.getVideoTracks = function() {
return this.videoTracks;
}
}
if (!webkitMediaStream.prototype.getAudioTracks) {
webkitMediaStream.prototype.getAudioTracks = function() {
return this.audioTracks;
}
}
} else {
console.log("Browser does not appear to be WebRTC-capable");
}

View File

@ -11,11 +11,15 @@
<html> <html>
<head> <head>
<title>Single Local Preview (Video and Audio)</title> <title>Single Local Preview (Video and Audio)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function requestVideoAndAudio() { function requestVideoAndAudio() {
navigator.webkitGetUserMedia({video: true, audio: true}, // Call into getUserMedia via the polyfill (adapter.js).
getUserMediaOkCallback, getUserMedia({video: true, audio: true},
getUserMediaFailedCallback); getUserMediaOkCallback,
getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -23,9 +27,8 @@
} }
function getUserMediaOkCallback(stream) { function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream); attachMediaStream(document.getElementById("view1"), stream);
document.getElementById("view1").src = streamUrl; attachMediaStream(document.getElementById("audio1"), stream);
//document.getElementById("audio1").src = streamUrl;
} }
</script> </script>
</head> </head>
@ -41,4 +44,4 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

View File

@ -11,6 +11,7 @@
<html> <html>
<head> <head>
<title>AppRTC web app in an IFRAME</title> <title>AppRTC web app in an IFRAME</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
</head> </head>
<body> <body>
AppRTC in an &lt;iframe&gt; element:<br> AppRTC in an &lt;iframe&gt; element:<br>

View File

@ -11,6 +11,7 @@
<html> <html>
<head> <head>
<title>IFRAME Single Local Preview (Video Only)</title> <title>IFRAME Single Local Preview (Video Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
</head> </head>
<body> <body>
<iframe width="100%" height="100%" src="single-video.html"></iframe> <iframe width="100%" height="100%" src="single-video.html"></iframe>

View File

@ -11,11 +11,15 @@
<html> <html>
<head> <head>
<title>Multiple Local Preview (Audio Only)</title> <title>Multiple Local Preview (Audio Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"> </script>
<script type="text/javascript"> <script type="text/javascript">
function requestAudio() { function requestAudio() {
navigator.webkitGetUserMedia({video: false, audio: true}, // Call into getUserMedia via the polyfill (adapter.js).
getUserMediaOkCallback, getUserMedia({video: false, audio: true},
getUserMediaFailedCallback); getUserMediaOkCallback,
getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -23,9 +27,9 @@
} }
function getUserMediaOkCallback(stream) { function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream); // Call the polyfill wrapper to attach the media stream to this element.
for (var i = 1; i <= 10; i++) { for (var i = 1; i <= 10; i++) {
document.getElementById("audio" + i).src = streamUrl; attachMediaStream(document.getElementById("audio" + i), stream);
} }
} }
</script> </script>
@ -49,4 +53,4 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

View File

@ -11,11 +11,15 @@
<html> <html>
<head> <head>
<title>Multiple Local Preview (Video Only)</title> <title>Multiple Local Preview (Video Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function requestVideo() { function requestVideo() {
navigator.webkitGetUserMedia({video: true, audio: false}, // Call into getUserMedia via the polyfill (adapter.js).
getUserMediaOkCallback, getUserMedia({video: true, audio: false},
getUserMediaFailedCallback); getUserMediaOkCallback,
getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -23,9 +27,9 @@
} }
function getUserMediaOkCallback(stream) { function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream); // Call the polyfill wrapper to attach the media stream to this element.
for (var i = 1; i <= 10; i++) { for (var i = 1; i <= 10; i++) {
document.getElementById("view" + i).src = streamUrl; attachMediaStream(document.getElementById("view" + i), stream);
} }
} }
</script> </script>
@ -65,4 +69,4 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

View File

@ -11,11 +11,14 @@
<html> <html>
<head> <head>
<title>Single Local Preview (Audio Only)</title> <title>Single Local Preview (Audio Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"> </script>
<script type="text/javascript"> <script type="text/javascript">
function requestAudio() { function requestAudio() {
navigator.webkitGetUserMedia({video: false, audio: true}, getUserMedia({video: false, audio: true},
getUserMediaOkCallback, getUserMediaOkCallback,
getUserMediaFailedCallback); getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -23,8 +26,8 @@
} }
function getUserMediaOkCallback(stream) { function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream); // Call the polyfill wrapper to attach the media stream to this element.
document.getElementById("audio1").src = streamUrl; attachMediaStream(document.getElementById("audio1"), stream);
} }
</script> </script>
</head> </head>
@ -38,4 +41,4 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

View File

@ -11,11 +11,14 @@
<html> <html>
<head> <head>
<title>Single Local Preview (Video Only)</title> <title>Single Local Preview (Video Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"> </script>
<script type="text/javascript"> <script type="text/javascript">
function requestVideo() { function requestVideo() {
navigator.webkitGetUserMedia({video: true, audio: false}, getUserMedia({video: true, audio: false},
getUserMediaOkCallback, getUserMediaOkCallback,
getUserMediaFailedCallback); getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -23,8 +26,8 @@
} }
function getUserMediaOkCallback(stream) { function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream); // Call the polyfill wrapper to attach the media stream to this element.
document.getElementById("view1").src = streamUrl; attachMediaStream(document.getElementById("view1"), stream);
} }
</script> </script>
</head> </head>
@ -39,4 +42,4 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

View File

@ -11,13 +11,17 @@
<html> <html>
<head> <head>
<title>Single Local Preview (Video Only)</title> <title>Single Local Preview (Video Only)</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
<script src="adapter.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function requestVideo(target) { function requestVideo(target) {
navigator.webkitGetUserMedia({video: true, audio: false}, // Call into getUserMedia via the polyfill (adapter.js).
function(stream) { getUserMedia({video: true, audio: false},
getUserMediaOkCallback(stream, target); function(stream) {
}, getUserMediaOkCallback(stream, target);
getUserMediaFailedCallback); },
getUserMediaFailedCallback);
} }
function getUserMediaFailedCallback(error) { function getUserMediaFailedCallback(error) {
@ -25,8 +29,9 @@
} }
function getUserMediaOkCallback(stream, target) { function getUserMediaOkCallback(stream, target) {
var streamUrl = webkitURL.createObjectURL(stream); // Call the polyfill wrapper to attach the media stream to this element.
document.getElementById(target).src = streamUrl; attachMediaStream(document.getElementById("view1"), stream);
attachMediaStream(document.getElementById("view2"), stream);
} }
</script> </script>
</head> </head>