Skip to content

Commit

Permalink
wip: Combine three Fuchsia-related PRs to run lab tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed May 11, 2024
1 parent 03ee77e commit d4332cc
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 40 deletions.
20 changes: 20 additions & 0 deletions lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ shaka.util.Platform = class {
return Platform.isChromecast() && Platform.isAndroid();
}

/**
* Check if the current platform is a Google Chromecast with Android
* (i.e. Chromecast with GoogleTV).
*
* @return {boolean}
*/
static isFuchsiaCastDevice() {
const Platform = shaka.util.Platform;
return Platform.isChromecast() && Platform.isFuchsia();
}

/**
* Returns a major version number for Chrome, or Chromium-based browsers.
*
Expand Down Expand Up @@ -459,6 +470,15 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('Android');
}

/**
* Return true if the platform is a Fuchsia, regardless of the browser.
*
* @return {boolean}
*/
static isFuchsia() {
return shaka.util.Platform.userAgentContains_('Fuchsia');
}

/**
* Return true if the platform is controlled by a remote control.
*
Expand Down
26 changes: 18 additions & 8 deletions test/media/drm_engine_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
describe('DrmEngine', () => {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

// These come from Axinom and use the Axinom license server.
// TODO: Do not rely on third-party services long-term.
// These come from Axinom.
const videoInitSegmentUri = '/base/test/test/assets/multidrm-video-init.mp4';
const videoSegmentUri = '/base/test/test/assets/multidrm-video-segment.mp4';
const audioInitSegmentUri = '/base/test/test/assets/multidrm-audio-init.mp4';
Expand Down Expand Up @@ -89,9 +88,13 @@ describe('DrmEngine', () => {
drmEngine = new shaka.media.DrmEngine(playerInterface);
const config = shaka.util.PlayerConfiguration.createDefault().drm;
config.servers['com.widevine.alpha'] =
'https://cwip-shaka-proxy.appspot.com/specific_key?blodJidXR9eARuql0dNLWg=GX8m9XLIZNIzizrl0RTqnA';
'https://cwip-shaka-proxy.appspot.com/specific_key?QGCoZYh4Qmecv5GuW64ecg=/DU0CDcxDMD7U96X4ipp4A';
config.servers['com.microsoft.playready'] =
'https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:6e5a1d26-2757-47d7-8046-eaa5d1d34b5a,contentkey:GX8m9XLIZNIzizrl0RTqnA==,sl:150)';
'https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:4060a865-8878-4267-9cbf-91ae5bae1e72,contentkey:/DU0CDcxDMD7U96X4ipp4A==,sl:150)';
config.preferredKeySystems = [
'com.widevine.alpha',
'com.microsoft.playready',
];
drmEngine.configure(config);

manifest = shaka.test.ManifestGenerator.generate((manifest) => {
Expand Down Expand Up @@ -179,8 +182,11 @@ describe('DrmEngine', () => {
eventManager.listen(video, 'encrypted', () => {
encryptedEventSeen.resolve();
});

eventManager.listen(video, 'error', () => {
fail('MediaError message ' + video.error.message);
fail('MediaError code ' + video.error.code);

let extended = video.error.msExtendedCode;
if (extended) {
if (extended < 0) {
Expand All @@ -197,16 +203,17 @@ describe('DrmEngine', () => {
});

const variants = manifest.variants;

await drmEngine.initForPlayback(variants, manifest.offlineSessionIds);
await drmEngine.attach(video);

await mediaSourceEngine.appendBuffer(
ContentType.VIDEO, videoInitSegment, null, fakeStream,
/* hasClosedCaptions= */ false);
await mediaSourceEngine.appendBuffer(
ContentType.AUDIO, audioInitSegment, null, fakeStream,
/* hasClosedCaptions= */ false);
await encryptedEventSeen;

