Skip to content

Commit

Permalink
test: Use MCap in test conditions (#6567)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 10, 2024
1 parent a1e4781 commit 43f275b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 91 deletions.
31 changes: 8 additions & 23 deletions test/codec_switching/codec_switching_integration.js
Expand Up @@ -19,21 +19,6 @@ describe('Codec Switching', () => {
/** @type {!shaka.test.Waiter} */
let waiter;

function isEc3Supported() {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) {
return false;
}
// It seems that EC3 on Edge Windows from github actions is not working
// (in the lab EC3 is working). The EC3 detection is currently hard-coded
// to true, which leads to a failure in GitHub's environment.
// We must enable this, once it is resolved:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
if (shaka.util.Platform.isWindows() && shaka.util.Platform.isEdge()) {
return false;
}
return true;
}

beforeAll(async () => {
video = shaka.test.UiUtils.createVideoElement();
document.body.appendChild(video);
Expand Down Expand Up @@ -74,7 +59,7 @@ describe('Codec Switching', () => {

describe('for audio and only-audio content aac -> opus', () => {
it('can switch codecs RELOAD', async () => {
if (!MediaSource.isTypeSupported('audio/webm; codecs="opus"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="opus"')) {
pending('Codec OPUS in WEBM is not supported by the platform.');
}

Expand Down Expand Up @@ -110,7 +95,7 @@ describe('Codec Switching', () => {
pending('Mediasource.ChangeType is not considered ' +
'reliable on this device');
}
if (!MediaSource.isTypeSupported('audio/webm; codecs="opus"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="opus"')) {
pending('Codec OPUS in WEBM is not supported by the platform.');
}

Expand Down Expand Up @@ -144,7 +129,7 @@ describe('Codec Switching', () => {

describe('for audio opus -> aac', () => {
it('can switch codecs RELOAD', async () => {
if (!MediaSource.isTypeSupported('audio/webm; codecs="opus"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="opus"')) {
pending('Codec OPUS in WEBM is not supported by the platform.');
}

Expand Down Expand Up @@ -179,7 +164,7 @@ describe('Codec Switching', () => {
pending('Mediasource.ChangeType is not considered ' +
'reliable on this device');
}
if (!MediaSource.isTypeSupported('audio/webm; codecs="opus"')) {
if (!await Util.isTypeSupported('audio/webm; codecs="opus"')) {
pending('Codec OPUS in WEBM is not supported by the platform.');
}

Expand Down Expand Up @@ -212,7 +197,7 @@ describe('Codec Switching', () => {

describe('for audio aac -> ec3', () => {
it('can switch codecs RELOAD', async () => {
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC3 in MP4 is not supported by the platform.');
}

Expand Down Expand Up @@ -248,7 +233,7 @@ describe('Codec Switching', () => {
pending('Mediasource.ChangeType is not considered ' +
'reliable on this device');
}
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC3 in MP4 is not supported by the platform.');
}

Expand Down Expand Up @@ -282,7 +267,7 @@ describe('Codec Switching', () => {

describe('for audio ec3 -> aac', () => {
it('can switch codecs RELOAD', async () => {
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC3 in MP4 is not supported by the platform.');
}

Expand Down Expand Up @@ -318,7 +303,7 @@ describe('Codec Switching', () => {
pending('Mediasource.ChangeType is not considered ' +
'reliable on this device');
}
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC3 in MP4 is not supported by the platform.');
}

Expand Down
57 changes: 57 additions & 0 deletions test/test/util/util.js
Expand Up @@ -310,6 +310,63 @@ shaka.test.Util = class {
// https://github.com/shaka-project/closure-compiler/issues/1422
return /** @type {Function} */(spy)(...varArgs);
}

/**
* @param {!string} mimetype
* @param {?number=} width
* @param {?number=} height
* @return {!Promise.<boolean>}
*/
static async isTypeSupported(mimetype, width, height) {
const MimeUtils = shaka.util.MimeUtils;
const StreamUtils = shaka.util.StreamUtils;

/** @type {!MediaDecodingConfiguration} */
const mediaDecodingConfig = {
type: 'media-source',
};
if (mimetype.startsWith('audio')) {
const codecs = StreamUtils.getCorrectAudioCodecs(
MimeUtils.getCodecs(mimetype));
if (codecs == 'ac-3' && shaka.util.Platform.isTizen()) {
// AC3 is flaky in some Tizen devices, so we need omit it for now.
return false;
}
if ((codecs == 'ec-3' || codecs == 'ac-3') &&
shaka.util.Platform.isWindows() && shaka.util.Platform.isEdge()) {
// It seems that AC3 and EC3 on Edge Windows from github actions is not
// working (in the lab AC3 and EC3 are working). The AC3 and EC3
// detection is currently hard-coded to true, which leads to a failure
// in GitHub's environment. We must enable this, once it is resolved:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
return false;
}
// AudioConfiguration
mediaDecodingConfig.audio = {
contentType: mimetype,
};
} else {
// VideoConfiguration
mediaDecodingConfig.video = {
contentType: mimetype,

// 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
// is the case in some of our simpler tests), assume a 64x64
// resolution to fill in this required field for MediaCapabilities.
//
// This became an issue specifically on Firefox on M1 Macs.
width: width || 64,
height: height || 64,

bitrate: 1,
framerate: 1,
};
}
const result =
await navigator.mediaCapabilities.decodingInfo(mediaDecodingConfig);
return result.supported;
}
};

/**
Expand Down
89 changes: 21 additions & 68 deletions test/transmuxer/transmuxer_integration.js
Expand Up @@ -22,61 +22,6 @@ describe('Transmuxer Player', () => {
/** @type {!shaka.test.Waiter} */
let waiter;

function isH265Supported() {
if (!MediaSource.isTypeSupported('video/mp4; codecs="hvc1.2.4.L123.B0"')) {
return false;
}
// As of Chrome 122, Chrome on Windows is still incorrectly reporting H.265
// support. Revisit this exclusion with a maximum chromeVersion if Chrome
// ever fixes it.
// We don't have a solid bug link for this issue. It's unclear if this is
// specific to GitHub CI systems, which may be missing some codecs.
const chromeVersion = shaka.util.Platform.chromeVersion();
if (shaka.util.Platform.isWindows() && chromeVersion) {
return false;
}
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
return true;
}

function isAc3Supported() {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="ac-3"')) {
return false;
}
// AC3 is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
return false;
}
// It seems that AC3 on Edge Windows from github actions is not working
// (in the lab AC3 is working). The AC3 detection is currently hard-coded
// to true, which leads to a failure in GitHub's environment.
// We must enable this, once it is resolved:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
if (shaka.util.Platform.isWindows() && shaka.util.Platform.isEdge()) {
return false;
}
return true;
}

function isEc3Supported() {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) {
return false;
}
// EC3 is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
return false;
}
// It seems that EC3 on Edge Windows from github actions is not working
// (in the lab EC3 is working). The EC3 detection is currently hard-coded
// to true, which leads to a failure in GitHub's environment.
// We must enable this, once it is resolved:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1450313
if (shaka.util.Platform.isWindows() && shaka.util.Platform.isEdge()) {
return false;
}
return true;
}

beforeAll(async () => {
video = shaka.test.UiUtils.createVideoElement();
document.body.appendChild(video);
Expand Down Expand Up @@ -132,7 +77,7 @@ describe('Transmuxer Player', () => {
});

it('raw MP3', async () => {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')) {
if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"')) {
pending('Codec MP3 in MP4 is not supported by the platform.');
}
await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8');
Expand All @@ -151,7 +96,7 @@ describe('Transmuxer Player', () => {
});

it('raw AC3', async () => {
if (!isAc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ac-3"')) {
pending('Codec AC-3 is not supported by the platform.');
}

Expand All @@ -171,7 +116,7 @@ describe('Transmuxer Player', () => {
});

it('raw EC3', async () => {
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC-3 is not supported by the platform.');
}

Expand Down Expand Up @@ -223,8 +168,8 @@ describe('Transmuxer Player', () => {
});

it('MP3 in TS', async () => {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"') &&
!MediaSource.isTypeSupported('audio/mpeg')) {
if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"') &&
!await Util.isTypeSupported('audio/mpeg')) {
pending('Codec MP3 is not supported by the platform.');
}
// This tests is flaky in some Tizen devices, so we need omit it for now.
Expand All @@ -247,7 +192,7 @@ describe('Transmuxer Player', () => {
});

it('AC3 in TS', async () => {
if (!isAc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ac-3"')) {
pending('Codec AC-3 is not supported by the platform.');
}

Expand All @@ -267,7 +212,7 @@ describe('Transmuxer Player', () => {
});

it('EC3 in TS', async () => {
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC-3 is not supported by the platform.');
}

Expand Down Expand Up @@ -305,7 +250,8 @@ describe('Transmuxer Player', () => {
});

it('H.265 in TS', async () => {
if (!isH265Supported()) {
if (!await Util.isTypeSupported('video/mp4; codecs="hvc1.2.4.L123.B0"',
/* width= */ 640, /* height= */ 360)) {
pending('Codec H.265 is not supported by the platform.');
}
await player.load('/base/test/test/assets/hls-ts-h265/hevc.m3u8');
Expand Down Expand Up @@ -365,7 +311,8 @@ describe('Transmuxer Player', () => {
});

it('H.265+AAC in TS', async () => {
if (!isH265Supported()) {
if (!await Util.isTypeSupported('video/mp4; codecs="hvc1.2.4.L123.B0"',
/* width= */ 720, /* height= */ 1280)) {
pending('Codec H.265 is not supported by the platform.');
}
if (shaka.util.Platform.isChromecast()) {
Expand Down Expand Up @@ -393,7 +340,7 @@ describe('Transmuxer Player', () => {
});

it('H.264+MP3 in TS', async () => {
if (!MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')) {
if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"')) {
pending('Codec MP3 in MP4 is not supported by the platform.');
}

Expand All @@ -414,9 +361,12 @@ describe('Transmuxer Player', () => {
});

it('H.264+AC3 in TS', async () => {
if (!isAc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ac-3"')) {
pending('Codec AC-3 is not supported by the platform.');
}
if (shaka.util.Platform.isTizen()) {
pending('Muxed AC-3 codec is not supported by the platform.');
}

// eslint-disable-next-line max-len
await player.load('/base/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8');
Expand All @@ -435,9 +385,12 @@ describe('Transmuxer Player', () => {
});

it('H.264+EC3 in TS', async () => {
if (!isEc3Supported()) {
if (!await Util.isTypeSupported('audio/mp4; codecs="ec-3"')) {
pending('Codec EC-3 is not supported by the platform.');
}
if (shaka.util.Platform.isTizen()) {
pending('Muxed AC-3 codec is not supported by the platform.');
}

// eslint-disable-next-line max-len
await player.load('/base/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8');
Expand All @@ -456,7 +409,7 @@ describe('Transmuxer Player', () => {
});

it('H.264+Opus in TS', 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.');
}

Expand Down

0 comments on commit 43f275b

Please sign in to comment.