2 * Apple HTTP Live Streaming Sample Encryption/Decryption
4 * Copyright (c) 2021 Nachiket Tarate
6 * This file is part of FFmpeg.
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.
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.
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
25 * Apple HTTP Live Streaming Sample Encryption
26 * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
29 #ifndef AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
30 #define AVFORMAT_HLS_SAMPLE_ENCRYPTION_H
35 #include "libavcodec/codec_id.h"
36 #include "libavcodec/packet.h"
40 #define HLS_MAX_ID3_TAGS_DATA_LEN 138
41 #define HLS_MAX_AUDIO_SETUP_DATA_LEN 10
43 typedef struct HLSCryptoContext
{
44 struct AVAES
*aes_ctx
;
49 typedef struct HLSAudioSetupInfo
{
50 enum AVCodecID codec_id
;
54 uint8_t setup_data_length
;
55 uint8_t setup_data
[HLS_MAX_AUDIO_SETUP_DATA_LEN
];
59 void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo
*info
, const uint8_t *buf
, size_t size
);
61 int ff_hls_senc_parse_audio_setup_info(AVStream
*st
, HLSAudioSetupInfo
*info
);
63 int ff_hls_senc_decrypt_frame(enum AVCodecID codec_id
, HLSCryptoContext
*crypto_ctx
, AVPacket
*pkt
);
65 #endif /* AVFORMAT_HLS_SAMPLE_ENCRYPTION_H */