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>
<head>
<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">
function requestVideoAndAudio() {
navigator.webkitGetUserMedia({video: true, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
// Call into getUserMedia via the polyfill (adapter.js).
getUserMedia({video: true, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -23,9 +27,8 @@
}
function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream);
document.getElementById("view1").src = streamUrl;
//document.getElementById("audio1").src = streamUrl;
attachMediaStream(document.getElementById("view1"), stream);
attachMediaStream(document.getElementById("audio1"), stream);
}
</script>
</head>
@ -41,4 +44,4 @@
</tr>
</table>
</body>
</html>
</html>

View File

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

View File

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

View File

@ -11,11 +11,15 @@
<html>
<head>
<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">
function requestAudio() {
navigator.webkitGetUserMedia({video: false, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
// Call into getUserMedia via the polyfill (adapter.js).
getUserMedia({video: false, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -23,9 +27,9 @@
}
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++) {
document.getElementById("audio" + i).src = streamUrl;
attachMediaStream(document.getElementById("audio" + i), stream);
}
}
</script>
@ -49,4 +53,4 @@
</tr>
</table>
</body>
</html>
</html>

View File

@ -11,11 +11,15 @@
<html>
<head>
<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">
function requestVideo() {
navigator.webkitGetUserMedia({video: true, audio: false},
getUserMediaOkCallback,
getUserMediaFailedCallback);
// Call into getUserMedia via the polyfill (adapter.js).
getUserMedia({video: true, audio: false},
getUserMediaOkCallback,
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -23,9 +27,9 @@
}
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++) {
document.getElementById("view" + i).src = streamUrl;
attachMediaStream(document.getElementById("view" + i), stream);
}
}
</script>
@ -65,4 +69,4 @@
</tr>
</table>
</body>
</html>
</html>

View File

@ -11,11 +11,14 @@
<html>
<head>
<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">
function requestAudio() {
navigator.webkitGetUserMedia({video: false, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
getUserMedia({video: false, audio: true},
getUserMediaOkCallback,
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -23,8 +26,8 @@
}
function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream);
document.getElementById("audio1").src = streamUrl;
// Call the polyfill wrapper to attach the media stream to this element.
attachMediaStream(document.getElementById("audio1"), stream);
}
</script>
</head>
@ -38,4 +41,4 @@
</tr>
</table>
</body>
</html>
</html>

View File

@ -11,11 +11,14 @@
<html>
<head>
<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">
function requestVideo() {
navigator.webkitGetUserMedia({video: true, audio: false},
getUserMediaOkCallback,
getUserMediaFailedCallback);
getUserMedia({video: true, audio: false},
getUserMediaOkCallback,
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -23,8 +26,8 @@
}
function getUserMediaOkCallback(stream) {
var streamUrl = webkitURL.createObjectURL(stream);
document.getElementById("view1").src = streamUrl;
// Call the polyfill wrapper to attach the media stream to this element.
attachMediaStream(document.getElementById("view1"), stream);
}
</script>
</head>
@ -39,4 +42,4 @@
</tr>
</table>
</body>
</html>
</html>

View File

@ -11,13 +11,17 @@
<html>
<head>
<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">
function requestVideo(target) {
navigator.webkitGetUserMedia({video: true, audio: false},
function(stream) {
getUserMediaOkCallback(stream, target);
},
getUserMediaFailedCallback);
// Call into getUserMedia via the polyfill (adapter.js).
getUserMedia({video: true, audio: false},
function(stream) {
getUserMediaOkCallback(stream, target);
},
getUserMediaFailedCallback);
}
function getUserMediaFailedCallback(error) {
@ -25,8 +29,9 @@
}
function getUserMediaOkCallback(stream, target) {
var streamUrl = webkitURL.createObjectURL(stream);
document.getElementById(target).src = streamUrl;
// Call the polyfill wrapper to attach the media stream to this element.
attachMediaStream(document.getElementById("view1"), stream);
attachMediaStream(document.getElementById("view2"), stream);
}
</script>
</head>