def test_full_widevine_cpix(): full_cpix = cpix.CPIX( content_keys=cpix.ContentKeyList( cpix.ContentKey( kid="0DC3EC4F-7683-548B-81E7-3C64E582E136", cek="WADwG2qCqkq5TVml+U5PXw==" ), cpix.ContentKey( kid="1447B7ED-2F66-572B-BD13-06CE7CF3610D", cek="ydugVLA+K017XoGM4mjxvA==" ), cpix.ContentKey( kid="00000000-0000-0000-0000-000000000002", cek="AAAAAAAAAAAAAAAAAAAAAg==" ) ), drm_systems=cpix.DRMSystemList( cpix.DRMSystem( kid="0DC3EC4F-7683-548B-81E7-3C64E582E136", system_id="EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED", pssh="AAAAxnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAINw+xPdoNUi4HnPGTlguE2FEe37S9mVyu9EwbOfPNhDQAAAIISEBRHt+0vZlcrvRMGznzzYQ0SEFrGoR6qL17Vv2aMQByBNMoSEG7hNRbI51h7rp9+zT6Zom4SEPnsEqYaJl1Hj4MzTjp40scSEA3D7E92g1SLgec8ZOWC4TYaDXdpZGV2aW5lX3Rlc3QiEXVuaWZpZWQtc3RyZWFtaW5nSOPclZsG", content_protection_data="PCEtLSBXaWRldmluZSAtLT4KPENvbnRlbnRQcm90ZWN0aW9uCiAgeG1sbnM9InVybjptcGVnOmRhc2g6c2NoZW1hOm1wZDoyMDExIgogIHhtbG5zOmNlbmM9InVybjptcGVnOmNlbmM6MjAxMyIKICBzY2hlbWVJZFVyaT0idXJuOnV1aWQ6RURFRjhCQTktNzlENi00QUNFLUEzQzgtMjdEQ0Q1MUQyMUVEIj4KICA8Y2VuYzpwc3NoPkFBQUF4bkJ6YzJnQkFBQUE3ZStMcVhuV1NzNmp5Q2ZjMVIwaDdRQUFBQUlOdyt4UGRvTlVpNEhuUEdUbGd1RTJGRWUzN1M5bVZ5dTlFd2JPZlBOaERRQUFBSUlTRUJSSHQrMHZabGNydlJNR3puenpZUTBTRUZyR29SNnFMMTdWdjJhTVFCeUJOTW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WVkIixLRVlGT1JNQVRWRVJTSU9OUz0iMSIK" ) ), usage_rules=cpix.UsageRuleList( cpix.UsageRule( kid="0DC3EC4F-7683-548B-81E7-3C64E582E136", filters=[cpix.AudioFilter()] ), cpix.UsageRule( kid="1447B7ED-2F66-572B-BD13-06CE7CF3610D", filters=[cpix.VideoFilter(max_pixels=38912)] ), cpix.UsageRule( kid="00000000-0000-0000-0000-000000000002", filters=[cpix.VideoFilter(min_pixels=38913)] ) ) ) assert full_cpix.validate_content()[0] xml = etree.tostring(full_cpix.element()) assert xml == b'<CPIX xmlns:pskc="urn:ietf:params:xml:ns:keyprov:pskc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:dashif:org:cpix" xsi:schemaLocation="urn:dashif:org:cpix cpix.xsd"><ContentKeyList><ContentKey kid="0dc3ec4f-7683-548b-81e7-3c64e582e136"><Data><pskc:Secret><pskc:PlainValue>WADwG2qCqkq5TVml+U5PXw==</pskc:PlainValue></pskc:Secret></Data></ContentKey><ContentKey kid="1447b7ed-2f66-572b-bd13-06ce7cf3610d"><Data><pskc:Secret><pskc:PlainValue>ydugVLA+K017XoGM4mjxvA==</pskc:PlainValue></pskc:Secret></Data></ContentKey><ContentKey kid="00000000-0000-0000-0000-000000000002"><Data><pskc:Secret><pskc:PlainValue>AAAAAAAAAAAAAAAAAAAAAg==</pskc:PlainValue></pskc:Secret></Data></ContentKey></ContentKeyList><DRMSystemList><DRMSystem kid="0dc3ec4f-7683-548b-81e7-3c64e582e136" systemId="edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"><PSSH>AAAAxnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAINw+xPdoNUi4HnPGTlguE2FEe37S9mVyu9EwbOfPNhDQAAAIISEBRHt+0vZlcrvRMGznzzYQ0SEFrGoR6qL17Vv2aMQByBNMoSEG7hNRbI51h7rp9+zT6Zom4SEPnsEqYaJl1Hj4MzTjp40scSEA3D7E92g1SLgec8ZOWC4TYaDXd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pZWQtc3RyZWFtaW5nSOPclZsG</PSSH><ContentProtectionData></ContentProtectionData><HLSSignalingData>I0VYVC1YLUtFWTpNRVRIT0Q9U0FNUExFLUFFUyxLRVlJRD0weDE0NDdCN0VEMkY2NjU3MkJCRDEzMDZDRTdDRjM2MTBELFVSST0iZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxBQUFBb25CemMyZ0FBQUFBN2UrTHFYbldTczZqeUNmYzFSMGg3UUFBQUlJU0VCUkh0KzB2WmxjcnZSTUd6bnp6WVEwU0VGckdvUjZxTDE3VnYyYU1RQnlCTk1vU0VHN2hOUmJJNTFoN3JwOSt6VDZab200U0VQbnNFcVlhSmwxSGo0TXpUanA0MHNjU0VBM0Q3RTkyZzFTTGdlYzhaT1dDNFRZYURYZHBaR1YyYVc1bFgzUmxjM1FpRVhWdWFXWnBaV1F0YzNSeVpXRnRhVzVuU09QY2xac0ciLEtFWUZPUk1BVD0idXJuOnV1aWQ6ZWRlZjhiYTktNzlkNi00YWNlLWEzYzgtMjdkY2Q1MWQyMWVkIixLRVlGT1JNQVRWRVJTSU9OUz0iMSIK</HLSSignalingData></DRMSystem></DRMSystemList><ContentKeyUsageRuleList><ContentKeyUsageRule kid="0dc3ec4f-7683-548b-81e7-3c64e582e136"><AudioFilter/></ContentKeyUsageRule><ContentKeyUsageRule kid="1447b7ed-2f66-572b-bd13-06ce7cf3610d"><VideoFilter maxPixels="38912"/></ContentKeyUsageRule><ContentKeyUsageRule kid="00000000-0000-0000-0000-000000000002"><VideoFilter minPixels="38913"/></ContentKeyUsageRule></ContentKeyUsageRuleList></CPIX>'
def test_simple_usage_rule(): usage_rule = cpix.UsageRule( kid="fdde4136-c15c-4953-bd45-ce0f454bd130", filters=[cpix.VideoFilter(), cpix.AudioFilter()], ) assert len(usage_rule) == 2 xml = etree.tostring(usage_rule.element()) assert xml == ( b'<ContentKeyUsageRule kid="fdde4136-c15c-4953-bd45-ce0f454bd130"><VideoFilter/><AudioFilter/></ContentKeyUsageRule>' )
def test_two_video_filters(): usage_rule = cpix.UsageRule( kid="ceb5153d-9b2c-45a0-9c8c-2bfc5e8b0d2f", filters=[ cpix.VideoFilter(hdr=True), cpix.VideoFilter(hdr=False), cpix.AudioFilter() ] ) assert len(usage_rule) == 3 xml = etree.tostring(usage_rule.element()) assert xml == ( b'<ContentKeyUsageRule kid="ceb5153d-9b2c-45a0-9c8c-2bfc5e8b0d2f"><VideoFilter hdr="true"/><VideoFilter hdr="false"/><AudioFilter/></ContentKeyUsageRule>')