use of com.acgist.snail.pojo.wrapper.KeyValueWrapper in project snail by acgist.
the class M3u8Builder method buildCipher.
/**
* <p>新建加密套件</p>
*
* @return 加密套件
*
* @throws NetException 网络异常
*/
private Cipher buildCipher() throws NetException {
final var optional = this.labels.stream().filter(label -> LABEL_EXT_X_KEY.equalsIgnoreCase(label.getName())).findFirst();
if (optional.isEmpty()) {
// 没有加密标签:不用解密
return null;
}
final KeyValueWrapper wrapper = optional.get().attrs();
final String method = wrapper.getIgnoreCase(ATTR_METHOD);
final M3u8.Protocol protocol = M3u8.Protocol.of(method);
LOGGER.debug("HLS加密算法:{}", method);
if (protocol == null || protocol == M3u8.Protocol.NONE) {
throw new NetException("不支持的HLS加密算法:" + method);
}
if (protocol == M3u8.Protocol.AES_128) {
return this.buildCipherAes128(wrapper.getIgnoreCase(ATTR_IV), wrapper.getIgnoreCase(ATTR_URI));
} else {
throw new NetException("不支持的HLS加密算法:" + method);
}
}
Aggregations