示例#1
0
 /// <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)
             }
         });
     }
 }
示例#2
0
        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();
            }
        }
示例#3
0
        protected EntityCollectionBase(CpixDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            Document = document;
        }
示例#4
0
        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);
        }
示例#5
0
        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.");
            }
        }
示例#6
0
        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.");
            }
        }
示例#7
0
 protected EntityCollection(CpixDocument document) : base(document)
 {
 }
示例#8
0
 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.
 }
示例#9
0
 internal override void ValidateNewEntity(CpixDocument document)
 {
     CryptographyHelpers.ValidateRecipientCertificateAndPublicKey(Certificate);
 }
示例#10
0
 internal RecipientCollection(CpixDocument document) : base(document)
 {
 }
示例#11
0
 public UsageRuleCollection(CpixDocument document) : base(document)
 {
 }
示例#12
0
 internal override void ValidateLoadedEntity(CpixDocument document)
 {
     ValidateEntity();
 }
示例#13
0
 public ContentKeyCollection(CpixDocument document) : base(document)
 {
 }
示例#14
0
 public DrmSystemCollection(CpixDocument document) : base(document)
 {
 }