Skip to content

Commit

Permalink
fix: do not try to use unsupported audio (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jul 10, 2020
1 parent 406cbcd commit 7711b26
Show file tree
Hide file tree
Showing 11 changed files with 405 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/create-test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const getManifests = () => (fs.readdirSync(manifestsDir) || [])
.map((f) => path.resolve(manifestsDir, f));

const getSegments = () => (fs.readdirSync(segmentsDir) || [])
.filter((f) => ((/\.(ts|mp4|key|webm)/).test(path.extname(f))))
.filter((f) => ((/\.(ts|mp4|key|webm|aac|ac3)/).test(path.extname(f))))
.map((f) => path.resolve(segmentsDir, f));

const buildManifestString = function() {
Expand Down
2 changes: 1 addition & 1 deletion src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
codecs.video += `,${playlistCodecs.audio || media.main.audioCodec || DEFAULT_AUDIO_CODEC}`;
}

if ((media.main.hasAudio && !media.main.isMuxed) || media.audio.hasAudio) {
if ((media.main.hasAudio && !media.main.isMuxed) || media.audio.hasAudio || usingAudioLoader) {
codecs.audio = playlistCodecs.audio || media.main.audioCodec || media.audio.audioCodec || DEFAULT_AUDIO_CODEC;
// set audio isFmp4 so we use the correct "supports" function below
media.audio.isFmp4 = (media.main.hasAudio && !media.main.isMuxed) ? media.main.isFmp4 : media.audio.isFmp4;
Expand Down
10 changes: 10 additions & 0 deletions src/media-segment-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ const handleSegmentBytes = ({
return;
}

if (typeof segment.container === 'undefined') {
segment.container = detectContainerForBytes(bytesAsUint8Array);
}

if (segment.container !== 'ts' && segment.container !== 'aac') {
trackInfoFn(segment, {hasAudio: false, hasVideo: false});
doneFn(null, segment, {});
return;
}

// ts or aac
transmuxAndNotify({
segment,
Expand Down
2 changes: 1 addition & 1 deletion src/segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ export default class SegmentLoader extends videojs.EventTarget {
// When we have track info, determine what media types this loader is dealing with.
// Guard against cases where we're not getting track info at all until we are
// certain that all streams will provide it.
if ((trackInfo.hasVideo || trackInfo.hasAudio) && !shallowEqual(this.startingMedia_, trackInfo)) {
if (!shallowEqual(this.startingMedia_, trackInfo)) {
this.startingMedia_ = trackInfo;
this.logger_('trackinfo update', trackInfo);
this.trigger('trackinfo');
Expand Down
4 changes: 2 additions & 2 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ QUnit.test(
// playlist
this.standardXHRResponse(this.requests.shift());
// segment
this.standardXHRResponse(this.requests.shift());
this.standardXHRResponse(this.requests.shift(), muxedSegment());
// change the source
this.player.src({
src: 'manifest/master.m3u8',
Expand Down Expand Up @@ -3100,7 +3100,7 @@ QUnit.test('switches off subtitles on subtitle errors', function(assert) {
// media
this.standardXHRResponse(this.requests.shift());
// media segment
this.standardXHRResponse(this.requests.shift());
this.standardXHRResponse(this.requests.shift(), muxedSegment());

const textTracks = this.player.textTracks();

Expand Down
Loading

0 comments on commit 7711b26

Please sign in to comment.