@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.
Files changed (213) hide show
  1. package/README.md +27 -28
  2. package/lib/LocalStreamManager.d.ts +1 -0
  3. package/lib/LocalStreamManager.d.ts.map +1 -1
  4. package/lib/LocalStreamManager.js +82 -84
  5. package/lib/LocalStreamManager.js.map +1 -1
  6. package/lib/MediaConstants.d.ts +20 -3
  7. package/lib/MediaConstants.d.ts.map +1 -1
  8. package/lib/MediaConstants.js +31 -13
  9. package/lib/MediaConstants.js.map +1 -1
  10. package/lib/MediaContracts.d.ts +7 -1
  11. package/lib/MediaContracts.d.ts.map +1 -1
  12. package/lib/MediaContracts.js +1 -4
  13. package/lib/MediaContracts.js.map +1 -1
  14. package/lib/MediaPublisher.d.ts +1 -0
  15. package/lib/MediaPublisher.d.ts.map +1 -1
  16. package/lib/MediaPublisher.js +7 -10
  17. package/lib/MediaPublisher.js.map +1 -1
  18. package/lib/MediaServiceBase.d.ts +1 -0
  19. package/lib/MediaServiceBase.d.ts.map +1 -1
  20. package/lib/MediaServiceBase.js +169 -198
  21. package/lib/MediaServiceBase.js.map +1 -1
  22. package/lib/MediaSession/MediaServer.d.ts +1 -0
  23. package/lib/MediaSession/MediaServer.d.ts.map +1 -1
  24. package/lib/MediaSession/MediaServer.js +62 -74
  25. package/lib/MediaSession/MediaServer.js.map +1 -1
  26. package/lib/MediaSession/MediaSessionBase.d.ts +1 -0
  27. package/lib/MediaSession/MediaSessionBase.d.ts.map +1 -1
  28. package/lib/MediaSession/MediaSessionBase.js +19 -23
  29. package/lib/MediaSession/MediaSessionBase.js.map +1 -1
  30. package/lib/MediaSession/SessionOpentok.d.ts +1 -0
  31. package/lib/MediaSession/SessionOpentok.d.ts.map +1 -1
  32. package/lib/MediaSession/SessionOpentok.js +51 -80
  33. package/lib/MediaSession/SessionOpentok.js.map +1 -1
  34. package/lib/MediaSession/SessionTurn.d.ts +1 -0
  35. package/lib/MediaSession/SessionTurn.d.ts.map +1 -1
  36. package/lib/MediaSession/SessionTurn.js +109 -151
  37. package/lib/MediaSession/SessionTurn.js.map +1 -1
  38. package/lib/MediaSession/TurnConstants.d.ts +1 -0
  39. package/lib/MediaSession/TurnConstants.d.ts.map +1 -1
  40. package/lib/MediaSession/TurnConstants.js +1 -16
  41. package/lib/MediaSession/TurnConstants.js.map +1 -1
  42. package/lib/MediaSubscriber.d.ts +1 -0
  43. package/lib/MediaSubscriber.d.ts.map +1 -1
  44. package/lib/MediaSubscriber.js +37 -43
  45. package/lib/MediaSubscriber.js.map +1 -1
  46. package/lib/MediaUtils/Compatibility.d.ts +3 -0
  47. package/lib/MediaUtils/Compatibility.d.ts.map +1 -1
  48. package/lib/MediaUtils/Compatibility.js +76 -34
  49. package/lib/MediaUtils/Compatibility.js.map +1 -1
  50. package/lib/MediaUtils/MediaDomUtils.d.ts +4 -2
  51. package/lib/MediaUtils/MediaDomUtils.d.ts.map +1 -1
  52. package/lib/MediaUtils/MediaDomUtils.js +64 -62
  53. package/lib/MediaUtils/MediaDomUtils.js.map +1 -1
  54. package/lib/MediaUtils/MediaTracer.d.ts +1 -0
  55. package/lib/MediaUtils/MediaTracer.d.ts.map +1 -1
  56. package/lib/MediaUtils/MediaTracer.js +2 -5
  57. package/lib/MediaUtils/MediaTracer.js.map +1 -1
  58. package/lib/MediaUtils/index.d.ts +2 -0
  59. package/lib/MediaUtils/index.d.ts.map +1 -0
  60. package/lib/MediaUtils/index.js +6 -0
  61. package/lib/MediaUtils/index.js.map +1 -0
  62. package/lib/MultiParty/DetectWebRtcService.d.ts +17 -14
  63. package/lib/MultiParty/DetectWebRtcService.d.ts.map +1 -1
  64. package/lib/MultiParty/DetectWebRtcService.js +98 -54
  65. package/lib/MultiParty/DetectWebRtcService.js.map +1 -1
  66. package/lib/MultiParty/MediaCapabilitiesService.d.ts +18 -0
  67. package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -0
  68. package/lib/MultiParty/MediaCapabilitiesService.js +158 -0
  69. package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -0
  70. package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +6 -0
  71. package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -0
  72. package/lib/MultiParty/MediaCapabilitiesUtils.js +123 -0
  73. package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -0
  74. package/lib/MultiParty/MediaTracer.d.ts +4 -0
  75. package/lib/MultiParty/MediaTracer.d.ts.map +1 -0
  76. package/lib/MultiParty/MediaTracer.js +10 -0
  77. package/lib/MultiParty/MediaTracer.js.map +1 -0
  78. package/lib/MultiParty/MultiPartyService.d.ts +49 -0
  79. package/lib/MultiParty/MultiPartyService.d.ts.map +1 -0
  80. package/lib/MultiParty/MultiPartyService.js +30 -0
  81. package/lib/MultiParty/MultiPartyService.js.map +1 -0
  82. package/lib/MultiParty/MultiPartyServiceFactory.d.ts +4 -0
  83. package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -0
  84. package/lib/MultiParty/MultiPartyServiceFactory.js +13 -0
  85. package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -0
  86. package/lib/MultiParty/MultipartyServiceEventTypes.d.ts +89 -0
  87. package/lib/MultiParty/MultipartyServiceEventTypes.d.ts.map +1 -0
  88. package/lib/MultiParty/MultipartyServiceEventTypes.js +16 -0
  89. package/lib/MultiParty/MultipartyServiceEventTypes.js.map +1 -0
  90. package/lib/MultiParty/index.d.ts +7 -0
  91. package/lib/MultiParty/index.d.ts.map +1 -0
  92. package/lib/MultiParty/index.js +25 -0
  93. package/lib/MultiParty/index.js.map +1 -0
  94. package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts +38 -0
  95. package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts.map +1 -0
  96. package/lib/MultiParty/opentok/OpentokMultiPartyService.js +492 -0
  97. package/lib/MultiParty/opentok/OpentokMultiPartyService.js.map +1 -0
  98. package/lib/MultiParty/opentok/OpentokPublisher.d.ts +34 -0
  99. package/lib/MultiParty/opentok/OpentokPublisher.d.ts.map +1 -0
  100. package/lib/MultiParty/opentok/OpentokPublisher.js +121 -0
  101. package/lib/MultiParty/opentok/OpentokPublisher.js.map +1 -0
  102. package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts +20 -0
  103. package/lib/MultiParty/opentok/OpentokPublisherEventMapper.d.ts.map +1 -0
  104. package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js +49 -0
  105. package/lib/MultiParty/opentok/OpentokPublisherEventMapper.js.map +1 -0
  106. package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts +6 -0
  107. package/lib/MultiParty/opentok/OpentokScreenPublisher.d.ts.map +1 -0
  108. package/lib/MultiParty/opentok/OpentokScreenPublisher.js +48 -0
  109. package/lib/MultiParty/opentok/OpentokScreenPublisher.js.map +1 -0
  110. package/lib/MultiParty/opentok/OpentokSubscriber.d.ts +2 -0
  111. package/lib/MultiParty/opentok/OpentokSubscriber.d.ts.map +1 -0
  112. package/lib/MultiParty/opentok/OpentokSubscriber.js +26 -0
  113. package/lib/MultiParty/opentok/OpentokSubscriber.js.map +1 -0
  114. package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts +19 -0
  115. package/lib/MultiParty/opentok/OpentokVideoPublisher.d.ts.map +1 -0
  116. package/lib/MultiParty/opentok/OpentokVideoPublisher.js +182 -0
  117. package/lib/MultiParty/opentok/OpentokVideoPublisher.js.map +1 -0
  118. package/lib/MultiParty/opentok/trace.d.ts +3 -0
  119. package/lib/MultiParty/opentok/trace.d.ts.map +1 -0
  120. package/lib/MultiParty/opentok/trace.js +18 -0
  121. package/lib/MultiParty/opentok/trace.js.map +1 -0
  122. package/lib/MultiParty/opentok.d.ts +463 -0
  123. package/lib/MultiParty/types.d.ts +33 -0
  124. package/lib/MultiParty/types.d.ts.map +1 -0
  125. package/lib/MultiParty/types.js +3 -0
  126. package/lib/MultiParty/types.js.map +1 -0
  127. package/lib/MultiParty/utils.d.ts +10 -0
  128. package/lib/MultiParty/utils.d.ts.map +1 -0
  129. package/lib/MultiParty/utils.js +17 -0
  130. package/lib/MultiParty/utils.js.map +1 -0
  131. package/lib/TechseeMediaStream.d.ts +1 -0
  132. package/lib/TechseeMediaStream.d.ts.map +1 -1
  133. package/lib/TechseeMediaStream.js +9 -12
  134. package/lib/TechseeMediaStream.js.map +1 -1
  135. package/lib/qos/raw-qos.d.ts +29 -0
  136. package/lib/qos/raw-qos.d.ts.map +1 -0
  137. package/lib/qos/raw-qos.js +84 -145
  138. package/lib/qos/raw-qos.js.map +1 -1
  139. package/lib/webrtc-ie-shim.d.ts +4 -0
  140. package/lib/webrtc-ie-shim.d.ts.map +1 -0
  141. package/lib/webrtc-ie-shim.js +1896 -2950
  142. package/lib/webrtc-ie-shim.js.map +1 -1
  143. package/package.json +66 -60
  144. package/lib/MultiParty/Contracts.d.ts +0 -11
  145. package/lib/MultiParty/Contracts.d.ts.map +0 -1
  146. package/lib/MultiParty/Contracts.js +0 -6
  147. package/lib/MultiParty/Contracts.js.map +0 -1
  148. package/lib/MultiParty/MediaCapabilitiesHelper.d.ts +0 -12
  149. package/lib/MultiParty/MediaCapabilitiesHelper.d.ts.map +0 -1
  150. package/lib/MultiParty/MediaCapabilitiesHelper.js +0 -167
  151. package/lib/MultiParty/MediaCapabilitiesHelper.js.map +0 -1
  152. package/lib/MultiParty/MultiParty.d.ts +0 -21
  153. package/lib/MultiParty/MultiParty.d.ts.map +0 -1
  154. package/lib/MultiParty/MultiParty.js +0 -155
  155. package/lib/MultiParty/MultiParty.js.map +0 -1
  156. package/lib/MultiParty/MultipartyFactory.d.ts +0 -2
  157. package/lib/MultiParty/MultipartyFactory.d.ts.map +0 -1
  158. package/lib/MultiParty/MultipartyFactory.js +0 -15
  159. package/lib/MultiParty/MultipartyFactory.js.map +0 -1
  160. package/lib/MultiParty/OpentokMultiparty.d.ts +0 -24
  161. package/lib/MultiParty/OpentokMultiparty.d.ts.map +0 -1
  162. package/lib/MultiParty/OpentokMultiparty.js +0 -408
  163. package/lib/MultiParty/OpentokMultiparty.js.map +0 -1
  164. package/lib/oldCode/constants.js +0 -20
  165. package/lib/oldCode/constants.js.map +0 -1
  166. package/lib/oldCode/event-emitter.js +0 -39
  167. package/lib/oldCode/event-emitter.js.map +0 -1
  168. package/lib/oldCode/index.js +0 -64
  169. package/lib/oldCode/index.js.map +0 -1
  170. package/lib/oldCode/opentok/session.js +0 -310
  171. package/lib/oldCode/opentok/session.js.map +0 -1
  172. package/lib/oldCode/opentok/stream.js +0 -310
  173. package/lib/oldCode/opentok/stream.js.map +0 -1
  174. package/lib/oldCode/publisher.js +0 -143
  175. package/lib/oldCode/publisher.js.map +0 -1
  176. package/lib/oldCode/service.js +0 -395
  177. package/lib/oldCode/service.js.map +0 -1
  178. package/lib/oldCode/session.js +0 -110
  179. package/lib/oldCode/session.js.map +0 -1
  180. package/lib/oldCode/stream.js +0 -195
  181. package/lib/oldCode/stream.js.map +0 -1
  182. package/lib/oldCode/subscriber.js +0 -90
  183. package/lib/oldCode/subscriber.js.map +0 -1
  184. package/lib/oldCode/tracer.d.ts +0 -36
  185. package/lib/oldCode/tracer.d.ts.map +0 -1
  186. package/lib/oldCode/tracer.js +0 -161
  187. package/lib/oldCode/tracer.js.map +0 -1
  188. package/lib/oldCode/utils/ImageFixer.d.ts +0 -1
  189. package/lib/oldCode/utils/ImageFixer.d.ts.map +0 -1
  190. package/lib/oldCode/utils/ImageFixer.js +0 -59
  191. package/lib/oldCode/utils/ImageFixer.js.map +0 -1
  192. package/lib/oldCode/webrtc/constants.js +0 -114
  193. package/lib/oldCode/webrtc/constants.js.map +0 -1
  194. package/lib/oldCode/webrtc/helper.js +0 -173
  195. package/lib/oldCode/webrtc/helper.js.map +0 -1
  196. package/lib/oldCode/webrtc/session-kms.js +0 -558
  197. package/lib/oldCode/webrtc/session-kms.js.map +0 -1
  198. package/lib/oldCode/webrtc/session-loopback.js +0 -336
  199. package/lib/oldCode/webrtc/session-loopback.js.map +0 -1
  200. package/lib/oldCode/webrtc/session-turn.js +0 -880
  201. package/lib/oldCode/webrtc/session-turn.js.map +0 -1
  202. package/lib/oldCode/webrtc/session-turn.v2.js +0 -583
  203. package/lib/oldCode/webrtc/session-turn.v2.js.map +0 -1
  204. package/lib/oldCode/webrtc/session.js +0 -52
  205. package/lib/oldCode/webrtc/session.js.map +0 -1
  206. package/lib/oldCode/webrtc/stream.js +0 -674
  207. package/lib/oldCode/webrtc/stream.js.map +0 -1
  208. package/lib/oldCode/webrtc/temasys/adapter-loader.js +0 -12
  209. package/lib/oldCode/webrtc/temasys/adapter-loader.js.map +0 -1
  210. package/lib/oldCode/webrtc/temasys/adapter.js +0 -5861
  211. package/lib/oldCode/webrtc/temasys/adapter.js.map +0 -1
  212. package/lib/oldCode/webrtc/webrtc-ie-shim.js +0 -3007
  213. package/lib/oldCode/webrtc/webrtc-ie-shim.js.map +0 -1
