summaryrefslogtreecommitdiff
path: root/libavformat/hls_sample_encryption.h
diff options
context:
space:
mode:
authorNachiket Tarate <nachiket.programmer@gmail.com>2021-09-22 00:12:00 +0530
committerSteven Liu <lq@chinaffmpeg.org>2021-10-13 11:23:53 +0800
commitff958b38463f6ebd17471c40001287c71698f639 (patch)
tree2b5e5bdf288d0308245fb9c63c167835d1b8220d /libavformat/hls_sample_encryption.h
parentef0f5d1be67a97bf8a5c3da07e12f55b34a24ec3 (diff)
downloadffmpeg-ff958b38463f6ebd17471c40001287c71698f639.tar.gz
libavformat/hls: add support for decryption of HLS media segments encrypted using SAMPLE-AES encryption method
Apple HTTP Live Streaming Sample Encryption: https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hls_sample_encryption.h')
-rw-r--r--libavformat/hls_sample_encryption.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/libavformat/hls_sample_encryption.h b/libavformat/hls_sample_encryption.h
new file mode 100644
index 0000000000..ff3f9c22f7
--- /dev/null
+++ b/libavformat/hls_sample_encryption.h
@@ -0,0 +1,65 @@
+/*
+ * Apple HTTP Live Streaming Sample Encryption/Decryption
+ *
+ * Copyright (c) 2021 Nachiket Tarate
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Apple HTTP Live Streaming Sample Encryption
+ * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
+ */
+
+#ifndef AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
+#define AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
+
+#include <stdint.h>
+
+#include "avformat.h"
+#include "libavcodec/avcodec.h"
+
+#include "libavutil/aes.h"
+
+#define HLS_MAX_ID3_TAGS_DATA_LEN 138
+#define HLS_MAX_AUDIO_SETUP_DATA_LEN 10
+
+typedef struct HLSCryptoContext {
+ struct AVAES *aes_ctx;
+ uint8_t key[16];
+ uint8_t iv[16];
+} HLSCryptoContext;
+
+typedef struct HLSAudioSetupInfo {
+ enum AVCodecID codec_id;
+ uint32_t codec_tag;
+ uint16_t priming;
+ uint8_t version;
+ uint8_t setup_data_length;
+ uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN];
+} HLSAudioSetupInfo;
+
+
+void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size);
+
+int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info);
+
+int ff_hls_senc_decrypt_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AVPacket *pkt);
+
+#endif /* AVFORMAT_HLS_SAMPLE_ENCRYPTION_H */
+