tools/sofa2wavs: fix build on Windows
[ffmpeg.git] / libavformat / hls_sample_encryption.h
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];
47 } HLSCryptoContext;
48
49 typedef struct HLSAudioSetupInfo {
50 enum AVCodecID codec_id;
51 uint32_t codec_tag;
52 uint16_t priming;
53 uint8_t version;
54 uint8_t setup_data_length;
55 uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN];
56 } HLSAudioSetupInfo;
57
58
59 void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size);
60
61 int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info);
62
63 int ff_hls_senc_decrypt_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AVPacket *pkt);
64
65 #endif /* AVFORMAT_HLS_SAMPLE_ENCRYPTION_H */