public void parse(String line, ParseState state) { lineParser.parse(line, state); EncryptionData.Builder builder = new EncryptionData.Builder() .withKeyFormat(Constants.DEFAULT_KEY_FORMAT) .withKeyFormatVersions(Constants.DEFAULT_KEY_FORMAT_VERSIONS); ParseUtil.parseAttributes(line, builder, state, HANDLERS, getTag()); EncryptionData encryptionData = builder.build(); if (encryptionData.getMethod() != EncryptionMethod.NONE && encryptionData.getUri() == null) { throw ParseException.create(ParseExceptionType.MISSING_ENCRYPTION_URI, getTag(), line); } state.getMedia().encryptionData = encryptionData; }
public void testEXT_X_KEY() { IExtTagParser handler = MediaPlaylistLineParser.EXT_X_KEY; String tag = Constants.EXT_X_KEY_TAG; String uri = "http://foo.bar.com/"; String format = "format"; String line = "#" + tag + ":METHOD=AES-128" + ",URI=\"" + uri + "\"" + ",IV=0x1234abcd5678EF90aabbccddeeff0011" + ",KEYFORMAT=\"" + format + "\"" + ",KEYFORMATVERSIONS=\"1/2/3\""; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); EncryptionData encryptionData = mParseState.getMedia().encryptionData; Assert.Equal(EncryptionMethod.AES, encryptionData.getMethod()); Assert.Equal(uri, encryptionData.getUri()); Assert.Equal( new List <byte>() { (byte)0x12, (byte)0x34, (byte)0xAB, (byte)0xCD, (byte)0x56, (byte)0x78, (byte)0xEF, (byte)0x90, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF, (byte)0x00, (byte)0x11 }, encryptionData.getInitializationVector()); Assert.Equal(format, encryptionData.getKeyFormat()); Assert.Equal(new List <int>() { 1, 2, 3 }, encryptionData.getKeyFormatVersions()); }