@flashphoner/websdk 2.0.206 → 2.0.210
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/docTemplate/README.md +1 -1
- package/examples/demo/streaming/2players/2players.js +0 -5
- package/examples/demo/streaming/canvas_streaming/canvas_streaming.js +0 -12
- package/examples/demo/streaming/embed_player/player.js +127 -198
- package/examples/demo/streaming/firewall-traversal-streaming/firewall-traversal-streaming.js +0 -12
- package/examples/demo/streaming/mcu_client/mcu_client.js +0 -8
- package/examples/demo/streaming/media_devices_manager/manager.js +2 -17
- package/examples/demo/streaming/player/player.js +10 -9
- package/examples/demo/streaming/screen-sharing/screen-sharing.html +1 -1
- package/examples/demo/streaming/screen-sharing/screen-sharing.js +1 -1
- package/examples/demo/streaming/stream-auto-restore/stream-auto-restore.css +23 -0
- package/examples/demo/streaming/stream-auto-restore/stream-auto-restore.html +152 -0
- package/examples/demo/streaming/stream-auto-restore/stream-auto-restore.js +744 -0
- package/examples/demo/streaming/stream-diagnostic/stream-diagnostic.js +0 -8
- package/examples/demo/streaming/stream-local-snapshot/stream-local-snapshot.js +0 -6
- package/examples/demo/streaming/stream-snapshot/stream-snapshot.js +0 -6
- package/examples/demo/streaming/stream_recording/recording.js +0 -6
- package/examples/demo/streaming/streamer/streamer.js +0 -8
- package/examples/demo/streaming/two_way_streaming/two_way_streaming.js +0 -11
- package/examples/demo/streaming/webrtc-as-rtmp-republishing/webrtc-as-rtmp-republishing.js +0 -6
- package/flashphoner-no-flash.js +131 -29
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +103 -19
- package/flashphoner-no-webrtc.min.js +1 -1
- package/flashphoner-no-wsplayer.js +132 -30
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api.js +105 -12
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +105 -21
- package/flashphoner-temasys-flash-websocket.js +105 -21
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +129 -27
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +132 -30
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/flashphoner-core.d.ts +22 -5
- package/src/flashphoner-core.js +79 -3
- package/src/webrtc-media-provider.js +26 -9
package/flashphoner-room-api.js
CHANGED
|
@@ -10035,6 +10035,9 @@ var getSession = function (id) {
|
|
|
10035
10035
|
* @param {Object=} options.sipOptions Sip configuration
|
|
10036
10036
|
* @param {Object=} options.mediaOptions Media connection configuration
|
|
10037
10037
|
* @param {Integer=} options.timeout Connection timeout in milliseconds
|
|
10038
|
+
* @param {Integer=} options.pingInterval Server ping interval in milliseconds [0]
|
|
10039
|
+
* @param {Integer=} options.receiveProbes A maximum subsequental pings received missing count [0]
|
|
10040
|
+
* @param {Integer=} options.probesInterval Interval to check subsequental pings received [0]
|
|
10038
10041
|
* @returns {Session} Created session
|
|
10039
10042
|
* @throws {Error} Error if API is not initialized
|
|
10040
10043
|
* @throws {TypeError} Error if options.urlServer is not specified
|
|
@@ -10059,6 +10062,8 @@ var createSession = function (options) {
|
|
|
10059
10062
|
var mediaOptions = options.mediaOptions;
|
|
10060
10063
|
var keepAlive = options.keepAlive;
|
|
10061
10064
|
var timeout = options.timeout;
|
|
10065
|
+
var wsPingSender = new WSPingSender(options.pingInterval || 0);
|
|
10066
|
+
var wsPingReceiver = new WSPingReceiver(options.receiveProbes || 0, options.probesInterval || 0);
|
|
10062
10067
|
var connectionTimeout;
|
|
10063
10068
|
|
|
10064
10069
|
var cConfig;
|
|
@@ -10166,7 +10171,7 @@ var createSession = function (options) {
|
|
|
10166
10171
|
mediaProviders: Object.keys(MediaProvider),
|
|
10167
10172
|
keepAlive: keepAlive,
|
|
10168
10173
|
authToken:authToken,
|
|
10169
|
-
clientVersion: "2.0.
|
|
10174
|
+
clientVersion: "2.0.210",
|
|
10170
10175
|
clientOSVersion: window.navigator.appVersion,
|
|
10171
10176
|
clientBrowserVersion: window.navigator.userAgent,
|
|
10172
10177
|
msePacketizationVersion: 2,
|
|
@@ -10178,6 +10183,10 @@ var createSession = function (options) {
|
|
|
10178
10183
|
//connect to REST App
|
|
10179
10184
|
send("connection", cConfig);
|
|
10180
10185
|
logger.setConnection(wsConnection);
|
|
10186
|
+
// Send ping messages to server to check if connection is still alive #WCS-3410
|
|
10187
|
+
wsPingSender.start();
|
|
10188
|
+
// Check subsequintel pings received from server to check if connection is still alive #WCS-3410
|
|
10189
|
+
wsPingReceiver.start();
|
|
10181
10190
|
};
|
|
10182
10191
|
wsConnection.onmessage = function (event) {
|
|
10183
10192
|
var data = {};
|
|
@@ -10190,6 +10199,7 @@ var createSession = function (options) {
|
|
|
10190
10199
|
switch (data.message) {
|
|
10191
10200
|
case 'ping':
|
|
10192
10201
|
send("pong", null);
|
|
10202
|
+
wsPingReceiver.success();
|
|
10193
10203
|
break;
|
|
10194
10204
|
case 'getUserData':
|
|
10195
10205
|
authToken = obj.authToken;
|
|
@@ -10316,6 +10326,10 @@ var createSession = function (options) {
|
|
|
10316
10326
|
function onSessionStatusChange(newStatus, obj) {
|
|
10317
10327
|
sessionStatus = newStatus;
|
|
10318
10328
|
if (sessionStatus == SESSION_STATUS.DISCONNECTED || sessionStatus == SESSION_STATUS.FAILED) {
|
|
10329
|
+
// Stop pinging server #WCS-3410
|
|
10330
|
+
wsPingSender.stop();
|
|
10331
|
+
// Stop checking pings received #WCS-3410
|
|
10332
|
+
wsPingReceiver.stop();
|
|
10319
10333
|
//remove streams
|
|
10320
10334
|
for (var prop in streamRefreshHandlers) {
|
|
10321
10335
|
if (streamRefreshHandlers.hasOwnProperty(prop) && typeof streamRefreshHandlers[prop] === 'function') {
|
|
@@ -10330,6 +10344,65 @@ var createSession = function (options) {
|
|
|
10330
10344
|
}
|
|
10331
10345
|
}
|
|
10332
10346
|
|
|
10347
|
+
// Websocket periodic ping sender
|
|
10348
|
+
function WSPingSender(interval) {
|
|
10349
|
+
this.interval = interval || 0;
|
|
10350
|
+
this.intervalId = null;
|
|
10351
|
+
this.start = function() {
|
|
10352
|
+
if (this.interval > 0) {
|
|
10353
|
+
this.intervalId = setInterval(function() {
|
|
10354
|
+
send("ping", null);
|
|
10355
|
+
}, this.interval);
|
|
10356
|
+
}
|
|
10357
|
+
};
|
|
10358
|
+
this.stop = function() {
|
|
10359
|
+
if (this.intervalId) {
|
|
10360
|
+
clearInterval(this.intervalId);
|
|
10361
|
+
}
|
|
10362
|
+
};
|
|
10363
|
+
|
|
10364
|
+
return(this);
|
|
10365
|
+
}
|
|
10366
|
+
|
|
10367
|
+
// Websocket ping receive prober
|
|
10368
|
+
function WSPingReceiver(receiveProbes, probesInterval) {
|
|
10369
|
+
this.maxPings = receiveProbes || 0;
|
|
10370
|
+
this.interval = probesInterval || 0;
|
|
10371
|
+
this.intervalId = null;
|
|
10372
|
+
this.pingsMissing = 0;
|
|
10373
|
+
this.start = function() {
|
|
10374
|
+
if (this.maxPings > 0 && this.interval > 0) {
|
|
10375
|
+
let receiver = this;
|
|
10376
|
+
this.intervalId = setInterval(function() {
|
|
10377
|
+
receiver.checkPingsReceived();
|
|
10378
|
+
}, this.interval);
|
|
10379
|
+
}
|
|
10380
|
+
};
|
|
10381
|
+
this.stop = function() {
|
|
10382
|
+
if (this.intervalId) {
|
|
10383
|
+
clearInterval(this.intervalId);
|
|
10384
|
+
}
|
|
10385
|
+
this.pingsMissing = 0;
|
|
10386
|
+
};
|
|
10387
|
+
this.checkPingsReceived = function() {
|
|
10388
|
+
this.pingsMissing++;
|
|
10389
|
+
if (this.pingsMissing >= this.maxPings) {
|
|
10390
|
+
this.failure();
|
|
10391
|
+
}
|
|
10392
|
+
};
|
|
10393
|
+
this.success = function() {
|
|
10394
|
+
this.pingsMissing = 0;
|
|
10395
|
+
};
|
|
10396
|
+
this.failure = function() {
|
|
10397
|
+
logger.info(LOG_PREFIX, "Missing " + this.pingsMissing + " pings from server, connection seems to be down");
|
|
10398
|
+
onSessionStatusChange(SESSION_STATUS.FAILED);
|
|
10399
|
+
wsConnection.close();
|
|
10400
|
+
};
|
|
10401
|
+
|
|
10402
|
+
return(this);
|
|
10403
|
+
}
|
|
10404
|
+
|
|
10405
|
+
|
|
10333
10406
|
/**
|
|
10334
10407
|
* @callback sdpHook
|
|
10335
10408
|
* @param {Object} sdp Callback options
|
|
@@ -11104,7 +11177,7 @@ var createSession = function (options) {
|
|
|
11104
11177
|
* @param {HTMLElement} options.display Div element stream should be displayed in
|
|
11105
11178
|
* @param {Object=} options.custom User provided custom object that will be available in REST App code
|
|
11106
11179
|
* @param {Integer} [options.flashBufferTime=0] Specifies how long to buffer messages before starting to display the stream (Flash-only)
|
|
11107
|
-
* @param {
|
|
11180
|
+
* @param {string=} options.stripCodecs Comma separated string of codecs which should be stripped from WebRTC SDP (ex. "H264,PCMA,PCMU,G722")
|
|
11108
11181
|
* @param {string=} options.rtmpUrl Rtmp url stream should be forwarded to
|
|
11109
11182
|
* @param {Object=} options.mediaConnectionConstraints Stream specific constraints for underlying RTCPeerConnection
|
|
11110
11183
|
* @param {Boolean=} options.flashShowFullScreenButton Show full screen button in flash
|
|
@@ -11113,6 +11186,7 @@ var createSession = function (options) {
|
|
|
11113
11186
|
* @param {Integer=} options.playoutDelay Time delay between network reception of media and playout
|
|
11114
11187
|
* @param {string=} options.useCanvasMediaStream EXPERIMENTAL: when publish bind browser's media stream to the canvas. It can be useful for image filtering
|
|
11115
11188
|
* @param {string=} options.videoContentHint Video content hint for browser ('detail' by default to maintain resolution), {@link Flashphoner.constants.CONTENT_HINT_TYPE}
|
|
11189
|
+
* @param {Boolean=} options.unmutePlayOnStart Unmute playback on start. May be used after user gesture only, so set 'unmutePlayOnStart: false' for autoplay
|
|
11116
11190
|
* @param {sdpHook} sdpHook The callback that handles sdp from the server
|
|
11117
11191
|
* @returns {Stream} Stream
|
|
11118
11192
|
* @throws {TypeError} Error if no options provided
|
|
@@ -11216,6 +11290,7 @@ var createSession = function (options) {
|
|
|
11216
11290
|
var playoutDelay = options.playoutDelay;
|
|
11217
11291
|
var useCanvasMediaStream = options.useCanvasMediaStream;
|
|
11218
11292
|
var videoContentHint = options.videoContentHint;
|
|
11293
|
+
var unmutePlayOnStart = options.unmutePlayOnStart;
|
|
11219
11294
|
|
|
11220
11295
|
var audioState_;
|
|
11221
11296
|
var videoState_;
|
|
@@ -11390,7 +11465,8 @@ var createSession = function (options) {
|
|
|
11390
11465
|
connectionConstraints: mediaConnectionConstraints,
|
|
11391
11466
|
audioOutputId: audioOutputId,
|
|
11392
11467
|
remoteVideo: remoteVideo,
|
|
11393
|
-
playoutDelay: playoutDelay
|
|
11468
|
+
playoutDelay: playoutDelay,
|
|
11469
|
+
unmutePlayOnStart: unmutePlayOnStart
|
|
11394
11470
|
}, streamRefreshHandlers[id_]).then(function (newConnection) {
|
|
11395
11471
|
mediaConnection = newConnection;
|
|
11396
11472
|
try {
|
|
@@ -13897,6 +13973,8 @@ var createConnection = function (options) {
|
|
|
13897
13973
|
var playoutDelay = options.playoutDelay;
|
|
13898
13974
|
// Set video track contentHint to `detail` by default to workaround Chromium 91 bug #WCS-3257
|
|
13899
13975
|
var videoContentHint = options.videoContentHint ? options.videoContentHint : 'detail';
|
|
13976
|
+
// Pass the option to unmute automatically (true by default) #WCS-2425
|
|
13977
|
+
var unmutePlayOnStart = options.unmutePlayOnStart !== undefined ? options.unmutePlayOnStart : true;
|
|
13900
13978
|
|
|
13901
13979
|
if (bidirectional) {
|
|
13902
13980
|
localVideo = getCacheInstance(localDisplay);
|
|
@@ -13912,7 +13990,7 @@ var createConnection = function (options) {
|
|
|
13912
13990
|
}
|
|
13913
13991
|
remoteVideo = getCacheInstance(remoteDisplay);
|
|
13914
13992
|
if (!remoteVideo) {
|
|
13915
|
-
remoteVideo =
|
|
13993
|
+
remoteVideo = createVideoElement();
|
|
13916
13994
|
remoteDisplay.appendChild(remoteVideo);
|
|
13917
13995
|
}
|
|
13918
13996
|
remoteVideo.id = id + "-remote";
|
|
@@ -13933,7 +14011,7 @@ var createConnection = function (options) {
|
|
|
13933
14011
|
if (cachedVideo) {
|
|
13934
14012
|
remoteVideo = cachedVideo;
|
|
13935
14013
|
} else {
|
|
13936
|
-
remoteVideo =
|
|
14014
|
+
remoteVideo = createVideoElement();
|
|
13937
14015
|
display.appendChild(remoteVideo);
|
|
13938
14016
|
}
|
|
13939
14017
|
remoteVideo.id = id;
|
|
@@ -13986,7 +14064,12 @@ var createConnection = function (options) {
|
|
|
13986
14064
|
remoteVideo.srcObject = event.streams[0];
|
|
13987
14065
|
remoteVideo.onloadedmetadata = function (e) {
|
|
13988
14066
|
if (remoteVideo) {
|
|
13989
|
-
remoteVideo.play().
|
|
14067
|
+
remoteVideo.play().then(function() {
|
|
14068
|
+
// Automatically unmute video if needed #WCS-2425
|
|
14069
|
+
if (unmutePlayOnStart) {
|
|
14070
|
+
remoteVideo.muted = false;
|
|
14071
|
+
}
|
|
14072
|
+
}).catch(function (e) {
|
|
13990
14073
|
if (validBrowsers.includes(browserDetails.browser)) {
|
|
13991
14074
|
//WCS-1698. fixed autoplay in chromium based browsers
|
|
13992
14075
|
//WCS-2375. fixed autoplay in ios safari
|
|
@@ -14262,14 +14345,14 @@ var createConnection = function (options) {
|
|
|
14262
14345
|
if (!report.isRemote) {
|
|
14263
14346
|
if (report.type == 'outbound-rtp') {
|
|
14264
14347
|
fillStatObject(result.outboundStream, report);
|
|
14265
|
-
if (report.mediaType == 'video') {
|
|
14348
|
+
if (report.mediaType == 'video' && localVideo != undefined && localVideo != null) {
|
|
14266
14349
|
var vSettings = localVideo.srcObject.getVideoTracks()[0].getSettings();
|
|
14267
14350
|
result.outboundStream[report.mediaType].height = vSettings.height;
|
|
14268
14351
|
result.outboundStream[report.mediaType].width = vSettings.width;
|
|
14269
14352
|
}
|
|
14270
14353
|
} else if (report.type == 'inbound-rtp') {
|
|
14271
14354
|
fillStatObject(result.inboundStream, report);
|
|
14272
|
-
if (report.mediaType == 'video' && remoteVideo != undefined) {
|
|
14355
|
+
if (report.mediaType == 'video' && remoteVideo != undefined && remoteVideo != null) {
|
|
14273
14356
|
result.inboundStream[report.mediaType].height = remoteVideo.videoHeight;
|
|
14274
14357
|
result.inboundStream[report.mediaType].width = remoteVideo.videoWidth;
|
|
14275
14358
|
}
|
|
@@ -14430,7 +14513,7 @@ var createConnection = function (options) {
|
|
|
14430
14513
|
if (browserDetails.browser === 'firefox') {
|
|
14431
14514
|
clonedConstraints.video.mediaSource = source;
|
|
14432
14515
|
}
|
|
14433
|
-
if (
|
|
14516
|
+
if (woExtension) {
|
|
14434
14517
|
getScreenDeviceIdWoExtension(clonedConstraints).then(function (screenSharingConstraints) {
|
|
14435
14518
|
navigator.mediaDevices.getDisplayMedia(screenSharingConstraints).then(
|
|
14436
14519
|
(stream) => {
|
|
@@ -14559,6 +14642,7 @@ var createConnection = function (options) {
|
|
|
14559
14642
|
};
|
|
14560
14643
|
|
|
14561
14644
|
|
|
14645
|
+
|
|
14562
14646
|
var mixAudioTracks = function (stream1, stream2) {
|
|
14563
14647
|
var stream1Sound = audioContext.createMediaStreamSource(stream1);
|
|
14564
14648
|
var stream2Sound = audioContext.createMediaStreamSource(stream2);
|
|
@@ -14690,13 +14774,11 @@ var getMediaAccess = function (constraints, display, disableConstraintsNormaliza
|
|
|
14690
14774
|
var loadOrdinaryVideo = function(display, stream, screenShare, constraints, video) {
|
|
14691
14775
|
let vEl = video;
|
|
14692
14776
|
if (!vEl) {
|
|
14693
|
-
vEl =
|
|
14777
|
+
vEl = createVideoElement();
|
|
14694
14778
|
display.appendChild(vEl);
|
|
14695
14779
|
}
|
|
14696
14780
|
vEl.id = uuid_v1() + LOCAL_CACHED_VIDEO;
|
|
14697
14781
|
vEl.srcObject = stream;
|
|
14698
|
-
//mute audio
|
|
14699
|
-
vEl.muted = true;
|
|
14700
14782
|
vEl.onloadedmetadata = function (e) {
|
|
14701
14783
|
//WCS-2751 Add screen capture using getDisplayMedia in Safari
|
|
14702
14784
|
if (screenShare && !screenCaptureSupportedBrowsers()) {
|
|
@@ -15030,6 +15112,17 @@ function getCacheInstance(display) {
|
|
|
15030
15112
|
}
|
|
15031
15113
|
}
|
|
15032
15114
|
|
|
15115
|
+
function createVideoElement() {
|
|
15116
|
+
let video = document.createElement('video');
|
|
15117
|
+
// Prepare video tag to auto play and add specific Safari tweaks #WCS-2425
|
|
15118
|
+
video.muted = true;
|
|
15119
|
+
if(util.Browser.isSafariWebRTC()) {
|
|
15120
|
+
video.setAttribute("playsinline", "");
|
|
15121
|
+
video.setAttribute("webkit-playsinline", "");
|
|
15122
|
+
}
|
|
15123
|
+
return(video);
|
|
15124
|
+
}
|
|
15125
|
+
|
|
15033
15126
|
function removeVideoElement(video) {
|
|
15034
15127
|
if (video.srcObject) {
|
|
15035
15128
|
//pause
|