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