Skip to content

Commit

Permalink
test: Use MCap on StreamUtils tests (shaka-project#6604)
Browse files Browse the repository at this point in the history
This prevents any tests from being skipped in Safari.
  • Loading branch information
avelad committed May 14, 2024
1 parent 024cb9b commit 87de6e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
8 changes: 6 additions & 2 deletions test/test/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,18 @@ shaka.test.Util = class {
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
return false;
}
const baseMimeType = MimeUtils.getBasicType(mimetype);
// AudioConfiguration
mediaDecodingConfig.audio = {
contentType: mimetype,
contentType: MimeUtils.getFullType(baseMimeType, codecs),
};
} else {
const codecs = StreamUtils.getCorrectVideoCodecs(
MimeUtils.getCodecs(mimetype));
const baseMimeType = MimeUtils.getBasicType(mimetype);
// VideoConfiguration
mediaDecodingConfig.video = {
contentType: mimetype,
contentType: MimeUtils.getFullType(baseMimeType, codecs),

// NOTE: Some decoders strictly check the width and height fields and
// won't decode smaller than 64x64. So if we don't have this info (as
Expand Down
33 changes: 17 additions & 16 deletions test/util/stream_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

describe('StreamUtils', () => {
const Util = shaka.test.Util;
const StreamUtils = shaka.util.StreamUtils;

let manifest;
Expand Down Expand Up @@ -678,7 +679,7 @@ describe('StreamUtils', () => {
});

it('supports VP9 codec', async () => {
if (!MediaSource.isTypeSupported('video/webm; codecs="vp9"')) {
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
pending('Codec VP9 is not supported by the platform.');
}
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand All @@ -695,7 +696,7 @@ describe('StreamUtils', () => {
});

it('supports fLaC codec', async () => {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="flac"')) {
if (!await Util.isTypeSupported('audio/mp4; codecs="flac"')) {
pending('Codec fLaC is not supported by the platform.');
}
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand All @@ -717,7 +718,7 @@ describe('StreamUtils', () => {
});

it('supports Opus codec', async () => {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="opus"')) {
if (!await Util.isTypeSupported('audio/mp4; codecs="opus"')) {
pending('Codec Opus is not supported by the platform.');
}
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand All @@ -739,7 +740,7 @@ describe('StreamUtils', () => {
});

it('supports legacy AVC1 codec', async () => {
if (!MediaSource.isTypeSupported('video/mp4; codecs="avc1.42001e"')) {
if (!await Util.isTypeSupported('video/mp4; codecs="avc1.42001e"')) {
pending('Codec avc1.42001e is not supported by the platform.');
}
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand Down Expand Up @@ -886,11 +887,11 @@ describe('StreamUtils', () => {
.toBeTruthy();
});

it('should allow multiple codecs for codec switching', () => {
if (!MediaSource.isTypeSupported('video/webm; codecs="vp9"')) {
it('should allow multiple codecs for codec switching', async () => {
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
pending('Codec VP9 is not supported by the platform.');
}
if (!MediaSource.isTypeSupported('video/webm; codecs="vorbis"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="vorbis"')) {
pending('Codec vorbis is not supported by the platform.');
}
// This test is flaky in some Tizen devices, due to codec restrictions.
Expand All @@ -915,11 +916,11 @@ describe('StreamUtils', () => {
.not.toBe(manifest.variants[1].video.codecs);
});

it('chooses preferred audio and video codecs', () => {
if (!MediaSource.isTypeSupported('video/webm; codecs="vp9"')) {
it('chooses preferred audio and video codecs', async () => {
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
pending('Codec VP9 is not supported by the platform.');
}
if (!MediaSource.isTypeSupported('video/webm; codecs="vorbis"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="vorbis"')) {
pending('Codec vorbis is not supported by the platform.');
}
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand All @@ -937,11 +938,11 @@ describe('StreamUtils', () => {
expect(variants[0].audio.codecs).toBe('mp4a.40.2');
});

it('chooses preferred video codecs', () => {
if (!MediaSource.isTypeSupported('video/webm; codecs="vp9"')) {
it('chooses preferred video codecs', async () => {
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
pending('Codec VP9 is not supported by the platform.');
}
if (!MediaSource.isTypeSupported('video/webm; codecs="vorbis"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="vorbis"')) {
pending('Codec vorbis is not supported by the platform.');
}
// If no preferred audio codecs is specified or can be found, choose the
Expand All @@ -963,11 +964,11 @@ describe('StreamUtils', () => {
expect(variants[1].audio.codecs).toBe('mp4a.40.2');
});

it('chooses preferred audio codecs', () => {
if (!MediaSource.isTypeSupported('video/webm; codecs="vp9"')) {
it('chooses preferred audio codecs', async () => {
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
pending('Codec VP9 is not supported by the platform.');
}
if (!MediaSource.isTypeSupported('video/webm; codecs="vorbis"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="vorbis"')) {
pending('Codec vorbis is not supported by the platform.');
}
// If no preferred video codecs is specified or can be found, choose the
Expand Down

0 comments on commit 87de6e0

Please sign in to comment.