@flashphoner/websdk 2.0.208 → 2.0.212

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 (38) hide show
  1. package/docTemplate/README.md +1 -1
  2. package/examples/demo/streaming/2players/2players.js +0 -5
  3. package/examples/demo/streaming/canvas_streaming/canvas_streaming.js +0 -12
  4. package/examples/demo/streaming/conference/conference.html +6 -0
  5. package/examples/demo/streaming/conference/conference.js +83 -23
  6. package/examples/demo/streaming/embed_player/player.js +127 -198
  7. package/examples/demo/streaming/firewall-traversal-streaming/firewall-traversal-streaming.js +0 -12
  8. package/examples/demo/streaming/mcu_client/mcu_client.js +0 -8
  9. package/examples/demo/streaming/media_devices_manager/manager.js +0 -12
  10. package/examples/demo/streaming/player/player.js +10 -9
  11. package/examples/demo/streaming/stream-auto-restore/stream-auto-restore.html +77 -1
  12. package/examples/demo/streaming/stream-auto-restore/stream-auto-restore.js +472 -84
  13. package/examples/demo/streaming/stream-diagnostic/stream-diagnostic.js +0 -8
  14. package/examples/demo/streaming/stream-local-snapshot/stream-local-snapshot.js +0 -6
  15. package/examples/demo/streaming/stream-snapshot/stream-snapshot.js +0 -6
  16. package/examples/demo/streaming/stream_recording/recording.js +0 -6
  17. package/examples/demo/streaming/streamer/streamer.js +0 -8
  18. package/examples/demo/streaming/two_way_streaming/two_way_streaming.js +0 -11
  19. package/examples/demo/streaming/webrtc-as-rtmp-republishing/webrtc-as-rtmp-republishing.js +0 -6
  20. package/flashphoner-no-flash.js +118 -14
  21. package/flashphoner-no-flash.min.js +2 -2
  22. package/flashphoner-no-webrtc.js +89 -5
  23. package/flashphoner-no-webrtc.min.js +1 -1
  24. package/flashphoner-no-wsplayer.js +118 -14
  25. package/flashphoner-no-wsplayer.min.js +2 -2
  26. package/flashphoner-room-api.js +104 -9
  27. package/flashphoner-room-api.min.js +2 -2
  28. package/flashphoner-temasys-flash-websocket-without-adapterjs.js +89 -5
  29. package/flashphoner-temasys-flash-websocket.js +89 -5
  30. package/flashphoner-temasys-flash-websocket.min.js +1 -1
  31. package/flashphoner-webrtc-only.js +118 -14
  32. package/flashphoner-webrtc-only.min.js +1 -1
  33. package/flashphoner.js +118 -14
  34. package/flashphoner.min.js +2 -2
  35. package/package.json +1 -1
  36. package/src/flashphoner-core.d.ts +22 -5
  37. package/src/flashphoner-core.js +79 -3
  38. package/src/webrtc-media-provider.js +25 -6
@@ -45,14 +45,6 @@ function onStopped() {
45
45
 
46
46
  function publishBtnClick() {
47
47
  $(this).prop('disabled', true);
48
- if (Browser.isSafariWebRTC()) {
49
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function () {
50
- Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(function () {
51
- start();
52
- });
53
- });
54
- return;
55
- }
56
48
  start();
57
49
  }
58
50
 
@@ -113,12 +113,6 @@ function onUnpublished() {
113
113
 
114
114
  function publishBtnClick() {
115
115
  $(this).prop('disabled', true);
116
- if (Browser.isSafariWebRTC()) {
117
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
118
- start()
119
- });
120
- return;
121
- }
122
116
  start()
123
117
  }
124
118
 
@@ -64,12 +64,6 @@ function onUnpublished() {
64
64
 
65
65
  function publishBtnClick() {
66
66
  $(this).prop('disabled', true);
67
- if (Browser.isSafariWebRTC()) {
68
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
69
- start()
70
- });
71
- return;
72
- }
73
67
  start()
74
68
  }
75
69
 
