Skip to content

Commit

Permalink
feat(FEC-9197): add streamerType and urlType into the getPlaybackCont…
Browse files Browse the repository at this point in the history
…ext (#124)

pass `mediaInfo.streamerType` and `mediaInfo.urlType` on the PlaybackContext object
  • Loading branch information
yairans authored Oct 13, 2020
1 parent 7410f0e commit 6a82d05
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions flow-typed/types/media-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ declare type OTTProviderMediaInfoObject = OVPProviderMediaInfoObject & {
contextType: string,
protocol?: string,
fileIds?: string,
streamerType?: string,
urlType?: string,
assetReferenceType?: string,
formats?: Array<string>
};
Expand Down
8 changes: 5 additions & 3 deletions flow-typed/types/playback-context.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
declare type ProviderPlaybackContextOptions = {
mediaProtocol: string,
assetFileIds: string,
context: string
mediaProtocol?: string,
assetFileIds?: string,
context?: string,
streamerType?: string,
urlType?: string
};
8 changes: 7 additions & 1 deletion src/k-provider/ott/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ export default class OTTProvider extends BaseProvider<OTTProviderMediaInfoObject
const contextType = mediaInfo.contextType || KalturaPlaybackContext.Type.PLAYBACK;
const mediaType = mediaInfo.mediaType || KalturaAsset.Type.MEDIA;
const assetReferenceType = mediaInfo.assetReferenceType || KalturaAsset.AssetReferenceType.MEDIA;
const playbackContext = {
const playbackContext: ProviderPlaybackContextOptions = {
mediaProtocol: mediaInfo.protocol,
assetFileIds: mediaInfo.fileIds,
context: contextType
};
if (mediaInfo.streamerType) {
playbackContext.streamerType = mediaInfo.streamerType;
}
if (mediaInfo.urlType) {
playbackContext.urlType = mediaInfo.urlType;
}
this._dataLoader.add(OTTAssetLoader, {
entryId: entryId,
ks: ks,
Expand Down
21 changes: 20 additions & 1 deletion test/src/k-provider/ott/provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {MultiRequestResult} from '../../../../src/k-provider/common/multi-reques
import MultiRequestBuilder from '../../../../src/k-provider/common/multi-request-builder';
import KalturaAsset from '../../../../src/k-provider/ott/response-types/kaltura-asset';
import KalturaPlaybackContext from '../../../../src/k-provider/ott/response-types/kaltura-playback-context';
import OTTAssetLoader from '../../../../src/k-provider/ott/loaders/asset-loader';

const partnerId = 198;
const playerVersion = '1.2.3';
Expand All @@ -18,7 +19,12 @@ describe('OTTProvider.partnerId:198', function () {

afterEach(() => {
sandbox.restore();
MultiRequestBuilder.prototype.execute.restore();
if (MultiRequestBuilder.prototype.execute.restore) {
MultiRequestBuilder.prototype.execute.restore();
}
if (OTTAssetLoader.prototype.buildRequests.restore) {
OTTAssetLoader.prototype.buildRequests.restore();
}
});

it('should return config without plugins and with drm data', done => {
Expand Down Expand Up @@ -130,6 +136,19 @@ describe('OTTProvider.partnerId:198', function () {
}
);
});

it('should pass streamerType and urlType on the playback context object', done => {
sinon.stub(OTTAssetLoader.prototype, 'buildRequests').callsFake(function (params: Object) {
try {
params.playbackContext.streamerType.should.equal('mpegdash');
params.playbackContext.urlType.should.equal('DIRECT');
done();
} catch (e) {
done(e);
}
});
provider.getMediaConfig({entryId: 1234, streamerType: 'mpegdash', urlType: 'DIRECT'});
});
});

describe('getEntryListConfig', function () {
Expand Down

0 comments on commit 6a82d05

Please sign in to comment.