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

feat(FEC-12611): Kaltura Image Entry Support - Load Kaltura Image Entries with or without KS #190

Merged
merged 13 commits into from
Jan 19, 2023
3 changes: 3 additions & 0 deletions flow-typed/types/media-config-sources.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @flow
import ImageSource from "../../src/entities/image-source";

declare type ProviderMediaConfigSourcesObject = {
dash: Array<ProviderMediaSourceObject>,
hls: Array<ProviderMediaSourceObject>,
progressive: Array<ProviderMediaSourceObject>,
image: Array<ImageSource>,
duration: number,
type: string,
id: string,
Expand Down
3 changes: 3 additions & 0 deletions flow-typed/types/media-sources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// @flow
import ImageSource from "../../src/entities/image-source";

declare type ProviderMediaSourcesObject = {
progressive: Array<ProviderMediaSourceObject>,
dash: Array<ProviderMediaSourceObject>,
hls: Array<ProviderMediaSourceObject>,
image: Array<ImageSource>,
captions?: Array<PKExternalCaptionObject>
};
37 changes: 37 additions & 0 deletions src/entities/image-source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//@flow

const BASE_THUMBNAIL_URL_TEMPLATE = '.+entry_id/[a-zA-Z0-9_]+/';

export default class ImageSource {
/**
* @member - media source id
* @type {string}
*/
id: string;
/**
* @member - media source url
* @type {string}
*/
url: string;
/**
* @member - media source mimetype
* @type {string}
*/
mimetype: string;

constructor(entry: Object) {
this.id = entry.id;
this.url = ImageSource.extractBaseThumbnailUrl(entry.dataUrl);
this.mimetype = '';
}

/**
* Extract the base thumbnail url.
* @param {string} url - dataUrl.
* @returns {string} - The base thumbnail url.
*/
static extractBaseThumbnailUrl(url: string): string {
JonathanTGold marked this conversation as resolved.
Show resolved Hide resolved
// $FlowFixMe
return url.match(BASE_THUMBNAIL_URL_TEMPLATE)[0].slice(0, -1);
}
}
7 changes: 6 additions & 1 deletion src/entities/media-sources.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import MediaSource from './media-source';
import {MediaFormat} from './media-format';
import ImageSource from './image-source';

export default class MediaSources {
/**
Expand All @@ -21,6 +22,7 @@ export default class MediaSources {
* @public
*/
hls: Array<MediaSource>;
image: Array<ImageSource>;
captions: Array<PKExternalCaptionObject>;

/**
Expand All @@ -30,6 +32,7 @@ export default class MediaSources {
this.progressive = [];
this.dash = [];
this.hls = [];
this.image = [];
}

/**
Expand Down Expand Up @@ -64,11 +67,13 @@ export default class MediaSources {
const response: ProviderMediaSourcesObject = {
progressive: [],
dash: [],
hls: []
hls: [],
image: []
};
this.progressive.forEach(p => response.progressive.push(p.toJSON()));
this.hls.forEach(h => response.hls.push(h.toJSON()));
this.dash.forEach(d => response.dash.push(d.toJSON()));
response.image = this.image;
return response;
}
}
2 changes: 1 addition & 1 deletion src/k-provider/common/base-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class BaseProvider<MI> {
}

_verifyHasSources(sources: ProviderMediaConfigSourcesObject) {
if (sources.hls.concat(sources.dash, sources.progressive).length === 0) {
if (sources.hls.concat(sources.dash, sources.progressive, sources.image).length === 0) {
throw new Error(Error.Severity.CRITICAL, Error.Category.SERVICE, Error.Code.MISSING_PLAY_SOURCE, {
action: '',
messages: `No play source for entry id: ${sources.id}`
Expand Down
1 change: 1 addition & 0 deletions src/k-provider/ott/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default class OTTProvider extends BaseProvider<OTTProviderMediaInfoObject
hls: [],
dash: [],
progressive: [],
image: [],
id: '',
duration: 0,
type: MediaEntry.Type.UNKNOWN,
Expand Down
11 changes: 10 additions & 1 deletion src/k-provider/ovp/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {KalturaRuleAction} from './response-types/kaltura-rule-action';
import {KalturaAccessControlMessage} from '../common/response-types/kaltura-access-control-message';
import type {OVPMediaEntryLoaderResponse} from './loaders/media-entry-loader';
import {ExternalCaptionsBuilder} from './external-captions-builder';
import ImageSource from '../../entities/image-source';

class OVPProviderParser {
static _logger = getLogger('OVPProviderParser');
Expand Down Expand Up @@ -147,7 +148,6 @@ class OVPProviderParser {
}

static _fillBaseData(mediaEntry: MediaEntry, entry: KalturaMediaEntry, metadataList: ?KalturaMetadataListResponse) {
mediaEntry.poster = entry.poster;
mediaEntry.id = entry.id;
mediaEntry.duration = entry.duration;
mediaEntry.metadata = OVPProviderParser._parseMetadata(metadataList);
Expand All @@ -162,6 +162,9 @@ class OVPProviderParser {
mediaEntry.dvrStatus = entry.dvrStatus;
}

if (mediaEntry.type !== MediaEntry.Type.IMAGE) {
mediaEntry.poster = entry.poster;
}
return mediaEntry;
}

Expand Down Expand Up @@ -230,6 +233,10 @@ class OVPProviderParser {
sources.progressive = OVPProviderParser._parseProgressiveSources(progressiveSource, playbackContext, ks, partnerId, uiConfId, entry.id);
};

const parseImageSources = () => {
sources.image.push(new ImageSource(entry));
};

const parseExternalMedia = () => {
const mediaSource = new MediaSource();
mediaSource.mimetype = 'video/youtube';
Expand All @@ -240,6 +247,8 @@ class OVPProviderParser {

if (entry.type === KalturaMediaEntry.EntryType.EXTERNAL_MEDIA.value) {
parseExternalMedia();
} else if (entry.entryType === KalturaMediaEntry.MediaType.IMAGE.value) {
parseImageSources();
} else if (kalturaSources && kalturaSources.length > 0) {
parseAdaptiveSources();
parseProgressiveSources();
Expand Down
2 changes: 2 additions & 0 deletions src/k-provider/ovp/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
hls: [],
dash: [],
progressive: [],
image: [],
id: '',
duration: 0,
type: MediaEntry.Type.UNKNOWN,
Expand All @@ -323,6 +324,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
sourcesObject.hls = mediaSources.hls;
sourcesObject.dash = mediaSources.dash;
sourcesObject.progressive = mediaSources.progressive;
sourcesObject.image = mediaSources.image;
sourcesObject.id = mediaEntry.id;
sourcesObject.duration = mediaEntry.duration;
sourcesObject.type = mediaEntry.type;
Expand Down
4 changes: 4 additions & 0 deletions test/src/k-provider/ott/media-config-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const NoPluginsWithDrm = {
plugins: {},
sources: {
progressive: [],
image: [],
dash: [
{
id: '728180,mpegdash',
Expand Down Expand Up @@ -454,6 +455,7 @@ const FilteredSourcesByDeviceType = {
],
progressive: [],
dash: [],
image: [],
hls: [
{
id: '728182,applehttp',
Expand Down Expand Up @@ -698,6 +700,7 @@ const LiveEntryNoDrm = {
height: 800
}
],
image: [],
progressive: [],
dash: [],
hls: [
Expand Down Expand Up @@ -767,6 +770,7 @@ const EntryWithBumper = {
}
],
progressive: [],
image: [],
id: 324284,
duration: 60,
type: 'Vod',
Expand Down
20 changes: 15 additions & 5 deletions test/src/k-provider/ovp/media-config-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ const NoPluginsNoDrm = {
url:
'https://cdnapisec.kaltura.com/p/1082342/sp/108234200/playManifest/entryId/1_rsrdfext/protocol/https/format/applehttp/flavorIds/1_ha0nqwz8,1_gw7u4nf1,1_rql6sqaa,1_sufd1yd9,1_9xvkk7a5,1_4typ4pat,1_n75294r4/a.m3u8'
}
]
],
image: []
}
};

Expand Down Expand Up @@ -175,6 +176,7 @@ const RegexAppliedSources = {
mimetype: 'application/dash+xml'
}
],
image: [],
progressive: [
{
id: '1_ha0nqwz810081,url',
Expand Down Expand Up @@ -336,7 +338,8 @@ const NoPluginsWithDrm = {
}
]
}
]
],
image: []
}
};

Expand Down Expand Up @@ -477,7 +480,8 @@ const WithPluginsNoDrm = {
url:
'https://cdnapisec.kaltura.com/p/1082342/sp/108234200/playManifest/entryId/1_rsrdfext/protocol/https/format/applehttp/flavorIds/1_ha0nqwz8,1_gw7u4nf1,1_rql6sqaa,1_sufd1yd9,1_9xvkk7a5,1_4typ4pat,1_n75294r4/a.m3u8?uiConfId=38621471'
}
]
],
image: []
}
};

Expand Down Expand Up @@ -539,7 +543,8 @@ const WithPluginsWithDrm = {
}
]
}
]
],
image: []
}
};

Expand Down Expand Up @@ -599,7 +604,8 @@ const AudioEntryWithoutPlugins = {
url:
'https://cdnapisec.kaltura.com/p/1082342/sp/108234200/playManifest/entryId/0_vyzw3ceu/protocol/https/format/applehttp/flavorIds/0_hawbhpz3/a.m3u8'
}
]
],
image: []
}
};

Expand Down Expand Up @@ -979,6 +985,7 @@ const EntryWithBumper = {
label: 'Undefined'
}
],
image: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1094,6 +1101,7 @@ const EntryWithBumperWithKs = {
label: 'Undefined'
}
],
image: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1212,6 +1220,7 @@ const EntryWithNoBumper = {
label: 'Undefined'
}
],
image: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1302,6 +1311,7 @@ const EntryOfPartner0 = {
label: 'Undefined'
}
],
image: [],
id: '0_pi55vv3r',
duration: 11,
type: 'Vod',
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 @@ -68,7 +68,8 @@ const youtubeMediaEntryResult = {
}
],
dash: [],
hls: []
hls: [],
image: []
},
duration: 0,
metadata: {
Expand Down