Skip to content

Commit

Permalink
fix: prefix provider types (#42)
Browse files Browse the repository at this point in the history
Prefix provider types with Provider to avoid collision between types in kaltura player js.
  • Loading branch information
Dan Ziv authored Jan 9, 2018
1 parent 9d8adef commit 80499d5
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 49 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var provider = new playkit.providers.ovp.Provider(options);
// Step 3 - Create media info object
var mediaInfo = {
entryId: "YOUR_ENTRY_ID" // Mandatory
ks: "YOUR_KS", // Optional
ks: "YOUR_KS" // Optional
};
// Step 4 - Get media config
provider.getMediaConfig(mediaInfo).then(function(mediaConfig) {
Expand Down Expand Up @@ -90,8 +90,8 @@ var provider = new playkit.providers.ott.Provider(options);
var mediaInfo = {
entryId: "YOUR_ENTRY_ID", // Mandatory
ks: "YOUR_KS", // Optional,
mediaType: "YOUR_MEDIA_TYPE" // Optional, default: "MEDIA",
contextType: "YOUR_MEDIA_CONTEXT_TYPE", // Optional, default: "PLAYBACK",
mediaType: "YOUR_MEDIA_TYPE" // Optional, default: "MEDIA"
contextType: "YOUR_MEDIA_CONTEXT_TYPE", // Optional, default: "PLAYBACK"
protocol: "YOUR_PROTOCOL", // Optional
fileIds: "YOUR_FILE_IDS" // Optional
};
Expand Down
2 changes: 1 addition & 1 deletion dist/playkit-bookmark-service.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/playkit-ott-provider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-ott-provider.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/playkit-ovp-provider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-ovp-provider.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-stats-service.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion flow-typed/types/drm-data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
declare type DrmDataObject = {
declare type ProviderDrmDataObject = {
licenseUrl: string,
scheme: string,
certificate?: string
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
declare type ProviderMediaConfigObject = {
id: string,
name: string,
session: SessionConfigObject,
sources: MediaSourcesObject,
session: ProviderSessionConfigObject,
sources: ProviderMediaSourcesObject,
duration: number,
type: string,
dvr: boolean,
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/types/media-entry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow
declare type MediaEntryObject = {
declare type ProviderMediaEntryObject = {
id: string,
name: string,
sources: MediaSourcesObject,
sources: ProviderMediaSourcesObject,
duration: number,
dvrStatus: number,
metadata: Object,
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/types/media-format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
declare type MediaFormatType = {
declare type ProviderMediaFormatType = {
name: string,
mimeType: string,
pathExt: string
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions flow-typed/types/media-source.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @flow
declare type MediaSourceObject = {
declare type ProviderMediaSourceObject = {
id: string,
url: string,
mimetype: string,
bandwidth?: number,
width?: number,
height?: number,
label?: string,
drmData?: Array<DrmDataObject>
drmData?: Array<ProviderDrmDataObject>
};
8 changes: 4 additions & 4 deletions flow-typed/types/media-sources.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
declare type MediaSourcesObject = {
progressive: Array<MediaSourceObject>,
dash: Array<MediaSourceObject>,
hls: Array<MediaSourceObject>
declare type ProviderMediaSourcesObject = {
progressive: Array<ProviderMediaSourceObject>,
dash: Array<ProviderMediaSourceObject>,
hls: Array<ProviderMediaSourceObject>
};
2 changes: 1 addition & 1 deletion flow-typed/types/playback-context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
declare type PlaybackContextOptions = {
declare type ProviderPlaybackContextOptions = {
mediaProtocol: string,
assetFileIds: string,
context: string
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/types/provider-options.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow
declare type ProviderOptionsObject = {
partnerId: number,
logLevel: string,
ks: string,
logLevel?: string,
ks?: string,
uiConfId?: number,
env?: ProviderEnvConfigObject
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
declare type SessionConfigObject = {
declare type ProviderSessionConfigObject = {
partnerId: number,
uiConfId?: number,
ks?: string
Expand Down
6 changes: 3 additions & 3 deletions src/entities/drm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export default class Drm {

/**
* Convert class to native js object.
* @returns {DrmDataObject} - The json class object.
* @returns {ProviderDrmDataObject} - The json class object.
*/
toJSON(): DrmDataObject {
const response: DrmDataObject = {
toJSON(): ProviderDrmDataObject {
const response: ProviderDrmDataObject = {
licenseUrl: this.licenseUrl,
scheme: this.scheme
};
Expand Down
4 changes: 2 additions & 2 deletions src/entities/media-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export default class MediaEntry {

/**
* Convert class to native js object.
* @returns {MediaEntryObject} - The json class object.
* @returns {ProviderMediaEntryObject} - The json class object.
*/
toJSON(): MediaEntryObject {
toJSON(): ProviderMediaEntryObject {
return {
id: this.id,
name: this.name,
Expand Down
4 changes: 2 additions & 2 deletions src/entities/media-format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@flow
export const MediaFormat: { [name: string]: MediaFormatType } = {
export const MediaFormat: { [name: string]: ProviderMediaFormatType } = {
DASH: {
name: 'dash',
mimeType: 'application/dash+xml',
Expand Down Expand Up @@ -27,7 +27,7 @@ export const MediaFormat: { [name: string]: MediaFormatType } = {
}
};

export const SupportedStreamFormat: Map<string, MediaFormatType> = new Map([
export const SupportedStreamFormat: Map<string, ProviderMediaFormatType> = new Map([
["mpegdash", MediaFormat.DASH],
["applehttp", MediaFormat.HLS],
["url", MediaFormat.MP4]
Expand Down
6 changes: 3 additions & 3 deletions src/entities/media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export default class MediaSource {

/**
* Convert class to native js object.
* @returns {MediaSourceObject} - The json class object.
* @returns {ProviderMediaSourceObject} - The json class object.
*/
toJSON(): MediaSourceObject {
const response: MediaSourceObject = {
toJSON(): ProviderMediaSourceObject {
const response: ProviderMediaSourceObject = {
id: this.id,
url: this.url,
mimetype: this.mimetype
Expand Down
8 changes: 4 additions & 4 deletions src/entities/media-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class MediaSources {
* @param {MediaFormat} mediaFormat - The media format of the source.
* @returns {void}
*/
map(source: MediaSource, mediaFormat: ?MediaFormatType) {
map(source: MediaSource, mediaFormat: ?ProviderMediaFormatType) {
if (mediaFormat) {
switch (mediaFormat.name) {
case MediaFormat.MP4.name:
Expand All @@ -57,10 +57,10 @@ export default class MediaSources {

/**
* Convert class to native js object.
* @returns {MediaSourcesObject} - The json class object.
* @returns {ProviderMediaSourcesObject} - The json class object.
*/
toJSON(): MediaSourcesObject {
const response: MediaSourcesObject = {
toJSON(): ProviderMediaSourcesObject {
const response: ProviderMediaSourcesObject = {
progressive: [],
dash: [],
hls: []
Expand Down
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 @@ -39,7 +39,7 @@ export default class BaseProvider<MI> {
this._partnerId = options.partnerId;
this._uiConfId = options.uiConfId;
this._isAnonymous = !options.ks;
this._ks = options.ks;
this._ks = options.ks || '';
this._playerVersion = playerVersion;
if (options.logLevel && this.LogLevel[options.logLevel]) {
setLogLevel(this.LogLevel[options.logLevel]);
Expand Down
7 changes: 7 additions & 0 deletions src/k-provider/ott/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
// @flow
import OTTProvider from './provider'
import KalturaPlaybackContext from './response-types/kaltura-playback-context'
import KalturaAsset from './response-types/kaltura-asset'

declare var __VERSION__: string;
declare var __NAME__: string;

const NAME = __NAME__ + '-ott';
const VERSION = __VERSION__;

const ContextType = KalturaPlaybackContext.Type;
const MediaType = KalturaAsset.Type;

export {
OTTProvider as Provider,
ContextType,
MediaType,
NAME,
VERSION
};
4 changes: 2 additions & 2 deletions src/k-provider/ott/services/asset-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default class OTTAssetService extends OTTService {
* @param {string} ks The partner ID
* @param {string} assetId The asset ID
* @param {string} type The asset type (media/recording/epg)
* @param {PlaybackContextOptions} playbackContextOptions The playbackContextOptions
* @param {ProviderPlaybackContextOptions} playbackContextOptions The playbackContextOptions
* @returns {RequestBuilder} The request builder
* @static
*/
static getPlaybackContext(serviceUrl: string, ks: string, assetId: string, type: string, playbackContextOptions: PlaybackContextOptions): RequestBuilder {
static getPlaybackContext(serviceUrl: string, ks: string, assetId: string, type: string, playbackContextOptions: ProviderPlaybackContextOptions): RequestBuilder {
const headers: Map<string, string> = new Map();
headers.set("Content-Type", "application/json");
const request = new RequestBuilder(headers);
Expand Down
13 changes: 8 additions & 5 deletions src/util/logger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//@flow
import * as JsLogger from 'js-logger';

const LogLevel: { [level: string]: Object } = {
export type LogLevelObject = { value: number, name: string };
export type LogLevelType = { [level: string]: LogLevelObject };

const LogLevel: LogLevelType = {
DEBUG: JsLogger.DEBUG,
INFO: JsLogger.INFO,
TIME: JsLogger.TIME,
Expand All @@ -27,19 +30,19 @@ function getLogger(name?: string): Object {
/**
* get the log level
* @param {?string} name - the logger name
* @returns {Object} - the log level
* @returns {LogLevelObject} - the log level
*/
function getLogLevel(name?: string): Object {
function getLogLevel(name?: string): LogLevelObject {
return getLogger(name).getLevel();
}

/**
* sets the logger level
* @param {Object} level - the log level
* @param {LogLevelObject} level - the log level
* @param {?string} name - the logger name
* @returns {void}
*/
function setLogLevel(level: Object, name?: string): void {
function setLogLevel(level: LogLevelObject, name?: string): void {
getLogger(name).setLevel(level);
}

Expand Down

0 comments on commit 80499d5

Please sign in to comment.