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 @@ -25,7 +25,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
// buddyPictureCapture
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.
$scope.captureSize = {
@ -110,7 +110,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct @@ -110,7 +110,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
var videoStop = function(stream, video) {
if (stream) {
video.pause();
stream.stop();
userMedia.stopUserMediaStream(stream);
stream = null;
}
};

24
static/js/mediastream/usermedia.js

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

3
static/js/mediastream/webrtc.js

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

9
static/js/services/services.js

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

36
static/js/services/usermedia.js

@ -0,0 +1,36 @@ @@ -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