Skip to content

Commit

Permalink
Misc fixes for const.
Browse files Browse the repository at this point in the history
This prepares some changes for the conversion from "let" to "const".
This ensures the follow-up is just an automated change with minimal
intervention.

Change-Id: I19b24dc67f20038dffd36b8903547f6ee4f00c25
  • Loading branch information
TheModMaker committed May 8, 2019
1 parent 7bfb00d commit a453095
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion demo/asset_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class AssetCard {
* Select this card if the card's asset matches |asset|.
* Used to simplify the implementation of "shaka-main-selected-asset-changed"
* handlers.
* @param {!ShakaDemoAssetInfo} asset
* @param {ShakaDemoAssetInfo} asset
*/
selectByAsset(asset) {
this.card_.classList.remove('selected');
Expand Down
11 changes: 9 additions & 2 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ShakaDemoConfig {
this.addSection_('DRM', docLink)
.addBoolInput_('Delay License Request Until Played',
'drm.delayLicenseRequestUntilPlayed');
const advanced = shakaDemoMain.getConfiguration().drm.advanced;
const advanced = shakaDemoMain.getConfiguration().drm.advanced || {};
const robustnessSuggestions = [
'SW_SECURE_CRYPTO',
'SW_SECURE_DECODE',
Expand All @@ -141,7 +141,14 @@ class ShakaDemoConfig {
// Add in any common drmSystem not currently in advanced.
for (let drmSystem of commonDrmSystems) {
if (!(drmSystem in advanced)) {
advanced[commonDrmSystems] = {};
advanced[commonDrmSystems] = {
distinctiveIdentifierRequired: false,
persistentStateRequired: false,
videoRobustness: '',
audioRobustness: '',
serverCertificate: null,
individualizationServer: '',
};
}
}
// Set the robustness.
Expand Down
12 changes: 6 additions & 6 deletions lib/dash/mpd_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ shaka.dash.MpdUtils.fillUriTemplate = function(

const re =
/\$(RepresentationID|Number|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g;
let uri = uriTemplate.replace(re, function(match, name, widthString, format) {
const uri = uriTemplate.replace(re, function(match, name, widthStr, format) {
if (match == '$$') {
return '$';
}
Expand All @@ -130,12 +130,12 @@ shaka.dash.MpdUtils.fillUriTemplate = function(
return match;
}

if (name == 'RepresentationID' && widthString) {
if (name == 'RepresentationID' && widthStr) {
shaka.log.warning(
'URL template should not contain a width specifier for identifier',
'"RepresentationID":',
uriTemplate);
widthString = undefined;
widthStr = undefined;
}

if (name == 'Time') {
Expand Down Expand Up @@ -169,9 +169,9 @@ shaka.dash.MpdUtils.fillUriTemplate = function(
}

// Create a padding string.
let width = window.parseInt(widthString, 10) || 1;
let paddingSize = Math.max(0, width - valueString.length);
let padding = (new Array(paddingSize + 1)).join('0');
const width = window.parseInt(widthStr, 10) || 1;
const paddingSize = Math.max(0, width - valueString.length);
const padding = (new Array(paddingSize + 1)).join('0');

return padding + valueString;
});
Expand Down
10 changes: 4 additions & 6 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,19 +1116,16 @@ shaka.hls.HlsParser.prototype.createStreamInfo_ = async function(
let absoluteMediaPlaylistUri = Utils.constructAbsoluteUri(
this.masterPlaylistUri_, verbatimMediaPlaylistUri);

/** @type {!shaka.hls.Playlist} */
let playlist;
/** @type {string} */
let codecs = '';
/** @type {string} */
let mimeType;

const response = await this.requestManifest_(absoluteMediaPlaylistUri);
// Record the final URI after redirects.
absoluteMediaPlaylistUri = response.uri;

// Record the redirected, final URI of this media playlist when we parse it.
playlist = this.manifestTextParser_.parsePlaylist(
/** @type {!shaka.hls.Playlist} */
const playlist = this.manifestTextParser_.parsePlaylist(
response.data, absoluteMediaPlaylistUri);

if (playlist.type != shaka.hls.PlaylistType.MEDIA) {
Expand Down Expand Up @@ -1201,7 +1198,8 @@ shaka.hls.HlsParser.prototype.createStreamInfo_ = async function(
codecs = this.guessCodecs_(type, allCodecs);
const mimeTypeArg = await this.guessMimeType_(type, codecs, playlist);

mimeType = mimeTypeArg;
/** @type {string} */
const mimeType = mimeTypeArg;

let mediaSequenceTag = Utils.getFirstTagWithName(playlist.tags,
'EXT-X-MEDIA-SEQUENCE');
Expand Down
26 changes: 15 additions & 11 deletions test/util/abortable_operation_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,21 @@ describe('AbortableOperation', function() {

// The second stage of the chain returns innerOperation. A brief moment
// later, the outer chain is aborted.
let operation = shaka.util.AbortableOperation.completed(100).chain(() => {
shaka.test.Util.delay(0.1).then(() => {
operation.abort();
p.resolve();
});
return innerOperation;
}).finally((ok) => {
expect(ok).toBe(true); // We resolved the non-abortable inner operation
expect(abortCalled).toBe(true);
done();
});
const operation =
shaka.util.AbortableOperation.completed(100)
.chain(() => {
shaka.test.Util.delay(0.1).then(() => {
operation.abort();
p.resolve();
});
return innerOperation;
})
.finally((ok) => {
// We resolved the non-abortable inner operation
expect(ok).toBe(true);
expect(abortCalled).toBe(true);
done();
});
});
}); // describe('chain')
}); // describe('AbortableOperation')

0 comments on commit a453095

Please sign in to comment.