Skip to content

Commit

Permalink
feat(FEC-13507): support doc sources (#233)
Browse files Browse the repository at this point in the history
* feat(FEC-13507): keep doc entries

* feat(FEC-13507): add doc source support

* feat(FEC-13507): upd tests

* feat(FEC-13507): address PR comments
  • Loading branch information
semarche-kaltura committed Jan 23, 2024
1 parent ece6a0e commit bb5f4a7
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 11 deletions.
31 changes: 31 additions & 0 deletions src/entities/document-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default class DocumentSource {
/**
* @member - media source id
* @type {string}
*/
public id: string;
/**
* @member - media source url
* @type {string}
*/
public url: string;
/**
* @member - thumbnail url
* @type {string}
*/
public thumbnailUrl: string;
/**
* @member - media source mimetype
* @type {string}
*/
public mimetype: string;

constructor(entry: any) {
this.id = entry.id;
this.url = entry.downloadUrl;
this.thumbnailUrl = entry.poster;
this.mimetype = '';
}
}

export {DocumentSource}
3 changes: 2 additions & 1 deletion src/entities/media-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default class MediaEntry {
LIVE: 'Live',
IMAGE: 'Image',
AUDIO: 'Audio',
UNKNOWN: 'Unknown'
UNKNOWN: 'Unknown',
DOCUMENT: 'Document'
};
public static DvrStatus: {[type: string]: number} = {
ON: 1,
Expand Down
7 changes: 6 additions & 1 deletion src/entities/media-sources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MediaSource from './media-source';
import {MediaFormat} from './media-format';
import {ImageSource} from './image-source';
import {DocumentSource} from './document-source';
import {PKExternalCaptionObject, ProviderMediaFormatType, ProviderMediaSourcesObject} from '../types';

export default class MediaSources {
Expand All @@ -23,6 +24,7 @@ export default class MediaSources {
*/
public hls: Array<MediaSource>;
public image: Array<ImageSource>;
public document: Array<DocumentSource>;
public captions?: Array<PKExternalCaptionObject>;

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

/**
Expand Down Expand Up @@ -68,12 +71,14 @@ export default class MediaSources {
progressive: [],
dash: [],
hls: [],
image: []
image: [],
document: []
};
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;
response.document = this.document;
return response;
}
}
2 changes: 1 addition & 1 deletion src/k-provider/common/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class BaseProvider<MI> {
}

protected _verifyHasSources(sources: ProviderMediaConfigSourcesObject): void {
if (sources.hls.concat(sources.dash, sources.progressive, sources.image).length === 0) {
if (sources.hls.concat(sources.dash, sources.progressive, sources.image, sources.document).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.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default class OTTProvider extends BaseProvider<OTTProviderMediaInfoObject
dash: [],
progressive: [],
image: [],
document: [],
id: '',
duration: 0,
type: MediaEntry.Type.UNKNOWN,
Expand Down
10 changes: 10 additions & 0 deletions src/k-provider/ovp/provider-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {KalturaAccessControlMessage} from '../common/response-types/kaltura-acce
import type {OVPMediaEntryLoaderResponse} from './loaders/media-entry-loader';
import {ExternalCaptionsBuilder} from './external-captions-builder';
import {ImageSource} from '../../entities/image-source';
import {DocumentSource} from '../../entities/document-source';

class OVPProviderParser {
private static _logger = getLogger('OVPProviderParser');
Expand Down Expand Up @@ -194,6 +195,9 @@ class OVPProviderParser {
case KalturaMediaEntry.EntryType.LIVE_CHANNEL.value:
type = MediaEntry.Type.LIVE;
break;
case KalturaMediaEntry.EntryType.DOCUMENT.value:
type = MediaEntry.Type.DOCUMENT;
break;
default:
type = MediaEntry.Type.UNKNOWN;
}
Expand Down Expand Up @@ -246,6 +250,10 @@ class OVPProviderParser {
sources.image.push(new ImageSource(entry));
};

const parseDocumentSources = (): void => {
sources.document.push(new DocumentSource(entry));
};

const parseExternalMedia = (): void => {
const mediaSource = new MediaSource();
mediaSource.mimetype = 'video/youtube';
Expand All @@ -258,6 +266,8 @@ class OVPProviderParser {
parseExternalMedia();
} else if (entry.entryType === KalturaMediaEntry.MediaType.IMAGE.value) {
parseImageSources();
} else if (entry.type === KalturaMediaEntry.EntryType.DOCUMENT.value) {
parseDocumentSources();
} else if (kalturaSources && kalturaSources.length > 0) {
parseAdaptiveSources();
parseProgressiveSources();
Expand Down
2 changes: 2 additions & 0 deletions src/k-provider/ovp/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
dash: [],
progressive: [],
image: [],
document: [],
id: '',
duration: 0,
type: MediaEntry.Type.UNKNOWN,
Expand All @@ -340,6 +341,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
sourcesObject.dash = mediaSources.dash;
sourcesObject.progressive = mediaSources.progressive;
sourcesObject.image = mediaSources.image;
sourcesObject.document = mediaSources.document;
sourcesObject.id = mediaEntry.id;
sourcesObject.duration = mediaEntry.duration;
sourcesObject.type = mediaEntry.type;
Expand Down
8 changes: 1 addition & 7 deletions src/k-provider/ovp/response-types/kaltura-media-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ export class KalturaMediaEntries extends ServiceResult {
super(responseObj);
if (!this.hasError) {
this.entries = [];
responseObj.map(entry => {
const kalturaMediaEntry = new KalturaMediaEntry(entry);
if (kalturaMediaEntry.type !== KalturaMediaEntry.EntryType.DOCUMENT.value) {
// filter out documents
this.entries.push(kalturaMediaEntry);
}
});
responseObj.map(entry => this.entries.push(new KalturaMediaEntry(entry)));
}
}
}
2 changes: 2 additions & 0 deletions src/types/media-config-sources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ImageSource} from '../entities/image-source';
import {DocumentSource} from '../entities/document-source';
import {ProviderMediaConfigMetadataObject} from './media-config-metadata';
import {PKExternalCaptionObject} from './external-caption-object';
import {ProviderMediaSourceObject} from './media-source';
Expand All @@ -8,6 +9,7 @@ export type ProviderMediaConfigSourcesObject = {
hls: Array<ProviderMediaSourceObject>;
progressive: Array<ProviderMediaSourceObject>;
image: Array<ImageSource>;
document: Array<DocumentSource>;
duration?: number;
type: string;
id?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/types/media-sources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ImageSource} from '../entities/image-source';
import {DocumentSource} from '../entities/document-source';
import {ProviderMediaSourceObject} from './media-source';
import {PKExternalCaptionObject} from './external-caption-object';

Expand All @@ -7,5 +8,6 @@ export type ProviderMediaSourcesObject = {
dash: Array<ProviderMediaSourceObject>;
hls: Array<ProviderMediaSourceObject>;
image: Array<ImageSource>;
document: Array<DocumentSource>;
captions?: Array<PKExternalCaptionObject>;
};
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 @@ -13,6 +13,7 @@ const NoPluginsWithDrm = {
sources: {
progressive: [],
image: [],
document: [],
dash: [
{
id: '728180,mpegdash',
Expand Down Expand Up @@ -457,6 +458,7 @@ const FilteredSourcesByDeviceType = {
progressive: [],
dash: [],
image: [],
document: [],
hls: [
{
id: '728182,applehttp',
Expand Down Expand Up @@ -703,6 +705,7 @@ const LiveEntryNoDrm = {
}
],
image: [],
document: [],
progressive: [],
dash: [],
hls: [
Expand Down Expand Up @@ -774,6 +777,7 @@ const EntryWithBumper = {
],
progressive: [],
image: [],
document: [],
id: 324284,
duration: 60,
type: 'Vod',
Expand Down
11 changes: 11 additions & 0 deletions test/src/k-provider/ovp/media-config-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const NoPluginsNoDrm = {
}
],
image: [],
document: [],
downloadUrl: ''
}
};
Expand Down Expand Up @@ -187,6 +188,7 @@ const RegexAppliedPlayManifestSources = {
}
],
image: [],
document: [],
progressive: [
{
id: '1_ha0nqwz810081,url',
Expand Down Expand Up @@ -330,6 +332,7 @@ const RegexAppliedAllSources = {
}
],
image: [],
document: [],
progressive: [
{
id: '1_ha0nqwz810081,url',
Expand Down Expand Up @@ -505,6 +508,7 @@ const NoPluginsWithDrm = {
}
],
image: [],
document: [],
downloadUrl: ''
}
};
Expand Down Expand Up @@ -648,6 +652,7 @@ const WithPluginsNoDrm = {
}
],
image: [],
document: [],
downloadUrl: ''
}
};
Expand Down Expand Up @@ -712,6 +717,7 @@ const WithPluginsWithDrm = {
}
],
image: [],
document: [],
downloadUrl: ''
}
};
Expand Down Expand Up @@ -774,6 +780,7 @@ const AudioEntryWithoutPlugins = {
}
],
image: [],
document: [],
downloadUrl: ''
}
};
Expand Down Expand Up @@ -1157,6 +1164,7 @@ const EntryWithBumper = {
}
],
image: [],
document: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1274,6 +1282,7 @@ const EntryWithBumperWithKs = {
}
],
image: [],
document: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1394,6 +1403,7 @@ const EntryWithNoBumper = {
}
],
image: [],
document: [],
id: '0_wifqaipd',
duration: 741,
type: 'Vod',
Expand Down Expand Up @@ -1486,6 +1496,7 @@ const EntryOfPartner0 = {
}
],
image: [],
document: [],
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 @@ -70,7 +70,8 @@ const youtubeMediaEntryResult = {
],
dash: [],
hls: [],
image: []
image: [],
document: []
},
duration: 0,
metadata: {
Expand Down
3 changes: 3 additions & 0 deletions test/src/k-provider/ovp/regex-action-handler-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const mediaConfig = {
}
],
image: [],
document: [],
id: '1_5w23wdlc',
duration: 206,
type: 'Vod',
Expand Down Expand Up @@ -632,6 +633,7 @@ const finalMediaConfigAllSourcesModified = {
}
],
image: [],
document: [],
id: '1_5w23wdlc',
duration: 206,
type: 'Vod',
Expand Down Expand Up @@ -764,6 +766,7 @@ const finalMediaConfigPlayManifestSourcesModified = {
}
],
image: [],
document: [],
id: '1_5w23wdlc',
duration: 206,
type: 'Vod',
Expand Down

0 comments on commit bb5f4a7

Please sign in to comment.