@@ -40,12 +40,6 @@ function publishBtnClick() {
40
40
  $(this).prop('disabled', true);
41
41
  $('#url').prop('disabled', true);
42
42
  $("#downloadDiv").hide();
43
- if (Browser.isSafariWebRTC()) {
44
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
45
- startRecording();
46
- });
47
- return;
48
- }
49
43
  startRecording();
50
44
  }
51
45
  }
@@ -40,14 +40,6 @@ function onStopped() {
40
40
 
41
41
  function publishBtnClick() {
42
42
  $(this).prop('disabled', true);
43
- if (Browser.isSafariWebRTC()) {
44
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
45
- Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(function() {
46
- start();
47
- });
48
- });
49
- return;
50
- }
51
43
  start();
52
44
  }
53
45
 
@@ -103,12 +103,6 @@ function publishBtnClick() {
103
103
  if (validateForm("streamerForm")) {
104
104
  $('#publishStream').prop('disabled', true);
105
105
  $(this).prop('disabled', true);
106
- if (Browser.isSafariWebRTC()) {
107
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
108
- publishStream();
109
- });
110
- return;
111
- }
112
106
  publishStream();
113
107
  }
114
108
  }
@@ -145,11 +139,6 @@ function playBtnClick() {
145
139
  $(this).prop('disabled', true);
146
140
  if (Flashphoner.getMediaProviders()[0] === "WSPlayer") {
147
141
  Flashphoner.playFirstSound();
148
- } else if (Browser.isSafariWebRTC() || Flashphoner.getMediaProviders()[0] === "MSE") {
149
- Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(function () {
150
- playStream();
151
- });
152
- return;
153
142
  }
154
143
  playStream();
155
144
  }
