From ff433f12a4710cc5cb272e93b203d5907621e6c5 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Tue, 28 Apr 2015 11:45:37 +0200 Subject: [PATCH] Merged DummyStream implementations into one. --- static/js/directives/audiovideo.js | 10 +------ static/js/mediastream/dummystream.js | 42 ++++++++++++++++++++++++++++ static/js/mediastream/usermedia.js | 12 +------- static/js/services/dummystream.js | 29 +++++++++++++++++++ static/js/services/services.js | 9 ++++-- 5 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 static/js/mediastream/dummystream.js create mode 100644 static/js/services/dummystream.js diff --git a/static/js/directives/audiovideo.js b/static/js/directives/audiovideo.js index 933ce8d5..85b0f619 100644 --- a/static/js/directives/audiovideo.js +++ b/static/js/directives/audiovideo.js @@ -22,7 +22,7 @@ "use strict"; define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/audiovideopeer.html', 'bigscreen', 'webrtc.adapter'], function($, _, template, templatePeer, BigScreen) { - return ["$window", "$compile", "$filter", "mediaStream", "safeApply", "desktopNotify", "buddyData", "videoWaiter", "videoLayout", "animationFrame", "$timeout", function($window, $compile, $filter, mediaStream, safeApply, desktopNotify, buddyData, videoWaiter, videoLayout, animationFrame, $timeout) { + return ["$window", "$compile", "$filter", "mediaStream", "safeApply", "desktopNotify", "buddyData", "videoWaiter", "videoLayout", "animationFrame", "$timeout", "dummyStream", function($window, $compile, $filter, mediaStream, safeApply, desktopNotify, buddyData, videoWaiter, videoLayout, animationFrame, $timeout, DummyStream) { var peerTemplate = $compile(templatePeer); @@ -37,14 +37,6 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ return id; }; - // Dummy stream. - var DummyStream = function() {}; - DummyStream.prototype.id = "defaultDummyStream"; - DummyStream.prototype.stop = function() {}; - DummyStream.is = function(stream) { - return stream && stream.stop === DummyStream.prototype.stop; - }; - $scope.container = $element[0]; $scope.layoutparent = $element.parent(); diff --git a/static/js/mediastream/dummystream.js b/static/js/mediastream/dummystream.js new file mode 100644 index 00000000..a2593330 --- /dev/null +++ b/static/js/mediastream/dummystream.js @@ -0,0 +1,42 @@ +/* + * 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 . + * + */ + +"use strict"; +define([], function() { + + // Dummy stream implementation. + var DummyStream = function(id) { + this.id = id ? id : "defaultDummyStream"; + }; + DummyStream.prototype.stop = function() {}; + DummyStream.prototype.getAudioTracks = function() { return [] }; + DummyStream.prototype.getVideoTracks = function() { return [] }; + DummyStream.not = function(stream) { + // Helper to test if stream is a dummy. + return !stream || stream.stop !== DummyStream.prototype.stop; + }; + DummyStream.is = function(stream) { + return !this.not(stream); + }; + + return DummyStream; + +}); \ No newline at end of file diff --git a/static/js/mediastream/usermedia.js b/static/js/mediastream/usermedia.js index ad6f87c1..2c9b1795 100644 --- a/static/js/mediastream/usermedia.js +++ b/static/js/mediastream/usermedia.js @@ -20,7 +20,7 @@ */ "use strict"; -define(['jquery', 'underscore', 'audiocontext', 'webrtc.adapter'], function($, _, AudioContext) { +define(['jquery', 'underscore', 'audiocontext', 'mediastream/dummystream', 'webrtc.adapter'], function($, _, AudioContext, DummyStream) { // Create AudioContext singleton, if supported. var context = AudioContext ? new AudioContext() : null; @@ -119,16 +119,6 @@ define(['jquery', 'underscore', 'audiocontext', 'webrtc.adapter'], function($, _ } })(); - // Create a dummy stream. - var DummyStream = function() {}; - DummyStream.prototype.stop = function() {}; - DummyStream.prototype.getAudioTracks = function() { return [] }; - DummyStream.prototype.getVideoTracks = function() { return [] }; - DummyStream.not = function(stream) { - // Helper to test if stream is a dummy. - return !stream || stream.stop !== DummyStream.prototype.stop; - }; - // UserMedia. var UserMedia = function(options) { diff --git a/static/js/services/dummystream.js b/static/js/services/dummystream.js new file mode 100644 index 00000000..29fa5f75 --- /dev/null +++ b/static/js/services/dummystream.js @@ -0,0 +1,29 @@ +/* + * 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 . + * + */ + +"use strict"; +define([ + 'mediastream/dummystream' +], function(DummyStream) { + return [function() { + return DummyStream; + }]; +}); diff --git a/static/js/services/services.js b/static/js/services/services.js index 8e7dc20f..198b92ee 100644 --- a/static/js/services/services.js +++ b/static/js/services/services.js @@ -68,7 +68,8 @@ define([ 'services/constraints', 'services/modules', 'services/mediadevices', - 'services/sandbox'], function(_, + 'services/sandbox', + 'services/dummystream'], function(_, desktopNotify, playSound, safeApply, @@ -114,7 +115,8 @@ roompin, constraints, modules, mediaDevices, -sandbox) { +sandbox, +dummyStream) { var services = { desktopNotify: desktopNotify, @@ -162,7 +164,8 @@ sandbox) { constraints: constraints, modules: modules, mediaDevices: mediaDevices, - sandbox: sandbox + sandbox: sandbox, + dummyStream: dummyStream }; var initialize = function(angModule) {