Skip to content

Commit af194a6

Browse files
committed
1 parent 86d740b commit af194a6

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

static/js/directives/buddypicturecapture.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
2525
// buddyPictureCapture
2626
return ["$compile", "$window", function($compile, $window) {
2727

28-
var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", function($scope, safeApply, $timeout, $q, mediaDevices) {
28+
var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", "userMedia", function($scope, safeApply, $timeout, $q, mediaDevices, userMedia) {
2929

3030
// Buddy picutre capture size.
3131
$scope.captureSize = {
@@ -110,7 +110,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct
110110
var videoStop = function(stream, video) {
111111
if (stream) {
112112
video.pause();
113-
stream.stop();
113+
userMedia.stopUserMediaStream(stream);
114114
stream = null;
115115
}
116116
};

static/js/mediastream/usermedia.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
106106
}
107107
})();
108108

109+
var stopUserMediaStream = (function() {
110+
return function(stream) {
111+
if (stream && stream.getTracks) {
112+
var tracks = stream.getTracks();
113+
_.each(tracks, function(t) {
114+
t.stop();
115+
});
116+
} else {
117+
console.warn("MediaStream.stop is deprecated");
118+
stream.stop();
119+
}
120+
}
121+
})();
122+
109123
// UserMedia.
110124
var UserMedia = function(options) {
111125

@@ -201,7 +215,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
201215
clearTimeout(timeout);
202216
timeout = null;
203217
}
204-
stream.stop();
218+
stopUserMediaStream(stream);
205219
if (complete.done) {
206220
return;
207221
}
@@ -238,6 +252,8 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
238252
})({});
239253

240254
};
255+
UserMedia.getUserMedia = getUserMedia;
256+
UserMedia.stopUserMediaStream = stopUserMediaStream;
241257

242258
UserMedia.prototype.doGetUserMedia = function(currentcall, mediaConstraints) {
243259

@@ -295,7 +311,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
295311
console.log('User has granted access to local media.');
296312

297313
if (!this.started) {
298-
stream.stop();
314+
stopUserMediaStream(stream);
299315
return;
300316
}
301317

@@ -323,7 +339,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
323339
oldStream.onended = function() {
324340
console.log("Silently ended replaced user media stream.");
325341
};
326-
oldStream.stop();
342+
stopUserMediaStream(oldStream);
327343
}
328344

329345
if (stream) {
@@ -368,7 +384,7 @@ define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webr
368384
this.audioSource = null;
369385
}
370386
if (this.localStream) {
371-
this.localStream.stop()
387+
stopUserMediaStream(this.localStream);
372388
this.localStream = null;
373389
}
374390
if (this.audioProcessor) {

static/js/mediastream/webrtc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,6 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
357357

358358
var success = function(stream) {
359359
console.info("testMediaAccess success");
360-
if (stream) {
361-
stream.stop();
362-
}
363360
cb(true);
364361
}
365362
var failed = function() {

static/js/services/services.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ define([
6969
'services/modules',
7070
'services/mediadevices',
7171
'services/sandbox',
72-
'services/dummystream'], function(_,
72+
'services/dummystream',
73+
'services/usermedia'], function(_,
7374
desktopNotify,
7475
playSound,
7576
safeApply,
@@ -116,7 +117,8 @@ constraints,
116117
modules,
117118
mediaDevices,
118119
sandbox,
119-
dummyStream) {
120+
dummyStream,
121+
userMedia) {
120122

121123
var services = {
122124
desktopNotify: desktopNotify,
@@ -165,7 +167,8 @@ dummyStream) {
165167
modules: modules,
166168
mediaDevices: mediaDevices,
167169
sandbox: sandbox,
168-
dummyStream: dummyStream
170+
dummyStream: dummyStream,
171+
userMedia: userMedia
169172
};
170173

171174
var initialize = function(angModule) {

static/js/services/usermedia.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Spreed WebRTC.
3+
* Copyright (C) 2013-2015 struktur AG
4+
*
5+
* This file is part of Spreed WebRTC.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
*/
21+
22+
"use strict";
23+
define(['mediastream/usermedia'], function(UserMedia) {
24+
25+
// userMedia
26+
return [function() {
27+
28+
// Public api.
29+
return {
30+
getUserMedia: UserMedia.getUserMedia,
31+
stopUserMediaStream: UserMedia.stopUserMediaStream
32+
}
33+
34+
}];
35+
36+
});

0 commit comments

Comments
 (0)