@flashphoner/websdk 2.0.257 → 2.0.258
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/media_devices_manager/manager.js +50 -3
- package/examples/demo/streaming/media_devices_manager/media_device_manager.html +14 -0
- package/flashphoner-no-flash.js +113 -10
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +39 -1
- package/flashphoner-no-webrtc.min.js +1 -1
- package/flashphoner-no-wsplayer.js +113 -10
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api-webrtc-only.js +112 -9
- package/flashphoner-room-api-webrtc-only.min.js +1 -1
- package/flashphoner-room-api.js +109 -11
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +39 -1
- package/flashphoner-temasys-flash-websocket.js +39 -1
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +112 -9
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +113 -10
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/constants.d.ts +6 -0
- package/src/constants.js +6 -0
- package/src/flashphoner-core.d.ts +2 -0
- package/src/flashphoner-core.js +32 -0
- package/src/media-source-media-provider.js +1 -1
- package/src/webrtc-media-provider.js +70 -10
|
@@ -7628,6 +7628,12 @@ var ERROR_INFO = Object.freeze({
|
|
|
7628
7628
|
* @memberOf Flashphoner.constants.ERROR_INFO
|
|
7629
7629
|
*/
|
|
7630
7630
|
CAN_NOT_SWITCH_MIC: 'Number of mics is less than 2 or microphone is already used by other application',
|
|
7631
|
+
/**
|
|
7632
|
+
* Error if cannot set a new resolution to the published track
|
|
7633
|
+
* @event CAN_NOT_SET_RESOLUTION
|
|
7634
|
+
* @memberOf Flashphoner.constants.ERROR_INFO
|
|
7635
|
+
*/
|
|
7636
|
+
CAN_NOT_SET_RESOLUTION: 'Cannot switch a published stream resolution',
|
|
7631
7637
|
/**
|
|
7632
7638
|
* Local browser error detected
|
|
7633
7639
|
* @event LOCAL_ERROR
|
|
@@ -10492,6 +10498,36 @@ var createSession = function createSession(options) {
|
|
|
10492
10498
|
}
|
|
10493
10499
|
}
|
|
10494
10500
|
};
|
|
10501
|
+
|
|
10502
|
+
/**
|
|
10503
|
+
* Update video publishing settings on the fly
|
|
10504
|
+
*
|
|
10505
|
+
* @param {Object} stream video settings: {maxBitrate, frameRate, scaleResolutionDownBy)}
|
|
10506
|
+
* @return {Promice} encodings object applied
|
|
10507
|
+
* @memberof Stream
|
|
10508
|
+
*/
|
|
10509
|
+
var updateVideoSettings = function updateVideoSettings(settings) {
|
|
10510
|
+
if (published() && mediaConnection) {
|
|
10511
|
+
return mediaConnection.updateVideoSettings(settings);
|
|
10512
|
+
} else {
|
|
10513
|
+
throw new Error("This function available for publishing stream only");
|
|
10514
|
+
}
|
|
10515
|
+
};
|
|
10516
|
+
|
|
10517
|
+
/**
|
|
10518
|
+
* Update video publishing resolution on the fly
|
|
10519
|
+
*
|
|
10520
|
+
* @param {Object} stream video resolution: {width, height)}
|
|
10521
|
+
* @return {Promice} video constaints object applied
|
|
10522
|
+
* @memberof Stream
|
|
10523
|
+
*/
|
|
10524
|
+
var updateVideoResolution = function updateVideoResolution(resolution) {
|
|
10525
|
+
if (published() && mediaConnection) {
|
|
10526
|
+
return mediaConnection.updateVideoResolution(resolution);
|
|
10527
|
+
} else {
|
|
10528
|
+
throw new Error("This function available for publishing stream only");
|
|
10529
|
+
}
|
|
10530
|
+
};
|
|
10495
10531
|
stream.play = play;
|
|
10496
10532
|
stream.publish = publish;
|
|
10497
10533
|
stream.stop = _stop;
|
|
@@ -10531,6 +10567,8 @@ var createSession = function createSession(options) {
|
|
|
10531
10567
|
stream.switchToCam = switchToCam;
|
|
10532
10568
|
stream.sendData = sendData;
|
|
10533
10569
|
stream.getLogger = getLogger;
|
|
10570
|
+
stream.updateVideoSettings = updateVideoSettings;
|
|
10571
|
+
stream.updateVideoResolution = updateVideoResolution;
|
|
10534
10572
|
streams[id_] = stream;
|
|
10535
10573
|
return stream;
|
|
10536
10574
|
};
|
|
@@ -12152,16 +12190,79 @@ var createConnection = function createConnection(options) {
|
|
|
12152
12190
|
screenShare = false;
|
|
12153
12191
|
};
|
|
12154
12192
|
var setPublishingBitrate = function setPublishingBitrate(minBitrate, maxBitrate) {
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12193
|
+
updateVideoSettings({
|
|
12194
|
+
maxBitrate: maxBitrate
|
|
12195
|
+
});
|
|
12196
|
+
};
|
|
12197
|
+
var updateVideoSettings = function updateVideoSettings(settings) {
|
|
12198
|
+
return new Promise(function (resolve, reject) {
|
|
12199
|
+
if (connection && settings) {
|
|
12200
|
+
connection.getSenders().forEach(function (sender) {
|
|
12201
|
+
if (sender.track.kind == "video") {
|
|
12202
|
+
var parameters = sender.getParameters();
|
|
12203
|
+
for (var i = 0; i < parameters.encodings.length; i++) {
|
|
12204
|
+
if (settings.maxBitrate) {
|
|
12205
|
+
parameters.encodings[i].maxBitrate = settings.maxBitrate * 1000;
|
|
12206
|
+
} else if (parameters.encodings[i].maxBitrate) {
|
|
12207
|
+
delete parameters.encodings[i].maxBitrate;
|
|
12208
|
+
}
|
|
12209
|
+
if (settings.frameRate) {
|
|
12210
|
+
parameters.encodings[i].maxFramerate = settings.frameRate;
|
|
12211
|
+
}
|
|
12212
|
+
if (settings.scaleResolutionDownBy) {
|
|
12213
|
+
parameters.encodings[i].scaleResolutionDownBy = settings.scaleResolutionDownBy;
|
|
12214
|
+
}
|
|
12215
|
+
}
|
|
12216
|
+
sender.setParameters(parameters).then(function () {
|
|
12217
|
+
logger.info(LOG_PREFIX, "Set video encoder parameters to " + JSON.stringify(parameters.encodings));
|
|
12218
|
+
resolve(parameters.encodings);
|
|
12219
|
+
})["catch"](function (reason) {
|
|
12220
|
+
logger.error(LOG_PREFIX, reason);
|
|
12221
|
+
reject(reason);
|
|
12222
|
+
});
|
|
12162
12223
|
}
|
|
12163
|
-
}
|
|
12164
|
-
|
|
12224
|
+
});
|
|
12225
|
+
}
|
|
12226
|
+
});
|
|
12227
|
+
};
|
|
12228
|
+
var updateVideoResolution = function updateVideoResolution(resolution) {
|
|
12229
|
+
return new Promise(function (resolve, reject) {
|
|
12230
|
+
if (connection && localVideo && localVideo.srcObject && !customStream && resolution) {
|
|
12231
|
+
connection.getSenders().forEach(function (sender) {
|
|
12232
|
+
if (sender.track.kind === 'audio') return;
|
|
12233
|
+
sender.track.stop();
|
|
12234
|
+
//use the settings that were set during connection initiation
|
|
12235
|
+
var clonedConstraints = Object.assign({}, constraints);
|
|
12236
|
+
if (resolution.width) {
|
|
12237
|
+
clonedConstraints.video.width = {
|
|
12238
|
+
ideal: resolution.width
|
|
12239
|
+
};
|
|
12240
|
+
}
|
|
12241
|
+
if (resolution.height) {
|
|
12242
|
+
clonedConstraints.video.height = {
|
|
12243
|
+
ideal: resolution.height
|
|
12244
|
+
};
|
|
12245
|
+
}
|
|
12246
|
+
clonedConstraints.audio = false;
|
|
12247
|
+
navigator.mediaDevices.getUserMedia(clonedConstraints).then(function (newStream) {
|
|
12248
|
+
var newVideoTrack = newStream.getVideoTracks()[0];
|
|
12249
|
+
newVideoTrack.enabled = localVideo.srcObject.getVideoTracks()[0].enabled;
|
|
12250
|
+
var audioTrack = localVideo.srcObject.getAudioTracks()[0];
|
|
12251
|
+
sender.replaceTrack(newVideoTrack);
|
|
12252
|
+
localVideo.srcObject = newStream;
|
|
12253
|
+
// On Safari mobile _newStream_ doesn't contain audio track, so we need to add track from previous stream
|
|
12254
|
+
if (localVideo.srcObject.getAudioTracks().length == 0 && audioTrack) {
|
|
12255
|
+
localVideo.srcObject.addTrack(audioTrack);
|
|
12256
|
+
}
|
|
12257
|
+
logger.info(LOG_PREFIX, "Set video constraints to " + JSON.stringify(clonedConstraints.video));
|
|
12258
|
+
resolve(clonedConstraints.video);
|
|
12259
|
+
})["catch"](function (reason) {
|
|
12260
|
+
logger.error(LOG_PREFIX, reason);
|
|
12261
|
+
reject(reason);
|
|
12262
|
+
});
|
|
12263
|
+
});
|
|
12264
|
+
} else {
|
|
12265
|
+
reject(constants.ERROR_INFO.CAN_NOT_SET_RESOLUTION);
|
|
12165
12266
|
}
|
|
12166
12267
|
});
|
|
12167
12268
|
};
|
|
@@ -12197,6 +12298,8 @@ var createConnection = function createConnection(options) {
|
|
|
12197
12298
|
exports.switchToScreen = switchToScreen;
|
|
12198
12299
|
exports.switchToCam = switchToCam;
|
|
12199
12300
|
exports.setPublishingBitrate = setPublishingBitrate;
|
|
12301
|
+
exports.updateVideoSettings = updateVideoSettings;
|
|
12302
|
+
exports.updateVideoResolution = updateVideoResolution;
|
|
12200
12303
|
connections[id] = exports;
|
|
12201
12304
|
resolve(exports);
|
|
12202
12305
|
});
|