Browse Source

Remove deprecated MediaStream.stop api (see https://groups.google.com/a/chromium.org/forum/#\!msg/blink-dev/s0UsMk8i2YM/WpepA4w3mPEJ for details).

pull/162/head
Simon Eisenmann 11 years ago
parent
commit
af194a64b8
  1. 4
      static/js/directives/buddypicturecapture.js
  2. 24
      static/js/mediastream/usermedia.js
  3. 3
      static/js/mediastream/webrtc.js
  4. 9
      static/js/services/services.js
  5. 36
      static/js/services/usermedia.js

4
static/js/directives/buddypicturecapture.js

@ -25,7 +25,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
// buddyPictureCapture // buddyPictureCapture
return ["$compile", "$window", function($compile, $window) { return ["$compile", "$window", function($compile, $window) {
var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", function($scope, safeApply, $timeout, $q, mediaDevices) { var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", "userMedia", function($scope, safeApply, $timeout, $q, mediaDevices, userMedia) {
// Buddy picutre capture size. // Buddy picutre capture size.
$scope.captureSize = { $scope.captureSize = {
@ -110,7 +110,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
var videoStop = function(stream, video) { var videoStop = function(stream, video) {
if (stream) { if (stream) {
video.pause(); video.pause();
stream.stop(); userMedia.stopUserMediaStream(stream);
stream = null; stream = null;
} }
}; };

24
static/js/mediastream/usermedia.js

@ -106,6 +106,20 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
} }
})(); })();
var stopUserMediaStream = (function() {
return function(stream) {
if (stream && stream.getTracks) {
var tracks = stream.getTracks();
_.each(tracks, function(t) {
t.stop();
});
} else {
console.warn("MediaStream.stop is deprecated");
stream.stop();
}
}
})();
// UserMedia. // UserMedia.
var UserMedia = function(options) { var UserMedia = function(options) {
@ -201,7 +215,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
clearTimeout(timeout); clearTimeout(timeout);
timeout = null; timeout = null;
} }
stream.stop(); stopUserMediaStream(stream);
if (complete.done) { if (complete.done) {
return; return;
} }
@ -238,6 +252,8 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
})({}); })({});
}; };
UserMedia.getUserMedia = getUserMedia;
UserMedia.stopUserMediaStream = stopUserMediaStream;
UserMedia.prototype.doGetUserMedia = function(currentcall, mediaConstraints) { UserMedia.prototype.doGetUserMedia = function(currentcall, mediaConstraints) {
@ -295,7 +311,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
console.log('User has granted access to local media.'); console.log('User has granted access to local media.');
if (!this.started) { if (!this.started) {
stream.stop(); stopUserMediaStream(stream);
return; return;
} }
@ -323,7 +339,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
oldStream.onended = function() { oldStream.onended = function() {
console.log("Silently ended replaced user media stream."); console.log("Silently ended replaced user media stream.");
}; };
oldStream.stop(); stopUserMediaStream(oldStream);
} }
if (stream) { if (stream) {
@ -368,7 +384,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
this.audioSource = null; this.audioSource = null;
} }
if (this.localStream) { if (this.localStream) {
this.localStream.stop() stopUserMediaStream(this.localStream);
this.localStream = null; this.localStream = null;
} }
if (this.audioProcessor) { if (this.audioProcessor) {

3
static/js/mediastream/webrtc.js

@ -357,9 +357,6 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
var success = function(stream) { var success = function(stream) {
console.info("testMediaAccess success"); console.info("testMediaAccess success");
if (stream) {
stream.stop();
}
cb(true); cb(true);
} }
var failed = function() { var failed = function() {

9
static/js/services/services.js

@ -69,7 +69,8 @@ define([
'services/modules', 'services/modules',
'services/mediadevices', 'services/mediadevices',
'services/sandbox', 'services/sandbox',
'services/dummystream'], function(_, 'services/dummystream',
'services/usermedia'], function(_,
desktopNotify, desktopNotify,
playSound, playSound,
safeApply, safeApply,
@ -116,7 +117,8 @@ constraints,
modules, modules,
mediaDevices, mediaDevices,
sandbox, sandbox,
dummyStream) { dummyStream,
userMedia) {
var services = { var services = {
desktopNotify: desktopNotify, desktopNotify: desktopNotify,
@ -165,7 +167,8 @@ dummyStream) {
modules: modules, modules: modules,
mediaDevices: mediaDevices, mediaDevices: mediaDevices,
sandbox: sandbox, sandbox: sandbox,
dummyStream: dummyStream dummyStream: dummyStream,
userMedia: userMedia
}; };
var initialize = function(angModule) { var initialize = function(angModule) {

36
static/js/services/usermedia.js

@ -0,0 +1,36 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2015 struktur AG
*
* This file is part of Spreed WebRTC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
"use strict";
define(['mediastream/usermedia'], function(UserMedia) {
// userMedia
return [function() {
// Public api.
return {
getUserMedia: UserMedia.getUserMedia,
stopUserMediaStream: UserMedia.stopUserMediaStream
}
}];
});
Loading…
Cancel
Save