/// <summary> /// Adds default DRM system signaling entries for all keys. /// </summary> public static void AddDefaultSignalingForAllKeys(CpixDocument document) { foreach (var key in document.ContentKeys) { document.DrmSystems.Add(new DrmSystem { SystemId = WidevineSystemId, KeyId = key.Id, ContentProtectionData = GenerateWidevineDashSignaling(key.Id), HlsSignalingData = new HlsSignalingData { MasterPlaylistData = GenerateWidevineHlsMasterPlaylistSignaling(key.Id), MediaPlaylistData = GenerateWidevineHlsMediaPlaylistSignaling(key.Id), } }); document.DrmSystems.Add(new DrmSystem { SystemId = PlayReadySystemId, KeyId = key.Id, ContentProtectionData = GeneratePlayReadyDashSignaling(key.Id), SmoothStreamingProtectionHeaderData = GeneratePlayReadyMssSignaling(key.Id) }); document.DrmSystems.Add(new DrmSystem { SystemId = FairPlaySystemId, KeyId = key.Id, HlsSignalingData = new HlsSignalingData { MasterPlaylistData = GenerateFairPlayHlsMasterPlaylistSignaling(key.Id), MediaPlaylistData = GenerateFairPlayHlsMediaPlaylistSignaling(key.Id) } }); } }
internal override void ValidateLoadedEntity(CpixDocument document) { if (!document.ContentKeys.Any(ck => ck.Id == KeyId)) { throw new InvalidCpixDataException("Content key usage rule references a content key that is not present in the CPIX document."); } foreach (var videoFilter in VideoFilters) { videoFilter.Validate(); } foreach (var audioFilter in AudioFilters) { audioFilter.Validate(); } foreach (var labelFilter in LabelFilters) { labelFilter.Validate(); } foreach (var bitrateFilter in BitrateFilters) { bitrateFilter.Validate(); } }
protected EntityCollectionBase(CpixDocument document) { if (document == null) { throw new ArgumentNullException(nameof(document)); } Document = document; }
internal override void ValidateNewEntity(CpixDocument document) { // This can happen if an entity with unsupported filters gets re-added to a document, for some misguided reason. if (ContainsUnsupportedFilters) { throw new InvalidCpixDataException("Cannot add a content key usage rule that contains unsupported filters. Such usage rules can only be passed through unmodified when processing a CPIX document."); } ValidateLoadedEntity(document); }
internal override void ValidateNewEntity(CpixDocument document) { if (Id == Guid.Empty) { throw new InvalidCpixDataException("A unique key ID must be provided for each content key."); } if (Value == null || Value.Length != Constants.ContentKeyLengthInBytes) { throw new InvalidCpixDataException($"A {Constants.ContentKeyLengthInBytes}-byte value must be provided for each new content key."); } if (ExplicitIv != null && ExplicitIv.Length != Constants.ContentKeyExplicitIvLengthInBytes) { throw new InvalidCpixDataException($"The explicit IVs associated with content keys must be {Constants.ContentKeyExplicitIvLengthInBytes} byte long."); } }
internal override void ValidateLoadedEntity(CpixDocument document) { if (Id == Guid.Empty) { throw new InvalidCpixDataException("A unique key ID must be provided for each content key."); } // We skip length check if we do not have a value for an encrypted key (it will be read-only). if (IsLoadedEncryptedKey && Value != null && Value.Length != Constants.ContentKeyLengthInBytes) { throw new InvalidCpixDataException($"A {Constants.ContentKeyLengthInBytes}-byte value must be provided for each new content key."); } if (ExplicitIv != null && ExplicitIv.Length != Constants.ContentKeyExplicitIvLengthInBytes) { throw new InvalidCpixDataException($"The explicit IVs associated with content keys must be {Constants.ContentKeyExplicitIvLengthInBytes} byte long."); } }
protected EntityCollection(CpixDocument document) : base(document) { }
internal override void ValidateLoadedEntity(CpixDocument document) { // We do not particularly care if someone has, with highly questionable intent, used weak certificates // in their CPIX documented generated via other mechanisms. We won't use them ourselves but we can ignore them here. }
internal override void ValidateNewEntity(CpixDocument document) { CryptographyHelpers.ValidateRecipientCertificateAndPublicKey(Certificate); }
internal RecipientCollection(CpixDocument document) : base(document) { }
public UsageRuleCollection(CpixDocument document) : base(document) { }
internal override void ValidateLoadedEntity(CpixDocument document) { ValidateEntity(); }
public ContentKeyCollection(CpixDocument document) : base(document) { }
public DrmSystemCollection(CpixDocument document) : base(document) { }