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 <stddef.h>
33 #include <stdint.h>
34 
35 #include "libavcodec/codec_id.h"
36 #include "libavcodec/packet.h"
37 #include "avformat.h"
38 
39 
40 #define HLS_MAX_ID3_TAGS_DATA_LEN 138
41 #define HLS_MAX_AUDIO_SETUP_DATA_LEN 10
42 
43 typedef struct HLSCryptoContext {
44  struct AVAES *aes_ctx;
45  uint8_t key[16];
46  uint8_t iv[16];
48 
49 typedef struct HLSAudioSetupInfo {
51  uint32_t codec_tag;
52  uint16_t priming;
53  uint8_t version;
57 
58 
59 void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size);
60 
62 
64 
65 #endif /* AVFORMAT_HLS_SAMPLE_ENCRYPTION_H */
66 
HLSAudioSetupInfo::version
uint8_t version
Definition: hls_sample_encryption.h:53
HLSAudioSetupInfo::setup_data_length
uint8_t setup_data_length
Definition: hls_sample_encryption.h:54
ff_hls_senc_parse_audio_setup_info
int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
Definition: hls_sample_encryption.c:93
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:387
HLSCryptoContext::iv
uint8_t iv[16]
Definition: hls_sample_encryption.h:46
pkt
AVPacket * pkt
Definition: movenc.c:60
codec_id.h
HLSCryptoContext::aes_ctx
struct AVAES * aes_ctx
Definition: hls_sample_encryption.h:44
info
MIPS optimizations info
Definition: mips.txt:2
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:387
HLSAudioSetupInfo::setup_data
uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN]
Definition: hls_sample_encryption.h:55
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
HLSCryptoContext
Definition: hls_sample_encryption.h:43
size
int size
Definition: twinvq_data.h:10344
HLSAudioSetupInfo::priming
uint16_t priming
Definition: hls_sample_encryption.h:52
HLSAudioSetupInfo::codec_id
enum AVCodecID codec_id
Definition: hls_sample_encryption.h:50
packet.h
HLS_MAX_AUDIO_SETUP_DATA_LEN
#define HLS_MAX_AUDIO_SETUP_DATA_LEN
Definition: hls_sample_encryption.h:41
AVStream
Stream structure.
Definition: avformat.h:743
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:61
AVPacket
This structure stores compressed data.
Definition: packet.h:501
HLSAudioSetupInfo::codec_tag
uint32_t codec_tag
Definition: hls_sample_encryption.h:51
HLSAudioSetupInfo
Definition: hls_sample_encryption.h:49
HLSCryptoContext::key
uint8_t key[16]
Definition: hls_sample_encryption.h:45