Skip to content

Commit

Permalink
fix(ABR): Do not adapt between spatial & non spatial audio (#7067)
Browse files Browse the repository at this point in the history
Do not adapt between spatial & non spatial audio to avoid annoying
users.
  • Loading branch information
tykus160 committed Jul 19, 2024
1 parent 38c691b commit 1dc5c87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/media/adaptation_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ shaka.media.AdaptationSet = class {
}
}

// Don't adapt between spatial and non spatial audio, which may
// annoy the user.
if (a.spatialAudio !== b.spatialAudio) {
return false;
}

// We can only adapt between base-codecs.
if (compareCodecs && !AdaptationSet.canTransitionBetween_(a, b)) {
return false;
Expand Down
22 changes: 20 additions & 2 deletions test/media/adaptation_set_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ describe('AdaptationSet', () => {
expect(set.canInclude(variants[1])).toBeFalsy();
});

it('rejects misaligned spatial audio', () => {
const variants = [
makeVariant(
1, // variant id
makeStream(11, 'a', ['a.35'], [], 6, false),
makeStream(12, 'a', ['b.12'], [], 6, false)),
makeVariant(
2, // variant id
makeStream(21, 'a', ['a.35'], [], 6, true),
makeStream(22, 'a', ['b.12'], [], 6, true)),
];

const set = new shaka.media.AdaptationSet(variants[0]);
expect(set.canInclude(variants[1])).toBeFalsy();
});

/**
* Create a variant where the audio stream is optional but the video stream
* is required. For the cases where audio and video are in the same stream,
Expand Down Expand Up @@ -193,13 +209,15 @@ describe('AdaptationSet', () => {
* @param {!Array.<string>} codecs
* @param {!Array.<string>} roles
* @param {?number} channelsCount
* @param {boolean=} spatialAudio
* @return {shaka.extern.Stream}
*/
function makeStream(id, mimeType, codecs, roles, channelsCount) {
function makeStream(id, mimeType, codecs, roles, channelsCount,
spatialAudio = false) {
return {
audioSamplingRate: null,
channelsCount: channelsCount,
spatialAudio: false,
spatialAudio,
closedCaptions: null,
codecs: codecs.join(','),
createSegmentIndex: () => Promise.resolve(),
Expand Down

0 comments on commit 1dc5c87

Please sign in to comment.