FFmpeg
hls_sample_encryption.h
Go to the documentation of this file.
1 /*
2  * Apple HTTP Live Streaming Sample Encryption/Decryption
3  *
4  * Copyright (c) 2021 Nachiket Tarate
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * Apple HTTP Live Streaming Sample Encryption
26  * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
27  */
28 
29 #ifndef AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
30 #define AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
31 
32 #include <stdint.h>
33 
34 #include "avformat.h"
35 #include "libavcodec/avcodec.h"
36 
37 #include "libavutil/aes.h"
38 
39 #define HLS_MAX_ID3_TAGS_DATA_LEN 138
40 #define HLS_MAX_AUDIO_SETUP_DATA_LEN 10
41 
42 typedef struct HLSCryptoContext {
43  struct AVAES *aes_ctx;
44  uint8_t key[16];
45  uint8_t iv[16];
47 
48 typedef struct HLSAudioSetupInfo {
50  uint32_t codec_tag;
51  uint16_t priming;
52  uint8_t version;
56 
57 
58 void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size);
59 
61 
63 
64 #endif /* AVFORMAT_HLS_SAMPLE_ENCRYPTION_H */
65 
HLSAudioSetupInfo::version
uint8_t version
Definition: hls_sample_encryption.h:52
HLSAudioSetupInfo::setup_data_length
uint8_t setup_data_length
Definition: hls_sample_encryption.h:53
ff_hls_senc_parse_audio_setup_info
int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
Definition: hls_sample_encryption.c:89
ff_hls_senc_decrypt_frame
int ff_hls_senc_decrypt_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AVPacket *pkt)
Definition: hls_sample_encryption.c:383
HLSCryptoContext::iv
uint8_t iv[16]
Definition: hls_sample_encryption.h:45
pkt
AVPacket * pkt
Definition: movenc.c:59
HLSCryptoContext::aes_ctx
struct AVAES * aes_ctx
Definition: hls_sample_encryption.h:43
info
MIPS optimizations info
Definition: mips.txt:2
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:369
aes.h
HLSAudioSetupInfo::setup_data
uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN]
Definition: hls_sample_encryption.h:54
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:47
HLSCryptoContext
Definition: hls_sample_encryption.h:42
size
int size
Definition: twinvq_data.h:10344
HLSAudioSetupInfo::priming
uint16_t priming
Definition: hls_sample_encryption.h:51
HLSAudioSetupInfo::codec_id
enum AVCodecID codec_id
Definition: hls_sample_encryption.h:49
HLS_MAX_AUDIO_SETUP_DATA_LEN
#define HLS_MAX_AUDIO_SETUP_DATA_LEN
Definition: hls_sample_encryption.h:40
avcodec.h
AVStream
Stream structure.
Definition: avformat.h:935
AVAES
Definition: aes_internal.h:34
avformat.h
ff_hls_senc_read_audio_setup_info
void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size)
Definition: hls_sample_encryption.c:58
AVPacket
This structure stores compressed data.
Definition: packet.h:350
HLSAudioSetupInfo::codec_tag
uint32_t codec_tag
Definition: hls_sample_encryption.h:50
HLSAudioSetupInfo
Definition: hls_sample_encryption.h:48
HLSCryptoContext::key
uint8_t key[16]
Definition: hls_sample_encryption.h:44