-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VIDEO-9282 - Migrate SDK from using node.js util. #1752
Merged
+340
−46
Merged
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
3e1f58e
Replacing util.inherits
PikaJoyce 4f0b622
Changing global.window to window object
PikaJoyce 94b400b
Fixing toplevel declaration
PikaJoyce 310b68b
Fixing toplevel global variable
PikaJoyce e228d1c
Add Changelog and license
PikaJoyce 2a73778
Replacing Backoff with Backo module
PikaJoyce eeadc7e
Changing backoff in twilioconnectiontransport
PikaJoyce 36e9ca5
Removing old reconnectBackoffConfig
PikaJoyce d305b4b
Adding max timeout retry to test unit tests
PikaJoyce 251f5e6
Trying to fix unit tests
PikaJoyce 80d32f7
Increasing no output timeout
PikaJoyce e5523b9
Changing toplevel declaration to globalThis
PikaJoyce b9e9953
reverting timeout in config
PikaJoyce 6fadf85
Fixing constant
PikaJoyce 517c440
Mock backoff in twilioconnectiontransport unit test
PikaJoyce 2492d84
Removing an options.backoff
PikaJoyce 6b5f520
Test circle without modified unit tests
PikaJoyce f206bb2
merge from develop
PikaJoyce 4767dcd
Reverting Mocha
PikaJoyce a0d1547
Adding affected unit tests back
PikaJoyce 9350df4
Add clearTimeout
PikaJoyce 6722640
Fixing unit tests on clearTimeout
PikaJoyce 72893c9
Adding unit tests for inherits and backoff
PikaJoyce c2e6617
Adding backoff.start and unit test
PikaJoyce 64b99ea
New Backoff class
PikaJoyce 69757b4
Backoff with unit tests
PikaJoyce d89a256
Adding a few more unit tests
PikaJoyce c226641
Moving passing of function into start method and cleaning up unit tests
PikaJoyce 8115a62
Merge branch 'develop' of https://github.com/twilio/twilio-video.js i…
PikaJoyce 4b7d2e2
TwilioConnectionTransport tests and adding constants
PikaJoyce b57a36c
Refactoring Backoff and adding more unit tests
PikaJoyce 0b09825
Allow backoff to take in function.
PikaJoyce bd15cde
Mock Backoff in unit tests
PikaJoyce e769544
Removing old Backoff replacing with new
PikaJoyce 32b4168
Replacing backoff in pc and tct
PikaJoyce 77730f7
Update pc and tct unit tests
PikaJoyce f696f9d
Running unit tests without backoff ut
PikaJoyce e61eca0
Fix documentvisibilitymonitor unit tests
PikaJoyce 7e396ac
Incorporating some of the requested changes
PikaJoyce 963dc18
Removing previous change to documentvisibilitymonitor unit tests
PikaJoyce 938596f
test framework + max test
makarandp0 9afc438
Merge branch 'VIDEO-9282-Migrate-from-util' of https://github.com/twi…
PikaJoyce cd811aa
Adding a few more unit tests against backoff options
PikaJoyce 516099a
Addressing Makarands suggestions
PikaJoyce 23d8d17
More requested changes
PikaJoyce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
/** | ||
* Expose `Backoff`. | ||
*/ | ||
|
||
class Backoff { | ||
/** | ||
* Construct a {@link Backoff}. | ||
* @param {object} options | ||
* @property {number} min - Initial timeout in milliseconds [100] | ||
* @property {number} max - Max timeout [10000] | ||
* @property {boolean} jitter - Apply jitter [0] | ||
* @property {number} factor - Multiplication factor for Backoff operation [2] | ||
*/ | ||
constructor(options) { | ||
Object.defineProperties(this, { | ||
_min: { | ||
value: options.min || 100 | ||
}, | ||
_max: { | ||
value: options.max || 10000 | ||
}, | ||
_jitter: { | ||
value: options.jitter > 0 && options.jitter <= 1 ? options.jitter : 0 | ||
}, | ||
_factor: { | ||
value: options.factor || 2 | ||
}, | ||
_attempts: { | ||
value: 0, | ||
writable: true | ||
}, | ||
_duration: { | ||
enumerable: false, | ||
get() { | ||
let ms = this._min * Math.pow(this._factor, this._attempts); | ||
if (this._jitter) { | ||
const rand = Math.random(); | ||
const deviation = Math.floor(rand * this._jitter * ms); | ||
ms = (Math.floor(rand * 10) & 1) === 0 ? ms - deviation : ms + deviation; | ||
} | ||
return Math.min(ms, this._max) | 0; | ||
} | ||
}, | ||
_timeoutID: { | ||
value: null, | ||
writable: true | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Start the backoff operation. | ||
* @param {function} fn - Function to call | ||
* @return {void} | ||
* @api public | ||
*/ | ||
backoff(fn) { | ||
PikaJoyce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let duration = this._duration; | ||
if (this._timeoutID) { | ||
clearTimeout(this._timeoutID); | ||
this._timeoutID = null; | ||
} | ||
this._timeoutID = setTimeout(() => { | ||
this._attempts++; | ||
fn(); | ||
}, duration); | ||
} | ||
|
||
/** | ||
* Reset the number of attempts and clear the timer. | ||
* | ||
* @return {void} | ||
* @api public | ||
*/ | ||
reset() { | ||
this._attempts = 0; | ||
if (this._timeoutID) { | ||
clearTimeout(this._timeoutID); | ||
this._timeoutID = null; | ||
} | ||
} | ||
} | ||
|
||
module.exports = Backoff; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2011-2022 Isaac Z. Schlueter | ||
* Licensed under the ISC License. | ||
* | ||
* Copied from https://github.com/isaacs/inherits (2.0.4) | ||
*/ | ||
|
||
module.exports = function inherits(ctor, superCtor) { | ||
PikaJoyce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (ctor && superCtor) { | ||
ctor.super_ = superCtor; | ||
if (typeof Object.create === 'function') { | ||
// implementation from standard node.js 'util' module | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
} else { | ||
// old school shim for old browsers | ||
class TempCtor { | ||
constructor() { } | ||
} | ||
TempCtor.prototype = superCtor.prototype; | ||
ctor.prototype = new TempCtor(); | ||
ctor.prototype.constructor = ctor; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -831,7 +831,7 @@ describe('connect', function() { | |||||||||
// eslint-disable-next-line no-warning-comments | ||||||||||
// TODO: The following tests verifies bitrates using default codec, OPUS. | ||||||||||
// We should also verify other codecs like ISAC, PCMU and PCMA. | ||||||||||
describe('called with EncodingParameters', () => { | ||||||||||
describe('called with EncodingParameters (@unstable: VIDEO-9969)', () => { | ||||||||||
const minAudioBitrate = 6000; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be marked unstable only for firefox, make sure
Suggested change
|
||||||||||
const minVideoBitrate = 20000; | ||||||||||
combinationContext([ | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a changelog entry