Skip to content

Commit

Permalink
fix(FEC-14047): add height to width ratio to media metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
SivanA-Kaltura authored Jul 16, 2024
1 parent f907063 commit d08bf71
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"watch": "webpack --mode=development --watch",
"test": "NODE_ENV=test karma start --color --mode development",
"test:watch": "NODE_ENV=test karma start --browsers=Chrome --single-run=false --auto-watch",
"test:debug": "NODE_ENV=test karma start --browsers=Chrome --single-run=false --auto-watch --debug",
"release": "standard-version",
"pushTaggedRelease": "git push --follow-tags --no-verify origin master",
"lint": "eslint src/ --ext .js --ext .ts",
Expand Down
14 changes: 12 additions & 2 deletions src/k-provider/ovp/provider-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OVPProviderParser {
const kalturaSources = playbackContext.sources;

mediaEntry.sources = OVPProviderParser._getParsedSources(kalturaSources, ks, partnerId, uiConfId, entry, playbackContext);
OVPProviderParser._fillBaseData(mediaEntry, entry, metadataList);
OVPProviderParser._fillBaseData(mediaEntry, entry, metadataList, playbackContext);
if (mediaEntry.type !== MediaEntry.Type.LIVE && OVPConfiguration.get().useApiCaptions && playbackContext.data.playbackCaptions) {
mediaEntry.sources.captions = ExternalCaptionsBuilder.createConfig(playbackContext.data.playbackCaptions, ks);
}
Expand Down Expand Up @@ -151,7 +151,7 @@ class OVPProviderParser {
}
}

