FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
movenccenc.h
Go to the documentation of this file.
1 /*
2  * MOV CENC (Common Encryption) writer
3  * Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFORMAT_MOVENCCENC_H
23 #define AVFORMAT_MOVENCCENC_H
24 
25 #include "libavutil/aes_ctr.h"
26 #include "avformat.h"
27 #include "avio.h"
28 
29 #define CENC_KID_SIZE (16)
30 
31 struct MOVTrack;
32 
33 typedef struct {
34  struct AVAESCTR* aes_ctr;
39 
40  /* subsample support */
42  uint16_t subsample_count;
47 
48 /**
49  * Initialize a CENC context
50  * @param key encryption key, must have a length of AES_CTR_KEY_SIZE
51  * @param use_subsamples when enabled parts of a packet can be encrypted, otherwise the whole packet is encrypted
52  */
53 int ff_mov_cenc_init(MOVMuxCencContext* ctx, uint8_t* encryption_key, int use_subsamples, int bitexact);
54 
55 /**
56  * Free a CENC context
57  */
59 
60 /**
61  * Write a fully encrypted packet
62  */
64 
65 /**
66  * Parse AVC NAL units from annex B format, the nal size and type are written in the clear while the body is encrypted
67  */
69 
70 /**
71  * Write AVC NAL units that are in MP4 format, the nal size and type are written in the clear while the body is encrypted
72  */
74  AVIOContext *pb, const uint8_t *buf_in, int size);
75 
76 /**
77  * Write the cenc atoms that should reside inside stbl
78  */
80 
81 /**
82  * Write the sinf atom, contained inside stsd
83  */
84 int ff_mov_cenc_write_sinf_tag(struct MOVTrack* track, AVIOContext *pb, uint8_t* kid);
85 
86 #endif /* AVFORMAT_MOVENCCENC_H */
const char * s
Definition: avisynth_c.h:768
Bytestream IO Context.
Definition: avio.h:161
Buffered I/O operations.
int ff_mov_cenc_init(MOVMuxCencContext *ctx, uint8_t *encryption_key, int use_subsamples, int bitexact)
Initialize a CENC context.
Definition: movenccenc.c:388
size_t auxiliary_info_size
Definition: movenccenc.h:36
struct AVAESCTR * aes_ctr
Definition: movenccenc.h:34
uint32_t auxiliary_info_entries
Definition: movenccenc.h:38
Format I/O context.
Definition: avformat.h:1349
uint8_t
void ff_mov_cenc_free(MOVMuxCencContext *ctx)
Free a CENC context.
Definition: movenccenc.c:412
int ff_mov_cenc_write_sinf_tag(struct MOVTrack *track, AVIOContext *pb, uint8_t *kid)
Write the sinf atom, contained inside stsd.
Definition: movenccenc.c:364
size_t auxiliary_info_sizes_alloc_size
Definition: movenccenc.h:45
ptrdiff_t size
Definition: opengl_enc.c:101
int ff_mov_cenc_write_packet(MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
Write a fully encrypted packet.
Definition: movenccenc.c:167
void ff_mov_cenc_write_stbl_atoms(MOVMuxCencContext *ctx, AVIOContext *pb)
Write the cenc atoms that should reside inside stbl.
Definition: movenccenc.c:339
uint16_t subsample_count
Definition: movenccenc.h:42
uint8_t * auxiliary_info
Definition: movenccenc.h:35
int ff_mov_cenc_avc_parse_nal_units(MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
Parse AVC NAL units from annex B format, the nal size and type are written in the clear while the bod...
Definition: movenccenc.c:192
uint8_t * auxiliary_info_sizes
Definition: movenccenc.h:44
AVFormatContext * ctx
Definition: movenc.c:48
size_t auxiliary_info_alloc_size
Definition: movenccenc.h:37
size_t auxiliary_info_subsample_start
Definition: movenccenc.h:43
Main libavformat public API header.
int ff_mov_cenc_avc_write_nal_units(AVFormatContext *s, MOVMuxCencContext *ctx, int nal_length_size, AVIOContext *pb, const uint8_t *buf_in, int size)
Write AVC NAL units that are in MP4 format, the nal size and type are written in the clear while the ...
Definition: movenccenc.c:232