@@ -43,12 +43,6 @@ function onStopped() {
43
43
  function publishBtnClick() {
44
44
  if (validateForm()) {
45
45
  $(this).prop('disabled', true);
46
- if (Browser.isSafariWebRTC()) {
47
- Flashphoner.playFirstVideo(localVideo, true, PRELOADER_URL).then(function() {
48
- start();
49
- });
50
- return;
51
- }
52
46
  start();
53
47
  }
54
48
  }
@@ -10001,6 +10001,9 @@ var getSession = function getSession(id) {
10001
10001
  * @param {Object=} options.sipOptions Sip configuration
10002
10002
  * @param {Object=} options.mediaOptions Media connection configuration
10003
10003
  * @param {Integer=} options.timeout Connection timeout in milliseconds
10004
+ * @param {Integer=} options.pingInterval Server ping interval in milliseconds [0]
10005
+ * @param {Integer=} options.receiveProbes A maximum subsequental pings received missing count [0]
10006
+ * @param {Integer=} options.probesInterval Interval to check subsequental pings received [0]
10004
10007
  * @returns {Session} Created session
10005
10008
  * @throws {Error} Error if API is not initialized
10006
10009
  * @throws {TypeError} Error if options.urlServer is not specified
@@ -10027,6 +10030,8 @@ var createSession = function createSession(options) {
10027
10030
  var mediaOptions = options.mediaOptions;
10028
10031
  var keepAlive = options.keepAlive;
10029
10032
  var timeout = options.timeout;
10033
+ var wsPingSender = new WSPingSender(options.pingInterval || 0);
10034
+ var wsPingReceiver = new WSPingReceiver(options.receiveProbes || 0, options.probesInterval || 0);
10030
10035
  var connectionTimeout;
10031
10036
  var cConfig; //SIP config
10032
10037
 
@@ -10144,7 +10149,7 @@ var createSession = function createSession(options) {
10144
10149
  mediaProviders: Object.keys(MediaProvider),
10145
10150
  keepAlive: keepAlive,
10146
10151
  authToken: authToken,
10147
- clientVersion: "2.0.208",
10152
+ clientVersion: "2.0.212",
10148
10153
  clientOSVersion: window.navigator.appVersion,
10149
10154
  clientBrowserVersion: window.navigator.userAgent,
10150
10155
  msePacketizationVersion: 2,
@@ -10157,7 +10162,11 @@ var createSession = function createSession(options) {
10157
10162
 
10158
10163
 
10159
10164
  send("connection", cConfig);
10160
- logger.setConnection(wsConnection);
10165
+ logger.setConnection(wsConnection); // Send ping messages to server to check if connection is still alive #WCS-3410
10166
+
10167
+ wsPingSender.start(); // Check subsequintel pings received from server to check if connection is still alive #WCS-3410
10168
+
10169
+ wsPingReceiver.start();
10161
10170
  };
10162
10171
 
10163
10172
  wsConnection.onmessage = function (event) {
@@ -10173,6 +10182,7 @@ var createSession = function createSession(options) {
10173
10182
  switch (data.message) {
10174
10183
  case 'ping':
10175
10184
  send("pong", null);
10185
+ wsPingReceiver.success();
10176
10186
  break;
10177
10187
 
10178
10188
  case 'getUserData':
@@ -10332,7 +10342,11 @@ var createSession = function createSession(options) {
10332
10342
  sessionStatus = newStatus;
10333
10343
 
10334
10344
  if (sessionStatus == SESSION_STATUS.DISCONNECTED || sessionStatus == SESSION_STATUS.FAILED) {
10335
- //remove streams
10345
+ // Stop pinging server #WCS-3410
10346
+ wsPingSender.stop(); // Stop checking pings received #WCS-3410
10347
+
10348
+ wsPingReceiver.stop(); //remove streams
10349
+
10336
10350
  for (var prop in streamRefreshHandlers) {
10337
10351
  if (streamRefreshHandlers.hasOwnProperty(prop) && typeof streamRefreshHandlers[prop] === 'function') {
10338
10352
  streamRefreshHandlers[prop]({
@@ -10348,6 +10362,73 @@ var createSession = function createSession(options) {
10348
10362
  if (callbacks[sessionStatus]) {
10349
10363
  callbacks[sessionStatus](session, obj);
10350
10364
  }
10365
+ } // Websocket periodic ping sender
10366
+
10367
+
10368
+ function WSPingSender(interval) {
10369
+ this.interval = interval || 0;
10370
+ this.intervalId = null;
10371
+
10372
+ this.start = function () {
10373
+ if (this.interval > 0) {
10374
+ this.intervalId = setInterval(function () {
10375
+ send("ping", null);
10376
+ }, this.interval);
10377
+ }
10378
+ };
10379
+
10380
+ this.stop = function () {
10381
+ if (this.intervalId) {
10382
+ clearInterval(this.intervalId);
10383
+ }
10384
+ };
10385
+
10386
+ return this;
10387
+ } // Websocket ping receive prober
10388
+
10389
+
10390
+ function WSPingReceiver(receiveProbes, probesInterval) {
10391
+ this.maxPings = receiveProbes || 0;
10392
+ this.interval = probesInterval || 0;
10393
+ this.intervalId = null;
10394
+ this.pingsMissing = 0;
10395
+
10396
+ this.start = function () {
10397
+ if (this.maxPings > 0 && this.interval > 0) {
10398
+ var receiver = this;
10399
+ this.intervalId = setInterval(function () {
10400
+ receiver.checkPingsReceived();
10401
+ }, this.interval);
10402
+ }
10403
+ };
10404
+
10405
+ this.stop = function () {
10406
+ if (this.intervalId) {
10407
+ clearInterval(this.intervalId);
10408
+ }
10409
+
10410
+ this.pingsMissing = 0;
10411
+ };
10412
+
10413
+ this.checkPingsReceived = function () {
10414
+ this.pingsMissing++;
10415
+
10416
+ if (this.pingsMissing >= this.maxPings) {
10417
+ this.failure();
10418
+ }
10419
+ };
10420
+
10421
+ this.success = function () {
10422
+ this.pingsMissing = 0;
10423
+ };
10424
+
10425
+ this.failure = function () {
10426
+ logger.info(LOG_PREFIX, "Missing " + this.pingsMissing + " pings from server, connection seems to be down");
10427
+ onSessionStatusChange(SESSION_STATUS.FAILED);
10428
+ wsConnection.close();
10429
+ };
10430
+
10431
+ return this;
10351
10432
  }
10352
10433
  /**
10353
10434
  * @callback sdpHook
@@ -11212,7 +11293,7 @@ var createSession = function createSession(options) {
11212
11293
  * @param {HTMLElement} options.display Div element stream should be displayed in
11213
11294
  * @param {Object=} options.custom User provided custom object that will be available in REST App code
11214
11295
  * @param {Integer} [options.flashBufferTime=0] Specifies how long to buffer messages before starting to display the stream (Flash-only)
11215
- * @param {String=} options.stripCodecs Comma separated string of codecs which should be stripped from WebRTC SDP (ex. "H264,PCMA,PCMU,G722")
11296
+ * @param {string=} options.stripCodecs Comma separated string of codecs which should be stripped from WebRTC SDP (ex. "H264,PCMA,PCMU,G722")
11216
11297
  * @param {string=} options.rtmpUrl Rtmp url stream should be forwarded to
11217
11298
  * @param {Object=} options.mediaConnectionConstraints Stream specific constraints for underlying RTCPeerConnection
11218
11299
  * @param {Boolean=} options.flashShowFullScreenButton Show full screen button in flash
@@ -11221,6 +11302,7 @@ var createSession = function createSession(options) {
11221
11302
  * @param {Integer=} options.playoutDelay Time delay between network reception of media and playout
11222
11303
  * @param {string=} options.useCanvasMediaStream EXPERIMENTAL: when publish bind browser's media stream to the canvas. It can be useful for image filtering
11223
11304
  * @param {string=} options.videoContentHint Video content hint for browser ('detail' by default to maintain resolution), {@link Flashphoner.constants.CONTENT_HINT_TYPE}
11305
+ * @param {Boolean=} options.unmutePlayOnStart Unmute playback on start. May be used after user gesture only, so set 'unmutePlayOnStart: false' for autoplay
11224
11306
  * @param {sdpHook} sdpHook The callback that handles sdp from the server
11225
11307
  * @returns {Stream} Stream
11226
11308
  * @throws {TypeError} Error if no options provided
@@ -11332,6 +11414,7 @@ var createSession = function createSession(options) {
11332
11414
  var playoutDelay = options.playoutDelay;
11333
11415
  var useCanvasMediaStream = options.useCanvasMediaStream;
11334
11416
  var videoContentHint = options.videoContentHint;
11417
+ var unmutePlayOnStart = options.unmutePlayOnStart;
11335
11418
  var audioState_;
11336
11419
  var videoState_;
11337
11420
  var connectionQuality;
@@ -11508,7 +11591,8 @@ var createSession = function createSession(options) {
11508
11591
  connectionConstraints: mediaConnectionConstraints,
11509
11592
  audioOutputId: audioOutputId,
11510
11593
  remoteVideo: remoteVideo,
11511
- playoutDelay: playoutDelay
11594
+ playoutDelay: playoutDelay,
11595
+ unmutePlayOnStart: unmutePlayOnStart
11512
11596
  }, streamRefreshHandlers[id_]).then(function (newConnection) {
11513
11597
  mediaConnection = newConnection;
11514
11598
 
@@ -13036,7 +13120,9 @@ var createConnection = function createConnection(options) {
13036
13120
  var screenShare = false;
13037
13121
  var playoutDelay = options.playoutDelay; // Set video track contentHint to `detail` by default to workaround Chromium 91 bug #WCS-3257
13038
13122
 
13039
- var videoContentHint = options.videoContentHint ? options.videoContentHint : 'detail';
13123
+ var videoContentHint = options.videoContentHint ? options.videoContentHint : 'detail'; // Pass the option to unmute automatically (true by default) #WCS-2425
13124
+
13125
+ var unmutePlayOnStart = options.unmutePlayOnStart !== undefined ? options.unmutePlayOnStart : true;
13040
13126
 
13041
13127
  if (bidirectional) {
13042
13128
  localVideo = getCacheInstance(localDisplay);
@@ -13055,7 +13141,7 @@ var createConnection = function createConnection(options) {
13055
13141
  remoteVideo = getCacheInstance(remoteDisplay);
13056
13142
 
13057
13143
  if (!remoteVideo) {
13058
- remoteVideo = document.createElement('video');
13144
+ remoteVideo = createVideoElement();
13059
13145
  remoteDisplay.appendChild(remoteVideo);
13060
13146
  }
13061
13147
 
@@ -13080,7 +13166,7 @@ var createConnection = function createConnection(options) {
13080
13166
  if (cachedVideo) {
13081
13167
  remoteVideo = cachedVideo;
13082
13168
  } else {
13083
- remoteVideo = document.createElement('video');
13169
+ remoteVideo = createVideoElement();
13084
13170
  display.appendChild(remoteVideo);
13085
13171
  }
13086
13172
 
@@ -13144,7 +13230,12 @@ var createConnection = function createConnection(options) {
13144
13230
 
13145
13231
  remoteVideo.onloadedmetadata = function (e) {
13146
13232
  if (remoteVideo) {
13147
- remoteVideo.play()["catch"](function (e) {
13233
+ remoteVideo.play().then(function () {
13234
+ // Automatically unmute video if needed #WCS-2425
13235
+ if (unmutePlayOnStart) {
13236
+ remoteVideo.muted = false;
13237
+ }
13238
+ })["catch"](function (e) {
13148
13239
  if (validBrowsers.includes(browserDetails.browser)) {
13149
13240
  //WCS-1698. fixed autoplay in chromium based browsers
13150
13241
  //WCS-2375. fixed autoplay in ios safari
@@ -13913,14 +14004,12 @@ var loadOrdinaryVideo = function loadOrdinaryVideo(display, stream, screenShare,
13913
14004
  var vEl = video;
13914
14005
 
13915
14006
  if (!vEl) {
13916
- vEl = document.createElement('video');
14007
+ vEl = createVideoElement();
13917
14008
  display.appendChild(vEl);
13918
14009
  }
13919
14010
 
13920
14011
  vEl.id = uuid_v1() + LOCAL_CACHED_VIDEO;
13921
- vEl.srcObject = stream; //mute audio
13922
-
13923
- vEl.muted = true;
14012
+ vEl.srcObject = stream;
13924
14013
 
13925
14014
  vEl.onloadedmetadata = function (e) {
13926
14015
  //WCS-2751 Add screen capture using getDisplayMedia in Safari
@@ -14296,6 +14385,19 @@ function getCacheInstance(display) {
14296
14385
  }
14297
14386
  }
14298
14387
 
14388
+ function createVideoElement() {
14389
+ var video = document.createElement('video'); // Prepare video tag to auto play and add specific Safari tweaks #WCS-2425
14390
+
14391
+ video.muted = true;
14392
+
14393
+ if (util.Browser.isSafariWebRTC()) {
14394
+ video.setAttribute("playsinline", "");
14395
+ video.setAttribute("webkit-playsinline", "");
14396
+ }
14397
+
14398
+ return video;
14399
+ }
14400
+
14299
14401
  function removeVideoElement(video) {
14300
14402
  if (video.srcObject) {
14301
14403
  //pause
@@ -14529,7 +14631,9 @@ var playFirstVideo = function playFirstVideo(display, isLocal, src) {
14529
14631
  if (!getCacheInstance(display)) {
14530
14632
  var video = document.createElement('video');
14531
14633
  video.setAttribute("playsinline", "");
14532
- video.setAttribute("webkit-playsinline", "");
14634
+ video.setAttribute("webkit-playsinline", ""); //Mute video tag to prevent local audio playback in Safari #WCS-3430
14635
+
14636
+ video.muted = true;
14533
14637
  video.id = uuid_v1() + (isLocal ? LOCAL_CACHED_VIDEO : REMOTE_CACHED_VIDEO); //in WCS-1560 we removed video.play() call, because it triggers the “Unhandled Promise Rejection” exception in iOS Safari
14534
14638
  //in WCS-2160 we rolled back the changes made in WCS-1560 due to no audio on first playback in iOS Safari
14535
14639