Skip to content

Commit

Permalink
fix(DASH): Allow play all time fastSwitching tracks (#7180)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored and joeyparrish committed Aug 20, 2024
1 parent bb2f99d commit 482d8d4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
5 changes: 2 additions & 3 deletions externs/shaka/abr_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ shaka.extern.AbrManager = class {

/**
* Chooses one variant to switch to. Called by the Player.
* @param {boolean=} preferFastSwitching If not provided meant "avoid fast
* switching if possible".
*
* @return {shaka.extern.Variant}
* @exportDoc
*/
chooseVariant(preferFastSwitching) {}
chooseVariant() {}

/**
* Enables automatic Variant choices from the last ones passed to setVariants.
Expand Down
6 changes: 2 additions & 4 deletions lib/abr/simple_abr_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,11 @@ shaka.abr.SimpleAbrManager = class {


/**
* @param {boolean=} preferFastSwitching
* @return {shaka.extern.Variant}
* @override
* @export
*/
chooseVariant(preferFastSwitching = false) {
chooseVariant() {
let maxHeight = Infinity;
let maxWidth = Infinity;

Expand Down Expand Up @@ -200,8 +199,7 @@ shaka.abr.SimpleAbrManager = class {
}

let variants = normalVariants;
if (preferFastSwitching &&
normalVariants.length != this.variants_.length) {
if (normalVariants.length != this.variants_.length) {
variants = this.variants_.filter((variant) => {
return variant && shaka.util.StreamUtils.isFastSwitching(variant);
});
Expand Down
3 changes: 1 addition & 2 deletions lib/media/preload_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
// Guess what the first variant will be, based on a SimpleAbrManager.
this.abrManager_.configure(this.config_.abr);
this.abrManager_.setVariants(Array.from(adaptationSet.values()));
const variant =
this.abrManager_.chooseVariant(/* preferFastSwitching= */ true);
const variant = this.abrManager_.chooseVariant();
if (variant) {
this.prefetchedVariant_ = variant;
if (variant.video) {
Expand Down
4 changes: 0 additions & 4 deletions lib/media/segment_prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ shaka.media.SegmentPrefetch = class {
segmentPrefetchOperation.dispatchFetch(reference, this.stream_);
this.segmentPrefetchMap_.set(reference, segmentPrefetchOperation);
}
if (this.stream_.fastSwitching && reference.isPartial() &&
reference.isLastPartial()) {
break;
}
}
this.clearInitSegments_();
}
Expand Down
11 changes: 3 additions & 8 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
do {
activeVariant = this.streamingEngine_.getCurrentVariant();
if (!activeVariant && !initialVariant) {
initialVariant = this.chooseVariant_(/* initialSelection= */ true);
initialVariant = this.chooseVariant_();
goog.asserts.assert(initialVariant, 'Must choose an initial variant!');
}

Expand Down Expand Up @@ -3620,10 +3620,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
this.onSegmentAppended_(
reference.startTime, reference.endTime, stream.type,
stream.codecs.includes(','));
if (this.abrManager_ && stream.fastSwitching &&
reference.isPartial() && reference.isLastPartial()) {
this.abrManager_.trySuggestStreams();
}
},
onInitSegmentAppended: (position, initSegment) => {
const mediaQuality = initSegment.getMediaQuality();
Expand Down Expand Up @@ -6760,13 +6756,12 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
*
* On error, this dispatches an error event and returns null.
*
* @param {boolean=} initialSelection
* @return {?shaka.extern.Variant}
* @private
*/
chooseVariant_(initialSelection = false) {
chooseVariant_() {
if (this.updateAbrManagerVariants_()) {
return this.abrManager_.chooseVariant(initialSelection);
return this.abrManager_.chooseVariant();
} else {
return null;
}
Expand Down

0 comments on commit 482d8d4

Please sign in to comment.