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

Unified Diff: adapter.js

Issue 12824011: Updated Chrome Test pages (Closed) Base URL: https://src.chromium.org/svn/trunk/src/chrome/test/data/webrtc/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | getusermedia.js » ('j') | getusermedia.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adapter.js
===================================================================
--- adapter.js (revision 0)
+++ adapter.js (revision 0)
@@ -0,0 +1,51 @@
+var RTCPeerConnection = null;
kjellander_chromium 2013/03/15 09:14:06 Please do not add another copy of adapter.js here.
elham1 2013/03/21 22:36:27 Done.
+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");
+}
« no previous file with comments | « no previous file | getusermedia.js » ('j') | getusermedia.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698