Skip to content

Commit

Permalink
Properly calculate the amount of sourcebuffers needed for streams wit…
Browse files Browse the repository at this point in the history
…h multiple non-alternate audio renditions (video-dev#1638)

* set altAudio only if videoCodecFound is true
* check if video is expected in onManifestParsed
  • Loading branch information
johnBartos authored Apr 13, 2018
1 parent fdc4c97 commit 2f99e66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controller/buffer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BufferController extends EventHandler {

onManifestParsed (data) {
let audioExpected = data.audio,
videoExpected = data.video || (data.levels.length && data.audio),
videoExpected = data.video || (data.levels.length && data.altAudio),
sourceBufferNb = 0;
// in case of alt audio 2 BUFFER_CODECS events will be triggered, one per stream controller
// sourcebuffers will be created all at once when the expected nb of tracks will be reached
Expand Down
3 changes: 2 additions & 1 deletion src/controller/cap-level-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class CapLevelController extends EventHandler {
onManifestParsed (data) {
const hls = this.hls;
this.restrictedLevels = [];
if (hls.config.capLevelToPlayerSize) {
// Only fire getMaxLevel or detectPlayerSize if video is expected in the manifest
if (hls.config.capLevelToPlayerSize && (data.video || (data.levels.length && data.altAudio))) {
this.autoLevelCapping = Number.POSITIVE_INFINITY;
this.levels = data.levels;
hls.firstLevel = this.getMaxLevel(data.firstLevel);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/level-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class LevelController extends EventHandler {
stats: data.stats,
audio: audioCodecFound,
video: videoCodecFound,
altAudio: audioTracks.length > 0
altAudio: audioTracks.length > 0 && videoCodecFound
});
} else {
this.hls.trigger(Event.ERROR, {
Expand Down
8 changes: 7 additions & 1 deletion tests/test-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,11 @@ module.exports = {
widevineLicenseUrl: 'https://cwip-shaka-proxy.appspot.com/no_auth',
emeEnabled: true
}
)
),
audioOnlyMultipleLevels: {
'url': 'https://s3.amazonaws.com/bob.jwplayer.com/~alex/121628/new_master.m3u8',
'description': 'Multiple non-alternate audio levels',
'live': false,
'abr': false
}
};

0 comments on commit 2f99e66

Please sign in to comment.