Skip to content

Commit

Permalink
fix(Demo): Allow manifest type for DAI custom assets (#4977)
Browse files Browse the repository at this point in the history
Fixes #4887
  • Loading branch information
avelad authored and joeyparrish committed Feb 9, 2023
1 parent acebfa1 commit d341f93
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 2 deletions.
15 changes: 15 additions & 0 deletions demo/common/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const ShakaDemoAssetInfo = class {
/** @type {?string} */
this.imaContentSrcId = null;
/** @type {?string} */
this.imaManifestType = null;
/** @type {?string} */
this.mimeType = null;


Expand Down Expand Up @@ -256,6 +258,19 @@ const ShakaDemoAssetInfo = class {
return this;
}

/**
* @param {string} type
* @return {!ShakaDemoAssetInfo}
*/
setIMAManifestType(type) {
this.imaManifestType = type;
if (!this.features.includes(shakaAssets.Feature.ADS)) {
this.addFeature(shakaAssets.Feature.ADS);
}

return this;
}

/**
* @param {string} headerName
* @param {string} headerValue
Expand Down
6 changes: 4 additions & 2 deletions demo/common/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ shakaAssets.testAssets = [
.addFeature(shakaAssets.Feature.MP4)
.addFeature(shakaAssets.Feature.OFFLINE)
.setIMAContentSourceId('2528370')
.setIMAVideoId('tears-of-steel'),
.setIMAVideoId('tears-of-steel')
.setIMAManifestType('HLS'),
new ShakaDemoAssetInfo(
/* name= */ 'Tears of Steel (live, DASH, Server Side ads)',
/* iconUri= */ 'https://storage.googleapis.com/shaka-asset-icons/tears_of_steel.png',
Expand All @@ -519,7 +520,8 @@ shakaAssets.testAssets = [
.addFeature(shakaAssets.Feature.MP4)
.addFeature(shakaAssets.Feature.SUBTITLES)
.addFeature(shakaAssets.Feature.LIVE)
.setIMAAssetKey('PSzZMzAkSXCmlJOWDmRj8Q'),
.setIMAAssetKey('PSzZMzAkSXCmlJOWDmRj8Q')
.setIMAManifestType('DASH'),
new ShakaDemoAssetInfo(
/* name= */ 'Tears of Steel (multicodec, surround + stereo)',
/* iconUri= */ 'https://storage.googleapis.com/shaka-asset-icons/tears_of_steel.png',
Expand Down
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ shakaDemo.MessageIds = {
ADS_TAB: 'DEMO_ADS_TAB',
IMA_ASSET_KEY: 'DEMO_IMA_ASSET_KEY',
IMA_CONTENT_SRC_ID: 'DEMO_IMA_CONTENT_SRC_ID',
IMA_MANIFEST_TYPE: 'DEMO_IMA_MANIFEST_TYPE',
IMA_VIDEO_ID: 'DEMO_IMA_VIDEO_ID',
CANCEL_BUTTON: 'DEMO_CANCEL_BUTTON',
CUSTOM_INTRO_ONE: 'DEMO_CUSTOM_INTRO_ONE',
Expand Down
19 changes: 19 additions & 0 deletions demo/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ shakaDemo.Custom = class {
this.makeField_(
container, assetKeyName, assetKeySetup, assetKeyChange);

// Make the manifest type field.
const manifestTypeSetup = (input, container) => {
if (assetInProgress.imaManifestType) {
input.value = assetInProgress.imaManifestType;
}

this.manifestField_.required =
this.checkManifestRequired_(assetInProgress);
};
const manifestTypeChange = (input) => {
assetInProgress.imaManifestType = input.value;
this.manifestField_.required =
this.checkManifestRequired_(assetInProgress);
};
const manifestTypeName = shakaDemoMain.getLocalizedString(
shakaDemo.MessageIds.IMA_MANIFEST_TYPE);
this.makeField_(
container, manifestTypeName, manifestTypeSetup, manifestTypeChange);

return adsDiv;
}

Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"DEMO_IGNORE_HLS_TEXT_FAILURES": "Ignore HLS Text Stream Failures",
"DEMO_IMA_ASSET_KEY": "Asset key (for LIVE DAI Content)",
"DEMO_IMA_CONTENT_SRC_ID": "Content source ID (for VOD DAI Content)",
"DEMO_IMA_MANIFEST_TYPE": "Manifest type (for DAI Content)",
"DEMO_IMA_VIDEO_ID": "Video ID (for VOD DAI Content)",
"DEMO_IGNORE_MIN_BUFFER_TIME": "Ignore Min Buffer Time",
"DEMO_IGNORE_TEXT_FAILURES": "Ignore Text Stream Failures",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@
"description": "The label on a field that allows users to provide a content source id for a custom asset.",
"message": "Asset key (for VOD DAI Content)"
},
"DEMO_IMA_MANIFEST_TYPE": {
"description": "The label on a field that allows users to provide a manifest type for a custom asset.",
"message": "Manifest type (for DAI Content)"
},
"DEMO_IMA_VIDEO_ID": {
"description": "The label on a field that allows users to provide a video id for a custom asset.",
"message": "Video ID (for VOD DAI Content)"
Expand Down
14 changes: 14 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,20 @@ shakaDemo.Main = class {
request.contentSourceId = asset.imaContentSrcId;
request.videoId = asset.imaVideoId;
}
switch (asset.imaManifestType) {
case 'DASH':
case 'dash':
case 'MPD':
case 'mpd':
request.format = google.ima.dai.api.StreamRequest.StreamFormat.DASH;
break;
case 'HLS':
case 'hls':
case 'M3U8':
case 'm3u8':
request.format = google.ima.dai.api.StreamRequest.StreamFormat.HLS;
break;
}

const uri = await adManager.requestServerSideStream(
request, /* backupUri= */ asset.manifestUri);
Expand Down
9 changes: 9 additions & 0 deletions externs/ima.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,15 @@ google.ima.dai.api.StreamRequest.prototype.streamActivityMonitorId;
google.ima.dai.api.StreamRequest.prototype.format;


/**
* @enum {string}
*/
google.ima.dai.api.StreamRequest.StreamFormat = {
DASH: 'dash',
HLS: 'hls',
};


/** @const */
google.ima.dai.api.VODStreamRequest =
class extends google.ima.dai.api.StreamRequest {};
Expand Down

0 comments on commit d341f93

Please sign in to comment.