Skip to content

Commit

Permalink
fix(FEC-10636): Add KS to playbackUrl for direct playbackContext url (#…
Browse files Browse the repository at this point in the history
…131)

Issue: ks didn't add for sources without flavorIds.
Solution: add ks to sources without flavorIds.
  • Loading branch information
Yuvalke authored Dec 28, 2020
1 parent 109cd55 commit aaa4484
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/k-provider/ovp/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ export default class OVPProviderParser {
});
} else {
playUrl = kalturaSource.url;
if (ks) {
if (playUrl.indexOf('?') === -1) {
const lastSlash = playUrl.lastIndexOf('/');
playUrl = playUrl.substr(0, lastSlash) + '/ks/' + ks + playUrl.substr(lastSlash, playUrl.length);
} else {
playUrl = playUrl + '&ks=' + ks;
}
}
}
if (!playUrl) {
const message = `failed to create play url from source, discarding source: (${entryId}_${deliveryProfileId}), ${format}`;
Expand Down
78 changes: 77 additions & 1 deletion test/src/k-provider/ovp/be-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3234,6 +3234,81 @@ const EntryWithBumperWithKs = {
]
};

const EntryDirectWithKs = {
response: [
{
objects: [
{
mediaType: 1,
dataUrl: 'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_wifqaipd/format/url/protocol/http',
flavorParamsIds: '',
duration: 741,
msDuration: 741000,
id: '0_wifqaipd',
name: 'MPEG Dash with MultiAudio New Transcoding',
status: 2,
type: 1,
thumbnailUrl: 'http://cdntesting.qa.mkaltura.com/p/1091/sp/109100/thumbnail/entry_id/0_wifqaipd/version/100042',
objectType: 'KalturaMediaEntry'
}
],
totalCount: 1,
objectType: 'KalturaBaseEntryListResponse'
},
{
sources: [
{
deliveryProfileId: 911,
format: 'mpegdash',
protocols: 'http,https',
flavorIds: '',
url:
'https://qa-apache-php7.dev.kaltura.com/p/1091/sp/1091/playManifest/entryId/0_wifqaipd/flavorIds/0_m131krws,0_5407xm9j,0_xcrwyk2n/deliveryProfileId/911/protocol/https/format/mpegdash/manifest.mpd',
drm: [],
objectType: 'KalturaPlaybackSource'
}
],
actions: [],
messages: [],
objectType: 'KalturaPlaybackContext'
},
{
objects: [
{
id: 13624421,
partnerId: 1091,
metadataProfileId: 4771,
metadataProfileVersion: 12,
metadataObjectType: 1,
objectId: '0_wifqaipd',
version: 12,
createdAt: 1499600020,
updatedAt: 1499600285,
status: 1,
xml: '<metadata/>',
objectType: 'KalturaMetadata'
},
{
id: 13624422,
partnerId: 1091,
metadataProfileId: 13126,
metadataProfileVersion: 2,
metadataObjectType: 1,
objectId: '0_wifqaipd',
version: 2,
createdAt: 1499600285,
updatedAt: 1499600285,
status: 1,
xml: '<metadata>\n <MediaType>Movie</MediaType>\n <WatchPermissionRule>Parrent Allowed</WatchPermissionRule>\n</metadata>',
objectType: 'KalturaMetadata'
}
],
totalCount: 2,
objectType: 'KalturaMetadataListResponse'
}
]
};

const EntryWithBumperWitNoSources = {
response: [
{
Expand Down Expand Up @@ -3592,5 +3667,6 @@ export {
EntryWithBumperWithKs,
EntryWithBumperWitNoSources,
EntryWithBumper as EntryExternalCaptionNoKS,
EntryWithBumperWithKs as EntryExternalCaptionWithKS
EntryWithBumperWithKs as EntryExternalCaptionWithKS,
EntryDirectWithKs
};
27 changes: 27 additions & 0 deletions test/src/k-provider/ovp/provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,33 @@ describe('getPlaybackContext', () => {
});
});

it('should add KS to direct playbackContext', done => {
sandbox = sinon.createSandbox();
sinon.stub(MultiRequestBuilder.prototype, 'execute').callsFake(function () {
return new Promise(resolve => {
resolve({response: new MultiRequestResult(BE_DATA.EntryDirectWithKs.response)});
});
});
provider = new OVPProvider({partnerId: partnerId}, playerVersion);
provider.getMediaConfig({entryId: '0_wifqaipd', ks: ks}).then(
mediaConfig => {
try {
const result = mediaConfig.sources.dash.filter(source => {
const ksParam = source.url.indexOf('?') === -1 ? '/ks/' : '&ks=';
return source.url.indexOf(ksParam + ks) !== -1;
});
result.should.deep.equal(mediaConfig.sources.dash);
done();
} catch (err) {
done(err);
}
},
err => {
done(err);
}
);
});

it('should add KS to external captions url', done => {
sandbox = sinon.createSandbox();
sinon.stub(MultiRequestBuilder.prototype, 'execute').callsFake(function () {
Expand Down

0 comments on commit aaa4484

Please sign in to comment.