@@ -1,48 +1,44 @@
1
1
  "use strict";
2
-
3
- var __extends = undefined && undefined.__extends || function () {
4
- var _extendStatics = function extendStatics(d, b) {
5
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
6
- d.__proto__ = b;
7
- } || function (d, b) {
8
- for (var p in b) {
9
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
10
- }
11
- };
12
- return _extendStatics(d, b);
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
13
8
  };
14
9
  return function (d, b) {
15
- _extendStatics(d, b);
16
- function __() {
17
- this.constructor = d;
18
- }
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
19
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20
15
  };
21
- }();
22
- var __createBinding = undefined && undefined.__createBinding || (Object.create ? function (o, m, k, k2) {
16
+ })();
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
18
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
25
- return m[k];
26
- } });
27
- } : function (o, m, k, k2) {
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
28
25
  if (k2 === undefined) k2 = k;
29
26
  o[k2] = m[k];
30
- });
31
- var __setModuleDefault = undefined && undefined.__setModuleDefault || (Object.create ? function (o, v) {
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
29
  Object.defineProperty(o, "default", { enumerable: true, value: v });
33
- } : function (o, v) {
30
+ }) : function(o, v) {
34
31
  o["default"] = v;
35
32
  });
36
- var __importStar = undefined && undefined.__importStar || function (mod) {
33
+ var __importStar = (this && this.__importStar) || function (mod) {
37
34
  if (mod && mod.__esModule) return mod;
38
35
  var result = {};
39
- if (mod != null) for (var k in mod) {
40
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41
- }__setModuleDefault(result, mod);
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
42
38
  return result;
43
39
  };
44
- var __importDefault = undefined && undefined.__importDefault || function (mod) {
45
- return mod && mod.__esModule ? mod : { "default": mod };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
42
  };
47
43
  Object.defineProperty(exports, "__esModule", { value: true });
48
44
  exports.TurnWebRtcSession = void 0;
@@ -52,22 +48,19 @@ var MediaConstants_1 = require("../MediaConstants");
52
48
  var TurnConstants_1 = require("./TurnConstants");
53
49
  var MediaTracer_1 = require("../MediaUtils/MediaTracer");
54
50
  var MediaSessionBase_1 = require("./MediaSessionBase");
55
- var trace = MediaTracer_1.getMediaTracer('TurnWebRtcSession');
56
- //Currently this version supports subscribing only. Publishing will be implemented as needed.
57
- var TurnWebRtcSession = /** @class */function (_super) {
51
+ var trace = (0, MediaTracer_1.getMediaTracer)('TurnWebRtcSession');
52
+ var TurnWebRtcSession = (function (_super) {
58
53
  __extends(TurnWebRtcSession, _super);
59
54
  function TurnWebRtcSession(sessionParams, sessionHandlers, streamFactory) {
60
55
  var _this = _super.call(this, sessionParams, streamFactory) || this;
61
56
  _this._sessionHandlers = sessionHandlers;
62
57
  _this._socket = null;
63
58
  _this._pendingPeersIce = {};
64
- var iceServers = sessionParams.credentials.ice.map(function (item) {
65
- return {
66
- urls: item.url,
67
- username: item.login,
68
- credential: item.password
69
- };
70
- });
59
+ var iceServers = sessionParams.credentials.ice.map(function (item) { return ({
60
+ urls: item.url,
61
+ username: item.login,
62
+ credential: item.password
63
+ }); });
71
64
  _this._configuration = {
72
65
  iceServers: iceServers,
73
66
  iceTransportPolicy: 'relay'
@@ -82,26 +75,25 @@ var TurnWebRtcSession = /** @class */function (_super) {
82
75
  return _this;
83
76
  }
84
77
  Object.defineProperty(TurnWebRtcSession.prototype, "id", {
85
- get: function get() {
78
+ get: function () {
86
79
  return this._sessionParams.sessionId;
87
80
  },
88
81
  enumerable: false,
89
82
  configurable: true
90
83
  });
91
- //#region Socket Connectivity
92
84
  TurnWebRtcSession.prototype.connect = function (connectOnly) {
93
85
  var _this = this;
94
- if (connectOnly === void 0) {
95
- connectOnly = false;
96
- }
86
+ if (connectOnly === void 0) { connectOnly = false; }
97
87
  trace.info('Connect to session');
98
- return this._connectSocket(this._sessionParams.credentials.url, connectOnly).then(function () {
88
+ return this._connectSocket(this._sessionParams.credentials.url, connectOnly)
89
+ .then(function () {
99
90
  trace.info('Joining SessionId: ' + _this._sessionParams.sessionId);
100
91
  _this._socket.emit(TurnConstants_1.SOCKET_EVENTS.OUTGOING.JOIN_ROOM, {
101
92
  clientType: _this._sessionParams.clientType,
102
93
  sessionId: _this._sessionParams.sessionId
103
94
  });
104
- }).catch(function (error) {
95
+ })
96
+ .catch(function (error) {
105
97
  throw error;
106
98
  });
107
99
  };
@@ -112,19 +104,17 @@ var TurnWebRtcSession = /** @class */function (_super) {
112
104
  TurnWebRtcSession.prototype._connectSocket = function (url, connectOnly) {
113
105
  var _this = this;
114
106
  return new Promise(function (resolve, reject) {
115
- var socket = _this._socket = io.connect(url, {
116
- 'forceNew': true,
117
- 'reconnectionDelay': TurnConstants_1.SOCKET_RECONNECTION_DELAY,
118
- 'reconnectionDelayMax': TurnConstants_1.SOCKET_RECONNECTION_DELAY_MAX,
119
- 'reconnectionAttempts': TurnConstants_1.SOCKET_RECONNECTION_ATTEMPTS,
120
- 'path': TurnConstants_1.SOCKET_PATH
121
- });
122
- var done = once_1.default(function (err) {
107
+ var socket = (_this._socket = io.connect(url, {
108
+ forceNew: true,
109
+ reconnectionDelay: TurnConstants_1.SOCKET_RECONNECTION_DELAY,
110
+ reconnectionDelayMax: TurnConstants_1.SOCKET_RECONNECTION_DELAY_MAX,
111
+ reconnectionAttempts: TurnConstants_1.SOCKET_RECONNECTION_ATTEMPTS,
112
+ path: TurnConstants_1.SOCKET_PATH
113
+ }));
114
+ var done = (0, once_1.default)(function (err) {
123
115
  err ? reject(err) : resolve();
124
116
  });
125
- socket.once('connect', function () {
126
- return done();
127
- });
117
+ socket.once('connect', function () { return done(); });
128
118
  socket.on(TurnConstants_1.SOCKET_EVENTS.INCOMING.ERROR, done);
129
119
  socket.on('connect_error', done);
130
120
  socket.on('connect_timeout', done);
@@ -142,14 +132,9 @@ var TurnWebRtcSession = /** @class */function (_super) {
142
132
  };
143
133
  TurnWebRtcSession.prototype._onSocketDisconnectedHandler = function (reason) {
144
134
  if (this._socket) {
145
- // The initial example of differentiating between "forced" disconnect and "network" disconnect is taken from:
146
- // https://socket.io/docs/client-api/#Event-%E2%80%98disconnect%E2%80%99
147
135
  if (reason !== 'io server disconnect' && reason !== 'io client disconnect') {
148
136
  trace.info('_onSocketDisconnectedHandler disconnect from session', MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect);
149
- // the disconnection was initiated by the server or by client, you need to call (connect) manually
150
- this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect).catch(function () {
151
- return undefined;
152
- });
137
+ this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.SignalingChannelDisconnect).catch(function () { return undefined; });
153
138
  }
154
139
  }
155
140
  };
@@ -159,12 +144,12 @@ var TurnWebRtcSession = /** @class */function (_super) {
159
144
  trace.info('replaceStreamTracks - Replace local tracks to peer connection');
160
145
  this._peerConnections.forEach(function (peerConnection) {
161
146
  mediaStream.getTracks().forEach(function (track) {
162
- var sender = peerConnection.getSenders().find(function (s) {
163
- return s.track.kind === track.kind;
164
- });
147
+ var sender = peerConnection.getSenders().find(function (s) { return s.track.kind === track.kind; });
165
148
  if (sender) {
166
- promises.push(sender.replaceTrack(track).then(function () {
167
- return trace.info("replaceStreamTracks - Local " + track.kind + " " + track.id + " track replace to peer connection");
149
+ promises.push(sender
150
+ .replaceTrack(track)
151
+ .then(function () {
152
+ return trace.info("replaceStreamTracks - Local ".concat(track.kind, " ").concat(track.id, " track replace to peer connection"));
168
153
  }));
169
154
  }
170
155
  });
@@ -175,33 +160,29 @@ var TurnWebRtcSession = /** @class */function (_super) {
175
160
  trace.info('replaceStreamTracks: replace stream tracks - Success');
176
161
  });
177
162
  };
178
- //#endregion
179
- //#region WebRTC Initiator - session Initiator (User on mobile device)
180
- // Received by Initiator, causing him to emit SDP_OFFER
181
163
  TurnWebRtcSession.prototype._sendOfferHandler = function (sendOfferEventData) {
182
164
  var _this = this;
183
- var uid = sendOfferEventData.uid,
184
- peerId = sendOfferEventData.peerId;
165
+ var uid = sendOfferEventData.uid, peerId = sendOfferEventData.peerId;
185
166
  trace.info('_sendOfferHandler');
186
- //Currently we not support of passing role through signaling, so we assume every connection is "AGENT" like
187
167
  var peerConnection = this._createPeerConnection(peerId, MediaConstants_1.SessionClientType.GUEST, MediaConstants_1.SessionClientRole.AGENT);
188
168
  var offerParams = { offerToReceiveAudio: true, offerToReceiveVideo: true };
189
- //TODO - Alex: Currently we not sending "role" through signaling, and by default we assume that the one who asks fot offer, is agent.
190
- //On later stages we can send or the client "role" or the list of "streams" that peer is interested in.
191
- this._sessionStreamsManager.getMediaStreamForRole(MediaConstants_1.SessionClientRole.AGENT).then(function (mediaStream) {
169
+ this._sessionStreamsManager
170
+ .getMediaStreamForRole(MediaConstants_1.SessionClientRole.AGENT)
171
+ .then(function (mediaStream) {
192
172
  trace.info('_sendOfferHandler stream and peer created');
193
173
  if (mediaStream) {
194
174
  trace.info('Adding local tracks to peer connection for sending offer');
195
175
  mediaStream.getTracks().forEach(function (track) {
196
176
  peerConnection.addTrack(track, mediaStream);
197
- trace.info("Local " + track.kind + " " + track.id + " track added to peer connection");
177
+ trace.info("Local ".concat(track.kind, " ").concat(track.id, " track added to peer connection"));
198
178
  });
199
- } else {
179
+ }
180
+ else {
200
181
  trace.info('No media stream was found for publishing');
201
182
  }
202
- }).then(function () {
203
- return peerConnection.createOffer(offerParams);
204
- }).then(function (offerDesc) {
183
+ })
184
+ .then(function () { return peerConnection.createOffer(offerParams); })
185
+ .then(function (offerDesc) {
205
186
  trace.info('Initiator has created sdp offer', { offerDesc: offerDesc });
206
187
  _this._socket.emit(TurnConstants_1.SOCKET_EVENTS.OUTGOING.SDP_OFFER, {
207
188
  uid: uid,
@@ -212,68 +193,65 @@ var TurnWebRtcSession = /** @class */function (_super) {
212
193
  return peerConnection.setLocalDescription(offerDesc).then(function () {
213
194
  trace.info('Local description was set on peerConnection', peerConnection);
214
195
  _this._setPeerConnectionMonitor(peerConnection);
215
- // make sure using the tracks of the last stream that used
216
196
  if (window.latestUserMediaStream && window.mediaStreamAlreadyReplaced) {
217
197
  _this.replaceStreamTracks(window.latestUserMediaStream.mediaStream).catch(function (e) {
218
198
  return trace.warn('_sendOfferHandler - Failed to replaceStreamTrace', e);
219
199
  });
220
200
  }
221
201
  });
222
- }).catch(function (e) {
202
+ })
203
+ .catch(function (e) {
223
204
  trace.warn('Error', e);
224
205
  });
225
206
  };
226
- // Received by the Initiator: Indicates that publish should be started
227
207
  TurnWebRtcSession.prototype._joinResponseHandler = function (joinResponseData) {
228
208
  var _this = this;
229
- var sdpAnswer = joinResponseData.sdpAnswer,
230
- uid = joinResponseData.uid,
231
- peerId = joinResponseData.peerId;
209
+ var sdpAnswer = joinResponseData.sdpAnswer, uid = joinResponseData.uid, peerId = joinResponseData.peerId;
232
210
  trace.info('joinResponse Received', { sdpAnswer: sdpAnswer });
233
211
  this._withPeerConnection(peerId, function (peerConnection) {
234
212
  var answer = new RTCSessionDescription({
235
213
  type: 'answer',
236
214
  sdp: sdpAnswer
237
215
  });
238
- peerConnection.setRemoteDescription(answer).then(function () {
216
+ peerConnection
217
+ .setRemoteDescription(answer)
218
+ .then(function () {
239
219
  trace.info('Remote description was set', answer);
240
220
  _this._processQueuedIceCandidates(peerId);
241
- }).catch(function (e) {
221
+ })
222
+ .catch(function (e) {
242
223
  trace.warn('Error', e);
243
224
  });
244
225
  });
245
226
  };
246
- // Received by Initiator after a guests socket has been disconnected
247
227
  TurnWebRtcSession.prototype._peerDisconnectedHandler = function (peerDisconnectedEvent) {
248
228
  var _this = this;
249
229
  var peerId = peerDisconnectedEvent.peerId;
250
230
  trace.info('_peerDisconnectedHandler');
251
231
  this._withPeerConnection(peerId, function (peerConnection) {
252
232
  _this._destroyPeerConnection(peerConnection);
253
- //this._disconnectInternal(MediaSessionDisconnectReason.PeerDisconnected).catch(() => undefined);
254
233
  });
255
234
  };
256
- //#endregion WebRTC Initiator - session Initiator (User on mobile device)
257
- //#region WebRTC Guest - session Guest (Agent on dashboard platform)
258
- // Received by Guest, causing him to emit SDP_ANSWER
259
235
  TurnWebRtcSession.prototype._sdpOfferHandler = function (sdpOfferEvent) {
260
236
  var _this = this;
261
- var sdpOffer = sdpOfferEvent.sdpOffer,
262
- peerId = sdpOfferEvent.peerId,
263
- uid = sdpOfferEvent.uid;
237
+ var sdpOffer = sdpOfferEvent.sdpOffer, peerId = sdpOfferEvent.peerId, uid = sdpOfferEvent.uid;
264
238
  trace.info('sdpOffer Received', { sdpOffer: sdpOffer });
265
239
  var peerConnection = this._createPeerConnection(peerId, MediaConstants_1.SessionClientType.INITIATOR, MediaConstants_1.SessionClientRole.USER);
266
- this._sessionStreamsManager.getMediaStreamForRole(MediaConstants_1.SessionClientRole.USER).then(function (mediaStream) {
240
+ this._sessionStreamsManager
241
+ .getMediaStreamForRole(MediaConstants_1.SessionClientRole.USER)
242
+ .then(function (mediaStream) {
267
243
  if (mediaStream) {
268
244
  trace.info('Adding local tracks to peer connection offer handler');
269
245
  mediaStream.getTracks().forEach(function (track) {
270
246
  peerConnection.addTrack(track, mediaStream);
271
- trace.info("Local " + track.kind + " track added to peer connection");
247
+ trace.info("Local ".concat(track.kind, " track added to peer connection"));
272
248
  });
273
- } else {
249
+ }
250
+ else {
274
251
  trace.info('No media stream was found for publishing');
275
252
  }
276
- }).then(function () {
253
+ })
254
+ .then(function () {
277
255
  var remoteDesc = new RTCSessionDescription({ type: 'offer', sdp: sdpOffer });
278
256
  return peerConnection.setRemoteDescription(remoteDesc).then(function () {
279
257
  trace.info('Remote description was set', remoteDesc);
@@ -292,34 +270,27 @@ var TurnWebRtcSession = /** @class */function (_super) {
292
270
  });
293
271
  });
294
272
  });
295
- }).catch(function (e) {
273
+ })
274
+ .catch(function (e) {
296
275
  trace.error('Error in _sdpOfferHandler', e);
297
276
  throw e;
298
277
  });
299
278
  };
300
- // Received by Guest after an Initiator reconnects to room
301
279
  TurnWebRtcSession.prototype._initiatorPeerReconnectHandler = function () {
302
280
  trace.info('_initiatorPeerReconnectHandler disconnect from session', MediaConstants_1.MediaSessionDisconnectReason.InitiatorPeerReconnected);
303
281
  this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.InitiatorPeerReconnected).catch(function (error) {
304
282
  trace.warn('Error while disconnecting during userPeerReconnectHandler.', error);
305
283
  });
306
284
  };
307
- //#endregion WebRTC Guest - session Guest (Agent on dashboard platform)
308
- //#region Peer Connection
309
- //#region Streams Handling
310
285
  TurnWebRtcSession.prototype.onMediaStreamDestroyed = function (clientRole) {
311
286
  var _this = this;
312
- //TODO - Alex: need to implement adding new tracks to peer connection and forcing negotiation
313
287
  trace.info('onMediaStreamDestroyed disconnect all peer connections from session', MediaConstants_1.MediaSessionDisconnectReason.PublishedStreamDestroyed);
314
288
  this._peerConnections.forEach(function (peerConnection) {
315
- _this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PublishedStreamDestroyed).catch(function () {
316
- return undefined;
317
- });
289
+ _this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PublishedStreamDestroyed).catch(function () { return undefined; });
318
290
  });
319
291
  return Promise.resolve();
320
292
  };
321
293
  TurnWebRtcSession.prototype.onMediaStreamRenewed = function (clientRole, mediaStream) {
322
- //TODO - Alex: need to implement adding new tracks to peer connection and forcing negotiation
323
294
  return Promise.resolve();
324
295
  };
325
296
  TurnWebRtcSession.prototype.getRemoteTrackStats = function (mediaTrack) {
@@ -329,7 +300,6 @@ var TurnWebRtcSession = /** @class */function (_super) {
329
300
  }
330
301
  return Promise.reject(new Error('Provided track is not remote track'));
331
302
  };
332
- //#endregion
333
303
  TurnWebRtcSession.prototype._disconnectInternal = function (reason) {
334
304
  var _this = this;
335
305
  this._peerConnections.forEach(function (peerConnection) {
@@ -339,16 +309,14 @@ var TurnWebRtcSession = /** @class */function (_super) {
339
309
  trace.info('Disconnecting from session', reason);
340
310
  this.sessionDisconnect();
341
311
  this._socket = null;
342
- setTimeout(function () {
343
- return _this._sessionHandlers.onDisconnectedHandler(reason);
344
- });
312
+ setTimeout(function () { return _this._sessionHandlers.onDisconnectedHandler(reason); });
345
313
  }
346
314
  return Promise.resolve();
347
315
  };
348
316
  TurnWebRtcSession.prototype._createPeerConnection = function (peerId, peerConnectionType, peerConnectionRole) {
349
317
  var _this = this;
350
318
  if (this._peerConnections.get(peerId)) {
351
- throw new Error(this._sessionParams.clientType + " peer connection for " + peerId + " already exists");
319
+ throw new Error("".concat(this._sessionParams.clientType, " peer connection for ").concat(peerId, " already exists"));
352
320
  }
353
321
  var peerConnection = new RTCPeerConnection(this._configuration);
354
322
  peerConnection.peerId = peerId;
@@ -360,38 +328,40 @@ var TurnWebRtcSession = /** @class */function (_super) {
360
328
  trace.info('onconnectionstatechange', peerConnection);
361
329
  };
362
330
  peerConnection.oniceconnectionstatechange = function (state) {
363
- trace.info("ICE Connection state for peer " + peerId + " was changed to: " + state.currentTarget.iceConnectionState, state);
331
+ trace.info("ICE Connection state for peer ".concat(peerId, " was changed to: ").concat(state.currentTarget.iceConnectionState), state);
364
332
  var cnState = state.currentTarget.iceConnectionState;
365
333
  clearTimeout(peerConnection.connectionTimoutPrt);
366
334
  if (['closed', 'disconnected', 'failed'].indexOf(cnState) > -1) {
367
335
  _this._iceStateDisconnected(peerConnection);
368
- } else if (cnState === 'connected') {
336
+ }
337
+ else if (cnState === 'connected') {
369
338
  _this.registerPeersRemoteTracks(peerConnection);
370
339
  }
371
340
  };
372
341
  peerConnection.onicecandidate = function (event) {
373
342
  if (event.candidate) {
374
- trace.info(_this._sessionParams.clientType + " peerConn.onicecandidate", event.candidate);
343
+ trace.info("".concat(_this._sessionParams.clientType, " peerConn.onicecandidate"), event.candidate);
375
344
  _this._socket.emit(TurnConstants_1.SOCKET_EVENTS.OUTGOING.ICE_CANDIDATE, {
376
345
  sessionId: _this._sessionParams.sessionId,
377
346
  peerId: peerId,
378
347
  candidate: event.candidate,
379
348
  clientType: _this._sessionParams.clientType
380
349
  });
381
- } else {
350
+ }
351
+ else {
382
352
  trace.info('ICE Candidate is null in peerConnection', event);
383
353
  }
384
354
  };
385
355
  peerConnection.ontrack = function (trackEvent) {
386
356
  var track = trackEvent.track;
387
- trace.info("MediaStreamTrack arrived from peerConnection: " + track.kind, track);
357
+ trace.info("MediaStreamTrack arrived from peerConnection: ".concat(track.kind), track);
388
358
  _this.addRemoteTrackToPeer(peerConnection, track);
389
359
  if (peerConnection.connectionState === 'connected') {
390
360
  _this.registerPeersRemoteTracks(peerConnection);
391
361
  }
392
362
  };
393
363
  this._peerConnections.set(peerId, peerConnection);
394
- trace.info(peerConnectionType + " peerConnection created");
364
+ trace.info("".concat(peerConnectionType, " peerConnection created"));
395
365
  return peerConnection;
396
366
  };
397
367
  TurnWebRtcSession.prototype._setPeerConnectionMonitor = function (peerConnection) {
@@ -405,9 +375,7 @@ var TurnWebRtcSession = /** @class */function (_super) {
405
375
  TurnWebRtcSession.prototype._handlePeerConnectionTimeout = function (peerConnection) {
406
376
  trace.info('_handlePeerConnectionTimeout disconnect from session', MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout);
407
377
  if (peerConnection.peerRole === MediaConstants_1.SessionClientRole.USER) {
408
- this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout).catch(function () {
409
- return undefined;
410
- });
378
+ this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionStateChangeTimeout).catch(function () { return undefined; });
411
379
  }
412
380
  };
413
381
  TurnWebRtcSession.prototype._destroyPeerConnection = function (peerConnection) {
@@ -418,9 +386,7 @@ var TurnWebRtcSession = /** @class */function (_super) {
418
386
  peerConnection.oniceconnectionstatechange = null;
419
387
  peerConnection.onicegatheringstatechange = null;
420
388
  clearTimeout(peerConnection.connectionTimoutPrt);
421
- this.unregisterPeersRemoteMediaTracks(peerConnection).catch(function () {
422
- return undefined;
423
- });
389
+ this.unregisterPeersRemoteMediaTracks(peerConnection).catch(function () { return undefined; });
424
390
  this._peerConnections.delete(peerConnection.peerId);
425
391
  peerConnection.close();
426
392
  };
@@ -430,11 +396,8 @@ var TurnWebRtcSession = /** @class */function (_super) {
430
396
  }
431
397
  return undefined;
432
398
  };
433
- //#endregion
434
- //#region ICE Candidates
435
399
  TurnWebRtcSession.prototype._iceCandidateReceivedHandler = function (iceCandidateData) {
436
- var candidate = iceCandidateData.candidate,
437
- peerId = iceCandidateData.peerId;
400
+ var candidate = iceCandidateData.candidate, peerId = iceCandidateData.peerId;
438
401
  trace.info('_iceCandidateReceivedHandler', candidate);
439
402
  if (!candidate) {
440
403
  trace.info('Unexpected case, iceCandidate message arrived without candidate');
@@ -447,14 +410,15 @@ var TurnWebRtcSession = /** @class */function (_super) {
447
410
  return;
448
411
  }
449
412
  trace.info('Going to add iceCandidate', candidate);
450
- this._addIceCandidateToPeer(candidate, peerConnection).catch(function () {
451
- return undefined;
452
- });
413
+ this._addIceCandidateToPeer(candidate, peerConnection).catch(function () { return undefined; });
453
414
  };
454
415
  TurnWebRtcSession.prototype._addIceCandidateToPeer = function (iceCandidate, peerConnection) {
455
- return peerConnection.addIceCandidate(iceCandidate).then(function () {
416
+ return peerConnection
417
+ .addIceCandidate(iceCandidate)
418
+ .then(function () {
456
419
  trace.info('ICE Candidate add to peer connection');
457
- }).catch(function (e) {
420
+ })
421
+ .catch(function (e) {
458
422
  trace.warn('Error adding ICE Candidate to peer connection', e);
459
423
  throw e;
460
424
  });
@@ -466,11 +430,10 @@ var TurnWebRtcSession = /** @class */function (_super) {
466
430
  if (pendingIces) {
467
431
  pendingIces.forEach(function (pendingIce) {
468
432
  trace.info('Adding pending ICE to peer connections');
469
- _this._addIceCandidateToPeer(pendingIce, peerConnection).catch(function () {
470
- return undefined;
471
- });
433
+ _this._addIceCandidateToPeer(pendingIce, peerConnection).catch(function () { return undefined; });
472
434
  });
473
- } else {
435
+ }
436
+ else {
474
437
  trace.info('No pending ICE found for peer', peerId);
475
438
  }
476
439
  });
@@ -483,11 +446,8 @@ var TurnWebRtcSession = /** @class */function (_super) {
483
446
  };
484
447
  TurnWebRtcSession.prototype._iceStateDisconnected = function (peerConnection) {
485
448
  trace.info('_iceStateDisconnected disconnect from session', MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted);
486
- this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted).catch(function () {
487
- return undefined;
488
- });
449
+ this._disconnectInternal(MediaConstants_1.MediaSessionDisconnectReason.PeerConnectionInterrupted).catch(function () { return undefined; });
489
450
  };
490
- //#endregion
491
451
  TurnWebRtcSession.prototype.sessionDisconnect = function () {
492
452
  if (this._socket) {
493
453
  this._socket.off();
@@ -495,8 +455,6 @@ var TurnWebRtcSession = /** @class */function (_super) {
495
455
  }
496
456
  };
497
457
  return TurnWebRtcSession;
498
- }(MediaSessionBase_1.MediaSessionBase);
458
+ }(MediaSessionBase_1.MediaSessionBase));
499
459
  exports.TurnWebRtcSession = TurnWebRtcSession;
500
-
501
- //# sourceMappingURL=SessionTurn.js.map
502
- //# sourceMappingURL=SessionTurn.js.map
460
+ //# sourceMappingURL=SessionTurn.js.map