@techsee/techsee-media-service 18.6.1 → 19.0.0
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 +1 -0
- package/lib/LocalStreamManager.d.ts.map +1 -1
- package/lib/LocalStreamManager.js +320 -441
- package/lib/LocalStreamManager.js.map +1 -1
- package/lib/MediaConstants.d.ts +1 -0
- package/lib/MediaConstants.d.ts.map +1 -1
- package/lib/MediaConstants.js +53 -95
- package/lib/MediaConstants.js.map +1 -1
- package/lib/MediaContracts.d.ts +1 -0
- package/lib/MediaContracts.d.ts.map +1 -1
- package/lib/MediaContracts.js +2 -5
- package/lib/MediaContracts.js.map +1 -1
- package/lib/MediaPublisher.d.ts +1 -0
- package/lib/MediaPublisher.d.ts.map +1 -1
- package/lib/MediaPublisher.js +36 -49
- package/lib/MediaPublisher.js.map +1 -1
- package/lib/MediaServiceBase.d.ts +1 -0
- package/lib/MediaServiceBase.d.ts.map +1 -1
- package/lib/MediaServiceBase.js +687 -937
- package/lib/MediaServiceBase.js.map +1 -1
- package/lib/MediaSession/MediaServer.d.ts +1 -0
- package/lib/MediaSession/MediaServer.d.ts.map +1 -1
- package/lib/MediaSession/MediaServer.js +372 -517
- package/lib/MediaSession/MediaServer.js.map +1 -1
- package/lib/MediaSession/MediaSessionBase.d.ts +1 -0
- package/lib/MediaSession/MediaSessionBase.d.ts.map +1 -1
- package/lib/MediaSession/MediaSessionBase.js +88 -127
- package/lib/MediaSession/MediaSessionBase.js.map +1 -1
- package/lib/MediaSession/SessionOpentok.d.ts +1 -0
- package/lib/MediaSession/SessionOpentok.d.ts.map +1 -1
- package/lib/MediaSession/SessionOpentok.js +357 -503
- package/lib/MediaSession/SessionOpentok.js.map +1 -1
- package/lib/MediaSession/SessionTurn.d.ts +1 -0
- package/lib/MediaSession/SessionTurn.d.ts.map +1 -1
- package/lib/MediaSession/SessionTurn.js +431 -613
- package/lib/MediaSession/SessionTurn.js.map +1 -1
- package/lib/MediaSession/TurnConstants.d.ts +1 -0
- package/lib/MediaSession/TurnConstants.d.ts.map +1 -1
- package/lib/MediaSession/TurnConstants.js +17 -32
- package/lib/MediaSession/TurnConstants.js.map +1 -1
- package/lib/MediaSubscriber.d.ts +1 -0
- package/lib/MediaSubscriber.d.ts.map +1 -1
- package/lib/MediaSubscriber.js +189 -245
- package/lib/MediaSubscriber.js.map +1 -1
- package/lib/MediaUtils/Compatibility.d.ts +1 -0
- package/lib/MediaUtils/Compatibility.d.ts.map +1 -1
- package/lib/MediaUtils/Compatibility.js +129 -283
- package/lib/MediaUtils/Compatibility.js.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.d.ts +1 -0
- package/lib/MediaUtils/MediaDomUtils.d.ts.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.js +184 -252
- package/lib/MediaUtils/MediaDomUtils.js.map +1 -1
- package/lib/MediaUtils/MediaTracer.d.ts +1 -0
- package/lib/MediaUtils/MediaTracer.d.ts.map +1 -1
- package/lib/MediaUtils/MediaTracer.js +3 -10
- package/lib/MediaUtils/MediaTracer.js.map +1 -1
- package/lib/MediaUtils/index.d.ts +1 -0
- package/lib/MediaUtils/index.d.ts.map +1 -1
- package/lib/MediaUtils/index.js +3 -13
- package/lib/MediaUtils/index.js.map +1 -1
- package/lib/MultiParty/DetectWebRtcService.d.ts +1 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts.map +1 -1
- package/lib/MultiParty/DetectWebRtcService.js +92 -241
- package/lib/MultiParty/DetectWebRtcService.js.map +1 -1
- package/lib/MultiParty/MediaCapabilitiesService.d.ts +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -1
- package/lib/MultiParty/MediaCapabilitiesService.js +143 -312
- package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -1
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -1
- package/lib/MultiParty/MediaCapabilitiesUtils.js +95 -277
- package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -1
- package/lib/MultiParty/MediaTracer.d.ts +1 -0
- package/lib/MultiParty/MediaTracer.d.ts.map +1 -1
- package/lib/MultiParty/MediaTracer.js +3 -10
- package/lib/MultiParty/MediaTracer.js.map +1 -1
- package/lib/MultiParty/MultiPartyService.d.ts +1 -0
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -1
- package/lib/MultiParty/MultiPartyService.js +24 -47
- package/lib/MultiParty/MultiPartyService.js.map +1 -1
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts +2 -1
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -1
- package/lib/MultiParty/MultiPartyServiceFactory.js +7 -15
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -1
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts +1 -0
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts.map +1 -1
- package/lib/MultiParty/MultipartyServiceEventTypes.js +11 -15
- package/lib/MultiParty/MultipartyServiceEventTypes.js.map +1 -1
- package/lib/MultiParty/index.d.ts +1 -0
- package/lib/MultiParty/index.d.ts.map +1 -1
- package/lib/MultiParty/index.js +15 -35
- package/lib/MultiParty/index.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts +2 -1
- package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokMultiPartyService.js +457 -839
- package/lib/MultiParty/opentok/OpentokMultiPartyService.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokPublisher.js +107 -269
- package/lib/MultiParty/opentok/OpentokPublisher.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js +34 -54
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokScreenPublisher.js +40 -77
- package/lib/MultiParty/opentok/OpentokScreenPublisher.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokSubscriber.js +20 -28
- package/lib/MultiParty/opentok/OpentokSubscriber.js.map +1 -1
- package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts.map +1 -1
- package/lib/MultiParty/opentok/OpentokVideoPublisher.js +150 -355
- package/lib/MultiParty/opentok/OpentokVideoPublisher.js.map +1 -1
- package/lib/MultiParty/opentok/trace.d.ts +1 -0
- package/lib/MultiParty/opentok/trace.d.ts.map +1 -1
- package/lib/MultiParty/opentok/trace.js +11 -24
- package/lib/MultiParty/opentok/trace.js.map +1 -1
- package/lib/MultiParty/types.d.ts +1 -0
- package/lib/MultiParty/types.d.ts.map +1 -1
- package/lib/MultiParty/types.js +2 -5
- package/lib/MultiParty/types.js.map +1 -1
- package/lib/MultiParty/utils.d.ts +1 -0
- package/lib/MultiParty/utils.d.ts.map +1 -1
- package/lib/MultiParty/utils.js +5 -15
- package/lib/MultiParty/utils.js.map +1 -1
- package/lib/TechseeMediaStream.d.ts +1 -0
- package/lib/TechseeMediaStream.d.ts.map +1 -1
- package/lib/TechseeMediaStream.js +53 -61
- package/lib/TechseeMediaStream.js.map +1 -1
- package/lib/qos/raw-qos.d.ts +29 -0
- package/lib/qos/raw-qos.d.ts.map +1 -0
- package/lib/qos/raw-qos.js +247 -382
- package/lib/qos/raw-qos.js.map +1 -1
- package/lib/webrtc-ie-shim.d.ts +4 -0
- package/lib/webrtc-ie-shim.d.ts.map +1 -0
- package/lib/webrtc-ie-shim.js +1999 -3454
- package/lib/webrtc-ie-shim.js.map +1 -1
- package/package.json +42 -45
package/lib/MediaServiceBase.js
CHANGED
|
@@ -1,976 +1,726 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return mod && mod.__esModule ? mod : {
|
|
21
|
-
"default": mod
|
|
22
|
-
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
15
|
};
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, "__esModule", {
|
|
26
|
-
value: true
|
|
27
|
-
});
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
17
|
exports.TechseeMediaServiceBase = void 0;
|
|
29
|
-
|
|
30
18
|
var filter_1 = __importDefault(require("lodash/filter"));
|
|
31
|
-
|
|
32
19
|
var cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
33
|
-
|
|
34
20
|
var values_1 = __importDefault(require("lodash/values"));
|
|
35
|
-
|
|
36
21
|
var debounce_1 = __importDefault(require("lodash/debounce"));
|
|
37
|
-
|
|
38
22
|
var includes_1 = __importDefault(require("lodash/includes"));
|
|
39
|
-
|
|
40
23
|
var events_1 = require("events");
|
|
41
|
-
|
|
42
24
|
var MediaSubscriber_1 = require("./MediaSubscriber");
|
|
43
|
-
|
|
44
25
|
var LocalStreamManager_1 = require("./LocalStreamManager");
|
|
45
|
-
|
|
46
26
|
var TechseeMediaStream_1 = require("./TechseeMediaStream");
|
|
47
|
-
|
|
48
27
|
var SessionTurn_1 = require("./MediaSession/SessionTurn");
|
|
49
|
-
|
|
50
28
|
var MediaDomUtils_1 = require("./MediaUtils/MediaDomUtils");
|
|
51
|
-
|
|
52
29
|
var Compatibility_1 = require("./MediaUtils/Compatibility");
|
|
53
|
-
|
|
54
30
|
var SessionOpentok_1 = require("./MediaSession/SessionOpentok");
|
|
55
|
-
|
|
56
31
|
var MediaConstants_1 = require("./MediaConstants");
|
|
57
|
-
|
|
58
32
|
var guards_1 = require("@techsee/techsee-common/lib/core/guards");
|
|
59
|
-
|
|
60
33
|
var MediaServer_1 = require("./MediaSession/MediaServer");
|
|
61
|
-
|
|
62
34
|
var MediaTracer_1 = require("./MediaUtils/MediaTracer");
|
|
63
|
-
|
|
64
35
|
var MediaSessionBase_1 = require("./MediaSession/MediaSessionBase");
|
|
65
|
-
|
|
66
|
-
var
|
|
67
|
-
var traceStatsInfo = debounce_1["default"](trace.info, 1000 * 5, {
|
|
68
|
-
leading: true,
|
|
69
|
-
maxWait: 1000 * 30
|
|
70
|
-
});
|
|
36
|
+
var trace = (0, MediaTracer_1.getMediaTracer)('MediaServiceBase');
|
|
37
|
+
var traceStatsInfo = (0, debounce_1.default)(trace.info, 1000 * 5, { leading: true, maxWait: 1000 * 30 });
|
|
71
38
|
var privateEvents;
|
|
72
|
-
|
|
73
39
|
(function (privateEvents) {
|
|
74
|
-
|
|
75
|
-
|
|
40
|
+
privateEvents["STREAM_CREATED"] = "STREAM_CREATED";
|
|
41
|
+
privateEvents["STREAM_DESTROYED"] = "STREAM_DESTROYED";
|
|
76
42
|
})(privateEvents || (privateEvents = {}));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
addRemoteMediaTrack: this.registerRemoteMediaTrack,
|
|
114
|
-
removeMediaTrack: this.unregisterRemoteMediaTrack
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
Object.defineProperty(TechseeMediaServiceBase.prototype, "deviceSupportInfo", {
|
|
119
|
-
get: function get() {
|
|
120
|
-
this.serviceInitGuard(false);
|
|
121
|
-
return cloneDeep_1["default"](this._deviceSupportFlags);
|
|
122
|
-
},
|
|
123
|
-
enumerable: false,
|
|
124
|
-
configurable: true
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(TechseeMediaServiceBase.prototype, "isVoipEnabled", {
|
|
127
|
-
get: function get() {
|
|
128
|
-
return this._isVoipEnabled;
|
|
129
|
-
},
|
|
130
|
-
enumerable: false,
|
|
131
|
-
configurable: true
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(TechseeMediaServiceBase.prototype, "isSessionActive", {
|
|
134
|
-
get: function get() {
|
|
135
|
-
return this._session !== null;
|
|
136
|
-
},
|
|
137
|
-
enumerable: false,
|
|
138
|
-
configurable: true
|
|
139
|
-
});
|
|
140
|
-
Object.defineProperty(TechseeMediaServiceBase.prototype, "isLocalStreamInitialized", {
|
|
141
|
-
get: function get() {
|
|
142
|
-
return this._initLocalStreamsPromise !== null;
|
|
143
|
-
},
|
|
144
|
-
enumerable: false,
|
|
145
|
-
configurable: true
|
|
146
|
-
});
|
|
147
|
-
/*
|
|
148
|
-
Initializes media service. Before using anything from this service it should be initialized first.
|
|
149
|
-
All of serviceOptions should be retrieved from account settings and by evaluating application state.
|
|
150
|
-
For example, when initializing service, accountSettings is already loaded, and we know if FS session is audio enabled.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
TechseeMediaServiceBase.prototype.initMediaService = function (serviceOptions) {
|
|
154
|
-
var _this = this;
|
|
155
|
-
|
|
156
|
-
trace.info('TechseeMediaServiceBase.initMediaService', serviceOptions);
|
|
157
|
-
var warnMessage = 'Multiple initialization does not supposed to happen. Not rejecting, but check the flow for correctness.';
|
|
158
|
-
|
|
159
|
-
if (this._initServicePromise || this._serviceOptions) {
|
|
160
|
-
console.warn(warnMessage);
|
|
161
|
-
return this._initServicePromise ? this._initServicePromise : Promise.resolve();
|
|
43
|
+
var TechseeMediaServiceBase = (function () {
|
|
44
|
+
function TechseeMediaServiceBase(environment, webRtcSupportInfo) {
|
|
45
|
+
this._subscribers = new Map();
|
|
46
|
+
this._publishers = new Map();
|
|
47
|
+
this._publisherPromises = new Map();
|
|
48
|
+
this._serviceOptions = null;
|
|
49
|
+
this._isIOS_13_orLater = false;
|
|
50
|
+
this._isIOS_14_orLater = false;
|
|
51
|
+
this._autoReconnectEnabled = true;
|
|
52
|
+
this._initLocalStreamsPromise = null;
|
|
53
|
+
this._initServicePromise = null;
|
|
54
|
+
this._registeredStreams = new Map();
|
|
55
|
+
this._isVoipEnabled = false;
|
|
56
|
+
this._session = null;
|
|
57
|
+
trace.info('TechseeMediaServiceBase created');
|
|
58
|
+
this.bindClassMethods();
|
|
59
|
+
this._emitter = new events_1.EventEmitter();
|
|
60
|
+
this._environment = environment;
|
|
61
|
+
this._deviceSupportFlags = {
|
|
62
|
+
videoPlayback: false,
|
|
63
|
+
hasCamera: false,
|
|
64
|
+
hasMicrophone: false,
|
|
65
|
+
webRtcSupportInfo: webRtcSupportInfo
|
|
66
|
+
};
|
|
67
|
+
this._localStreamsManager = new LocalStreamManager_1.LocalStreamManager(this._environment);
|
|
68
|
+
this._isIOS_13_orLater =
|
|
69
|
+
this._environment.isIOS() && (!this._environment.majorVersion() || this._environment.majorVersion() >= 13);
|
|
70
|
+
this._isIOS_14_orLater =
|
|
71
|
+
this._environment.isIOS() && (!this._environment.majorVersion() || this._environment.majorVersion() >= 14);
|
|
72
|
+
trace.info("TechseeMediaServiceBase: isIOS_13_orLater: ".concat(this._isIOS_13_orLater));
|
|
73
|
+
trace.info("TechseeMediaServiceBase: isIOS_14_orLater: ".concat(this._isIOS_14_orLater));
|
|
74
|
+
this._sessionStreamsManager = {
|
|
75
|
+
getMediaStreamForRole: this.getStreamForDestinationRole,
|
|
76
|
+
addRemoteMediaTrack: this.registerRemoteMediaTrack,
|
|
77
|
+
removeMediaTrack: this.unregisterRemoteMediaTrack
|
|
78
|
+
};
|
|
162
79
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
80
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "deviceSupportInfo", {
|
|
81
|
+
get: function () {
|
|
82
|
+
this.serviceInitGuard(false);
|
|
83
|
+
return (0, cloneDeep_1.default)(this._deviceSupportFlags);
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "isVoipEnabled", {
|
|
89
|
+
get: function () {
|
|
90
|
+
return this._isVoipEnabled;
|
|
91
|
+
},
|
|
92
|
+
enumerable: false,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "isSessionActive", {
|
|
96
|
+
get: function () {
|
|
97
|
+
return this._session !== null;
|
|
98
|
+
},
|
|
99
|
+
enumerable: false,
|
|
100
|
+
configurable: true
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "isLocalStreamInitialized", {
|
|
103
|
+
get: function () {
|
|
104
|
+
return this._initLocalStreamsPromise !== null;
|
|
105
|
+
},
|
|
106
|
+
enumerable: false,
|
|
107
|
+
configurable: true
|
|
108
|
+
});
|
|
109
|
+
TechseeMediaServiceBase.prototype.initMediaService = function (serviceOptions) {
|
|
110
|
+
var _this = this;
|
|
111
|
+
trace.info('TechseeMediaServiceBase.initMediaService', serviceOptions);
|
|
112
|
+
var warnMessage = 'Multiple initialization does not supposed to happen. Not rejecting, but check the flow for correctness.';
|
|
113
|
+
if (this._initServicePromise || this._serviceOptions) {
|
|
114
|
+
console.warn(warnMessage);
|
|
115
|
+
return this._initServicePromise ? this._initServicePromise : Promise.resolve();
|
|
116
|
+
}
|
|
117
|
+
this._serviceOptions = (0, cloneDeep_1.default)(serviceOptions);
|
|
118
|
+
this._initServicePromise = Promise.all([
|
|
119
|
+
(0, Compatibility_1.isVideoPlaySupportedOnDevice)(this._serviceOptions.mediaServiceType).then(function (isSupported) { return (_this._deviceSupportFlags.videoPlayback = isSupported); }),
|
|
120
|
+
(this._isIOS_14_orLater || !this._deviceSupportFlags.webRtcSupportInfo.isWebRTCSupported
|
|
121
|
+
? Promise.resolve([])
|
|
122
|
+
: (0, Compatibility_1.enumerateMediaDevices)())
|
|
123
|
+
.catch(function (error) {
|
|
124
|
+
trace.warn(error);
|
|
125
|
+
return [];
|
|
126
|
+
})
|
|
127
|
+
.then(function (localDevicesList) {
|
|
128
|
+
var groupedDevices = {
|
|
129
|
+
video: (0, filter_1.default)(localDevicesList, function (device) { return device.kind.toLowerCase() === 'videoinput'; }),
|
|
130
|
+
audio: (0, filter_1.default)(localDevicesList, function (device) { return device.kind.toLowerCase() === 'audioinput'; })
|
|
131
|
+
};
|
|
132
|
+
_this._localStreamsManager.setGroupedDevices(groupedDevices);
|
|
133
|
+
_this._deviceSupportFlags.hasCamera = _this._isIOS_13_orLater || groupedDevices.video.length > 0;
|
|
134
|
+
_this._deviceSupportFlags.hasMicrophone = _this._isIOS_13_orLater || groupedDevices.audio.length > 0;
|
|
135
|
+
})
|
|
136
|
+
]).then(function () { return undefined; });
|
|
137
|
+
return this._initServicePromise;
|
|
138
|
+
};
|
|
139
|
+
TechseeMediaServiceBase.prototype.initLocalMediaStreams = function () {
|
|
140
|
+
this.serviceInitGuard();
|
|
141
|
+
var isDashboardOpentok = this._serviceOptions.mediaServiceType === MediaConstants_1.MediaServiceType.OPENTOK &&
|
|
142
|
+
(this._serviceOptions.clientRole === MediaConstants_1.SessionClientRole.AGENT ||
|
|
143
|
+
this._serviceOptions.clientRole === MediaConstants_1.SessionClientRole.OBSERVER);
|
|
144
|
+
if (!this._initLocalStreamsPromise || (this._isIOS_14_orLater && !isDashboardOpentok)) {
|
|
145
|
+
trace.info('initLocalMediaStreams creating media streams');
|
|
146
|
+
this._initLocalStreamsPromise = this.getLocalMediaImplementation().catch(function (mediaRequestFailResult) {
|
|
147
|
+
trace.error("initLocalMediaStreams failure: ".concat(mediaRequestFailResult));
|
|
148
|
+
throw mediaRequestFailResult;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
trace.info('initLocalMediaStreams already done or in progress');
|
|
153
|
+
}
|
|
154
|
+
return this._initLocalStreamsPromise;
|
|
155
|
+
};
|
|
156
|
+
TechseeMediaServiceBase.prototype.createSubscriber = function (subscriberParams) {
|
|
157
|
+
if (this._subscribers.has(subscriberParams.container)) {
|
|
158
|
+
return Promise.reject('Subscriber for provided DIV element already exists');
|
|
159
|
+
}
|
|
160
|
+
var subscriber = new MediaSubscriber_1.TechseeMediaSubscriber(subscriberParams);
|
|
161
|
+
this._subscribers.set(subscriberParams.container, subscriber);
|
|
162
|
+
var streamForSubscriber = this.getRegisteredStreamByType(subscriber.streamType);
|
|
163
|
+
if (streamForSubscriber) {
|
|
164
|
+
trace.info("Stream for ".concat(subscriberParams.streamType, " is ready."));
|
|
165
|
+
subscriber.renderStream(streamForSubscriber);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
trace.info("Stream for ".concat(subscriberParams.streamType, " not created yet"));
|
|
169
|
+
}
|
|
170
|
+
return Promise.resolve(subscriber);
|
|
171
|
+
};
|
|
172
|
+
TechseeMediaServiceBase.prototype.destroySubscriber = function (container) {
|
|
173
|
+
if (this._subscribers.has(container)) {
|
|
174
|
+
var subscriber = this._subscribers.get(container);
|
|
175
|
+
subscriber.dispose();
|
|
176
|
+
}
|
|
177
|
+
this._subscribers.delete(container);
|
|
178
|
+
return Promise.resolve();
|
|
179
|
+
};
|
|
180
|
+
TechseeMediaServiceBase.prototype.onStreamDestroyed = function (callback) {
|
|
181
|
+
this.registerEventCallback(privateEvents.STREAM_DESTROYED, callback);
|
|
182
|
+
};
|
|
183
|
+
TechseeMediaServiceBase.prototype.onStreamCreated = function (callback) {
|
|
184
|
+
this.registerEventCallback(privateEvents.STREAM_CREATED, callback);
|
|
185
|
+
};
|
|
186
|
+
TechseeMediaServiceBase.prototype.onRecordStarted = function (callback) {
|
|
187
|
+
if (this._session && this._session.instance) {
|
|
188
|
+
this._session.instance.registerEventCallback(MediaSessionBase_1.recordingEvents.RECORD_STARTED, callback);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
TechseeMediaServiceBase.prototype.onRecordStopped = function (callback) {
|
|
192
|
+
if (this._session && this._session.instance) {
|
|
193
|
+
this._session.instance.registerEventCallback(MediaSessionBase_1.recordingEvents.RECORD_STOPPED, callback);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
TechseeMediaServiceBase.prototype.onReconnecting = function (callback) {
|
|
197
|
+
if (this._session && this._session.instance) {
|
|
198
|
+
this._session.instance.registerEventCallback(MediaSessionBase_1.recordingEvents.RECONNECTING, callback);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
TechseeMediaServiceBase.prototype.getSwitchCameraConstraints = function () {
|
|
202
|
+
var constraints = (0, cloneDeep_1.default)(window.latestLocalMediaConstraints);
|
|
203
|
+
if (!constraints) {
|
|
204
|
+
throw new Error('getSwitchCameraConstraints: unexpected use case constraints is null.');
|
|
205
|
+
}
|
|
206
|
+
trace.info('getSwitchCameraConstraints - Start switch camera with constraints:', constraints);
|
|
207
|
+
var videoSourceType = constraints.video.videoSourceType === MediaConstants_1.LocalVideoSourceType.CAMERA
|
|
208
|
+
? MediaConstants_1.LocalVideoSourceType.CAMERA_FRONT
|
|
209
|
+
: MediaConstants_1.LocalVideoSourceType.CAMERA;
|
|
210
|
+
trace.info("getSwitchCameraConstraints - switch to videoSourceType: ".concat(videoSourceType));
|
|
211
|
+
constraints.video.videoSourceType = videoSourceType;
|
|
212
|
+
return constraints;
|
|
213
|
+
};
|
|
214
|
+
TechseeMediaServiceBase.prototype.switchCamera = function (revertCameraWhenFailed) {
|
|
215
|
+
var _this = this;
|
|
216
|
+
trace.info('switchCamera: start');
|
|
217
|
+
var latestLocalMediaConstraints = (0, cloneDeep_1.default)(window.latestLocalMediaConstraints);
|
|
218
|
+
var constraints = !revertCameraWhenFailed ? this.getSwitchCameraConstraints() : latestLocalMediaConstraints;
|
|
219
|
+
if (!constraints) {
|
|
220
|
+
throw new Error('switchCamera - unexpected use case constraints is null.');
|
|
221
|
+
}
|
|
222
|
+
return this._localStreamsManager
|
|
223
|
+
.destroyUserMediaStream()
|
|
224
|
+
.then(function () {
|
|
225
|
+
return _this._localStreamsManager
|
|
226
|
+
.getUserMediaStream(constraints)
|
|
227
|
+
.then(function (streamResult) {
|
|
228
|
+
var stream = streamResult.mediaStream;
|
|
229
|
+
trace.info('switchCamera: new stream: ', stream);
|
|
230
|
+
return _this.replaceStreamTracks(stream).then(function () {
|
|
231
|
+
return _this.registerStreamResult(constraints, streamResult, true).then(function () { return ({
|
|
232
|
+
revertCameraWhenFailed: revertCameraWhenFailed,
|
|
233
|
+
constraints: constraints,
|
|
234
|
+
streamResult: streamResult
|
|
235
|
+
}); });
|
|
236
|
+
});
|
|
237
|
+
});
|
|
177
238
|
})
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
239
|
+
.catch(function (err) {
|
|
240
|
+
trace.error('switchCamera: Failed to switch camera: ', err);
|
|
241
|
+
if (!revertCameraWhenFailed) {
|
|
242
|
+
window.latestLocalMediaConstraints = latestLocalMediaConstraints;
|
|
243
|
+
return _this.switchCamera(true);
|
|
244
|
+
}
|
|
245
|
+
return Promise.reject('Failed to switch camera.');
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
TechseeMediaServiceBase.prototype.replaceStreamTracks = function (mediaStream) {
|
|
249
|
+
if (this._session.instance) {
|
|
250
|
+
return this._session.instance.replaceStreamTracks(mediaStream);
|
|
251
|
+
}
|
|
252
|
+
return Promise.reject('replaceStreamTracks - session instance is not exists.');
|
|
253
|
+
};
|
|
254
|
+
TechseeMediaServiceBase.prototype.registerStreamResult = function (constraints, streamResult, switchCamera, addStreamType) {
|
|
255
|
+
var _this = this;
|
|
256
|
+
var regPromises = [];
|
|
257
|
+
var isOpentok = this._serviceOptions.mediaServiceType === MediaConstants_1.MediaServiceType.OPENTOK;
|
|
258
|
+
if (streamResult.isNew) {
|
|
259
|
+
trace.info('registerStreamResult: stream result from getUserMediaStream:', streamResult.mediaStream);
|
|
260
|
+
streamResult.mediaStream.getTracks().forEach(function (mediaTrack) {
|
|
261
|
+
trace.info('registerStreamResult: stream result from mediaTrack:', mediaTrack);
|
|
262
|
+
var streamType = addStreamType ||
|
|
263
|
+
(mediaTrack.kind === 'video'
|
|
264
|
+
? MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM
|
|
265
|
+
: MediaConstants_1.KnownMediaStream.USER_AUDIO_STREAM);
|
|
266
|
+
var newDedicatedStream = new TechseeMediaStream_1.TechseeMediaStream(mediaTrack, streamType, false);
|
|
267
|
+
if (isOpentok) {
|
|
268
|
+
regPromises.push(_this.registerStream(newDedicatedStream));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
regPromises.push(switchCamera
|
|
272
|
+
? _this.registerTrack(newDedicatedStream)
|
|
273
|
+
: _this.registerLocalMediaStream(newDedicatedStream));
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return Promise.all(regPromises);
|
|
278
|
+
};
|
|
279
|
+
TechseeMediaServiceBase.prototype.disconnectFromMediaSession = function () {
|
|
280
|
+
if (this._session && this._session.instance) {
|
|
281
|
+
return this._session.instance.sessionDisconnect();
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "supportSwitchCameras", {
|
|
285
|
+
get: function () {
|
|
286
|
+
return this._isIOS_13_orLater || this._localStreamsManager.groupedDevices.camerasCount > 1;
|
|
287
|
+
},
|
|
288
|
+
enumerable: false,
|
|
289
|
+
configurable: true
|
|
186
290
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this._session.instance.registerEventCallback(MediaSessionBase_1.recordingEvents.RECONNECTING, callback);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
TechseeMediaServiceBase.prototype.getSwitchCameraConstraints = function () {
|
|
284
|
-
var constraints = cloneDeep_1["default"](window.latestLocalMediaConstraints);
|
|
285
|
-
|
|
286
|
-
if (!constraints) {
|
|
287
|
-
throw new Error('getSwitchCameraConstraints: unexpected use case constraints is null.');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
trace.info('getSwitchCameraConstraints - Start switch camera with constraints:', constraints);
|
|
291
|
-
var videoSourceType = constraints.video.videoSourceType === MediaConstants_1.LocalVideoSourceType.CAMERA ? MediaConstants_1.LocalVideoSourceType.CAMERA_FRONT : MediaConstants_1.LocalVideoSourceType.CAMERA;
|
|
292
|
-
trace.info("getSwitchCameraConstraints - switch to videoSourceType: " + videoSourceType);
|
|
293
|
-
constraints.video.videoSourceType = videoSourceType;
|
|
294
|
-
return constraints;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
TechseeMediaServiceBase.prototype.switchCamera = function (revertCameraWhenFailed) {
|
|
298
|
-
var _this = this;
|
|
299
|
-
|
|
300
|
-
trace.info('switchCamera: start');
|
|
301
|
-
var latestLocalMediaConstraints = cloneDeep_1["default"](window.latestLocalMediaConstraints);
|
|
302
|
-
var constraints = !revertCameraWhenFailed ? this.getSwitchCameraConstraints() : latestLocalMediaConstraints;
|
|
303
|
-
|
|
304
|
-
if (!constraints) {
|
|
305
|
-
throw new Error('switchCamera - unexpected use case constraints is null.');
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return this._localStreamsManager.destroyUserMediaStream().then(function () {
|
|
309
|
-
return _this._localStreamsManager.getUserMediaStream(constraints).then(function (streamResult) {
|
|
310
|
-
var stream = streamResult.mediaStream;
|
|
311
|
-
trace.info('switchCamera: new stream: ', stream);
|
|
312
|
-
return _this.replaceStreamTracks(stream).then(function () {
|
|
313
|
-
return _this.registerStreamResult(constraints, streamResult, true).then(function () {
|
|
291
|
+
TechseeMediaServiceBase.prototype._connectToSession = function (sessionParams) {
|
|
292
|
+
var _this = this;
|
|
293
|
+
this.serviceInitGuard();
|
|
294
|
+
if (!this._session) {
|
|
295
|
+
this._session = { params: (0, cloneDeep_1.default)(sessionParams) };
|
|
296
|
+
this._session.connectPromise = new Promise(function (resolve, reject) {
|
|
297
|
+
var doAsyncReject = function (error) {
|
|
298
|
+
setTimeout(function () {
|
|
299
|
+
_this._session = null;
|
|
300
|
+
reject(error);
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
var sessionHandlers = {
|
|
304
|
+
onDisconnectedHandler: _this.onSessionDisconnectHandler
|
|
305
|
+
};
|
|
306
|
+
var mediaSessionParams = __assign(__assign({}, sessionParams), { peerConnectivityTimeoutSeconds: _this._serviceOptions.peerConnectivityTimeoutSeconds ||
|
|
307
|
+
MediaConstants_1.DEFAULT_PEER_CONNECTIVITY_TIMEOUT_SECONDS });
|
|
308
|
+
trace.info('connectToSession', sessionParams);
|
|
309
|
+
var allowedValues = (0, values_1.default)(MediaConstants_1.MediaServiceType);
|
|
310
|
+
switch (_this._serviceOptions.mediaServiceType) {
|
|
311
|
+
case MediaConstants_1.MediaServiceType.TURNSERVER:
|
|
312
|
+
_this._session.instance = new SessionTurn_1.TurnWebRtcSession(mediaSessionParams, sessionHandlers, _this._sessionStreamsManager);
|
|
313
|
+
break;
|
|
314
|
+
case MediaConstants_1.MediaServiceType.OPENTOK:
|
|
315
|
+
_this._session.instance = new SessionOpentok_1.OpentokSession(mediaSessionParams, _this._sessionStreamsManager);
|
|
316
|
+
break;
|
|
317
|
+
case MediaConstants_1.MediaServiceType.MEDIASERVER:
|
|
318
|
+
_this._session.instance = new MediaServer_1.MediaServerSession(mediaSessionParams, _this._sessionStreamsManager);
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
trace.error("mediaServiceType '".concat(_this._serviceOptions.mediaServiceType, "' is not supported."), {
|
|
322
|
+
allowedValues: allowedValues
|
|
323
|
+
});
|
|
324
|
+
doAsyncReject(new Error('mediaServiceType is not supported'));
|
|
325
|
+
}
|
|
326
|
+
if (_this._session && _this._session.instance) {
|
|
327
|
+
_this._session.instance.connect()
|
|
328
|
+
.then(function () {
|
|
329
|
+
trace.info('Session is connected');
|
|
330
|
+
resolve();
|
|
331
|
+
})
|
|
332
|
+
.catch(function (error) {
|
|
333
|
+
trace.error('Failed to connect to session', error);
|
|
334
|
+
doAsyncReject(error);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
trace.warn('Session connected already. Disconnect before connect to new session again');
|
|
341
|
+
}
|
|
342
|
+
return this._session.connectPromise;
|
|
343
|
+
};
|
|
344
|
+
TechseeMediaServiceBase.prototype.connectToSession = function (sessionParams) {
|
|
345
|
+
return this._connectToSession(sessionParams);
|
|
346
|
+
};
|
|
347
|
+
TechseeMediaServiceBase.prototype.disconnectFromSession = function () {
|
|
348
|
+
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer);
|
|
349
|
+
};
|
|
350
|
+
TechseeMediaServiceBase.prototype.updateSessionCredentials = function (credentials) {
|
|
351
|
+
trace.info('updateSessionCredentials');
|
|
352
|
+
if (!this.sessionExistsGuard(false)) {
|
|
353
|
+
return Promise.reject('There no session to update credentials');
|
|
354
|
+
}
|
|
355
|
+
this._session.params.credentials = (0, cloneDeep_1.default)(credentials);
|
|
356
|
+
return Promise.resolve();
|
|
357
|
+
};
|
|
358
|
+
TechseeMediaServiceBase.prototype.enableVoipDuringSession = function () {
|
|
359
|
+
if (!this._isVoipEnabled && this.isLocalStreamInitialized) {
|
|
360
|
+
this._initLocalStreamsPromise = null;
|
|
361
|
+
}
|
|
362
|
+
this._isVoipEnabled = true;
|
|
363
|
+
};
|
|
364
|
+
TechseeMediaServiceBase.prototype.disconnectFromSessionInternal = function (reason) {
|
|
365
|
+
if (!this._session) {
|
|
366
|
+
return Promise.resolve();
|
|
367
|
+
}
|
|
368
|
+
trace.info('Disconnecting from session', reason);
|
|
369
|
+
var lastSession = this._session;
|
|
370
|
+
this._session = null;
|
|
371
|
+
return Promise.all([lastSession.instance.disconnect(), this.clearPublishers()]).then(function () { return undefined; });
|
|
372
|
+
};
|
|
373
|
+
TechseeMediaServiceBase.prototype.getStatsForRemoteTrack = function (streamType) {
|
|
374
|
+
if (!this.sessionExistsGuard(false)) {
|
|
375
|
+
return Promise.reject(new Error('Media session not started'));
|
|
376
|
+
}
|
|
377
|
+
var streamForStats = this.getRegisteredStreamByType(streamType);
|
|
378
|
+
if (!streamForStats) {
|
|
379
|
+
return Promise.reject(new Error('Stream for requested type was not found'));
|
|
380
|
+
}
|
|
381
|
+
return this._session.instance.getRemoteTrackStats(streamForStats.mediaTrack).then(function (trackStats) {
|
|
382
|
+
traceStatsInfo("MediaTrackStats for ".concat(streamType, ": ").concat(JSON.stringify(trackStats)));
|
|
314
383
|
return {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
streamResult: streamResult
|
|
384
|
+
trackId: streamForStats.mediaTrack.id,
|
|
385
|
+
trackStats: trackStats
|
|
318
386
|
};
|
|
319
|
-
});
|
|
320
387
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
388
|
+
};
|
|
389
|
+
TechseeMediaServiceBase.prototype.onSessionDisconnectHandler = function (reason) {
|
|
390
|
+
var _this = this;
|
|
391
|
+
trace.info('onSessionDisconnectHandler', reason);
|
|
392
|
+
if (reason !== MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer) {
|
|
393
|
+
var lastParams_1 = this._session && this._session.params ? this._session.params : null;
|
|
394
|
+
this.disconnectFromSessionInternal(reason).then(function () {
|
|
395
|
+
var reconnectReasons = [
|
|
396
|
+
MediaConstants_1.MediaSessionDisconnectReason.InitiatorPeerReconnected,
|
|
397
|
+
MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect,
|
|
398
|
+
MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted,
|
|
399
|
+
MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout
|
|
400
|
+
];
|
|
401
|
+
if (lastParams_1 && (0, includes_1.default)(reconnectReasons, reason) && _this._autoReconnectEnabled) {
|
|
402
|
+
_this.reconnectToSession(lastParams_1);
|
|
403
|
+
}
|
|
404
|
+
else if (!_this._autoReconnectEnabled) {
|
|
405
|
+
trace.info('No reconnection- auto reconnect disabled');
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
trace.info('No params for reconnection to media session');
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
trace.info('Ignore Session disconnect event');
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
TechseeMediaServiceBase.prototype.setAutoReconnect = function (state) {
|
|
417
|
+
this._autoReconnectEnabled = state;
|
|
418
|
+
trace.info('_autoReconnectEnabled:', state);
|
|
419
|
+
if (this._autoReconnectEnabled && !this.isSessionActive) {
|
|
420
|
+
var lastParams = this._session && this._session.params ? this._session.params : null;
|
|
421
|
+
if (lastParams) {
|
|
422
|
+
trace.info('setAutoReconnect - reconnect to session');
|
|
423
|
+
this.reconnectToSession(lastParams);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
TechseeMediaServiceBase.prototype.reconnectToSession = function (lastParams) {
|
|
428
|
+
trace.info('Reconnecting to media session, sessionParams:', lastParams);
|
|
429
|
+
this._connectToSession(lastParams)
|
|
430
|
+
.then(function () {
|
|
431
|
+
trace.info('Media session reconnected');
|
|
432
|
+
})
|
|
433
|
+
.catch(function (error) {
|
|
434
|
+
trace.error('Error while reconnecting to media session', error);
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
TechseeMediaServiceBase.prototype.getSnapshotFromKnownStream = function (sourceStream, snapshotOptions) {
|
|
438
|
+
var _this = this;
|
|
439
|
+
return new Promise(function (resolve, reject) {
|
|
440
|
+
if (sourceStream !== MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM &&
|
|
441
|
+
sourceStream !== MediaConstants_1.KnownMediaStream.USER_SCREEN_SHARE_STREAM) {
|
|
442
|
+
trace.error('The requested stream is not video stream, and cannot be used for snapshot');
|
|
443
|
+
reject(new Error('INCOMPATIBLE_STREAM_FOR_SNAPSHOT'));
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
var snapshotStream = _this.getRegisteredStreamByType(sourceStream);
|
|
447
|
+
if (!snapshotStream) {
|
|
448
|
+
trace.error('Cannot make snapshot: The requested stream not exists yet.');
|
|
449
|
+
reject(new Error('NO_REQUESTED_STREAM'));
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
(0, MediaDomUtils_1.getSnapshotFromMediaStream)(snapshotStream.mediaStream, sourceStream, snapshotOptions)
|
|
453
|
+
.then(function (imageData) {
|
|
454
|
+
var urlComponents = imageData.split(';base64,');
|
|
455
|
+
var mimeType = urlComponents[0].split(':')[1];
|
|
456
|
+
var bytes = atob(urlComponents[1]);
|
|
457
|
+
var buffer = new ArrayBuffer(bytes.length);
|
|
458
|
+
var rawData = new Uint8Array(buffer);
|
|
459
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
460
|
+
rawData[i] = bytes.charCodeAt(i);
|
|
461
|
+
}
|
|
462
|
+
var blob = new Blob([rawData], { type: mimeType });
|
|
463
|
+
var objectUrl = window.URL.createObjectURL(blob);
|
|
464
|
+
trace.info('Snapshot created successfully');
|
|
465
|
+
var result = {
|
|
466
|
+
base64img: imageData,
|
|
467
|
+
objectUrl: objectUrl,
|
|
468
|
+
imageBlob: blob,
|
|
469
|
+
mimeType: mimeType
|
|
470
|
+
};
|
|
471
|
+
resolve(result);
|
|
472
|
+
})
|
|
473
|
+
.catch(function (error) {
|
|
474
|
+
trace.error('Error creating snapshot', error);
|
|
475
|
+
reject(error);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
TechseeMediaServiceBase.prototype.clearService = function () {
|
|
480
|
+
var _this = this;
|
|
481
|
+
trace.info('MediaService clearing all resources');
|
|
482
|
+
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer)
|
|
483
|
+
.then(this.clearSubscribers)
|
|
484
|
+
.then(this.clearRegisteredStreams)
|
|
485
|
+
.then(this._localStreamsManager.clearAllStreams)
|
|
486
|
+
.then(function () {
|
|
487
|
+
_this._initLocalStreamsPromise = null;
|
|
488
|
+
_this._isVoipEnabled = false;
|
|
489
|
+
})
|
|
490
|
+
.then(function () { return undefined; });
|
|
491
|
+
};
|
|
492
|
+
TechseeMediaServiceBase.prototype.dispose = function () {
|
|
493
|
+
var _this = this;
|
|
494
|
+
return this.clearService()
|
|
495
|
+
.catch(function () { return undefined; })
|
|
496
|
+
.then(function () {
|
|
497
|
+
_this._emitter.removeAllListeners();
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
Object.defineProperty(TechseeMediaServiceBase.prototype, "subscribers", {
|
|
501
|
+
get: function () {
|
|
502
|
+
return this._subscribers;
|
|
503
|
+
},
|
|
504
|
+
enumerable: false,
|
|
505
|
+
configurable: true
|
|
331
506
|
});
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (!this._session) {
|
|
386
|
-
this._session = {
|
|
387
|
-
params: cloneDeep_1["default"](sessionParams)
|
|
388
|
-
};
|
|
389
|
-
this._session.connectPromise = new Promise(function (resolve, reject) {
|
|
390
|
-
var doAsyncReject = function doAsyncReject(error) {
|
|
391
|
-
// eslint-disable-next-line prettier/prettier
|
|
392
|
-
|
|
393
|
-
/*
|
|
394
|
-
Reject with timeout, to change JS 'execution flow'.
|
|
395
|
-
If timeout removed, session is assigned to null, before promise returns, and "catch" will not
|
|
396
|
-
work on promise that is returned.
|
|
397
|
-
*/
|
|
398
|
-
setTimeout(function () {
|
|
399
|
-
_this._session = null;
|
|
400
|
-
reject(error);
|
|
401
|
-
});
|
|
507
|
+
TechseeMediaServiceBase.prototype.registerLocalMediaStream = function (tsMediaStream) {
|
|
508
|
+
trace.info('Registering local stream', tsMediaStream.streamType);
|
|
509
|
+
if (this._registeredStreams.has(tsMediaStream.streamType)) {
|
|
510
|
+
return Promise.reject(new Error("Stream ".concat(tsMediaStream.streamType, " already registered")));
|
|
511
|
+
}
|
|
512
|
+
return this.registerStream(tsMediaStream);
|
|
513
|
+
};
|
|
514
|
+
TechseeMediaServiceBase.prototype.getRegisteredStreamByType = function (streamType) {
|
|
515
|
+
return this._registeredStreams.get(streamType) || null;
|
|
516
|
+
};
|
|
517
|
+
TechseeMediaServiceBase.prototype.changeEnableForKnownStream = function (streamType, isPaused) {
|
|
518
|
+
var streamToChangeState = this.getRegisteredStreamByType(streamType);
|
|
519
|
+
if (!streamToChangeState) {
|
|
520
|
+
trace.warn('There no stream found to change enable state', streamType);
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
streamToChangeState.mediaTrack.enabled = !isPaused;
|
|
524
|
+
if (streamToChangeState.isRemote && streamToChangeState.streamKind === MediaConstants_1.KnownMediaStreamKind.Audio) {
|
|
525
|
+
this.subscribers.forEach(function (subscriber) {
|
|
526
|
+
if (subscriber.streamType === streamType) {
|
|
527
|
+
subscriber.muteSound(isPaused);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
trace.info('Local stream enable state is changed', { streamType: streamType, isPaused: isPaused });
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
TechseeMediaServiceBase.prototype.registerEventCallback = function (event, callback) {
|
|
535
|
+
this._emitter.on(event, callback);
|
|
536
|
+
};
|
|
537
|
+
TechseeMediaServiceBase.prototype.unregisterEventCallback = function (event, callback) {
|
|
538
|
+
this._emitter.off(event, callback);
|
|
539
|
+
};
|
|
540
|
+
TechseeMediaServiceBase.prototype.emitEvent = function (event, eventArgs) {
|
|
541
|
+
var _this = this;
|
|
542
|
+
setTimeout(function () {
|
|
543
|
+
_this._emitter.emit(event, eventArgs);
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
TechseeMediaServiceBase.prototype.registerRemoteMediaTrack = function (remoteMediaTrack) {
|
|
547
|
+
trace.info("Registering remote ".concat(remoteMediaTrack.trackType, " MediaStreamTrack"), remoteMediaTrack.mediaTrack);
|
|
548
|
+
var currentStream = this._registeredStreams.get(remoteMediaTrack.trackType);
|
|
549
|
+
if (currentStream && !currentStream.isRemote) {
|
|
550
|
+
return Promise.reject(new Error('Cannot register remote stream with the same type as local stream'));
|
|
551
|
+
}
|
|
552
|
+
var newDedicatedStream = new TechseeMediaStream_1.TechseeMediaStream(remoteMediaTrack.mediaTrack, remoteMediaTrack.trackType, true);
|
|
553
|
+
return this.registerStream(newDedicatedStream);
|
|
554
|
+
};
|
|
555
|
+
TechseeMediaServiceBase.prototype.registerTrack = function (mediaStream) {
|
|
556
|
+
var _this = this;
|
|
557
|
+
mediaStream.mediaTrack.onended = function () {
|
|
558
|
+
return _this.unregisterTechseeMediaStream(mediaStream, MediaConstants_1.MediaStreamUnregisterReason.NativeEvent);
|
|
402
559
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
560
|
+
this._registeredStreams.set(mediaStream.streamType, mediaStream);
|
|
561
|
+
trace.info("TechseeMediaStream registered - ".concat(mediaStream.streamType), TechseeMediaStream_1.TechseeMediaStream);
|
|
562
|
+
return this.updateSubscribersWithNewStream(mediaStream).then(function () {
|
|
563
|
+
var eventArgs = { streamType: mediaStream.streamType };
|
|
564
|
+
_this.emitEvent(privateEvents.STREAM_CREATED, eventArgs);
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
TechseeMediaServiceBase.prototype.registerStream = function (mediaStream) {
|
|
568
|
+
var _this = this;
|
|
569
|
+
var currentStream = this._registeredStreams.get(mediaStream.streamType);
|
|
570
|
+
if (currentStream) {
|
|
571
|
+
return this.unregisterTechseeMediaStream(currentStream, MediaConstants_1.MediaStreamUnregisterReason.ReplacingStream).then(function () { return _this.registerTrack(mediaStream); });
|
|
572
|
+
}
|
|
573
|
+
return this.registerTrack(mediaStream);
|
|
574
|
+
};
|
|
575
|
+
TechseeMediaServiceBase.prototype.unregisterTechseeMediaStream = function (streamToUnregister, reason) {
|
|
576
|
+
var _this = this;
|
|
577
|
+
var traceError = function (error) {
|
|
578
|
+
trace.warn('Unregister TechseeMediaStream error:', error);
|
|
406
579
|
};
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
580
|
+
var promises = [];
|
|
581
|
+
trace.info('Unregister TechseeMediaStream: ', streamToUnregister.streamType);
|
|
582
|
+
this._subscribers.forEach(function (subscriber) {
|
|
583
|
+
if (subscriber.streamType === streamToUnregister.streamType) {
|
|
584
|
+
promises.push(subscriber.stopRendering().catch(traceError));
|
|
585
|
+
}
|
|
410
586
|
});
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
break;
|
|
419
|
-
|
|
420
|
-
case MediaConstants_1.MediaServiceType.OPENTOK:
|
|
421
|
-
_this._session.instance = new SessionOpentok_1.OpentokSession(mediaSessionParams, _this._sessionStreamsManager);
|
|
422
|
-
break;
|
|
423
|
-
|
|
424
|
-
case MediaConstants_1.MediaServiceType.MEDIASERVER:
|
|
425
|
-
_this._session.instance = new MediaServer_1.MediaServerSession(mediaSessionParams, _this._sessionStreamsManager);
|
|
426
|
-
break;
|
|
427
|
-
|
|
428
|
-
default:
|
|
429
|
-
trace.error("mediaServiceType '" + _this._serviceOptions.mediaServiceType + "' is not supported.", {
|
|
430
|
-
allowedValues: allowedValues
|
|
587
|
+
if (!streamToUnregister.isRemote) {
|
|
588
|
+
this._publishers.forEach(function (publisher) {
|
|
589
|
+
if (publisher.streamTypes.find(function (streamType) { return streamType === streamToUnregister.streamType; })) {
|
|
590
|
+
if (_this._session && _this._session.instance) {
|
|
591
|
+
promises.push(_this._session.instance.onMediaStreamDestroyed(publisher.destinationRole).catch(traceError));
|
|
592
|
+
}
|
|
593
|
+
}
|
|
431
594
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
resolve();
|
|
439
|
-
})["catch"](function (error) {
|
|
440
|
-
trace.error('Failed to connect to session', error);
|
|
441
|
-
doAsyncReject(error);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
} else {
|
|
446
|
-
trace.warn('Session connected already. Disconnect before connect to new session again');
|
|
447
|
-
} //TODO - Alex: Change a structure of this function to be more safe
|
|
448
|
-
//(when we return, there should not be case when session or promise is null)
|
|
449
|
-
//To fix, need to return promise immediately, then execute process in setTimeout(fn, 0);
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return this._session.connectPromise;
|
|
453
|
-
}; //#endregion Media Streams Management
|
|
454
|
-
//#region Session Management
|
|
455
|
-
|
|
456
|
-
/*
|
|
457
|
-
Creates instance of WebRTC session which connects to (signaling server), and begins to listen to WebRTC events.
|
|
458
|
-
*/
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
TechseeMediaServiceBase.prototype.connectToSession = function (sessionParams) {
|
|
462
|
-
return this._connectToSession(sessionParams);
|
|
463
|
-
};
|
|
464
|
-
/*
|
|
465
|
-
Disconnects from WebRTC session.
|
|
466
|
-
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
TechseeMediaServiceBase.prototype.disconnectFromSession = function () {
|
|
470
|
-
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer);
|
|
471
|
-
};
|
|
472
|
-
/*
|
|
473
|
-
Updates a credentials for turn server
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
TechseeMediaServiceBase.prototype.updateSessionCredentials = function (credentials) {
|
|
478
|
-
trace.info('updateSessionCredentials');
|
|
479
|
-
|
|
480
|
-
if (!this.sessionExistsGuard(false)) {
|
|
481
|
-
return Promise.reject('There no session to update credentials');
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
this._session.params.credentials = cloneDeep_1["default"](credentials);
|
|
485
|
-
return Promise.resolve();
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
TechseeMediaServiceBase.prototype.enableVoipDuringSession = function () {
|
|
489
|
-
if (!this._isVoipEnabled && this.isLocalStreamInitialized) {
|
|
490
|
-
this._initLocalStreamsPromise = null;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
this._isVoipEnabled = true;
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
TechseeMediaServiceBase.prototype.disconnectFromSessionInternal = function (reason) {
|
|
497
|
-
if (!this._session) {
|
|
498
|
-
return Promise.resolve();
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
trace.info('Disconnecting from session', reason);
|
|
502
|
-
var lastSession = this._session;
|
|
503
|
-
this._session = null;
|
|
504
|
-
return Promise.all([lastSession.instance.disconnect(), this.clearPublishers()]).then(function () {
|
|
505
|
-
return undefined;
|
|
506
|
-
});
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
TechseeMediaServiceBase.prototype.getStatsForRemoteTrack = function (streamType) {
|
|
510
|
-
if (!this.sessionExistsGuard(false)) {
|
|
511
|
-
return Promise.reject(new Error('Media session not started'));
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
var streamForStats = this.getRegisteredStreamByType(streamType);
|
|
515
|
-
|
|
516
|
-
if (!streamForStats) {
|
|
517
|
-
return Promise.reject(new Error('Stream for requested type was not found'));
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
return this._session.instance.getRemoteTrackStats(streamForStats.mediaTrack).then(function (trackStats) {
|
|
521
|
-
traceStatsInfo("MediaTrackStats for " + streamType + ": " + JSON.stringify(trackStats));
|
|
522
|
-
return {
|
|
523
|
-
trackId: streamForStats.mediaTrack.id,
|
|
524
|
-
trackStats: trackStats
|
|
525
|
-
};
|
|
526
|
-
});
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
TechseeMediaServiceBase.prototype.onSessionDisconnectHandler = function (reason) {
|
|
530
|
-
var _this = this;
|
|
531
|
-
|
|
532
|
-
trace.info('onSessionDisconnectHandler', reason);
|
|
533
|
-
|
|
534
|
-
if (reason !== MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer) {
|
|
535
|
-
var lastParams_1 = this._session && this._session.params ? this._session.params : null;
|
|
536
|
-
this.disconnectFromSessionInternal(reason).then(function () {
|
|
537
|
-
var reconnectReasons = [MediaConstants_1.MediaSessionDisconnectReason.InitiatorPeerReconnected, MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect, MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted, MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout];
|
|
538
|
-
|
|
539
|
-
if (lastParams_1 && includes_1["default"](reconnectReasons, reason) && _this._autoReconnectEnabled) {
|
|
540
|
-
_this.reconnectToSession(lastParams_1);
|
|
541
|
-
} else if (!_this._autoReconnectEnabled) {
|
|
542
|
-
trace.info('No reconnection- auto reconnect disabled');
|
|
543
|
-
} else {
|
|
544
|
-
trace.info('No params for reconnection to media session');
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
} else {
|
|
548
|
-
trace.info('Ignore Session disconnect event');
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
TechseeMediaServiceBase.prototype.setAutoReconnect = function (state) {
|
|
553
|
-
this._autoReconnectEnabled = state;
|
|
554
|
-
trace.info('_autoReconnectEnabled:', state);
|
|
555
|
-
|
|
556
|
-
if (this._autoReconnectEnabled && !this.isSessionActive) {
|
|
557
|
-
var lastParams = this._session && this._session.params ? this._session.params : null;
|
|
558
|
-
|
|
559
|
-
if (lastParams) {
|
|
560
|
-
trace.info('setAutoReconnect - reconnect to session');
|
|
561
|
-
this.reconnectToSession(lastParams);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
TechseeMediaServiceBase.prototype.reconnectToSession = function (lastParams) {
|
|
567
|
-
trace.info('Reconnecting to media session, sessionParams:', lastParams);
|
|
568
|
-
|
|
569
|
-
this._connectToSession(lastParams).then(function () {
|
|
570
|
-
trace.info('Media session reconnected');
|
|
571
|
-
})["catch"](function (error) {
|
|
572
|
-
trace.error('Error while reconnecting to media session', error);
|
|
573
|
-
});
|
|
574
|
-
}; //#endregion Session Management
|
|
575
|
-
//#region Utils
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
TechseeMediaServiceBase.prototype.getSnapshotFromKnownStream = function (sourceStream, snapshotOptions) {
|
|
579
|
-
var _this = this;
|
|
580
|
-
|
|
581
|
-
return new Promise(function (resolve, reject) {
|
|
582
|
-
if (sourceStream !== MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM && sourceStream !== MediaConstants_1.KnownMediaStream.USER_SCREEN_SHARE_STREAM) {
|
|
583
|
-
trace.error('The requested stream is not video stream, and cannot be used for snapshot');
|
|
584
|
-
reject(new Error('INCOMPATIBLE_STREAM_FOR_SNAPSHOT'));
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
var snapshotStream = _this.getRegisteredStreamByType(sourceStream);
|
|
589
|
-
|
|
590
|
-
if (!snapshotStream) {
|
|
591
|
-
trace.error('Cannot make snapshot: The requested stream not exists yet.');
|
|
592
|
-
reject(new Error('NO_REQUESTED_STREAM'));
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
MediaDomUtils_1.getSnapshotFromMediaStream(snapshotStream.mediaStream, sourceStream, snapshotOptions).then(function (imageData) {
|
|
597
|
-
var urlComponents = imageData.split(';base64,');
|
|
598
|
-
var mimeType = urlComponents[0].split(':')[1];
|
|
599
|
-
var bytes = atob(urlComponents[1]);
|
|
600
|
-
var buffer = new ArrayBuffer(bytes.length);
|
|
601
|
-
var rawData = new Uint8Array(buffer);
|
|
602
|
-
|
|
603
|
-
for (var i = 0; i < bytes.length; i++) {
|
|
604
|
-
rawData[i] = bytes.charCodeAt(i);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
var blob = new Blob([rawData], {
|
|
608
|
-
type: mimeType
|
|
595
|
+
}
|
|
596
|
+
return Promise.all(promises).then(function () {
|
|
597
|
+
_this._registeredStreams.delete(streamToUnregister.streamType);
|
|
598
|
+
trace.info('Stream deleted', streamToUnregister.streamType);
|
|
599
|
+
var eventArgs = { streamType: streamToUnregister.streamType, reason: reason };
|
|
600
|
+
_this.emitEvent(privateEvents.STREAM_DESTROYED, eventArgs);
|
|
609
601
|
});
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
var
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
resolve(result);
|
|
619
|
-
})["catch"](function (error) {
|
|
620
|
-
trace.error('Error creating snapshot', error);
|
|
621
|
-
reject(error);
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
}; //Will clean streams, publishers and subscribers, but will not remove event listeners
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
TechseeMediaServiceBase.prototype.clearService = function () {
|
|
628
|
-
var _this = this;
|
|
629
|
-
|
|
630
|
-
trace.info('MediaService clearing all resources');
|
|
631
|
-
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer).then(this.clearSubscribers).then(this.clearRegisteredStreams).then(this._localStreamsManager.clearAllStreams).then(function () {
|
|
632
|
-
_this._initLocalStreamsPromise = null;
|
|
633
|
-
_this._isVoipEnabled = false;
|
|
634
|
-
}).then(function () {
|
|
635
|
-
return undefined;
|
|
636
|
-
});
|
|
637
|
-
}; //Will clear the service and remove all event listeners
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
TechseeMediaServiceBase.prototype.dispose = function () {
|
|
641
|
-
var _this = this;
|
|
642
|
-
|
|
643
|
-
return this.clearService()["catch"](function () {
|
|
644
|
-
return undefined;
|
|
645
|
-
}).then(function () {
|
|
646
|
-
_this._emitter.removeAllListeners();
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
Object.defineProperty(TechseeMediaServiceBase.prototype, "subscribers", {
|
|
651
|
-
//#endregion
|
|
652
|
-
//#region Protected Methods
|
|
653
|
-
get: function get() {
|
|
654
|
-
return this._subscribers;
|
|
655
|
-
},
|
|
656
|
-
enumerable: false,
|
|
657
|
-
configurable: true
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
TechseeMediaServiceBase.prototype.registerLocalMediaStream = function (tsMediaStream) {
|
|
661
|
-
trace.info('Registering local stream', tsMediaStream.streamType);
|
|
662
|
-
|
|
663
|
-
if (this._registeredStreams.has(tsMediaStream.streamType)) {
|
|
664
|
-
return Promise.reject(new Error("Stream " + tsMediaStream.streamType + " already registered"));
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
return this.registerStream(tsMediaStream);
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
TechseeMediaServiceBase.prototype.getRegisteredStreamByType = function (streamType) {
|
|
671
|
-
return this._registeredStreams.get(streamType) || null;
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
TechseeMediaServiceBase.prototype.changeEnableForKnownStream = function (streamType, isPaused) {
|
|
675
|
-
var streamToChangeState = this.getRegisteredStreamByType(streamType);
|
|
676
|
-
|
|
677
|
-
if (!streamToChangeState) {
|
|
678
|
-
trace.warn('There no stream found to change enable state', streamType);
|
|
679
|
-
} else {
|
|
680
|
-
streamToChangeState.mediaTrack.enabled = !isPaused;
|
|
681
|
-
|
|
682
|
-
if (streamToChangeState.isRemote && streamToChangeState.streamKind === MediaConstants_1.KnownMediaStreamKind.Audio) {
|
|
683
|
-
this.subscribers.forEach(function (subscriber) {
|
|
684
|
-
if (subscriber.streamType === streamType) {
|
|
685
|
-
subscriber.muteSound(isPaused);
|
|
686
|
-
}
|
|
602
|
+
};
|
|
603
|
+
TechseeMediaServiceBase.prototype.unregisterRemoteMediaTrack = function (mediaTrack) {
|
|
604
|
+
var _this = this;
|
|
605
|
+
var promises = [];
|
|
606
|
+
this._registeredStreams.forEach(function (registeredStream) {
|
|
607
|
+
if (registeredStream.mediaTrack.id === mediaTrack.id) {
|
|
608
|
+
promises.push(_this.unregisterTechseeMediaStream(registeredStream, MediaConstants_1.MediaStreamUnregisterReason.ClosedRemotely));
|
|
609
|
+
}
|
|
687
610
|
});
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
TechseeMediaServiceBase.prototype.unregisterRemoteMediaTrack = function (mediaTrack) {
|
|
803
|
-
var _this = this;
|
|
804
|
-
|
|
805
|
-
var promises = [];
|
|
806
|
-
|
|
807
|
-
this._registeredStreams.forEach(function (registeredStream) {
|
|
808
|
-
if (registeredStream.mediaTrack.id === mediaTrack.id) {
|
|
809
|
-
promises.push(_this.unregisterTechseeMediaStream(registeredStream, MediaConstants_1.MediaStreamUnregisterReason.ClosedRemotely));
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
|
|
813
|
-
return Promise.all(promises).then(function () {
|
|
814
|
-
return undefined;
|
|
815
|
-
});
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
TechseeMediaServiceBase.prototype.removePublisher = function (publisher) {
|
|
819
|
-
this._publishers["delete"](publisher.destinationRole);
|
|
820
|
-
|
|
821
|
-
if (this._session && this._session.instance) {
|
|
822
|
-
trace.info('Removing publisher', publisher.destinationRole);
|
|
823
|
-
return this._session.instance.onMediaStreamDestroyed(publisher.destinationRole)["catch"](function (error) {
|
|
824
|
-
trace.warn('Error while removing publisher', error);
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
return Promise.resolve();
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
TechseeMediaServiceBase.prototype.getStreamForDestinationRole = function (destinationRole) {
|
|
832
|
-
var _this = this;
|
|
833
|
-
|
|
834
|
-
this.serviceInitGuard();
|
|
835
|
-
|
|
836
|
-
if (this._publishers.has(destinationRole)) {
|
|
837
|
-
trace.info("Publisher for " + destinationRole + " already exists");
|
|
838
|
-
return Promise.resolve(this._publishers.get(destinationRole).mediaStream);
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
if (!this._publisherPromises.get(destinationRole)) {
|
|
842
|
-
trace.info("Creating publisher for " + destinationRole);
|
|
843
|
-
var publisherPromise = this.initLocalMediaStreams().then(function () {
|
|
844
|
-
return _this.createMediaPublisher(destinationRole);
|
|
845
|
-
}).then(function (mediaPublisher) {
|
|
846
|
-
if (mediaPublisher) {
|
|
847
|
-
_this._publishers.set(destinationRole, mediaPublisher);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
_this._publisherPromises["delete"](destinationRole);
|
|
851
|
-
|
|
852
|
-
return mediaPublisher ? mediaPublisher.mediaStream : null;
|
|
853
|
-
})["catch"](function (ex) {
|
|
854
|
-
if (ex && ex.message === 'audioStreamFailed') {
|
|
855
|
-
_this._isVoipEnabled = false;
|
|
856
|
-
return null;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
_this._publisherPromises["delete"](destinationRole);
|
|
860
|
-
|
|
861
|
-
throw ex;
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
this._publisherPromises.set(destinationRole, publisherPromise);
|
|
865
|
-
} else {
|
|
866
|
-
trace.info("Create publisher promise for " + destinationRole + " already exists");
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
return this._publisherPromises.get(destinationRole);
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
TechseeMediaServiceBase.prototype.updateSubscribersWithNewStream = function (registeredStream) {
|
|
873
|
-
trace.info("Updating subscribers of " + registeredStream.streamType + " with new stream");
|
|
874
|
-
|
|
875
|
-
if (this._subscribers.size === 0) {
|
|
876
|
-
trace.warn("No subscribers exists for the " + registeredStream.streamType + ".");
|
|
877
|
-
} else {
|
|
878
|
-
trace.info("Total " + this._subscribers.size + " subscribers exists, will check if rerender needed.");
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
this._subscribers.forEach(function (subscriber) {
|
|
882
|
-
if (subscriber.streamType === registeredStream.streamType) {
|
|
883
|
-
trace.info(registeredStream.streamType + " rendering on subscriber");
|
|
884
|
-
subscriber.renderStream(registeredStream);
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
return Promise.resolve();
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
TechseeMediaServiceBase.prototype.bindClassMethods = function () {
|
|
892
|
-
this.updateSessionCredentials = this.updateSessionCredentials.bind(this);
|
|
893
|
-
this.getStreamForDestinationRole = this.getStreamForDestinationRole.bind(this);
|
|
894
|
-
this.registerRemoteMediaTrack = this.registerRemoteMediaTrack.bind(this);
|
|
895
|
-
this.unregisterRemoteMediaTrack = this.unregisterRemoteMediaTrack.bind(this);
|
|
896
|
-
this.createMediaPublisher = this.createMediaPublisher.bind(this);
|
|
897
|
-
this.updateSubscribersWithNewStream = this.updateSubscribersWithNewStream.bind(this);
|
|
898
|
-
this.initLocalMediaStreams = this.initLocalMediaStreams.bind(this);
|
|
899
|
-
this.onSessionDisconnectHandler = this.onSessionDisconnectHandler.bind(this);
|
|
900
|
-
this.clearService = this.clearService.bind(this);
|
|
901
|
-
this.clearRegisteredStreams = this.clearRegisteredStreams.bind(this);
|
|
902
|
-
this.clearPublishers = this.clearPublishers.bind(this);
|
|
903
|
-
this.clearSubscribers = this.clearSubscribers.bind(this);
|
|
904
|
-
this._connectToSession = this._connectToSession.bind(this);
|
|
905
|
-
this.disconnectFromMediaSession = this.disconnectFromMediaSession.bind(this);
|
|
906
|
-
}; //region Cleanup
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
TechseeMediaServiceBase.prototype.clearRegisteredStreams = function () {
|
|
910
|
-
var _this = this;
|
|
911
|
-
|
|
912
|
-
trace.info('Clearing registered streams');
|
|
913
|
-
var promises = [];
|
|
914
|
-
|
|
915
|
-
this._registeredStreams.forEach(function (streamToUnregister) {
|
|
916
|
-
promises.push(_this.unregisterTechseeMediaStream(streamToUnregister, MediaConstants_1.MediaStreamUnregisterReason.ServiceCleanUp));
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
return Promise.all(promises).then(function () {
|
|
920
|
-
return undefined;
|
|
921
|
-
});
|
|
922
|
-
};
|
|
923
|
-
|
|
924
|
-
TechseeMediaServiceBase.prototype.clearSubscribers = function () {
|
|
925
|
-
var _this = this;
|
|
926
|
-
|
|
927
|
-
trace.info('Clearing subscribers');
|
|
928
|
-
var promises = [];
|
|
929
|
-
|
|
930
|
-
this._subscribers.forEach(function (subscriber) {
|
|
931
|
-
promises.push(_this.destroySubscriber(subscriber.container));
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
return Promise.all(promises).then(function () {
|
|
935
|
-
return undefined;
|
|
936
|
-
});
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
TechseeMediaServiceBase.prototype.clearPublishers = function () {
|
|
940
|
-
var _this = this;
|
|
941
|
-
|
|
942
|
-
trace.info('Clearing publishers');
|
|
943
|
-
var promises = [];
|
|
944
|
-
|
|
945
|
-
this._publishers.forEach(function (publisher) {
|
|
946
|
-
promises.push(_this.removePublisher(publisher));
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
return Promise.all(promises).then(function () {
|
|
950
|
-
return undefined;
|
|
951
|
-
});
|
|
952
|
-
}; //#endregion Cleanup
|
|
953
|
-
//#region Simple Validation Methods
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
TechseeMediaServiceBase.prototype.serviceInitGuard = function (shouldThrow) {
|
|
957
|
-
if (shouldThrow === void 0) {
|
|
958
|
-
shouldThrow = true;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
return guards_1.throwableGuard(!!this._serviceOptions, 'Media service is not initialized', shouldThrow);
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
TechseeMediaServiceBase.prototype.sessionExistsGuard = function (shouldThrow) {
|
|
965
|
-
if (shouldThrow === void 0) {
|
|
966
|
-
shouldThrow = true;
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
return guards_1.throwableGuard(!!this._session, 'There no active session', shouldThrow);
|
|
970
|
-
};
|
|
971
|
-
|
|
972
|
-
return TechseeMediaServiceBase;
|
|
973
|
-
}();
|
|
974
|
-
|
|
611
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
612
|
+
};
|
|
613
|
+
TechseeMediaServiceBase.prototype.removePublisher = function (publisher) {
|
|
614
|
+
this._publishers.delete(publisher.destinationRole);
|
|
615
|
+
if (this._session && this._session.instance) {
|
|
616
|
+
trace.info('Removing publisher', publisher.destinationRole);
|
|
617
|
+
return this._session.instance.onMediaStreamDestroyed(publisher.destinationRole).catch(function (error) {
|
|
618
|
+
trace.warn('Error while removing publisher', error);
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return Promise.resolve();
|
|
622
|
+
};
|
|
623
|
+
TechseeMediaServiceBase.prototype.getStreamForDestinationRole = function (destinationRole) {
|
|
624
|
+
var _this = this;
|
|
625
|
+
this.serviceInitGuard();
|
|
626
|
+
if (this._publishers.has(destinationRole)) {
|
|
627
|
+
trace.info("Publisher for ".concat(destinationRole, " already exists"));
|
|
628
|
+
return Promise.resolve(this._publishers.get(destinationRole).mediaStream);
|
|
629
|
+
}
|
|
630
|
+
if (!this._publisherPromises.get(destinationRole)) {
|
|
631
|
+
trace.info("Creating publisher for ".concat(destinationRole));
|
|
632
|
+
var publisherPromise = this.initLocalMediaStreams()
|
|
633
|
+
.then(function () { return _this.createMediaPublisher(destinationRole); })
|
|
634
|
+
.then(function (mediaPublisher) {
|
|
635
|
+
if (mediaPublisher) {
|
|
636
|
+
_this._publishers.set(destinationRole, mediaPublisher);
|
|
637
|
+
}
|
|
638
|
+
_this._publisherPromises.delete(destinationRole);
|
|
639
|
+
return mediaPublisher ? mediaPublisher.mediaStream : null;
|
|
640
|
+
})
|
|
641
|
+
.catch(function (ex) {
|
|
642
|
+
if (ex && ex.message === 'audioStreamFailed') {
|
|
643
|
+
_this._isVoipEnabled = false;
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
_this._publisherPromises.delete(destinationRole);
|
|
647
|
+
throw ex;
|
|
648
|
+
});
|
|
649
|
+
this._publisherPromises.set(destinationRole, publisherPromise);
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
trace.info("Create publisher promise for ".concat(destinationRole, " already exists"));
|
|
653
|
+
}
|
|
654
|
+
return this._publisherPromises.get(destinationRole);
|
|
655
|
+
};
|
|
656
|
+
TechseeMediaServiceBase.prototype.updateSubscribersWithNewStream = function (registeredStream) {
|
|
657
|
+
trace.info("Updating subscribers of ".concat(registeredStream.streamType, " with new stream"));
|
|
658
|
+
if (this._subscribers.size === 0) {
|
|
659
|
+
trace.warn("No subscribers exists for the ".concat(registeredStream.streamType, "."));
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
trace.info("Total ".concat(this._subscribers.size, " subscribers exists, will check if rerender needed."));
|
|
663
|
+
}
|
|
664
|
+
this._subscribers.forEach(function (subscriber) {
|
|
665
|
+
if (subscriber.streamType === registeredStream.streamType) {
|
|
666
|
+
trace.info("".concat(registeredStream.streamType, " rendering on subscriber"));
|
|
667
|
+
subscriber.renderStream(registeredStream);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
return Promise.resolve();
|
|
671
|
+
};
|
|
672
|
+
TechseeMediaServiceBase.prototype.bindClassMethods = function () {
|
|
673
|
+
this.updateSessionCredentials = this.updateSessionCredentials.bind(this);
|
|
674
|
+
this.getStreamForDestinationRole = this.getStreamForDestinationRole.bind(this);
|
|
675
|
+
this.registerRemoteMediaTrack = this.registerRemoteMediaTrack.bind(this);
|
|
676
|
+
this.unregisterRemoteMediaTrack = this.unregisterRemoteMediaTrack.bind(this);
|
|
677
|
+
this.createMediaPublisher = this.createMediaPublisher.bind(this);
|
|
678
|
+
this.updateSubscribersWithNewStream = this.updateSubscribersWithNewStream.bind(this);
|
|
679
|
+
this.initLocalMediaStreams = this.initLocalMediaStreams.bind(this);
|
|
680
|
+
this.onSessionDisconnectHandler = this.onSessionDisconnectHandler.bind(this);
|
|
681
|
+
this.clearService = this.clearService.bind(this);
|
|
682
|
+
this.clearRegisteredStreams = this.clearRegisteredStreams.bind(this);
|
|
683
|
+
this.clearPublishers = this.clearPublishers.bind(this);
|
|
684
|
+
this.clearSubscribers = this.clearSubscribers.bind(this);
|
|
685
|
+
this._connectToSession = this._connectToSession.bind(this);
|
|
686
|
+
this.disconnectFromMediaSession = this.disconnectFromMediaSession.bind(this);
|
|
687
|
+
};
|
|
688
|
+
TechseeMediaServiceBase.prototype.clearRegisteredStreams = function () {
|
|
689
|
+
var _this = this;
|
|
690
|
+
trace.info('Clearing registered streams');
|
|
691
|
+
var promises = [];
|
|
692
|
+
this._registeredStreams.forEach(function (streamToUnregister) {
|
|
693
|
+
promises.push(_this.unregisterTechseeMediaStream(streamToUnregister, MediaConstants_1.MediaStreamUnregisterReason.ServiceCleanUp));
|
|
694
|
+
});
|
|
695
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
696
|
+
};
|
|
697
|
+
TechseeMediaServiceBase.prototype.clearSubscribers = function () {
|
|
698
|
+
var _this = this;
|
|
699
|
+
trace.info('Clearing subscribers');
|
|
700
|
+
var promises = [];
|
|
701
|
+
this._subscribers.forEach(function (subscriber) {
|
|
702
|
+
promises.push(_this.destroySubscriber(subscriber.container));
|
|
703
|
+
});
|
|
704
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
705
|
+
};
|
|
706
|
+
TechseeMediaServiceBase.prototype.clearPublishers = function () {
|
|
707
|
+
var _this = this;
|
|
708
|
+
trace.info('Clearing publishers');
|
|
709
|
+
var promises = [];
|
|
710
|
+
this._publishers.forEach(function (publisher) {
|
|
711
|
+
promises.push(_this.removePublisher(publisher));
|
|
712
|
+
});
|
|
713
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
714
|
+
};
|
|
715
|
+
TechseeMediaServiceBase.prototype.serviceInitGuard = function (shouldThrow) {
|
|
716
|
+
if (shouldThrow === void 0) { shouldThrow = true; }
|
|
717
|
+
return (0, guards_1.throwableGuard)(!!this._serviceOptions, 'Media service is not initialized', shouldThrow);
|
|
718
|
+
};
|
|
719
|
+
TechseeMediaServiceBase.prototype.sessionExistsGuard = function (shouldThrow) {
|
|
720
|
+
if (shouldThrow === void 0) { shouldThrow = true; }
|
|
721
|
+
return (0, guards_1.throwableGuard)(!!this._session, 'There no active session', shouldThrow);
|
|
722
|
+
};
|
|
723
|
+
return TechseeMediaServiceBase;
|
|
724
|
+
}());
|
|
975
725
|
exports.TechseeMediaServiceBase = TechseeMediaServiceBase;
|
|
976
|
-
//# sourceMappingURL=MediaServiceBase.js.map
|
|
726
|
+
//# sourceMappingURL=MediaServiceBase.js.map
|