Skip to content

Commit

Permalink
Light build optimizations and fixes (#5160)
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Jan 26, 2023
1 parent 7b2a343 commit 0bc24ef
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ export const hlsDefaultConfig: HlsConfig = {
widevineLicenseUrl: undefined, // used by eme-controller
drmSystems: {}, // used by eme-controller
drmSystemOptions: {}, // used by eme-controller
requestMediaKeySystemAccessFunc: requestMediaKeySystemAccess, // used by eme-controller
requestMediaKeySystemAccessFunc: __USE_EME_DRM__
? requestMediaKeySystemAccess
: null, // used by eme-controller
testBandwidth: true,
progressive: false,
lowLatencyMode: true,
Expand Down
2 changes: 1 addition & 1 deletion src/controller/buffer-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class BufferController implements ComponentAPI {
// in case alt audio is not used, only one BUFFER_CODEC event will be fired from main stream controller
// it will contain the expected nb of source buffers, no need to compute it
let codecEvents: number = 2;
if ((data.audio && !data.video) || !data.altAudio) {
if ((data.audio && !data.video) || !data.altAudio || !__USE_ALT_AUDIO__) {
codecEvents = 1;
}
this.bufferCodecEventsExpected = this._bufferCodecEventsTotal = codecEvents;
Expand Down
38 changes: 22 additions & 16 deletions src/loader/level-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,24 @@ export class LevelKey implements DecryptData {
if (this.method === 'AES-128' || this.method === 'NONE') {
return true;
}
switch (this.keyFormat) {
case 'identity':
// Maintain support for clear SAMPLE-AES with MPEG-3 TS
return this.method === 'SAMPLE-AES';
case KeySystemFormats.FAIRPLAY:
case KeySystemFormats.WIDEVINE:
case KeySystemFormats.PLAYREADY:
case KeySystemFormats.CLEARKEY:
return (
[
'ISO-23001-7',
'SAMPLE-AES',
'SAMPLE-AES-CENC',
'SAMPLE-AES-CTR',
].indexOf(this.method) !== -1
);
if (this.keyFormat === 'identity') {
// Maintain support for clear SAMPLE-AES with MPEG-3 TS
return this.method === 'SAMPLE-AES';
} else if (__USE_EME_DRM__) {
switch (this.keyFormat) {
case KeySystemFormats.FAIRPLAY:
case KeySystemFormats.WIDEVINE:
case KeySystemFormats.PLAYREADY:
case KeySystemFormats.CLEARKEY:
return (
[
'ISO-23001-7',
'SAMPLE-AES',
'SAMPLE-AES-CENC',
'SAMPLE-AES-CTR',
].indexOf(this.method) !== -1
);
}
}
}
return false;
Expand Down Expand Up @@ -110,6 +112,10 @@ export class LevelKey implements DecryptData {
return decryptdata;
}

if (!__USE_EME_DRM__) {
return this;
}

// Initialize keyId if possible
const keyBytes = convertDataUriToArrayBytes(this.uri);
if (keyBytes) {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/auto/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu

const entries = Object.entries(streams);
if (HlsjsLightBuild) {
entries.length = 1;
entries.length = 10;
}

entries
Expand Down
11 changes: 5 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function getAliasesForLightDist() {
if (!addEMESupport) {
aliases = Object.assign({}, aliases, {
'./controller/eme-controller': './empty.js',
'./utils/mediakeys-helper': './empty.js',
});
}

Expand Down Expand Up @@ -238,14 +239,12 @@ const multiConfig = [
...mainPlugins,
new webpack.DefinePlugin({
__NETLIFY__: JSON.stringify(
process.env.NETLIFY === 'true'
env.NETLIFY === 'true'
? {
branch: process.env.BRANCH,
commitRef: process.env.COMMIT_REF,
branch: env.BRANCH,
commitRef: env.COMMIT_REF,
reviewID:
process.env.PULL_REQUEST === 'true'
? parseInt(process.env.REVIEW_ID)
: null,
env.PULL_REQUEST === 'true' ? parseInt(env.REVIEW_ID) : null,
}
: {}
),
Expand Down

0 comments on commit 0bc24ef

Please sign in to comment.