@techsee/techsee-media-service 999.19.3-alphasap → 999.19.6-nodejs20
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/README.md +27 -28
- package/lib/LocalStreamManager.d.ts +1 -0
- package/lib/LocalStreamManager.d.ts.map +1 -1
- package/lib/LocalStreamManager.js +82 -84
- package/lib/LocalStreamManager.js.map +1 -1
- package/lib/MediaConstants.d.ts +20 -3
- package/lib/MediaConstants.d.ts.map +1 -1
- package/lib/MediaConstants.js +31 -13
- package/lib/MediaConstants.js.map +1 -1
- package/lib/MediaContracts.d.ts +7 -1
- package/lib/MediaContracts.d.ts.map +1 -1
- package/lib/MediaContracts.js +1 -4
- 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 +7 -10
- 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 +169 -198
- 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 +62 -74
- 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 +19 -23
- 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 +51 -80
- 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 +109 -151
- 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 +1 -16
- 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 +37 -43
- package/lib/MediaSubscriber.js.map +1 -1
- package/lib/MediaUtils/Compatibility.d.ts +3 -0
- package/lib/MediaUtils/Compatibility.d.ts.map +1 -1
- package/lib/MediaUtils/Compatibility.js +76 -34
- package/lib/MediaUtils/Compatibility.js.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.d.ts +4 -2
- package/lib/MediaUtils/MediaDomUtils.d.ts.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.js +64 -62
- 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 +2 -5
- package/lib/MediaUtils/MediaTracer.js.map +1 -1
- package/lib/MediaUtils/index.d.ts +2 -0
- package/lib/MediaUtils/index.d.ts.map +1 -0
- package/lib/MediaUtils/index.js +6 -0
- package/lib/MediaUtils/index.js.map +1 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts +17 -14
- package/lib/MultiParty/DetectWebRtcService.d.ts.map +1 -1
- package/lib/MultiParty/DetectWebRtcService.js +98 -54
- package/lib/MultiParty/DetectWebRtcService.js.map +1 -1
- package/lib/MultiParty/MediaCapabilitiesService.d.ts +18 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.js +158 -0
- package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +6 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js +123 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -0
- package/lib/MultiParty/MediaTracer.d.ts +4 -0
- package/lib/MultiParty/MediaTracer.d.ts.map +1 -0
- package/lib/MultiParty/MediaTracer.js +10 -0
- package/lib/MultiParty/MediaTracer.js.map +1 -0
- package/lib/MultiParty/MultiPartyService.d.ts +49 -0
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyService.js +30 -0
- package/lib/MultiParty/MultiPartyService.js.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts +4 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js +13 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -0
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts +89 -0
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts.map +1 -0
- package/lib/MultiParty/MultipartyServiceEventTypes.js +16 -0
- package/lib/MultiParty/MultipartyServiceEventTypes.js.map +1 -0
- package/lib/MultiParty/index.d.ts +7 -0
- package/lib/MultiParty/index.d.ts.map +1 -0
- package/lib/MultiParty/index.js +25 -0
- package/lib/MultiParty/index.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts +38 -0
- package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokMultiPartyService.js +492 -0
- package/lib/MultiParty/opentok/OpentokMultiPartyService.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts +34 -0
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisher.js +121 -0
- package/lib/MultiParty/opentok/OpentokPublisher.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts +20 -0
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js +49 -0
- package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts +6 -0
- package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokScreenPublisher.js +48 -0
- package/lib/MultiParty/opentok/OpentokScreenPublisher.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts +2 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.js +26 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts +19 -0
- package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokVideoPublisher.js +182 -0
- package/lib/MultiParty/opentok/OpentokVideoPublisher.js.map +1 -0
- package/lib/MultiParty/opentok/trace.d.ts +3 -0
- package/lib/MultiParty/opentok/trace.d.ts.map +1 -0
- package/lib/MultiParty/opentok/trace.js +18 -0
- package/lib/MultiParty/opentok/trace.js.map +1 -0
- package/lib/MultiParty/opentok.d.ts +463 -0
- package/lib/MultiParty/types.d.ts +33 -0
- package/lib/MultiParty/types.d.ts.map +1 -0
- package/lib/MultiParty/types.js +3 -0
- package/lib/MultiParty/types.js.map +1 -0
- package/lib/MultiParty/utils.d.ts +10 -0
- package/lib/MultiParty/utils.d.ts.map +1 -0
- package/lib/MultiParty/utils.js +17 -0
- package/lib/MultiParty/utils.js.map +1 -0
- package/lib/TechseeMediaStream.d.ts +1 -0
- package/lib/TechseeMediaStream.d.ts.map +1 -1
- package/lib/TechseeMediaStream.js +9 -12
- 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 +84 -145
- 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 +1896 -2950
- package/lib/webrtc-ie-shim.js.map +1 -1
- package/package.json +66 -60
- package/lib/MultiParty/Contracts.d.ts +0 -11
- package/lib/MultiParty/Contracts.d.ts.map +0 -1
- package/lib/MultiParty/Contracts.js +0 -6
- package/lib/MultiParty/Contracts.js.map +0 -1
- package/lib/MultiParty/MediaCapabilitiesHelper.d.ts +0 -12
- package/lib/MultiParty/MediaCapabilitiesHelper.d.ts.map +0 -1
- package/lib/MultiParty/MediaCapabilitiesHelper.js +0 -167
- package/lib/MultiParty/MediaCapabilitiesHelper.js.map +0 -1
- package/lib/MultiParty/MultiParty.d.ts +0 -21
- package/lib/MultiParty/MultiParty.d.ts.map +0 -1
- package/lib/MultiParty/MultiParty.js +0 -155
- package/lib/MultiParty/MultiParty.js.map +0 -1
- package/lib/MultiParty/MultipartyFactory.d.ts +0 -2
- package/lib/MultiParty/MultipartyFactory.d.ts.map +0 -1
- package/lib/MultiParty/MultipartyFactory.js +0 -15
- package/lib/MultiParty/MultipartyFactory.js.map +0 -1
- package/lib/MultiParty/OpentokMultiparty.d.ts +0 -24
- package/lib/MultiParty/OpentokMultiparty.d.ts.map +0 -1
- package/lib/MultiParty/OpentokMultiparty.js +0 -408
- package/lib/MultiParty/OpentokMultiparty.js.map +0 -1
- package/lib/oldCode/constants.js +0 -20
- package/lib/oldCode/constants.js.map +0 -1
- package/lib/oldCode/event-emitter.js +0 -39
- package/lib/oldCode/event-emitter.js.map +0 -1
- package/lib/oldCode/index.js +0 -64
- package/lib/oldCode/index.js.map +0 -1
- package/lib/oldCode/opentok/session.js +0 -310
- package/lib/oldCode/opentok/session.js.map +0 -1
- package/lib/oldCode/opentok/stream.js +0 -310
- package/lib/oldCode/opentok/stream.js.map +0 -1
- package/lib/oldCode/publisher.js +0 -143
- package/lib/oldCode/publisher.js.map +0 -1
- package/lib/oldCode/service.js +0 -395
- package/lib/oldCode/service.js.map +0 -1
- package/lib/oldCode/session.js +0 -110
- package/lib/oldCode/session.js.map +0 -1
- package/lib/oldCode/stream.js +0 -195
- package/lib/oldCode/stream.js.map +0 -1
- package/lib/oldCode/subscriber.js +0 -90
- package/lib/oldCode/subscriber.js.map +0 -1
- package/lib/oldCode/tracer.d.ts +0 -36
- package/lib/oldCode/tracer.d.ts.map +0 -1
- package/lib/oldCode/tracer.js +0 -161
- package/lib/oldCode/tracer.js.map +0 -1
- package/lib/oldCode/utils/ImageFixer.d.ts +0 -1
- package/lib/oldCode/utils/ImageFixer.d.ts.map +0 -1
- package/lib/oldCode/utils/ImageFixer.js +0 -59
- package/lib/oldCode/utils/ImageFixer.js.map +0 -1
- package/lib/oldCode/webrtc/constants.js +0 -114
- package/lib/oldCode/webrtc/constants.js.map +0 -1
- package/lib/oldCode/webrtc/helper.js +0 -173
- package/lib/oldCode/webrtc/helper.js.map +0 -1
- package/lib/oldCode/webrtc/session-kms.js +0 -558
- package/lib/oldCode/webrtc/session-kms.js.map +0 -1
- package/lib/oldCode/webrtc/session-loopback.js +0 -336
- package/lib/oldCode/webrtc/session-loopback.js.map +0 -1
- package/lib/oldCode/webrtc/session-turn.js +0 -880
- package/lib/oldCode/webrtc/session-turn.js.map +0 -1
- package/lib/oldCode/webrtc/session-turn.v2.js +0 -583
- package/lib/oldCode/webrtc/session-turn.v2.js.map +0 -1
- package/lib/oldCode/webrtc/session.js +0 -52
- package/lib/oldCode/webrtc/session.js.map +0 -1
- package/lib/oldCode/webrtc/stream.js +0 -674
- package/lib/oldCode/webrtc/stream.js.map +0 -1
- package/lib/oldCode/webrtc/temasys/adapter-loader.js +0 -12
- package/lib/oldCode/webrtc/temasys/adapter-loader.js.map +0 -1
- package/lib/oldCode/webrtc/temasys/adapter.js +0 -5861
- package/lib/oldCode/webrtc/temasys/adapter.js.map +0 -1
- package/lib/oldCode/webrtc/webrtc-ie-shim.js +0 -3007
- package/lib/oldCode/webrtc/webrtc-ie-shim.js.map +0 -1
package/lib/MediaServiceBase.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__assign = Object.assign || function (t) {
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
5
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
5
|
s = arguments[i];
|
|
7
|
-
for (var p in s)
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
10
8
|
}
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
11
|
return __assign.apply(this, arguments);
|
|
14
12
|
};
|
|
15
|
-
var __importDefault =
|
|
16
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
15
|
};
|
|
18
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
17
|
exports.TechseeMediaServiceBase = void 0;
|
|
@@ -35,14 +33,14 @@ var guards_1 = require("@techsee/techsee-common/lib/core/guards");
|
|
|
35
33
|
var MediaServer_1 = require("./MediaSession/MediaServer");
|
|
36
34
|
var MediaTracer_1 = require("./MediaUtils/MediaTracer");
|
|
37
35
|
var MediaSessionBase_1 = require("./MediaSession/MediaSessionBase");
|
|
38
|
-
var trace = MediaTracer_1.getMediaTracer('MediaServiceBase');
|
|
39
|
-
var traceStatsInfo = debounce_1.default(trace.info, 1000 * 5, { leading: true, maxWait: 1000 * 30 });
|
|
36
|
+
var trace = (0, MediaTracer_1.getMediaTracer)('MediaServiceBase');
|
|
37
|
+
var traceStatsInfo = (0, debounce_1.default)(trace.info, 1000 * 5, { leading: true, maxWait: 1000 * 30 });
|
|
40
38
|
var privateEvents;
|
|
41
39
|
(function (privateEvents) {
|
|
42
40
|
privateEvents["STREAM_CREATED"] = "STREAM_CREATED";
|
|
43
41
|
privateEvents["STREAM_DESTROYED"] = "STREAM_DESTROYED";
|
|
44
42
|
})(privateEvents || (privateEvents = {}));
|
|
45
|
-
var TechseeMediaServiceBase =
|
|
43
|
+
var TechseeMediaServiceBase = (function () {
|
|
46
44
|
function TechseeMediaServiceBase(environment, webRtcSupportInfo) {
|
|
47
45
|
this._subscribers = new Map();
|
|
48
46
|
this._publishers = new Map();
|
|
@@ -67,12 +65,12 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
67
65
|
webRtcSupportInfo: webRtcSupportInfo
|
|
68
66
|
};
|
|
69
67
|
this._localStreamsManager = new LocalStreamManager_1.LocalStreamManager(this._environment);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
trace.info("TechseeMediaServiceBase: isIOS_13_orLater: "
|
|
75
|
-
trace.info("TechseeMediaServiceBase: isIOS_14_orLater: "
|
|
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));
|
|
76
74
|
this._sessionStreamsManager = {
|
|
77
75
|
getMediaStreamForRole: this.getStreamForDestinationRole,
|
|
78
76
|
addRemoteMediaTrack: this.registerRemoteMediaTrack,
|
|
@@ -80,39 +78,34 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
80
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "deviceSupportInfo", {
|
|
83
|
-
get: function
|
|
81
|
+
get: function () {
|
|
84
82
|
this.serviceInitGuard(false);
|
|
85
|
-
return cloneDeep_1.default(this._deviceSupportFlags);
|
|
83
|
+
return (0, cloneDeep_1.default)(this._deviceSupportFlags);
|
|
86
84
|
},
|
|
87
85
|
enumerable: false,
|
|
88
86
|
configurable: true
|
|
89
87
|
});
|
|
90
88
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "isVoipEnabled", {
|
|
91
|
-
get: function
|
|
89
|
+
get: function () {
|
|
92
90
|
return this._isVoipEnabled;
|
|
93
91
|
},
|
|
94
92
|
enumerable: false,
|
|
95
93
|
configurable: true
|
|
96
94
|
});
|
|
97
95
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "isSessionActive", {
|
|
98
|
-
get: function
|
|
96
|
+
get: function () {
|
|
99
97
|
return this._session !== null;
|
|
100
98
|
},
|
|
101
99
|
enumerable: false,
|
|
102
100
|
configurable: true
|
|
103
101
|
});
|
|
104
102
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "isLocalStreamInitialized", {
|
|
105
|
-
get: function
|
|
103
|
+
get: function () {
|
|
106
104
|
return this._initLocalStreamsPromise !== null;
|
|
107
105
|
},
|
|
108
106
|
enumerable: false,
|
|
109
107
|
configurable: true
|
|
110
108
|
});
|
|
111
|
-
/*
|
|
112
|
-
Initializes media service. Before using anything from this service it should be initialized first.
|
|
113
|
-
All of serviceOptions should be retrieved from account settings and by evaluating application state.
|
|
114
|
-
For example, when initializing service, accountSettings is already loaded, and we know if FS session is audio enabled.
|
|
115
|
-
*/
|
|
116
109
|
TechseeMediaServiceBase.prototype.initMediaService = function (serviceOptions) {
|
|
117
110
|
var _this = this;
|
|
118
111
|
trace.info('TechseeMediaServiceBase.initMediaService', serviceOptions);
|
|
@@ -121,55 +114,45 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
121
114
|
console.warn(warnMessage);
|
|
122
115
|
return this._initServicePromise ? this._initServicePromise : Promise.resolve();
|
|
123
116
|
}
|
|
124
|
-
this._serviceOptions = cloneDeep_1.default(serviceOptions);
|
|
125
|
-
this._initServicePromise = Promise.all([
|
|
126
|
-
return _this._deviceSupportFlags.videoPlayback = isSupported;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return device.kind.toLowerCase() === '
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
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; });
|
|
145
137
|
return this._initServicePromise;
|
|
146
138
|
};
|
|
147
|
-
//#region Media Streams Management
|
|
148
|
-
/*
|
|
149
|
-
The main method to start the initialization of local media streams.
|
|
150
|
-
This method can be executed many times and it will insure all calls are synced and only relevant stream will be created.
|
|
151
|
-
DO NOT USE ANY OTHER METHOD THAT FORCES "navigator.getUserMedia" OTHER THAN THIS ONE.
|
|
152
|
-
*/
|
|
153
139
|
TechseeMediaServiceBase.prototype.initLocalMediaStreams = function () {
|
|
154
140
|
this.serviceInitGuard();
|
|
155
|
-
var isDashboardOpentok = this._serviceOptions.mediaServiceType === MediaConstants_1.MediaServiceType.OPENTOK &&
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (!this._initLocalStreamsPromise || this._isIOS_14_orLater && !isDashboardOpentok) {
|
|
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)) {
|
|
159
145
|
trace.info('initLocalMediaStreams creating media streams');
|
|
160
146
|
this._initLocalStreamsPromise = this.getLocalMediaImplementation().catch(function (mediaRequestFailResult) {
|
|
161
|
-
trace.error("initLocalMediaStreams failure: "
|
|
147
|
+
trace.error("initLocalMediaStreams failure: ".concat(mediaRequestFailResult));
|
|
162
148
|
throw mediaRequestFailResult;
|
|
163
149
|
});
|
|
164
|
-
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
165
152
|
trace.info('initLocalMediaStreams already done or in progress');
|
|
166
153
|
}
|
|
167
154
|
return this._initLocalStreamsPromise;
|
|
168
155
|
};
|
|
169
|
-
/*
|
|
170
|
-
Creates an instance of subscriber that will "listen" to the requested stream.
|
|
171
|
-
Whenever requested stream is available, subscriber will render it.
|
|
172
|
-
*/
|
|
173
156
|
TechseeMediaServiceBase.prototype.createSubscriber = function (subscriberParams) {
|
|
174
157
|
if (this._subscribers.has(subscriberParams.container)) {
|
|
175
158
|
return Promise.reject('Subscriber for provided DIV element already exists');
|
|
@@ -178,16 +161,14 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
178
161
|
this._subscribers.set(subscriberParams.container, subscriber);
|
|
179
162
|
var streamForSubscriber = this.getRegisteredStreamByType(subscriber.streamType);
|
|
180
163
|
if (streamForSubscriber) {
|
|
181
|
-
trace.info("Stream for "
|
|
164
|
+
trace.info("Stream for ".concat(subscriberParams.streamType, " is ready."));
|
|
182
165
|
subscriber.renderStream(streamForSubscriber);
|
|
183
|
-
}
|
|
184
|
-
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
trace.info("Stream for ".concat(subscriberParams.streamType, " not created yet"));
|
|
185
169
|
}
|
|
186
170
|
return Promise.resolve(subscriber);
|
|
187
171
|
};
|
|
188
|
-
/*
|
|
189
|
-
Destroys the subscriber for provided HTML DIV container
|
|
190
|
-
*/
|
|
191
172
|
TechseeMediaServiceBase.prototype.destroySubscriber = function (container) {
|
|
192
173
|
if (this._subscribers.has(container)) {
|
|
193
174
|
var subscriber = this._subscribers.get(container);
|
|
@@ -218,39 +199,44 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
218
199
|
}
|
|
219
200
|
};
|
|
220
201
|
TechseeMediaServiceBase.prototype.getSwitchCameraConstraints = function () {
|
|
221
|
-
var constraints = cloneDeep_1.default(window.latestLocalMediaConstraints);
|
|
202
|
+
var constraints = (0, cloneDeep_1.default)(window.latestLocalMediaConstraints);
|
|
222
203
|
if (!constraints) {
|
|
223
204
|
throw new Error('getSwitchCameraConstraints: unexpected use case constraints is null.');
|
|
224
205
|
}
|
|
225
206
|
trace.info('getSwitchCameraConstraints - Start switch camera with constraints:', constraints);
|
|
226
|
-
var videoSourceType = constraints.video.videoSourceType === MediaConstants_1.LocalVideoSourceType.CAMERA
|
|
227
|
-
|
|
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));
|
|
228
211
|
constraints.video.videoSourceType = videoSourceType;
|
|
229
212
|
return constraints;
|
|
230
213
|
};
|
|
231
214
|
TechseeMediaServiceBase.prototype.switchCamera = function (revertCameraWhenFailed) {
|
|
232
215
|
var _this = this;
|
|
233
216
|
trace.info('switchCamera: start');
|
|
234
|
-
var latestLocalMediaConstraints = cloneDeep_1.default(window.latestLocalMediaConstraints);
|
|
217
|
+
var latestLocalMediaConstraints = (0, cloneDeep_1.default)(window.latestLocalMediaConstraints);
|
|
235
218
|
var constraints = !revertCameraWhenFailed ? this.getSwitchCameraConstraints() : latestLocalMediaConstraints;
|
|
236
219
|
if (!constraints) {
|
|
237
220
|
throw new Error('switchCamera - unexpected use case constraints is null.');
|
|
238
221
|
}
|
|
239
|
-
return this._localStreamsManager
|
|
240
|
-
|
|
222
|
+
return this._localStreamsManager
|
|
223
|
+
.destroyUserMediaStream()
|
|
224
|
+
.then(function () {
|
|
225
|
+
return _this._localStreamsManager
|
|
226
|
+
.getUserMediaStream(constraints)
|
|
227
|
+
.then(function (streamResult) {
|
|
241
228
|
var stream = streamResult.mediaStream;
|
|
242
229
|
trace.info('switchCamera: new stream: ', stream);
|
|
243
230
|
return _this.replaceStreamTracks(stream).then(function () {
|
|
244
|
-
return _this.registerStreamResult(constraints, streamResult, true).then(function () {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
};
|
|
250
|
-
});
|
|
231
|
+
return _this.registerStreamResult(constraints, streamResult, true).then(function () { return ({
|
|
232
|
+
revertCameraWhenFailed: revertCameraWhenFailed,
|
|
233
|
+
constraints: constraints,
|
|
234
|
+
streamResult: streamResult
|
|
235
|
+
}); });
|
|
251
236
|
});
|
|
252
237
|
});
|
|
253
|
-
})
|
|
238
|
+
})
|
|
239
|
+
.catch(function (err) {
|
|
254
240
|
trace.error('switchCamera: Failed to switch camera: ', err);
|
|
255
241
|
if (!revertCameraWhenFailed) {
|
|
256
242
|
window.latestLocalMediaConstraints = latestLocalMediaConstraints;
|
|
@@ -260,7 +246,8 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
260
246
|
});
|
|
261
247
|
};
|
|
262
248
|
TechseeMediaServiceBase.prototype.replaceStreamTracks = function (mediaStream) {
|
|
263
|
-
|
|
249
|
+
var _a;
|
|
250
|
+
if ((_a = this._session) === null || _a === void 0 ? void 0 : _a.instance) {
|
|
264
251
|
return this._session.instance.replaceStreamTracks(mediaStream);
|
|
265
252
|
}
|
|
266
253
|
return Promise.reject('replaceStreamTracks - session instance is not exists.');
|
|
@@ -273,12 +260,18 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
273
260
|
trace.info('registerStreamResult: stream result from getUserMediaStream:', streamResult.mediaStream);
|
|
274
261
|
streamResult.mediaStream.getTracks().forEach(function (mediaTrack) {
|
|
275
262
|
trace.info('registerStreamResult: stream result from mediaTrack:', mediaTrack);
|
|
276
|
-
var streamType = addStreamType ||
|
|
263
|
+
var streamType = addStreamType ||
|
|
264
|
+
(mediaTrack.kind === 'video'
|
|
265
|
+
? MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM
|
|
266
|
+
: MediaConstants_1.KnownMediaStream.USER_AUDIO_STREAM);
|
|
277
267
|
var newDedicatedStream = new TechseeMediaStream_1.TechseeMediaStream(mediaTrack, streamType, false);
|
|
278
268
|
if (isOpentok) {
|
|
279
269
|
regPromises.push(_this.registerStream(newDedicatedStream));
|
|
280
|
-
}
|
|
281
|
-
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
regPromises.push(switchCamera
|
|
273
|
+
? _this.registerTrack(newDedicatedStream)
|
|
274
|
+
: _this.registerLocalMediaStream(newDedicatedStream));
|
|
282
275
|
}
|
|
283
276
|
});
|
|
284
277
|
}
|
|
@@ -290,7 +283,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
290
283
|
}
|
|
291
284
|
};
|
|
292
285
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "supportSwitchCameras", {
|
|
293
|
-
get: function
|
|
286
|
+
get: function () {
|
|
294
287
|
return this._isIOS_13_orLater || this._localStreamsManager.groupedDevices.camerasCount > 1;
|
|
295
288
|
},
|
|
296
289
|
enumerable: false,
|
|
@@ -300,14 +293,9 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
300
293
|
var _this = this;
|
|
301
294
|
this.serviceInitGuard();
|
|
302
295
|
if (!this._session) {
|
|
303
|
-
this._session = { params: cloneDeep_1.default(sessionParams) };
|
|
296
|
+
this._session = { params: (0, cloneDeep_1.default)(sessionParams) };
|
|
304
297
|
this._session.connectPromise = new Promise(function (resolve, reject) {
|
|
305
|
-
var doAsyncReject = function
|
|
306
|
-
/*
|
|
307
|
-
Reject with timeout, to change JS 'execution flow'.
|
|
308
|
-
If timeout removed, session is assigned to null, before promise returns, and "catch" will not
|
|
309
|
-
work on promise that is returned.
|
|
310
|
-
*/
|
|
298
|
+
var doAsyncReject = function (error) {
|
|
311
299
|
setTimeout(function () {
|
|
312
300
|
_this._session = null;
|
|
313
301
|
reject(error);
|
|
@@ -316,9 +304,10 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
316
304
|
var sessionHandlers = {
|
|
317
305
|
onDisconnectedHandler: _this.onSessionDisconnectHandler
|
|
318
306
|
};
|
|
319
|
-
var mediaSessionParams = __assign(__assign({}, sessionParams), { peerConnectivityTimeoutSeconds: _this._serviceOptions.peerConnectivityTimeoutSeconds ||
|
|
307
|
+
var mediaSessionParams = __assign(__assign({}, sessionParams), { peerConnectivityTimeoutSeconds: _this._serviceOptions.peerConnectivityTimeoutSeconds ||
|
|
308
|
+
MediaConstants_1.DEFAULT_PEER_CONNECTIVITY_TIMEOUT_SECONDS });
|
|
320
309
|
trace.info('connectToSession', sessionParams);
|
|
321
|
-
var allowedValues = values_1.default(MediaConstants_1.MediaServiceType);
|
|
310
|
+
var allowedValues = (0, values_1.default)(MediaConstants_1.MediaServiceType);
|
|
322
311
|
switch (_this._serviceOptions.mediaServiceType) {
|
|
323
312
|
case MediaConstants_1.MediaServiceType.TURNSERVER:
|
|
324
313
|
_this._session.instance = new SessionTurn_1.TurnWebRtcSession(mediaSessionParams, sessionHandlers, _this._sessionStreamsManager);
|
|
@@ -330,50 +319,41 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
330
319
|
_this._session.instance = new MediaServer_1.MediaServerSession(mediaSessionParams, _this._sessionStreamsManager);
|
|
331
320
|
break;
|
|
332
321
|
default:
|
|
333
|
-
trace.error("mediaServiceType '"
|
|
322
|
+
trace.error("mediaServiceType '".concat(_this._serviceOptions.mediaServiceType, "' is not supported."), {
|
|
323
|
+
allowedValues: allowedValues
|
|
324
|
+
});
|
|
334
325
|
doAsyncReject(new Error('mediaServiceType is not supported'));
|
|
335
326
|
}
|
|
336
327
|
if (_this._session && _this._session.instance) {
|
|
337
|
-
_this._session.instance.connect()
|
|
328
|
+
_this._session.instance.connect()
|
|
329
|
+
.then(function () {
|
|
338
330
|
trace.info('Session is connected');
|
|
339
331
|
resolve();
|
|
340
|
-
})
|
|
332
|
+
})
|
|
333
|
+
.catch(function (error) {
|
|
341
334
|
trace.error('Failed to connect to session', error);
|
|
342
335
|
doAsyncReject(error);
|
|
343
336
|
});
|
|
344
337
|
}
|
|
345
338
|
});
|
|
346
|
-
}
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
347
341
|
trace.warn('Session connected already. Disconnect before connect to new session again');
|
|
348
342
|
}
|
|
349
|
-
//TODO - Alex: Change a structure of this function to be more safe
|
|
350
|
-
//(when we return, there should not be case when session or promise is null)
|
|
351
|
-
//To fix, need to return promise immediately, then execute process in setTimeout(fn, 0);
|
|
352
343
|
return this._session.connectPromise;
|
|
353
344
|
};
|
|
354
|
-
//#endregion Media Streams Management
|
|
355
|
-
//#region Session Management
|
|
356
|
-
/*
|
|
357
|
-
Creates instance of WebRTC session which connects to (signaling server), and begins to listen to WebRTC events.
|
|
358
|
-
*/
|
|
359
345
|
TechseeMediaServiceBase.prototype.connectToSession = function (sessionParams) {
|
|
360
346
|
return this._connectToSession(sessionParams);
|
|
361
347
|
};
|
|
362
|
-
/*
|
|
363
|
-
Disconnects from WebRTC session.
|
|
364
|
-
*/
|
|
365
348
|
TechseeMediaServiceBase.prototype.disconnectFromSession = function () {
|
|
366
349
|
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer);
|
|
367
350
|
};
|
|
368
|
-
/*
|
|
369
|
-
Updates a credentials for turn server
|
|
370
|
-
*/
|
|
371
351
|
TechseeMediaServiceBase.prototype.updateSessionCredentials = function (credentials) {
|
|
372
352
|
trace.info('updateSessionCredentials');
|
|
373
353
|
if (!this.sessionExistsGuard(false)) {
|
|
374
354
|
return Promise.reject('There no session to update credentials');
|
|
375
355
|
}
|
|
376
|
-
this._session.params.credentials = cloneDeep_1.default(credentials);
|
|
356
|
+
this._session.params.credentials = (0, cloneDeep_1.default)(credentials);
|
|
377
357
|
return Promise.resolve();
|
|
378
358
|
};
|
|
379
359
|
TechseeMediaServiceBase.prototype.enableVoipDuringSession = function () {
|
|
@@ -383,15 +363,14 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
383
363
|
this._isVoipEnabled = true;
|
|
384
364
|
};
|
|
385
365
|
TechseeMediaServiceBase.prototype.disconnectFromSessionInternal = function (reason) {
|
|
366
|
+
var _a;
|
|
386
367
|
if (!this._session) {
|
|
387
368
|
return Promise.resolve();
|
|
388
369
|
}
|
|
389
370
|
trace.info('Disconnecting from session', reason);
|
|
390
371
|
var lastSession = this._session;
|
|
391
372
|
this._session = null;
|
|
392
|
-
return Promise.all([lastSession.instance.disconnect(), this.clearPublishers()]).then(function () {
|
|
393
|
-
return undefined;
|
|
394
|
-
});
|
|
373
|
+
return Promise.all([(_a = lastSession.instance) === null || _a === void 0 ? void 0 : _a.disconnect(), this.clearPublishers()]).then(function () { return undefined; });
|
|
395
374
|
};
|
|
396
375
|
TechseeMediaServiceBase.prototype.getStatsForRemoteTrack = function (streamType) {
|
|
397
376
|
if (!this.sessionExistsGuard(false)) {
|
|
@@ -402,7 +381,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
402
381
|
return Promise.reject(new Error('Stream for requested type was not found'));
|
|
403
382
|
}
|
|
404
383
|
return this._session.instance.getRemoteTrackStats(streamForStats.mediaTrack).then(function (trackStats) {
|
|
405
|
-
traceStatsInfo("MediaTrackStats for "
|
|
384
|
+
traceStatsInfo("MediaTrackStats for ".concat(streamType, ": ").concat(JSON.stringify(trackStats)));
|
|
406
385
|
return {
|
|
407
386
|
trackId: streamForStats.mediaTrack.id,
|
|
408
387
|
trackStats: trackStats
|
|
@@ -415,16 +394,24 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
415
394
|
if (reason !== MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer) {
|
|
416
395
|
var lastParams_1 = this._session && this._session.params ? this._session.params : null;
|
|
417
396
|
this.disconnectFromSessionInternal(reason).then(function () {
|
|
418
|
-
var reconnectReasons = [
|
|
419
|
-
|
|
397
|
+
var reconnectReasons = [
|
|
398
|
+
MediaConstants_1.MediaSessionDisconnectReason.InitiatorPeerReconnected,
|
|
399
|
+
MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect,
|
|
400
|
+
MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted,
|
|
401
|
+
MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout
|
|
402
|
+
];
|
|
403
|
+
if (lastParams_1 && (0, includes_1.default)(reconnectReasons, reason) && _this._autoReconnectEnabled) {
|
|
420
404
|
_this.reconnectToSession(lastParams_1);
|
|
421
|
-
}
|
|
405
|
+
}
|
|
406
|
+
else if (!_this._autoReconnectEnabled) {
|
|
422
407
|
trace.info('No reconnection- auto reconnect disabled');
|
|
423
|
-
}
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
424
410
|
trace.info('No params for reconnection to media session');
|
|
425
411
|
}
|
|
426
412
|
});
|
|
427
|
-
}
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
428
415
|
trace.info('Ignore Session disconnect event');
|
|
429
416
|
}
|
|
430
417
|
};
|
|
@@ -441,18 +428,19 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
441
428
|
};
|
|
442
429
|
TechseeMediaServiceBase.prototype.reconnectToSession = function (lastParams) {
|
|
443
430
|
trace.info('Reconnecting to media session, sessionParams:', lastParams);
|
|
444
|
-
this._connectToSession(lastParams)
|
|
431
|
+
this._connectToSession(lastParams)
|
|
432
|
+
.then(function () {
|
|
445
433
|
trace.info('Media session reconnected');
|
|
446
|
-
})
|
|
434
|
+
})
|
|
435
|
+
.catch(function (error) {
|
|
447
436
|
trace.error('Error while reconnecting to media session', error);
|
|
448
437
|
});
|
|
449
438
|
};
|
|
450
|
-
//#endregion Session Management
|
|
451
|
-
//#region Utils
|
|
452
439
|
TechseeMediaServiceBase.prototype.getSnapshotFromKnownStream = function (sourceStream, snapshotOptions) {
|
|
453
440
|
var _this = this;
|
|
454
441
|
return new Promise(function (resolve, reject) {
|
|
455
|
-
if (sourceStream !== MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM &&
|
|
442
|
+
if (sourceStream !== MediaConstants_1.KnownMediaStream.USER_VIDEO_STREAM &&
|
|
443
|
+
sourceStream !== MediaConstants_1.KnownMediaStream.USER_SCREEN_SHARE_STREAM) {
|
|
456
444
|
trace.error('The requested stream is not video stream, and cannot be used for snapshot');
|
|
457
445
|
reject(new Error('INCOMPATIBLE_STREAM_FOR_SNAPSHOT'));
|
|
458
446
|
return;
|
|
@@ -463,7 +451,8 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
463
451
|
reject(new Error('NO_REQUESTED_STREAM'));
|
|
464
452
|
return;
|
|
465
453
|
}
|
|
466
|
-
MediaDomUtils_1.getSnapshotFromMediaStream(snapshotStream.mediaStream, sourceStream, snapshotOptions)
|
|
454
|
+
(0, MediaDomUtils_1.getSnapshotFromMediaStream)(snapshotStream.mediaStream, sourceStream, snapshotOptions)
|
|
455
|
+
.then(function (imageData) {
|
|
467
456
|
var urlComponents = imageData.split(';base64,');
|
|
468
457
|
var mimeType = urlComponents[0].split(':')[1];
|
|
469
458
|
var bytes = atob(urlComponents[1]);
|
|
@@ -482,36 +471,36 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
482
471
|
mimeType: mimeType
|
|
483
472
|
};
|
|
484
473
|
resolve(result);
|
|
485
|
-
})
|
|
474
|
+
})
|
|
475
|
+
.catch(function (error) {
|
|
486
476
|
trace.error('Error creating snapshot', error);
|
|
487
477
|
reject(error);
|
|
488
478
|
});
|
|
489
479
|
});
|
|
490
480
|
};
|
|
491
|
-
//Will clean streams, publishers and subscribers, but will not remove event listeners
|
|
492
481
|
TechseeMediaServiceBase.prototype.clearService = function () {
|
|
493
482
|
var _this = this;
|
|
494
483
|
trace.info('MediaService clearing all resources');
|
|
495
|
-
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer)
|
|
484
|
+
return this.disconnectFromSessionInternal(MediaConstants_1.MediaSessionDisconnectReason.ForcedByConsumer)
|
|
485
|
+
.then(this.clearSubscribers)
|
|
486
|
+
.then(this.clearRegisteredStreams)
|
|
487
|
+
.then(this._localStreamsManager.clearAllStreams)
|
|
488
|
+
.then(function () {
|
|
496
489
|
_this._initLocalStreamsPromise = null;
|
|
497
490
|
_this._isVoipEnabled = false;
|
|
498
|
-
})
|
|
499
|
-
return undefined;
|
|
500
|
-
});
|
|
491
|
+
})
|
|
492
|
+
.then(function () { return undefined; });
|
|
501
493
|
};
|
|
502
|
-
//Will clear the service and remove all event listeners
|
|
503
494
|
TechseeMediaServiceBase.prototype.dispose = function () {
|
|
504
495
|
var _this = this;
|
|
505
|
-
return this.clearService()
|
|
506
|
-
return undefined;
|
|
507
|
-
|
|
496
|
+
return this.clearService()
|
|
497
|
+
.catch(function () { return undefined; })
|
|
498
|
+
.then(function () {
|
|
508
499
|
_this._emitter.removeAllListeners();
|
|
509
500
|
});
|
|
510
501
|
};
|
|
511
502
|
Object.defineProperty(TechseeMediaServiceBase.prototype, "subscribers", {
|
|
512
|
-
|
|
513
|
-
//#region Protected Methods
|
|
514
|
-
get: function get() {
|
|
503
|
+
get: function () {
|
|
515
504
|
return this._subscribers;
|
|
516
505
|
},
|
|
517
506
|
enumerable: false,
|
|
@@ -520,7 +509,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
520
509
|
TechseeMediaServiceBase.prototype.registerLocalMediaStream = function (tsMediaStream) {
|
|
521
510
|
trace.info('Registering local stream', tsMediaStream.streamType);
|
|
522
511
|
if (this._registeredStreams.has(tsMediaStream.streamType)) {
|
|
523
|
-
return Promise.reject(new Error("Stream "
|
|
512
|
+
return Promise.reject(new Error("Stream ".concat(tsMediaStream.streamType, " already registered")));
|
|
524
513
|
}
|
|
525
514
|
return this.registerStream(tsMediaStream);
|
|
526
515
|
};
|
|
@@ -531,7 +520,8 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
531
520
|
var streamToChangeState = this.getRegisteredStreamByType(streamType);
|
|
532
521
|
if (!streamToChangeState) {
|
|
533
522
|
trace.warn('There no stream found to change enable state', streamType);
|
|
534
|
-
}
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
535
525
|
streamToChangeState.mediaTrack.enabled = !isPaused;
|
|
536
526
|
if (streamToChangeState.isRemote && streamToChangeState.streamKind === MediaConstants_1.KnownMediaStreamKind.Audio) {
|
|
537
527
|
this.subscribers.forEach(function (subscriber) {
|
|
@@ -555,10 +545,8 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
555
545
|
_this._emitter.emit(event, eventArgs);
|
|
556
546
|
});
|
|
557
547
|
};
|
|
558
|
-
//#endregion Protected Methods
|
|
559
|
-
//#region Private Methods
|
|
560
548
|
TechseeMediaServiceBase.prototype.registerRemoteMediaTrack = function (remoteMediaTrack) {
|
|
561
|
-
trace.info("Registering remote "
|
|
549
|
+
trace.info("Registering remote ".concat(remoteMediaTrack.trackType, " MediaStreamTrack"), remoteMediaTrack.mediaTrack);
|
|
562
550
|
var currentStream = this._registeredStreams.get(remoteMediaTrack.trackType);
|
|
563
551
|
if (currentStream && !currentStream.isRemote) {
|
|
564
552
|
return Promise.reject(new Error('Cannot register remote stream with the same type as local stream'));
|
|
@@ -572,7 +560,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
572
560
|
return _this.unregisterTechseeMediaStream(mediaStream, MediaConstants_1.MediaStreamUnregisterReason.NativeEvent);
|
|
573
561
|
};
|
|
574
562
|
this._registeredStreams.set(mediaStream.streamType, mediaStream);
|
|
575
|
-
trace.info("TechseeMediaStream registered - "
|
|
563
|
+
trace.info("TechseeMediaStream registered - ".concat(mediaStream.streamType), TechseeMediaStream_1.TechseeMediaStream);
|
|
576
564
|
return this.updateSubscribersWithNewStream(mediaStream).then(function () {
|
|
577
565
|
var eventArgs = { streamType: mediaStream.streamType };
|
|
578
566
|
_this.emitEvent(privateEvents.STREAM_CREATED, eventArgs);
|
|
@@ -582,15 +570,13 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
582
570
|
var _this = this;
|
|
583
571
|
var currentStream = this._registeredStreams.get(mediaStream.streamType);
|
|
584
572
|
if (currentStream) {
|
|
585
|
-
return this.unregisterTechseeMediaStream(currentStream, MediaConstants_1.MediaStreamUnregisterReason.ReplacingStream).then(function () {
|
|
586
|
-
return _this.registerTrack(mediaStream);
|
|
587
|
-
});
|
|
573
|
+
return this.unregisterTechseeMediaStream(currentStream, MediaConstants_1.MediaStreamUnregisterReason.ReplacingStream).then(function () { return _this.registerTrack(mediaStream); });
|
|
588
574
|
}
|
|
589
575
|
return this.registerTrack(mediaStream);
|
|
590
576
|
};
|
|
591
577
|
TechseeMediaServiceBase.prototype.unregisterTechseeMediaStream = function (streamToUnregister, reason) {
|
|
592
578
|
var _this = this;
|
|
593
|
-
var traceError = function
|
|
579
|
+
var traceError = function (error) {
|
|
594
580
|
trace.warn('Unregister TechseeMediaStream error:', error);
|
|
595
581
|
};
|
|
596
582
|
var promises = [];
|
|
@@ -602,9 +588,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
602
588
|
});
|
|
603
589
|
if (!streamToUnregister.isRemote) {
|
|
604
590
|
this._publishers.forEach(function (publisher) {
|
|
605
|
-
if (publisher.streamTypes.find(function (streamType) {
|
|
606
|
-
return streamType === streamToUnregister.streamType;
|
|
607
|
-
})) {
|
|
591
|
+
if (publisher.streamTypes.find(function (streamType) { return streamType === streamToUnregister.streamType; })) {
|
|
608
592
|
if (_this._session && _this._session.instance) {
|
|
609
593
|
promises.push(_this._session.instance.onMediaStreamDestroyed(publisher.destinationRole).catch(traceError));
|
|
610
594
|
}
|
|
@@ -626,9 +610,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
626
610
|
promises.push(_this.unregisterTechseeMediaStream(registeredStream, MediaConstants_1.MediaStreamUnregisterReason.ClosedRemotely));
|
|
627
611
|
}
|
|
628
612
|
});
|
|
629
|
-
return Promise.all(promises).then(function () {
|
|
630
|
-
return undefined;
|
|
631
|
-
});
|
|
613
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
632
614
|
};
|
|
633
615
|
TechseeMediaServiceBase.prototype.removePublisher = function (publisher) {
|
|
634
616
|
this._publishers.delete(publisher.destinationRole);
|
|
@@ -644,20 +626,21 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
644
626
|
var _this = this;
|
|
645
627
|
this.serviceInitGuard();
|
|
646
628
|
if (this._publishers.has(destinationRole)) {
|
|
647
|
-
trace.info("Publisher for "
|
|
629
|
+
trace.info("Publisher for ".concat(destinationRole, " already exists"));
|
|
648
630
|
return Promise.resolve(this._publishers.get(destinationRole).mediaStream);
|
|
649
631
|
}
|
|
650
632
|
if (!this._publisherPromises.get(destinationRole)) {
|
|
651
|
-
trace.info("Creating publisher for "
|
|
652
|
-
var publisherPromise = this.initLocalMediaStreams()
|
|
653
|
-
return _this.createMediaPublisher(destinationRole);
|
|
654
|
-
|
|
633
|
+
trace.info("Creating publisher for ".concat(destinationRole));
|
|
634
|
+
var publisherPromise = this.initLocalMediaStreams()
|
|
635
|
+
.then(function () { return _this.createMediaPublisher(destinationRole); })
|
|
636
|
+
.then(function (mediaPublisher) {
|
|
655
637
|
if (mediaPublisher) {
|
|
656
638
|
_this._publishers.set(destinationRole, mediaPublisher);
|
|
657
639
|
}
|
|
658
640
|
_this._publisherPromises.delete(destinationRole);
|
|
659
641
|
return mediaPublisher ? mediaPublisher.mediaStream : null;
|
|
660
|
-
})
|
|
642
|
+
})
|
|
643
|
+
.catch(function (ex) {
|
|
661
644
|
if (ex && ex.message === 'audioStreamFailed') {
|
|
662
645
|
_this._isVoipEnabled = false;
|
|
663
646
|
return null;
|
|
@@ -666,21 +649,23 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
666
649
|
throw ex;
|
|
667
650
|
});
|
|
668
651
|
this._publisherPromises.set(destinationRole, publisherPromise);
|
|
669
|
-
}
|
|
670
|
-
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
trace.info("Create publisher promise for ".concat(destinationRole, " already exists"));
|
|
671
655
|
}
|
|
672
656
|
return this._publisherPromises.get(destinationRole);
|
|
673
657
|
};
|
|
674
658
|
TechseeMediaServiceBase.prototype.updateSubscribersWithNewStream = function (registeredStream) {
|
|
675
|
-
trace.info("Updating subscribers of "
|
|
659
|
+
trace.info("Updating subscribers of ".concat(registeredStream.streamType, " with new stream"));
|
|
676
660
|
if (this._subscribers.size === 0) {
|
|
677
|
-
trace.warn("No subscribers exists for the "
|
|
678
|
-
}
|
|
679
|
-
|
|
661
|
+
trace.warn("No subscribers exists for the ".concat(registeredStream.streamType, "."));
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
trace.info("Total ".concat(this._subscribers.size, " subscribers exists, will check if rerender needed."));
|
|
680
665
|
}
|
|
681
666
|
this._subscribers.forEach(function (subscriber) {
|
|
682
667
|
if (subscriber.streamType === registeredStream.streamType) {
|
|
683
|
-
trace.info(registeredStream.streamType
|
|
668
|
+
trace.info("".concat(registeredStream.streamType, " rendering on subscriber"));
|
|
684
669
|
subscriber.renderStream(registeredStream);
|
|
685
670
|
}
|
|
686
671
|
});
|
|
@@ -701,8 +686,8 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
701
686
|
this.clearSubscribers = this.clearSubscribers.bind(this);
|
|
702
687
|
this._connectToSession = this._connectToSession.bind(this);
|
|
703
688
|
this.disconnectFromMediaSession = this.disconnectFromMediaSession.bind(this);
|
|
689
|
+
this.getSnapshotFromKnownStream = this.getSnapshotFromKnownStream.bind(this);
|
|
704
690
|
};
|
|
705
|
-
//region Cleanup
|
|
706
691
|
TechseeMediaServiceBase.prototype.clearRegisteredStreams = function () {
|
|
707
692
|
var _this = this;
|
|
708
693
|
trace.info('Clearing registered streams');
|
|
@@ -710,9 +695,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
710
695
|
this._registeredStreams.forEach(function (streamToUnregister) {
|
|
711
696
|
promises.push(_this.unregisterTechseeMediaStream(streamToUnregister, MediaConstants_1.MediaStreamUnregisterReason.ServiceCleanUp));
|
|
712
697
|
});
|
|
713
|
-
return Promise.all(promises).then(function () {
|
|
714
|
-
return undefined;
|
|
715
|
-
});
|
|
698
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
716
699
|
};
|
|
717
700
|
TechseeMediaServiceBase.prototype.clearSubscribers = function () {
|
|
718
701
|
var _this = this;
|
|
@@ -721,9 +704,7 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
721
704
|
this._subscribers.forEach(function (subscriber) {
|
|
722
705
|
promises.push(_this.destroySubscriber(subscriber.container));
|
|
723
706
|
});
|
|
724
|
-
return Promise.all(promises).then(function () {
|
|
725
|
-
return undefined;
|
|
726
|
-
});
|
|
707
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
727
708
|
};
|
|
728
709
|
TechseeMediaServiceBase.prototype.clearPublishers = function () {
|
|
729
710
|
var _this = this;
|
|
@@ -732,27 +713,17 @@ var TechseeMediaServiceBase = /** @class */function () {
|
|
|
732
713
|
this._publishers.forEach(function (publisher) {
|
|
733
714
|
promises.push(_this.removePublisher(publisher));
|
|
734
715
|
});
|
|
735
|
-
return Promise.all(promises).then(function () {
|
|
736
|
-
return undefined;
|
|
737
|
-
});
|
|
716
|
+
return Promise.all(promises).then(function () { return undefined; });
|
|
738
717
|
};
|
|
739
|
-
//#endregion Cleanup
|
|
740
|
-
//#region Simple Validation Methods
|
|
741
718
|
TechseeMediaServiceBase.prototype.serviceInitGuard = function (shouldThrow) {
|
|
742
|
-
if (shouldThrow === void 0) {
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
return guards_1.throwableGuard(!!this._serviceOptions, 'Media service is not initialized', shouldThrow);
|
|
719
|
+
if (shouldThrow === void 0) { shouldThrow = true; }
|
|
720
|
+
return (0, guards_1.throwableGuard)(!!this._serviceOptions, 'Media service is not initialized', shouldThrow);
|
|
746
721
|
};
|
|
747
722
|
TechseeMediaServiceBase.prototype.sessionExistsGuard = function (shouldThrow) {
|
|
748
|
-
if (shouldThrow === void 0) {
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
return guards_1.throwableGuard(!!this._session, 'There no active session', shouldThrow);
|
|
723
|
+
if (shouldThrow === void 0) { shouldThrow = true; }
|
|
724
|
+
return (0, guards_1.throwableGuard)(!!this._session, 'There no active session', shouldThrow);
|
|
752
725
|
};
|
|
753
726
|
return TechseeMediaServiceBase;
|
|
754
|
-
}();
|
|
727
|
+
}());
|
|
755
728
|
exports.TechseeMediaServiceBase = TechseeMediaServiceBase;
|
|
756
|
-
|
|
757
|
-
//# sourceMappingURL=MediaServiceBase.js.map
|
|
758
|
-
//# sourceMappingURL=MediaServiceBase.js.map
|
|
729
|
+
//# sourceMappingURL=MediaServiceBase.js.map
|