Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add LCEVC SEI tests #8209

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions demo/common/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ shakaAssets.testAssets = [
dynamicPerformanceScaling: true,
logLevel: 0,
drawLogo: false,
poster: true,
},
}),
new ShakaDemoAssetInfo(
Expand All @@ -1583,6 +1584,7 @@ shakaAssets.testAssets = [
dynamicPerformanceScaling: true,
logLevel: 0,
drawLogo: false,
poster: true,
},
}),
new ShakaDemoAssetInfo(
Expand All @@ -1602,6 +1604,7 @@ shakaAssets.testAssets = [
dynamicPerformanceScaling: true,
logLevel: 0,
drawLogo: false,
poster: true,
},
}),
new ShakaDemoAssetInfo(
Expand All @@ -1620,6 +1623,7 @@ shakaAssets.testAssets = [
dynamicPerformanceScaling: true,
logLevel: 0,
drawLogo: false,
poster: true,
},
}),
new ShakaDemoAssetInfo(
Expand Down
3 changes: 2 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ shakaDemo.Config = class {
.addBoolInput_('LCEVC Dynamic Performance scaling',
'lcevc.dynamicPerformanceScaling')
.addNumberInput_('LCEVC Log Level', 'lcevc.logLevel')
.addBoolInput_('Draw LCEVC Logo', 'lcevc.drawLogo');
.addBoolInput_('Draw LCEVC Logo', 'lcevc.drawLogo')
.addBoolInput_('Enable LCEVC Poster', 'lcevc.poster');
}

/** @private */
Expand Down
19 changes: 19 additions & 0 deletions externs/lcevc.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ LCEVCdec.SupportObject.SupportStatus;
*/
LCEVCdec.SupportObject.SupportError;

/**
* Promise that resolves once the LCEVC libraries have finished loading.
* @type {Promise}
*/
LCEVCdec.ready;

/**
* LCEVC instance for debugging and testing
* @type {typeof LCEVCdec.LCEVCdec}
*/
LCEVCdec.instance;

/** @type {boolean} */
LCEVCdec.instance.isLcevcEnabled;
/** @type {boolean} */
LCEVCdec.instance.firstLcevcSegmentLoaded;
/** @type {boolean} */
LCEVCdec.instance.lcevcDataDetected;

/**
* Typedef for the module interface. Both LCEVCdec (new module) and LcevcDil
* (old module) implement roughly the same interface.
Expand Down
8 changes: 7 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,8 @@ shaka.extern.CmsdConfiguration;
* enabled: boolean,
* dynamicPerformanceScaling: boolean,
* logLevel: number,
* drawLogo: boolean
* drawLogo: boolean,
* poster: boolean
* }}
*
* @description
Expand Down Expand Up @@ -2375,6 +2376,11 @@ shaka.extern.CmsdConfiguration;
* unless explicitly set to true through config.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} poster
* If <code>true</code>, render a poster frame before the video is started.
* Defaults to true for the lib and set to true in the integration.
* <br>
* Defaults to <code>true</code>.
* @exportDoc
*/
shaka.extern.LcevcConfiguration;
Expand Down
8 changes: 8 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ module.exports = (config) => {
// codem-isoboxer module next
'node_modules/codem-isoboxer/dist/iso_boxer.min.js',

// LCEVC decoder libraries (.wasm & .js)
{
pattern: 'node_modules/lcevc_dec.js/dist/liblcevc_dpi.wasm',
included: false,
},
'node_modules/lcevc_dec.js/dist/lcevc_dec.min.js',

// EME encryption scheme polyfill, compiled into Shaka Player, but outside
// of the Closure deps system, so not in shaka-player.uncompiled.js. This
// is specifically the compiled, minified, cross-browser build of it. It
Expand Down Expand Up @@ -295,6 +302,7 @@ module.exports = (config) => {
{pattern: 'test/test/assets/hls-ts-muxed-opus-h264/*', included: false},
{pattern: 'test/test/assets/hls-ts-raw-aac/*', included: false},
{pattern: 'test/test/assets/hls-ts-rollover/*', included: false},
{pattern: 'test/test/assets/lcevc-sei/*', included: false},
{pattern: 'dist/shaka-player.ui.js', included: false},
{pattern: 'dist/locales.js', included: false},
{pattern: 'demo/**/*.js', included: false},
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ shaka.util.PlayerConfiguration = class {
dynamicPerformanceScaling: true,
logLevel: 0,
drawLogo: false,
poster: true,
};

const mediaSource = {
Expand Down
1 change: 1 addition & 0 deletions project-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ latm
laurl
lcevc
libav
liblcevc
linears
loas
lpcm
Expand Down
104 changes: 104 additions & 0 deletions test/lcevc/lcevc_integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

describe('LCEVC Integration', () => {
const Util = shaka.test.Util;

/** @type {!jasmine.Spy} */
let onErrorSpy;

/** @type {!HTMLCanvasElement} */
let canvas;

/** @type {!HTMLVideoElement} */
let video;
/** @type {shaka.Player} */
let player;
/** @type {!shaka.util.EventManager} */
let eventManager;

let compiledShaka;

/** @type {!shaka.test.Waiter} */
let waiter;

const seiManifests = {
FMP4_DASH: '/base/test/test/assets/lcevc-sei/lcevc-sei.mpd',
};

beforeAll(async () => {
video = shaka.test.UiUtils.createVideoElement();
canvas = shaka.test.UiUtils.createCanvasElement();

document.body.appendChild(video);
document.body.appendChild(canvas);

compiledShaka =
await shaka.test.Loader.loadShaka(getClientArg('uncompiled'));
});

beforeEach(async () => {
await shaka.test.TestScheme.createManifests(compiledShaka, '_compiled');
player = new compiledShaka.Player();

player.attachCanvas(canvas);
await player.attach(video);

// Enable the LCEVC enhancement.
player.configure('lcevc.enabled', true);
player.configure('lcevc.drawLogo', true);
player.configure('lcevc.dynamicPerformanceScaling', false);
player.configure('lcevc.poster', false);

// Grab event manager from the uncompiled library:
eventManager = new shaka.util.EventManager();
waiter = new shaka.test.Waiter(eventManager);
waiter.setPlayer(player);

onErrorSpy = jasmine.createSpy('onError');
onErrorSpy.and.callFake((event) => fail(event.detail));
eventManager.listen(player, 'error', Util.spyFunc(onErrorSpy));
});

afterEach(async () => {
await player.unload();
eventManager.release();
await player.destroy();
});

afterAll(() => {
document.body.removeChild(video);
document.body.removeChild(canvas);
});

describe('SEI Integration', () => {
it('Should decode LCEVC in FMP4 DASH manifest', async () => {
if (shaka.util.Platform.isTizen() || shaka.util.Platform.isChromecast()) {
pending('Disabled on unsupported platform.');
}

// Wait for LCEVCdec to finish loading
await LCEVCdec.ready;

await player.load(seiManifests.FMP4_DASH);
await video.play();

// Wait for the video to start playback. If it takes longer than 10
// seconds, fail the test.
await waiter.waitForMovementOrFailOnTimeout(video, 10);

// Play for 6 seconds, but stop early if the video ends. If it takes
// longer than 45 seconds, fail the test.
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 6, 45);

// Expect LCEVCdec to be enabled and have detected LCEVC data in SEI
expect(LCEVCdec.instance).toBeDefined();
expect(LCEVCdec.instance.isLcevcEnabled).toBe(true);
expect(LCEVCdec.instance.firstLcevcSegmentLoaded).toBe(true);
expect(LCEVCdec.instance.lcevcDataDetected).toBe(true);
});
});
});
Binary file added test/test/assets/lcevc-sei/lcevc-sei-1.mp4
Binary file not shown.
14 changes: 14 additions & 0 deletions test/test/assets/lcevc-sei/lcevc-sei.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version v2.4.3-dd98700-release-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT10.166666984558105S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="1920" height="1080" frameRate="15360/512" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="2764800" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1">
<BaseURL>lcevc-sei-1.mp4</BaseURL>
<SegmentBase indexRange="865-908" timescale="15360">
<Initialization range="0-864"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Loading