mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-23 23:09:28 +00:00
feat(DashManifest): Add DRM infos to MPD
Required in newer versions of Shaka (for playback of protected content).
This commit is contained in:
@@ -65,6 +65,17 @@ function SegmentInfo({ info }: { info: FSegmentInfo }) {
|
||||
</>;
|
||||
}
|
||||
|
||||
function getDrmSystemId(drm_family?: string): string | null {
|
||||
switch (drm_family) {
|
||||
case 'WIDEVINE':
|
||||
return 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed';
|
||||
case 'PLAYREADY':
|
||||
return '9a04f079-9840-4286-ab92-e65be0885f95';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function DashManifest({
|
||||
streamingData,
|
||||
isPostLiveDvr,
|
||||
@@ -109,6 +120,11 @@ async function DashManifest({
|
||||
audioSamplingRate={set.audio_sample_rate}
|
||||
contentType="audio"
|
||||
>
|
||||
{
|
||||
set.drm_families && set.drm_families.map((drm_family) => (
|
||||
<contentProtection schemeIdUri={`urn:uuid:${getDrmSystemId(drm_family)}`}/>
|
||||
))
|
||||
}
|
||||
{
|
||||
set.track_roles && set.track_roles.map((role) => (
|
||||
<role
|
||||
@@ -164,6 +180,11 @@ async function DashManifest({
|
||||
frameRate={set.fps}
|
||||
contentType="video"
|
||||
>
|
||||
{
|
||||
set.drm_families && set.drm_families.map((drm_family) => (
|
||||
<contentProtection schemeIdUri={`urn:uuid:${getDrmSystemId(drm_family)}`}/>
|
||||
))
|
||||
}
|
||||
{
|
||||
set.color_info.primaries &&
|
||||
<supplementalProperty
|
||||
@@ -295,4 +316,4 @@ export function toDash(
|
||||
captionTracks={caption_tracks}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ export interface AudioSet {
|
||||
track_name?: string;
|
||||
track_roles?: ('main' | 'dub' | 'description' | 'enhanced-audio-intelligibility' | 'alternate')[];
|
||||
channels?: number;
|
||||
drm_families?: string[];
|
||||
drm_track_type?: string;
|
||||
representations: AudioRepresentation[];
|
||||
}
|
||||
|
||||
@@ -81,6 +83,8 @@ export interface VideoSet {
|
||||
color_info: ColorInfo;
|
||||
codecs?: string;
|
||||
fps?: number;
|
||||
drm_families?: string[];
|
||||
drm_track_type?: string;
|
||||
representations: VideoRepresentation[]
|
||||
}
|
||||
|
||||
@@ -481,6 +485,8 @@ function getAudioSet(
|
||||
track_name,
|
||||
track_roles: getTrackRoles(first_format, has_drc_streams),
|
||||
channels: hoistAudioChannelsIfPossible(formats, hoisted),
|
||||
drm_families: first_format.drm_families,
|
||||
drm_track_type: first_format.drm_track_type,
|
||||
representations: formats.map((format) => getAudioRepresentation(format, hoisted, url_transformer, actions, player, cpn, shared_post_live_dvr_info, is_sabr))
|
||||
};
|
||||
|
||||
@@ -596,6 +602,8 @@ function getVideoSet(
|
||||
color_info,
|
||||
codecs: hoistCodecsIfPossible(formats, hoisted),
|
||||
fps: hoistNumberAttributeIfPossible(formats, 'fps', hoisted),
|
||||
drm_families: first_format.drm_families,
|
||||
drm_track_type: first_format.drm_track_type,
|
||||
representations: formats.map((format) => getVideoRepresentation(format, url_transformer, hoisted, player, actions, cpn, shared_post_live_dvr_info, is_sabr))
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user