private static _fillBaseData(mediaEntry: MediaEntry, entry: KalturaMediaEntry, metadataList?: KalturaMetadataListResponse): MediaEntry {
private static _fillBaseData(mediaEntry: MediaEntry, entry: KalturaMediaEntry, metadataList?: KalturaMetadataListResponse, playbackContext?: any): MediaEntry {
mediaEntry.poster = entry.poster;
mediaEntry.id = entry.id;
mediaEntry.duration = entry.duration;
Expand All @@ -174,6 +174,16 @@ class OVPProviderParser {
mediaEntry.dvrStatus = entry.dvrStatus;
}

if (playbackContext &&
playbackContext.flavorAssets[0] &&
playbackContext.flavorAssets[0].width && playbackContext.flavorAssets[0].height) {

const {height, width} = playbackContext.flavorAssets[0];
mediaEntry.metadata.heightRatio = +Number(height / width).toFixed(2);
} else {
mediaEntry.metadata.heightRatio = 1.78;
}

return mediaEntry;
}

Expand Down
33 changes: 22 additions & 11 deletions test/src/k-provider/ovp/media-config-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const NoPluginsNoDrm = {
ScheduleSource: 'VOD',
HLSOnly: 'android',
ChannelName: 'Disney Channel SE',
tags: ''
tags: '',
heightRatio: 0.56
},
progressive: [
{
Expand Down Expand Up @@ -288,7 +289,8 @@ const RegexAppliedPlayManifestSources = {
ZeroTouchIds: 'se-dc-lf',
ScheduleSource: 'VOD',
HLSOnly: 'android',
ChannelName: 'Disney Channel SE'
ChannelName: 'Disney Channel SE',
heightRatio: 0.56
},
downloadUrl: ''
},
Expand Down Expand Up @@ -433,7 +435,8 @@ const RegexAppliedAllSources = {
ZeroTouchIds: 'se-dc-lf',
ScheduleSource: 'VOD',
HLSOnly: 'android',
ChannelName: 'Disney Channel SE'
ChannelName: 'Disney Channel SE',
heightRatio: 0.56
},
captions: [
{
Expand Down Expand Up @@ -468,7 +471,8 @@ const NoPluginsWithDrm = {
name: 'DRM TEST',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel semper libero. Curabitur in felis elementum, porttitor sem ac, volutpat mi. Sed dignissim facilisis magna, ac suscipit orci suscipit id. Suspendisse feugiat sapien laoreet auctor convallis. Cras volutpat dictum massa, in pharetra erat placerat eget. Donec at elit est. Donec id cursus elit. Etiam sit amet sapien sed mi aliquam finibus at lobortis diam. Aenean at gravida libero.',
tags: ''
tags: '',
heightRatio: 0.57
},
progressive: [],
dash: [
Expand Down Expand Up @@ -549,7 +553,8 @@ const WithPluginsNoDrm = {
ScheduleSource: 'VOD',
HLSOnly: 'android',
ChannelName: 'Disney Channel SE',
tags: ''
tags: '',
heightRatio: 0.56
},
progressive: [
{
Expand Down Expand Up @@ -677,7 +682,8 @@ const WithPluginsWithDrm = {
name: 'DRM TEST',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel semper libero. Curabitur in felis elementum, porttitor sem ac, volutpat mi. Sed dignissim facilisis magna, ac suscipit orci suscipit id. Suspendisse feugiat sapien laoreet auctor convallis. Cras volutpat dictum massa, in pharetra erat placerat eget. Donec at elit est. Donec id cursus elit. Etiam sit amet sapien sed mi aliquam finibus at lobortis diam. Aenean at gravida libero.',
tags: ''
tags: '',
heightRatio: 0.57
},
progressive: [],
dash: [
Expand Down Expand Up @@ -741,7 +747,8 @@ const AudioEntryWithoutPlugins = {
name: 'TEST_WAESP_PLACINGTEST_DUAL',
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel semper libero. Curabitur in felis elementum, porttitor sem ac, volutpat mi. Sed dignissim facilisis magna, ac suscipit orci suscipit id. Suspendisse feugiat sapien laoreet auctor convallis. Cras volutpat dictum massa, in pharetra erat placerat eget. Donec at elit est. Donec id cursus elit. Etiam sit amet sapien sed mi aliquam finibus at lobortis diam. Aenean at gravida libero.',
tags: 'dual audio, english, spanish'
tags: 'dual audio, english, spanish',
heightRatio: 1.78
},
progressive: [
{
Expand Down Expand Up @@ -1177,7 +1184,8 @@ const EntryWithBumper = {
description: '',
tags: '',
MediaType: 'Movie',
WatchPermissionRule: 'Parrent Allowed'
WatchPermissionRule: 'Parrent Allowed',
heightRatio: 1.78
},
captions: [
{
Expand Down Expand Up @@ -1295,7 +1303,8 @@ const EntryWithBumperWithKs = {
description: '',
tags: '',
MediaType: 'Movie',
WatchPermissionRule: 'Parrent Allowed'
WatchPermissionRule: 'Parrent Allowed',
heightRatio: 1.78
},
captions: [
{
Expand Down Expand Up @@ -1416,7 +1425,8 @@ const EntryWithNoBumper = {
description: '',
tags: '',
MediaType: 'Movie',
WatchPermissionRule: 'Parrent Allowed'
WatchPermissionRule: 'Parrent Allowed',
heightRatio: 1.78
},
captions: [
{
Expand Down Expand Up @@ -1507,7 +1517,8 @@ const EntryOfPartner0 = {
name: 'Titanic in 5 Seconds',
entryId: '0_pi55vv3r',
description: 'Titanic movie summarized in 5 seconds',
tags: 'titanic, short'
tags: 'titanic, short',
heightRatio: 0.75
},
captions: [],
downloadUrl: ''
Expand Down
3 changes: 2 additions & 1 deletion test/src/k-provider/ovp/provider-parser-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const youtubeMediaEntryResult = {
entryId: '1234',
description: 'youtube description',
name: 'test youtube entry',
tags: ''
tags: '',
heightRatio: 1.78,
},
type: 'Unknown',
poster: 'https://cfvod.kaltura.com/p/1111/sp/1111/thumbnail/entry_id/1234/version/100001',
Expand Down

0 comments on commit d08bf71

Please sign in to comment.