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

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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',
};
29 changes: 10 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 @@ -32,19 +25,16 @@ export const getSources = ({
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'}`;
Comment on lines +31 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntonLantukh we believe this now replaces external hosted URLs with the SSAI URL. This prevents playback because the SSAI URL yields an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ChristiaanScheermeijer ! Could you elaborate on this one? I see we use a APP_API_BASE_URL env which should be cdn.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use an externally hosted media file (e.g. https://videdock.com/video.m3u8) in JW dashboard, this shouldn't be replaced with the SSAI manifest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to check the type (mpd | m3u8) and make changes only for this case.

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 +45,7 @@ export const getSources = ({
}

source.file = url.toString();

return source;
});
};
Expand Down
Loading