-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add safe margin parameter to avoid rebuffering interruptions when clearing the buffer #1154
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ec609a6
Introduced optional safe margin when clearing the buffer to avoid reb…
wasp898 c265c00
Fixed calls to switchInternal_ to reflect that the safe margin is a n…
wasp898 4f6316f
Fixed errors that made the build fail.
wasp898 50260b6
Fix unit test files + update contributors list
wasp898 8bfd113
Refactor optional parameters and comply with style requirements
wasp898 0270ac9
Fix same margin type issue
wasp898 cc7b0a5
Fix styling issue in player.js and streaming_engine_unit
wasp898 e4b1880
Rename deferred safe margin variable
wasp898 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
Refactor optional parameters and comply with style requirements
- Loading branch information
commit 8bfd1135fcb76ac010dadd33626e46e9f367f2e4
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ shaka.Player = function(video, dependencyInjector) { | |
/** @private {number} */ | ||
this.deferredVariantClearBufferOffset_ = 0; | ||
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. "Deferred" is fine here, but again, I think it should include safeMargin instead of offset. |
||
|
||
/** @private {?shakaExtern.Stream} */ | ||
/** @private {?shaka.extern.Stream} */ | ||
this.deferredTextStream_ = null; | ||
|
||
/** | ||
|
@@ -1642,12 +1642,12 @@ shaka.Player.prototype.usingEmbeddedTextTrack = function() { | |
* track selections. | ||
* | ||
* @param {shaka.extern.Track} track | ||
* @param {boolean=} opt_clearBuffer | ||
* @param {number=} opt_safeMargin | ||
* @param {boolean=} clearBuffer | ||
* @param {?number=} safeMargin | ||
* @export | ||
*/ | ||
shaka.Player.prototype.selectVariantTrack = function(track, opt_clearBuffer, | ||
opt_safeMargin) { | ||
shaka.Player.prototype.selectVariantTrack = function( | ||
track, clearBuffer, safeMargin = 0) { | ||
if (!this.streamingEngine_) { | ||
return; | ||
} | ||
|
@@ -1682,7 +1682,7 @@ shaka.Player.prototype.selectVariantTrack = function(track, opt_clearBuffer, | |
|
||
// Add entries to the history. | ||
this.addVariantToSwitchHistory_(variant, /* fromAdaptation */ false); | ||
this.switchVariant_(variant, opt_clearBuffer, opt_safeMargin); | ||
this.switchVariant_(variant, clearBuffer, safeMargin || 0); | ||
|
||
// Workaround for https://github.com/google/shaka-player/issues/1299 | ||
// When track is selected, back-propogate the language to | ||
|
@@ -2499,21 +2499,21 @@ shaka.Player.prototype.filterNewPeriod_ = function(period) { | |
/** | ||
* Switches to the given variant, deferring if needed. | ||
* @param {shaka.extern.Variant} variant | ||
* @param {boolean=} opt_clearBuffer | ||
* @param {number=} opt_safeMargin | ||
* @param {boolean=} clearBuffer | ||
* @param {?number=} safeMargin | ||
* @private | ||
*/ | ||
shaka.Player.prototype.switchVariant_ = | ||
function(variant, opt_clearBuffer, opt_safeMargin) { | ||
function(variant, clearBuffer, safeMargin = 0) { | ||
if (this.switchingPeriods_) { | ||
// Store this action for later. | ||
this.deferredVariant_ = variant; | ||
this.deferredVariantClearBuffer_ = opt_clearBuffer || false; | ||
this.deferredVariantClearBufferOffset_ = opt_safeMargin || 0; | ||
this.deferredVariantClearBuffer_ = clearBuffer || false; | ||
this.deferredVariantClearBufferOffset_ = safeMargin || 0; | ||
} else { | ||
// Act now. | ||
this.streamingEngine_.switchVariant(variant, opt_clearBuffer || false, | ||
opt_safeMargin || 0); | ||
this.streamingEngine_.switchVariant( | ||
variant, clearBuffer || false, safeMargin || 0); | ||
} | ||
}; | ||
|
||
|
@@ -2969,12 +2969,12 @@ shaka.Player.prototype.onSegmentAppended_ = function() { | |
* Callback from AbrManager. | ||
* | ||
* @param {shaka.extern.Variant} variant | ||
* @param {boolean=} opt_clearBuffer | ||
* @param {number=} opt_safeMargin | ||
* @param {boolean=} clearBuffer | ||
* @param {?number=} safeMargin | ||
* @private | ||
*/ | ||
shaka.Player.prototype.switch_ = function(variant, opt_clearBuffer, | ||
opt_safeMargin) { | ||
shaka.Player.prototype.switch_ = function( | ||
variant, clearBuffer, safeMargin = 0) { | ||
shaka.log.debug('switch_'); | ||
goog.asserts.assert(this.config_.abr.enabled, | ||
'AbrManager should not call switch while disabled!'); | ||
|
@@ -2988,9 +2988,8 @@ shaka.Player.prototype.switch_ = function(variant, opt_clearBuffer, | |
return; | ||
} | ||
|
||
var clearBuffer = opt_clearBuffer || false; | ||
var safeMargin = opt_safeMargin || 0; | ||
this.streamingEngine_.switchVariant(variant, clearBuffer, safeMargin); | ||
this.streamingEngine_.switchVariant( | ||
variant, clearBuffer || false, safeMargin || 0); | ||
this.onAdaptation_(); | ||
}; | ||
|
||
|
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.
The style is to keep all the arguments aligned. So please do either:
Or