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(project): add user_id support for DRM, Live and SSAI #653

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ export const APP_CONFIG_ITEM_TYPE = {
content_list: 'content_list',
media: 'media',
} as const;

export const MANIFEST_TYPE = {
dash: 'application/dash+xml"',
hls: 'application/vnd.apple.mpegurl',
};
31 changes: 12 additions & 19 deletions packages/common/src/utils/sources.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import type { PlaylistItem, Source } from '@jwp/ott-common/types/playlist';
import type { Config } from '@jwp/ott-common/types/config';
import type { Customer } from '@jwp/ott-common/types/account';

const isVODManifestType = (sourceUrl: string, baseUrl: string, mediaId: string, extensions: ('m3u8' | 'mpd')[]) => {
return extensions.some((ext) => sourceUrl === `${baseUrl}/manifests/${mediaId}.${ext}`);
};

const isBCLManifestType = (sourceUrl: string, baseUrl: string, mediaId: string, extensions: ('m3u8' | 'mpd')[]) => {
return extensions.some((ext) => sourceUrl === `${baseUrl}/live/broadcast/${mediaId}.${ext}`);
};
import { MANIFEST_TYPE } from '@jwp/ott-common/src/constants';

export const getSources = ({
item,
Expand All @@ -29,22 +22,21 @@ export const getSources = ({
const userId = user?.id;
const hasServerAds = !!adConfig && adDeliveryMethod === 'ssai';

console.info(item, 'item');

return sources.map((source: Source) => {
const url = new URL(source.file);

const sourceUrl = url.href;
const isDRM = (url.searchParams.has('exp') && url.searchParams.has('sig')) || source.drm;

const isBCLManifest = isBCLManifestType(sourceUrl, baseUrl, mediaid, ['m3u8', 'mpd']);
const isVODManifest = isVODManifestType(sourceUrl, baseUrl, mediaid, ['m3u8', 'mpd']);
const isDRM = url.searchParams.has('exp') && url.searchParams.has('sig');

// Use SSAI URL for configs with server side ads, DRM is not supported
if (isVODManifest && hasServerAds && !isDRM) {
// Only HLS is supported now
url.href = `${baseUrl}/v2/sites/${siteId}/media/${mediaid}/ssai.m3u8`;
// Use SSAI URL for configs with server side ads, DRM is not supported yet
if (hasServerAds && !isDRM) {
url.href = `${baseUrl}/v2/sites/${siteId}/media/${mediaid}/ssai.${MANIFEST_TYPE.dash === source.type ? 'mpd' : 'm3u8'}`;
url.searchParams.set('ad_config_id', adConfig);
// Attach user_id only for VOD and BCL SaaS Live Streams (doesn't work with SSAI items)
} else if ((isVODManifest || isBCLManifest) && userId) {
}

// Attach user_id for VOD and BCL SaaS Live Streams
if (userId) {
url.searchParams.set('user_id', userId);
}

Expand All @@ -55,6 +47,7 @@ export const getSources = ({
}

source.file = url.toString();

return source;
});
};
Expand Down
Loading