// With PlayReady, a persistent license policy can cause a different
// chain of events. In particular, the request is bypassed and we
// get a usable key right away.
Expand Down Expand Up @@ -264,8 +271,8 @@ describe('DrmEngine', () => {
// Configure DrmEngine for ClearKey playback.
const config = shaka.util.PlayerConfiguration.createDefault().drm;
config.clearKeys = {
// From https://github.com/Axinom/public-test-vectors/tree/conservative#v61-multidrm
'6e5a1d26275747d78046eaa5d1d34b5a': '197f26f572c864d2338b3ae5d114ea9c',
// From https://github.com/Axinom/public-test-vectors/blob/master/README.md#v10
'4060a865887842679cbf91ae5bae1e72': 'fc35340837310cc0fb53de97e22a69e0',
};
drmEngine.configure(config);

Expand All @@ -277,8 +284,11 @@ describe('DrmEngine', () => {
eventManager.listen(video, 'encrypted', () => {
encryptedEventSeen.resolve();
});

eventManager.listen(video, 'error', () => {
fail('MediaError message ' + video.error.message);
fail('MediaError code ' + video.error.code);

let extended = video.error.msExtendedCode;
if (extended) {
if (extended < 0) {
Expand All @@ -295,9 +305,9 @@ describe('DrmEngine', () => {
});

const variants = manifest.variants;

await drmEngine.initForPlayback(variants, manifest.offlineSessionIds);
await drmEngine.attach(video);

await mediaSourceEngine.appendBuffer(
ContentType.VIDEO, videoInitSegment, null, fakeStream,
/* hasClosedCaptions= */ false);
Expand Down
3 changes: 1 addition & 2 deletions test/offline/storage_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,7 @@ filterDescribe('Storage', storageSupport, () => {
/** @type {!shaka.util.EventManager} */
let eventManager;
/** @type {!HTMLVideoElement} */
const videoElement = /** @type {!HTMLVideoElement} */(
document.createElement('video'));
const videoElement = shaka.test.UiUtils.createVideoElement();

beforeEach(async () => {
netEngine = makeNetworkEngine();
Expand Down
Binary file modified test/test/assets/multidrm-audio-init.mp4
Binary file not shown.
Binary file modified test/test/assets/multidrm-audio-segment.mp4
Binary file not shown.
Binary file modified test/test/assets/multidrm-video-init.mp4
Binary file not shown.
Binary file modified test/test/assets/multidrm-video-segment.mp4
Binary file not shown.
45 changes: 28 additions & 17 deletions test/test/util/test_scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,47 +453,58 @@ const widevineDrmServers = {
'com.widevine.alpha': 'https://cwip-shaka-proxy.appspot.com/no_auth',
};

/** @type {string} */
const axinomMultiDrmInitData = [
'AAAAXHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADwSEEBgqGWIeEJnnL+RrluuHnISEE',
'BgqGWIeEJnnL+RrluuHnISEEBgqGWIeEJnnL+RrluuHnJI49yVmwYAAAImcHNzaAAAAACa',
'BPB5mEBChquS5lvgiF+VAAACBgYCAAABAAEA/AE8AFcAUgBNAEgARQBBAEQARQBSACAAeA',
'BtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8A',
'cwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAG',
'UAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAu',
'ADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQ',
'BMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMA',
'VABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAE',
'kARAA+AFoAYQBoAGcAUQBIAGkASQBaADAASwBjAHYANQBHAHUAVwA2ADQAZQBjAGcAPQA9',
'ADwALwBLAEkARAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4AeQB4AGwARwBsAGgAZgBEACsAYQ',
'BjAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgA',
'RQBBAEQARQBSAD4A',
].join('');

/** @type {AVMetadataType} */
const axinomMultiDrmVideoSegment = {
// Taken from Axinom's v6 test vector.
// Taken from Axinom's v10 test vectors.
initSegmentUri: '/base/test/test/assets/multidrm-video-init.mp4',
mdhdOffset: 0x1d1,
mdhdOffset: 0x191,
segmentUri: '/base/test/test/assets/multidrm-video-segment.mp4',
tfdtOffset: 0x78,
tfdtOffset: 0x88,
segmentDuration: 4,
mimeType: 'video/mp4',
codecs: 'avc1.64001e',
initData:
'AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQblodJidXR9eARuq' +
'l0dNLWg==',
initData: axinomMultiDrmInitData,
};

/** @type {AVMetadataType} */
const axinomMultiDrmAudioSegment = {
// Taken from Axinom's v6 test vector.
// Taken from Axinom's v10 test vectors.
initSegmentUri: '/base/test/test/assets/multidrm-audio-init.mp4',
mdhdOffset: 0x192,
mdhdOffset: 0x18d,
segmentUri: '/base/test/test/assets/multidrm-audio-segment.mp4',
tfdtOffset: 0x7c,
tfdtOffset: 0x88,
segmentDuration: 4,
mimeType: 'audio/mp4',
codecs: 'mp4a.40.2',
initData:
'AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQblodJidXR9eARuq' +
'l0dNLWg==',
initData: axinomMultiDrmInitData,
};

/** @type {!Object.<string, string>} */
const axinomDrmServers = {
// NOTE: These are not Axinom's actual servers. These are test servers for
// Widevine and PlayReady that let us specify the known key IDs and keys for
// Axinom's v6 test vectors. Axinom's own servers started returning 403
// errors for these older test vectors, and we were forced to switch to
// something stable and independent.
// Axinom's v10 test vectors.
'com.widevine.alpha':
'https://cwip-shaka-proxy.appspot.com/specific_key?blodJidXR9eARuql0dNLWg=GX8m9XLIZNIzizrl0RTqnA',
'https://cwip-shaka-proxy.appspot.com/specific_key?QGCoZYh4Qmecv5GuW64ecg=/DU0CDcxDMD7U96X4ipp4A',
'com.microsoft.playready':
'https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:6e5a1d26-2757-47d7-8046-eaa5d1d34b5a,contentkey:GX8m9XLIZNIzizrl0RTqnA==,sl:150)',
'https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:4060a865-8878-4267-9cbf-91ae5bae1e72,contentkey:/DU0CDcxDMD7U96X4ipp4A==,sl:150)',
};

/** @type {TextMetadataType} */
Expand Down
8 changes: 5 additions & 3 deletions test/test/util/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ shaka.test.UiUtils = class {
const video = /** @type {!HTMLVideoElement} */(document.createElement(
'video'));

// Tizen has issues with audio-only playbacks on muted video elements.
// Don't mute Tizen.
if (!shaka.util.Platform.isTizen()) {
// Some platforms have issues with audio-only playbacks on muted video
// elements. Don't mute them.
// Fuchsia reference: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/media/web_media_player_impl.cc;l=3535;drc=d23075f3
if (!shaka.util.Platform.isTizen() &&
!shaka.util.Platform.isFuchsiaCastDevice()) {
video.muted = true;
}
video.width = 600;
Expand Down
22 changes: 14 additions & 8 deletions test/test/util/waiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,31 @@ shaka.test.Waiter = class {
const goalName = 'movement from ' + mediaElement.currentTime +
' to ' + timeGoal;

// The cleanup on timeout
let timer = null;
const cleanup = () => {
if (timer) {
timer.stop();
}
this.eventManager_.unlisten(mediaElement, 'timeupdate');
this.eventManager_.unlisten(mediaElement, 'ended');
};

// The conditions for success
const p = new Promise((resolve) => {
const check = () => {
if (mediaElement.currentTime >= timeGoal || mediaElement.ended) {
this.eventManager_.unlisten(mediaElement, 'timeupdate');
this.eventManager_.unlisten(mediaElement, 'ended');
cleanup();
resolve();
}
};

timer = new shaka.util.Timer(check);
timer.tickEvery(/* seconds= */ 1);
this.eventManager_.listen(mediaElement, 'timeupdate', check);
this.eventManager_.listen(mediaElement, 'ended', check);
});

// The cleanup on timeout
const cleanup = () => {
this.eventManager_.unlisten(mediaElement, 'timeupdate');
this.eventManager_.unlisten(mediaElement, 'ended');
};

return this.waitUntilGeneric_(goalName, p, cleanup, mediaElement);
}

Expand Down
3 changes: 1 addition & 2 deletions test/ui/ui_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ describe('UI', () => {
// multi-video use case. It could be replaces with any other
// (reasonable) number.
for (let i = 0; i < 4; i++) {
const video = /** @type {!HTMLVideoElement} */
(document.createElement('video'));
const video = shaka.test.UiUtils.createVideoElement();

document.body.appendChild(video);
videos.push(video);
Expand Down

0 comments on commit d4332cc

Please sign in to comment.