@techsee/techsee-media-service 999.0.2-switch → 999.0.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LocalStreamManager.d.ts +12 -0
- package/lib/LocalStreamManager.d.ts.map +1 -1
- package/lib/LocalStreamManager.js +440 -283
- package/lib/LocalStreamManager.js.map +1 -1
- package/lib/MediaConstants.d.ts +14 -4
- package/lib/MediaConstants.d.ts.map +1 -1
- package/lib/MediaConstants.js +83 -38
- package/lib/MediaConstants.js.map +1 -1
- package/lib/MediaContracts.d.ts +17 -14
- package/lib/MediaContracts.d.ts.map +1 -1
- package/lib/MediaContracts.js +3 -3
- package/lib/MediaContracts.js.map +1 -1
- package/lib/MediaPublisher.d.ts +3 -3
- package/lib/MediaPublisher.d.ts.map +1 -1
- package/lib/MediaPublisher.js +46 -35
- package/lib/MediaPublisher.js.map +1 -1
- package/lib/MediaServiceBase.d.ts +21 -7
- package/lib/MediaServiceBase.d.ts.map +1 -1
- package/lib/MediaServiceBase.js +924 -586
- package/lib/MediaServiceBase.js.map +1 -1
- package/lib/MediaSession/MediaServer.d.ts +45 -0
- package/lib/MediaSession/MediaServer.d.ts.map +1 -0
- package/lib/MediaSession/MediaServer.js +538 -0
- package/lib/MediaSession/MediaServer.js.map +1 -0
- package/lib/MediaSession/MediaSessionBase.d.ts +10 -1
- package/lib/MediaSession/MediaSessionBase.d.ts.map +1 -1
- package/lib/MediaSession/MediaSessionBase.js +128 -66
- package/lib/MediaSession/MediaSessionBase.js.map +1 -1
- package/lib/MediaSession/SessionOpentok.d.ts +11 -9
- package/lib/MediaSession/SessionOpentok.d.ts.map +1 -1
- package/lib/MediaSession/SessionOpentok.js +500 -352
- package/lib/MediaSession/SessionOpentok.js.map +1 -1
- package/lib/MediaSession/SessionTurn.d.ts +4 -1
- package/lib/MediaSession/SessionTurn.d.ts.map +1 -1
- package/lib/MediaSession/SessionTurn.js +611 -422
- package/lib/MediaSession/SessionTurn.js.map +1 -1
- package/lib/MediaSession/TurnConstants.js +31 -30
- package/lib/MediaSession/TurnConstants.js.map +1 -1
- package/lib/MediaSubscriber.d.ts +11 -11
- package/lib/MediaSubscriber.d.ts.map +1 -1
- package/lib/MediaSubscriber.js +236 -192
- package/lib/MediaSubscriber.js.map +1 -1
- package/lib/MediaUtils/Compatibility.d.ts +2 -1
- package/lib/MediaUtils/Compatibility.d.ts.map +1 -1
- package/lib/MediaUtils/Compatibility.js +130 -85
- package/lib/MediaUtils/Compatibility.js.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.d.ts +3 -2
- package/lib/MediaUtils/MediaDomUtils.d.ts.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.js +235 -174
- package/lib/MediaUtils/MediaDomUtils.js.map +1 -1
- package/lib/MediaUtils/MediaTracer.js +9 -4
- package/lib/MediaUtils/MediaTracer.js.map +1 -1
- package/lib/MediaUtils/index.d.ts +1 -0
- package/lib/MediaUtils/index.d.ts.map +1 -0
- package/lib/MediaUtils/index.js +16 -0
- package/lib/MediaUtils/index.js.map +1 -0
- package/lib/MultiParty/Contracts.d.ts +16 -0
- package/lib/MultiParty/Contracts.d.ts.map +1 -0
- package/lib/MultiParty/Contracts.js +6 -0
- package/lib/MultiParty/Contracts.js.map +1 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts +16 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts.map +1 -0
- package/lib/MultiParty/DetectWebRtcService.js +79 -0
- package/lib/MultiParty/DetectWebRtcService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts +23 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.js +369 -0
- package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +5 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js +305 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -0
- package/lib/MultiParty/MultiPartyService.d.ts +41 -0
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyService.js +72 -0
- package/lib/MultiParty/MultiPartyService.js.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts +3 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js +21 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -0
- package/lib/MultiParty/OpentokMultiPartyService.d.ts +29 -0
- package/lib/MultiParty/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/OpentokMultiPartyService.js +888 -0
- package/lib/MultiParty/OpentokMultiPartyService.js.map +1 -0
- package/lib/MultiParty/VideoLayoutType.d.ts +4 -0
- package/lib/MultiParty/VideoLayoutType.d.ts.map +1 -0
- package/lib/MultiParty/VideoLayoutType.js +13 -0
- package/lib/MultiParty/VideoLayoutType.js.map +1 -0
- package/lib/MultiParty/index.d.ts +4 -0
- package/lib/MultiParty/index.d.ts.map +1 -0
- package/lib/MultiParty/index.js +61 -0
- package/lib/MultiParty/index.js.map +1 -0
- package/lib/MultiParty/opentok.d.ts +503 -0
- package/lib/TechseeMediaStream.d.ts +6 -6
- package/lib/TechseeMediaStream.d.ts.map +1 -1
- package/lib/TechseeMediaStream.js +59 -53
- package/lib/TechseeMediaStream.js.map +1 -1
- package/lib/oldCode/constants.js +20 -15
- package/lib/oldCode/constants.js.map +1 -1
- package/lib/oldCode/event-emitter.js +45 -22
- package/lib/oldCode/event-emitter.js.map +1 -1
- package/lib/oldCode/index.js +48 -52
- package/lib/oldCode/index.js.map +1 -1
- package/lib/oldCode/opentok/session.js +261 -236
- package/lib/oldCode/opentok/session.js.map +1 -1
- package/lib/oldCode/opentok/stream.js +283 -269
- package/lib/oldCode/opentok/stream.js.map +1 -1
- package/lib/oldCode/publisher.js +96 -71
- package/lib/oldCode/publisher.js.map +1 -1
- package/lib/oldCode/service.js +294 -272
- package/lib/oldCode/service.js.map +1 -1
- package/lib/oldCode/session.js +82 -60
- package/lib/oldCode/session.js.map +1 -1
- package/lib/oldCode/stream.js +153 -125
- package/lib/oldCode/stream.js.map +1 -1
- package/lib/oldCode/subscriber.js +60 -35
- package/lib/oldCode/subscriber.js.map +1 -1
- package/lib/oldCode/tracer.d.ts +3 -2
- package/lib/oldCode/tracer.d.ts.map +1 -1
- package/lib/oldCode/tracer.js +181 -130
- package/lib/oldCode/tracer.js.map +1 -1
- package/lib/oldCode/utils/ImageFixer.js +67 -44
- package/lib/oldCode/utils/ImageFixer.js.map +1 -1
- package/lib/oldCode/webrtc/constants.js +102 -110
- package/lib/oldCode/webrtc/constants.js.map +1 -1
- package/lib/oldCode/webrtc/helper.js +176 -124
- package/lib/oldCode/webrtc/helper.js.map +1 -1
- package/lib/oldCode/webrtc/session-kms.js +408 -393
- package/lib/oldCode/webrtc/session-kms.js.map +1 -1
- package/lib/oldCode/webrtc/session-loopback.js +245 -227
- package/lib/oldCode/webrtc/session-loopback.js.map +1 -1
- package/lib/oldCode/webrtc/session-turn.js +705 -658
- package/lib/oldCode/webrtc/session-turn.js.map +1 -1
- package/lib/oldCode/webrtc/session-turn.v2.js +480 -471
- package/lib/oldCode/webrtc/session-turn.v2.js.map +1 -1
- package/lib/oldCode/webrtc/session.js +12 -6
- package/lib/oldCode/webrtc/session.js.map +1 -1
- package/lib/oldCode/webrtc/stream.js +526 -504
- package/lib/oldCode/webrtc/stream.js.map +1 -1
- package/lib/oldCode/webrtc/temasys/adapter-loader.js +5 -6
- package/lib/oldCode/webrtc/temasys/adapter-loader.js.map +1 -1
- package/lib/oldCode/webrtc/temasys/adapter.js +5264 -5192
- package/lib/oldCode/webrtc/temasys/adapter.js.map +1 -1
- package/lib/oldCode/webrtc/webrtc-ie-shim.js +3357 -2927
- package/lib/oldCode/webrtc/webrtc-ie-shim.js.map +1 -1
- package/lib/qos/raw-qos.js +348 -273
- package/lib/qos/raw-qos.js.map +1 -1
- package/lib/webrtc-ie-shim.js +3386 -2985
- package/lib/webrtc-ie-shim.js.map +1 -1
- package/package.json +54 -42
package/lib/oldCode/service.js
CHANGED
|
@@ -1,88 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
exports.TsMediaService = exports.EVENTS = undefined;
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.TsMediaService = exports.EVENTS = void 0;
|
|
7
9
|
|
|
8
|
-
var _tsEnvironmentDetect = require(
|
|
10
|
+
var _tsEnvironmentDetect = require("@techsee/techsee-common/lib/helpers/ts-environment-detect");
|
|
9
11
|
|
|
10
|
-
var _eventEmitter = require(
|
|
12
|
+
var _eventEmitter = require("./event-emitter");
|
|
11
13
|
|
|
12
|
-
var _session = require(
|
|
14
|
+
var _session = require("./session");
|
|
13
15
|
|
|
14
|
-
var _session2 = require(
|
|
16
|
+
var _session2 = require("./opentok/session");
|
|
15
17
|
|
|
16
|
-
var _session3 = require(
|
|
18
|
+
var _session3 = require("./webrtc/session");
|
|
17
19
|
|
|
18
|
-
var _helper = require(
|
|
20
|
+
var _helper = require("./webrtc/helper");
|
|
19
21
|
|
|
20
|
-
var _constants = require(
|
|
22
|
+
var _constants = require("./constants");
|
|
21
23
|
|
|
22
|
-
var _constants2 = require(
|
|
24
|
+
var _constants2 = require("./webrtc/constants");
|
|
23
25
|
|
|
24
|
-
var _tracer = require(
|
|
26
|
+
var _tracer = require("./tracer");
|
|
25
27
|
|
|
26
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
|
+
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
|
+
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
41
|
+
|
|
42
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
45
|
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
|
+
|
|
48
|
+
var tracer = (0, _tracer.getTracer)();
|
|
34
49
|
var environmentDetect = new _tsEnvironmentDetect.TsEnvironmentDetect();
|
|
35
50
|
var isIE11 = environmentDetect.isIE11();
|
|
36
51
|
|
|
37
52
|
if (isIE11) {
|
|
38
|
-
|
|
53
|
+
require('./webrtc/webrtc-ie-shim.js');
|
|
39
54
|
} else if (!(environmentDetect.isChrome() && environmentDetect.majorVersion() < 49)) {
|
|
40
|
-
|
|
55
|
+
require('webrtc-adapter/src/js/adapter_core'); // eslint-disable-line global-require
|
|
56
|
+
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
function _isOTDefined() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
try {
|
|
61
|
+
return !!OT;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
function _waitForOT() {
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
if (_isOTDefined()) {
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var isDefined = false;
|
|
73
|
+
return Promise.reduce(new Array(_constants.WAIT_FOR_OPENTOK_INITIALIZATION_MAX_ATTEMPTS), function () {
|
|
74
|
+
if (isDefined || _isOTDefined()) {
|
|
75
|
+
isDefined = true;
|
|
76
|
+
return Promise.resolve();
|
|
54
77
|
}
|
|
55
78
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return Promise.
|
|
59
|
-
|
|
60
|
-
isDefined = true;
|
|
61
|
-
|
|
62
|
-
return Promise.resolve();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return Promise.delay(_constants.WAIT_FOR_OPENTOK_INITIALIZATION_INTERVAL);
|
|
66
|
-
}, 0).then(function () {
|
|
67
|
-
return isDefined || Promise.reject('OT is undefined');
|
|
68
|
-
});
|
|
79
|
+
return Promise.delay(_constants.WAIT_FOR_OPENTOK_INITIALIZATION_INTERVAL);
|
|
80
|
+
}, 0).then(function () {
|
|
81
|
+
return isDefined || Promise.reject('OT is undefined');
|
|
82
|
+
});
|
|
69
83
|
}
|
|
70
|
-
|
|
71
84
|
/**
|
|
72
85
|
* @enum SERVICE_EVENTS
|
|
73
86
|
*/
|
|
87
|
+
|
|
88
|
+
|
|
74
89
|
var SERVICE_EVENTS = {
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
SESSION_CREATED: 'SESSION_CREATED',
|
|
91
|
+
EXCEPTION: 'EXCEPTION'
|
|
77
92
|
};
|
|
78
|
-
|
|
79
93
|
exports.EVENTS = SERVICE_EVENTS;
|
|
80
|
-
|
|
81
|
-
|
|
82
94
|
var sessions = [];
|
|
83
95
|
var latestLocalStream = null;
|
|
84
96
|
var userMediaPromise = null;
|
|
85
|
-
|
|
86
97
|
/**
|
|
87
98
|
* The top of hierarchy and the entry point of the TsMedia Service.
|
|
88
99
|
*
|
|
@@ -91,90 +102,102 @@ var userMediaPromise = null;
|
|
|
91
102
|
* @extends EventEmitter
|
|
92
103
|
*/
|
|
93
104
|
|
|
94
|
-
var TsMediaServiceFacade = function (_EventEmitter) {
|
|
95
|
-
|
|
105
|
+
var TsMediaServiceFacade = /*#__PURE__*/function (_EventEmitter) {
|
|
106
|
+
_inherits(TsMediaServiceFacade, _EventEmitter);
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
_classCallCheck(this, TsMediaServiceFacade);
|
|
108
|
+
var _super = _createSuper(TsMediaServiceFacade);
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
function TsMediaServiceFacade() {
|
|
111
|
+
var _this;
|
|
101
112
|
|
|
102
|
-
|
|
103
|
-
_this.destroyLocalMediaStream = _this.destroyLocalMediaStream.bind(_this);
|
|
104
|
-
return _this;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* All created sessoins
|
|
109
|
-
*
|
|
110
|
-
* @member { Object }
|
|
111
|
-
* @memberof TsMediaService
|
|
112
|
-
* @type { Array<TsMediaSession> }
|
|
113
|
-
*/
|
|
113
|
+
_classCallCheck(this, TsMediaServiceFacade);
|
|
114
114
|
|
|
115
|
+
_this = _super.call(this);
|
|
116
|
+
_this.createLocalMediaStream = _this.createLocalMediaStream.bind(_assertThisInitialized(_this));
|
|
117
|
+
_this.destroyLocalMediaStream = _this.destroyLocalMediaStream.bind(_assertThisInitialized(_this));
|
|
118
|
+
return _this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* All created sessoins
|
|
122
|
+
*
|
|
123
|
+
* @member { Object }
|
|
124
|
+
* @memberof TsMediaService
|
|
125
|
+
* @type { Array<TsMediaSession> }
|
|
126
|
+
*/
|
|
115
127
|
|
|
116
|
-
TsMediaServiceFacade.prototype.createLocalMediaStream = function createLocalMediaStream(constraints) {
|
|
117
|
-
tracer.trace('createLocalMediaStream');
|
|
118
|
-
if (userMediaPromise) {
|
|
119
|
-
return userMediaPromise;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (latestLocalStream) {
|
|
123
|
-
var videoTrack = latestLocalStream.getVideoTracks();
|
|
124
|
-
if (videoTrack.length > 0 && videoTrack[0].readyState === 'live') {
|
|
125
|
-
return Promise.resolve(latestLocalStream);
|
|
126
|
-
} else {
|
|
127
|
-
this.destroyLocalMediaStream();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
userMediaPromise = null;
|
|
141
|
-
reject(err);
|
|
142
|
-
});
|
|
143
|
-
} catch (e) {
|
|
144
|
-
userMediaPromise = null;
|
|
145
|
-
reject(e);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
129
|
+
_createClass(TsMediaServiceFacade, [{
|
|
130
|
+
key: "sessions",
|
|
131
|
+
get: function get() {
|
|
132
|
+
return sessions;
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "createLocalMediaStream",
|
|
136
|
+
value: function createLocalMediaStream(constraints) {
|
|
137
|
+
tracer.trace('createLocalMediaStream');
|
|
148
138
|
|
|
139
|
+
if (userMediaPromise) {
|
|
149
140
|
return userMediaPromise;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
TsMediaServiceFacade.prototype.destroyLocalMediaStream = function destroyLocalMediaStream() {
|
|
153
|
-
tracer.trace('Destroy local streams');
|
|
154
|
-
if (latestLocalStream) {
|
|
155
|
-
latestLocalStream.getTracks().forEach(function (track) {
|
|
156
|
-
track.stop();
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
latestLocalStream = null;
|
|
161
|
-
};
|
|
141
|
+
}
|
|
162
142
|
|
|
163
|
-
|
|
164
|
-
var
|
|
143
|
+
if (latestLocalStream) {
|
|
144
|
+
var videoTrack = latestLocalStream.getVideoTracks();
|
|
165
145
|
|
|
166
|
-
if (
|
|
167
|
-
|
|
146
|
+
if (videoTrack.length > 0 && videoTrack[0].readyState === 'live') {
|
|
147
|
+
return Promise.resolve(latestLocalStream);
|
|
148
|
+
} else {
|
|
149
|
+
this.destroyLocalMediaStream();
|
|
168
150
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
userMediaPromise = new Promise(function (resolve, reject) {
|
|
154
|
+
try {
|
|
155
|
+
tracer.trace('createLocalMediaStream inside promise');
|
|
156
|
+
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
|
|
157
|
+
latestLocalStream = stream;
|
|
158
|
+
userMediaPromise = null;
|
|
159
|
+
resolve(stream);
|
|
160
|
+
})["catch"](function (err) {
|
|
161
|
+
userMediaPromise = null;
|
|
162
|
+
reject(err);
|
|
163
|
+
});
|
|
164
|
+
} catch (e) {
|
|
165
|
+
userMediaPromise = null;
|
|
166
|
+
reject(e);
|
|
173
167
|
}
|
|
168
|
+
});
|
|
169
|
+
return userMediaPromise;
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "destroyLocalMediaStream",
|
|
173
|
+
value: function destroyLocalMediaStream() {
|
|
174
|
+
tracer.trace('Destroy local streams');
|
|
175
|
+
|
|
176
|
+
if (latestLocalStream) {
|
|
177
|
+
latestLocalStream.getTracks().forEach(function (track) {
|
|
178
|
+
track.stop();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
latestLocalStream = null;
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
185
|
+
key: "toggleMicrophone",
|
|
186
|
+
value: function toggleMicrophone() {
|
|
187
|
+
var enableMic = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
174
188
|
|
|
189
|
+
if (!latestLocalStream) {
|
|
175
190
|
return Promise.resolve();
|
|
176
|
-
|
|
191
|
+
}
|
|
177
192
|
|
|
193
|
+
var audioTracks = latestLocalStream.getAudioTracks();
|
|
194
|
+
|
|
195
|
+
if (audioTracks.length > 0) {
|
|
196
|
+
audioTracks[0].enabled = enableMic;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
178
201
|
/**
|
|
179
202
|
* Enumerate available media devices
|
|
180
203
|
*
|
|
@@ -185,27 +208,27 @@ var TsMediaServiceFacade = function (_EventEmitter) {
|
|
|
185
208
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo | MediaDeviceInfo documentation}
|
|
186
209
|
*/
|
|
187
210
|
|
|
211
|
+
}, {
|
|
212
|
+
key: "getDevices",
|
|
213
|
+
value: function getDevices() {
|
|
214
|
+
if (typeof OT !== 'undefined' && OT && OT.getDevices) {
|
|
215
|
+
return new Promise(function (resolve, reject) {
|
|
216
|
+
OT.getDevices(function (error, devices) {
|
|
217
|
+
if (error) {
|
|
218
|
+
return reject(error);
|
|
219
|
+
}
|
|
188
220
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (error) {
|
|
194
|
-
return reject(error);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return resolve(devices);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
|
|
203
|
-
return navigator.mediaDevices.enumerateDevices();
|
|
204
|
-
}
|
|
221
|
+
return resolve(devices);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
205
225
|
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
|
|
227
|
+
return navigator.mediaDevices.enumerateDevices();
|
|
228
|
+
}
|
|
208
229
|
|
|
230
|
+
return Promise.reject('getDevices is not supported');
|
|
231
|
+
}
|
|
209
232
|
/**
|
|
210
233
|
* Verifies camera access
|
|
211
234
|
*
|
|
@@ -216,27 +239,28 @@ var TsMediaServiceFacade = function (_EventEmitter) {
|
|
|
216
239
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo | MediaDeviceInfo documentation}
|
|
217
240
|
*/
|
|
218
241
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
}, {
|
|
243
|
+
key: "verifyCameraAccess",
|
|
244
|
+
value: function verifyCameraAccess(deviceOpts) {
|
|
245
|
+
return (0, _helper.getHighestResolutionStream)(deviceOpts);
|
|
246
|
+
}
|
|
247
|
+
}, {
|
|
248
|
+
key: "isVideoPlaySupportedOnDevice",
|
|
249
|
+
value: function isVideoPlaySupportedOnDevice() {
|
|
250
|
+
if (!isIE11) {
|
|
251
|
+
return Promise.resolve(true);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (!!window.WebRTCAdapter) {
|
|
255
|
+
return Promise.resolve(true);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (window.OT && window.OTPlugin && window.OTPlugin.isInstalled && window.OTPlugin.isInstalled()) {
|
|
259
|
+
return Promise.resolve(true);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return Promise.resolve(false);
|
|
263
|
+
}
|
|
240
264
|
/**
|
|
241
265
|
* Init WebRTC or OpenTok session depends on required type.
|
|
242
266
|
*
|
|
@@ -257,139 +281,137 @@ var TsMediaServiceFacade = function (_EventEmitter) {
|
|
|
257
281
|
* @returns { Promise<TsMediaSession> }
|
|
258
282
|
*/
|
|
259
283
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
var sessionOptions = {
|
|
303
|
-
isMobile: isMobile,
|
|
304
|
-
resolution: resolution,
|
|
305
|
-
credentials: creds,
|
|
306
|
-
deviceOpts: deviceOpts || { audio: true, video: true }
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
if (isLoopback) {
|
|
310
|
-
return new _session3.LoopbackWebRTCSession(sessionOptions);
|
|
311
|
-
} else if (isMobile) {
|
|
312
|
-
return new _session3.TurnWebRTCSession(sessionOptions, _this2.createLocalMediaStream);
|
|
313
|
-
} else {
|
|
314
|
-
return _this2.getTurnMediaSessionV2(sessionOptions).then(function (mediaSession) {
|
|
315
|
-
_this2.subscribeTurnSessionEvents(mediaSession);
|
|
316
|
-
|
|
317
|
-
return mediaSession;
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
});
|
|
284
|
+
}, {
|
|
285
|
+
key: "initSession",
|
|
286
|
+
value: function initSession() {
|
|
287
|
+
var _this2 = this;
|
|
288
|
+
|
|
289
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
290
|
+
isMobile: false,
|
|
291
|
+
resolution: '640x480'
|
|
292
|
+
},
|
|
293
|
+
mediaServiceType = _ref.mediaServiceType,
|
|
294
|
+
isMobile = _ref.isMobile,
|
|
295
|
+
resolution = _ref.resolution,
|
|
296
|
+
credentials = _ref.credentials,
|
|
297
|
+
deviceOpts = _ref.deviceOpts,
|
|
298
|
+
isLoopback = _ref.isLoopback;
|
|
299
|
+
|
|
300
|
+
return Promise.resolve().then(function () {
|
|
301
|
+
if (mediaServiceType === _constants.MEDIA_SERVICE_TYPES.MEDIASERVER) {
|
|
302
|
+
//
|
|
303
|
+
// KMS CONNECTION
|
|
304
|
+
//
|
|
305
|
+
return Promise.resolve().then(function () {
|
|
306
|
+
var sessionOptions = {
|
|
307
|
+
isMobile: isMobile,
|
|
308
|
+
resolution: resolution,
|
|
309
|
+
credentials: credentials.tsMediaServer,
|
|
310
|
+
deviceOpts: deviceOpts || {
|
|
311
|
+
audio: true,
|
|
312
|
+
video: true
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
return new _session3.KMSWebRTCSession(sessionOptions);
|
|
316
|
+
});
|
|
317
|
+
} else if (mediaServiceType === _constants.MEDIA_SERVICE_TYPES.TURNSERVER || isLoopback) {
|
|
318
|
+
//
|
|
319
|
+
// TURN-based connection or loopback (no connection)
|
|
320
|
+
//
|
|
321
|
+
return Promise.resolve().then(function () {
|
|
322
|
+
var creds = null;
|
|
323
|
+
|
|
324
|
+
if (!isLoopback) {
|
|
325
|
+
creds = mediaServiceType === _constants.MEDIA_SERVICE_TYPES.TURNSERVER ? credentials.turnServer : credentials.opentok;
|
|
321
326
|
}
|
|
322
327
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
credentials: credentials.opentok
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
return new _session2.TsOpenTokSession(sessionOptions);
|
|
337
|
-
});
|
|
338
|
-
}).then(function (session) {
|
|
339
|
-
_this2.emit(SERVICE_EVENTS.SESSION_CREATED, session);
|
|
340
|
-
|
|
341
|
-
sessions.push(session);
|
|
342
|
-
|
|
343
|
-
return session;
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
TsMediaServiceFacade.prototype.getTurnMediaSessionV2 = function getTurnMediaSessionV2(sessionOptions) {
|
|
348
|
-
var _this3 = this;
|
|
328
|
+
var sessionOptions = {
|
|
329
|
+
isMobile: isMobile,
|
|
330
|
+
resolution: resolution,
|
|
331
|
+
credentials: creds,
|
|
332
|
+
deviceOpts: deviceOpts || {
|
|
333
|
+
audio: true,
|
|
334
|
+
video: true
|
|
335
|
+
}
|
|
336
|
+
};
|
|
349
337
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
338
|
+
if (isLoopback) {
|
|
339
|
+
return new _session3.LoopbackWebRTCSession(sessionOptions);
|
|
340
|
+
} else if (isMobile) {
|
|
341
|
+
return new _session3.TurnWebRTCSession(sessionOptions, _this2.createLocalMediaStream);
|
|
342
|
+
} else {
|
|
343
|
+
return _this2.getTurnMediaSessionV2(sessionOptions).then(function (mediaSession) {
|
|
344
|
+
_this2.subscribeTurnSessionEvents(mediaSession);
|
|
355
345
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if (clientType === _constants2.CLIENT_TYPES.GUEST) {
|
|
359
|
-
delete constraints.video;
|
|
346
|
+
return mediaSession;
|
|
347
|
+
});
|
|
360
348
|
}
|
|
349
|
+
});
|
|
350
|
+
} //
|
|
351
|
+
// OT CONNECTION (default mediaServiceType)
|
|
352
|
+
//
|
|
361
353
|
|
|
362
|
-
var sessionParams = {
|
|
363
|
-
constraints: constraints,
|
|
364
|
-
clientType: clientType,
|
|
365
|
-
credentials: sessionOptions.credentials,
|
|
366
|
-
streamFactory: _this3.createLocalMediaStream
|
|
367
|
-
};
|
|
368
354
|
|
|
369
|
-
|
|
355
|
+
return Promise.resolve().then(function () {
|
|
356
|
+
return _waitForOT();
|
|
357
|
+
}).then(function () {
|
|
358
|
+
var sessionOptions = {
|
|
359
|
+
isMobile: isMobile,
|
|
360
|
+
resolution: resolution,
|
|
361
|
+
credentials: credentials.opentok
|
|
362
|
+
};
|
|
363
|
+
return new _session2.TsOpenTokSession(sessionOptions);
|
|
370
364
|
});
|
|
371
|
-
|
|
365
|
+
}).then(function (session) {
|
|
366
|
+
_this2.emit(SERVICE_EVENTS.SESSION_CREATED, session);
|
|
372
367
|
|
|
373
|
-
|
|
374
|
-
|
|
368
|
+
sessions.push(session);
|
|
369
|
+
return session;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
key: "getTurnMediaSessionV2",
|
|
374
|
+
value: function getTurnMediaSessionV2(sessionOptions) {
|
|
375
|
+
var _this3 = this;
|
|
376
|
+
|
|
377
|
+
return (0, _helper.getMediaConstraints)({
|
|
378
|
+
resolution: sessionOptions.resolution,
|
|
379
|
+
deviceOpts: sessionOptions.deviceOpts
|
|
380
|
+
}).then(function (constraints) {
|
|
381
|
+
var clientType = sessionOptions.isMobile ? _constants2.CLIENT_TYPES.INITIATOR : _constants2.CLIENT_TYPES.GUEST; // streaming from dashboard is not supported and we
|
|
382
|
+
// don't want to access the camera without a reason
|
|
383
|
+
|
|
384
|
+
if (clientType === _constants2.CLIENT_TYPES.GUEST) {
|
|
385
|
+
delete constraints.video;
|
|
386
|
+
}
|
|
375
387
|
|
|
376
|
-
var
|
|
377
|
-
|
|
378
|
-
|
|
388
|
+
var sessionParams = {
|
|
389
|
+
constraints: constraints,
|
|
390
|
+
clientType: clientType,
|
|
391
|
+
credentials: sessionOptions.credentials,
|
|
392
|
+
streamFactory: _this3.createLocalMediaStream
|
|
379
393
|
};
|
|
394
|
+
return new _session3.TurnWebRtcSessionV2(sessionParams);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}, {
|
|
398
|
+
key: "subscribeTurnSessionEvents",
|
|
399
|
+
value: function subscribeTurnSessionEvents(mediaSession) {
|
|
400
|
+
var _this4 = this;
|
|
380
401
|
|
|
381
|
-
|
|
382
|
-
|
|
402
|
+
var disconnectHandler = function disconnectHandler() {
|
|
403
|
+
_this4.destroyLocalMediaStream();
|
|
383
404
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
405
|
+
mediaSession.off(_session.SESSION_EVENTS.DISCONNECTED, disconnectHandler);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
mediaSession.on(_session.SESSION_EVENTS.DISCONNECTED, disconnectHandler);
|
|
409
|
+
}
|
|
410
|
+
}]);
|
|
390
411
|
|
|
391
|
-
|
|
412
|
+
return TsMediaServiceFacade;
|
|
392
413
|
}(_eventEmitter.EventEmitter);
|
|
393
414
|
|
|
394
|
-
var TsMediaService =
|
|
415
|
+
var TsMediaService = new TsMediaServiceFacade();
|
|
416
|
+
exports.TsMediaService = TsMediaService;
|
|
395
417
|
//# sourceMappingURL=service.js.map
|