livekit-client
Advanced tools
Comparing version 0.11.1 to 0.11.2
@@ -48,2 +48,3 @@ "use strict"; | ||
function connect(url, token, options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -58,3 +59,3 @@ // set defaults | ||
loglevel_1.default.setLevel(options.logLevel); | ||
const config = {}; | ||
const config = (_a = options.rtcConfig) !== null && _a !== void 0 ? _a : {}; | ||
if (options.iceServers) { | ||
@@ -61,0 +62,0 @@ config.iceServers = options.iceServers; |
@@ -17,2 +17,6 @@ import LocalTrack from './room/track/LocalTrack'; | ||
/** | ||
* use to override any RTCConfiguration options. | ||
*/ | ||
rtcConfig?: RTCConfiguration; | ||
/** | ||
* Tracks to publish to the room after joining. These can be obtained by calling | ||
@@ -19,0 +23,0 @@ * [[createLocalTracks]]. when this is passed in, it'll ignore audio and video options |
@@ -10,3 +10,3 @@ import { SignalClient } from '../../api/SignalClient'; | ||
private lastQualityChange?; | ||
private disableCount; | ||
private lastExplicitQualityChange?; | ||
private encodings?; | ||
@@ -13,0 +13,0 @@ constructor(mediaTrack: MediaStreamTrack, name?: string, constraints?: MediaTrackConstraints); |
@@ -20,10 +20,6 @@ "use strict"; | ||
const Track_1 = require("./Track"); | ||
// upgrade delay for diff qualities | ||
const QUALITY_UPGRADE_DELAY = { | ||
h: 120 * 1000, | ||
q: 60 * 1000, | ||
}; | ||
// once it's disabled this number of times, it will be turned off for the rest | ||
// of the session | ||
const MAX_QUALITY_ATTEMPTS = 3; | ||
// delay before attempting to upgrade | ||
const QUALITY_UPGRADE_DELAY = 60 * 1000; | ||
// avoid downgrading too quickly | ||
const QUALITY_DOWNGRADE_DELAY = 5 * 1000; | ||
const ridOrder = ['f', 'h', 'q']; | ||
@@ -33,8 +29,2 @@ class LocalVideoTrack extends LocalTrack_1.default { | ||
super(mediaTrack, Track_1.Track.Kind.Video, name, constraints); | ||
// keep track of times we had to disable a track | ||
this.disableCount = { | ||
2: 0, | ||
1: 0, | ||
0: 0, | ||
}; | ||
this.monitorSender = () => __awaiter(this, void 0, void 0, function* () { | ||
@@ -167,2 +157,3 @@ if (!this.sender) { | ||
this.lastQualityChange = new Date().getTime(); | ||
this.lastExplicitQualityChange = new Date().getTime(); | ||
(_a = this.signalClient) === null || _a === void 0 ? void 0 : _a.sendSetSimulcastLayers(this.sid, layers); | ||
@@ -210,6 +201,7 @@ const params = this.sender.getParameters(); | ||
const currentQuality = videoQualityForRid(rid); | ||
// adaptive simulcast algorithm notes (dz) | ||
// adaptive simulcast algorithm notes (davidzhao) | ||
// Chrome (and other browsers) will automatically pause the highest layer | ||
// when it runs into bandwidth limitations. When that happens, it would not | ||
// be able to send any new frames between the two stats checks. | ||
// | ||
// We need to set that layer to inactive intentionally, because chrome tends | ||
@@ -219,4 +211,4 @@ // to flicker, meaning it will attempt to send that layer again shortly | ||
// | ||
// We also have to notify the server that the layer isn't available, so | ||
// the SFU could stop serving it to clients. | ||
// Note: even after bandwidth recovers, the flip-flopping behavior continues | ||
// this is possibly due to SFU-side PLI generation and imperfect bandwidth estimation | ||
if (sendStats.qualityLimitationResolutionChanges | ||
@@ -233,9 +225,5 @@ - lastStats.qualityLimitationResolutionChanges > 0) { | ||
const nextQuality = currentQuality + 1; | ||
const upgradeDelay = QUALITY_UPGRADE_DELAY[rid]; | ||
if (!upgradeDelay || (new Date()).getTime() - this.lastQualityChange < upgradeDelay) { | ||
if ((new Date()).getTime() - this.lastQualityChange < QUALITY_UPGRADE_DELAY) { | ||
return; | ||
} | ||
if (this.disableCount[nextQuality] >= MAX_QUALITY_ATTEMPTS) { | ||
return; | ||
} | ||
loglevel_1.default.debug('upgrading video quality to', nextQuality); | ||
@@ -245,2 +233,8 @@ this.setPublishingQuality(nextQuality); | ||
} | ||
// if we've upgraded or downgraded recently, give it a bit of time before | ||
// downgrading again | ||
if (this.lastExplicitQualityChange | ||
&& ((new Date()).getTime() - this.lastExplicitQualityChange) < QUALITY_DOWNGRADE_DELAY) { | ||
return; | ||
} | ||
if (currentQuality === livekit_rtc_1.VideoQuality.UNRECOGNIZED) { | ||
@@ -254,3 +248,2 @@ return; | ||
loglevel_1.default.debug('downgrading video quality to', currentQuality - 1); | ||
this.disableCount[currentQuality] += 1; | ||
this.setPublishingQuality(currentQuality - 1); | ||
@@ -257,0 +250,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.11.1"; | ||
export declare const version = "0.11.2"; | ||
export declare const protocolVersion = 2; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.protocolVersion = exports.version = void 0; | ||
exports.version = '0.11.1'; | ||
exports.version = '0.11.2'; | ||
exports.protocolVersion = 2; | ||
//# sourceMappingURL=version.js.map |
@@ -163,4 +163,5 @@ import { | ||
const simulcast = (<HTMLInputElement>$('simulcast')).checked; | ||
const forceTURN = (<HTMLInputElement>$('force-turn')).checked; | ||
window.connectToRoom(url, token, simulcast); | ||
window.connectToRoom(url, token, simulcast, forceTURN); | ||
}; | ||
@@ -172,4 +173,9 @@ | ||
simulcast: boolean = false, | ||
forceTURN: boolean = false, | ||
) => { | ||
let room: Room; | ||
const rtcConfig: RTCConfiguration = {}; | ||
if (forceTURN) { | ||
rtcConfig.iceTransportPolicy = 'relay'; | ||
} | ||
try { | ||
@@ -183,2 +189,3 @@ room = await connect(url, token, { | ||
simulcast, | ||
rtcConfig, | ||
}); | ||
@@ -185,0 +192,0 @@ } catch (error) { |
{ | ||
"name": "livekit-client", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "JavaScript/TypeScript client SDK for LiveKit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
513983
8058