FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
movenccenc.c File Reference
#include "movenccenc.h"
#include "libavutil/intreadwrite.h"
#include "avio_internal.h"
#include "movenc.h"
#include "avc.h"

Go to the source code of this file.

Functions

static int auxiliary_info_alloc_size (MOVMuxCencContext *ctx, int size)
 
static int auxiliary_info_write (MOVMuxCencContext *ctx, const uint8_t *buf_in, int size)
 
static int auxiliary_info_add_subsample (MOVMuxCencContext *ctx, uint16_t clear_bytes, uint32_t encrypted_bytes)
 
static void mov_cenc_write_encrypted (MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
 Encrypt the input buffer and write using avio_write. More...
 
static int mov_cenc_start_packet (MOVMuxCencContext *ctx)
 Start writing a packet. More...
 
static int mov_cenc_end_packet (MOVMuxCencContext *ctx)
 Finalize a packet. More...
 
int ff_mov_cenc_write_packet (MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
 Write a fully encrypted packet. More...
 
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 body is encrypted. More...
 
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 body is encrypted. More...
 
static int64_t update_size (AVIOContext *pb, int64_t pos)
 
static int mov_cenc_write_senc_tag (MOVMuxCencContext *ctx, AVIOContext *pb, int64_t *auxiliary_info_offset)
 
static int mov_cenc_write_saio_tag (AVIOContext *pb, int64_t auxiliary_info_offset)
 
static int mov_cenc_write_saiz_tag (MOVMuxCencContext *ctx, AVIOContext *pb)
 
void ff_mov_cenc_write_stbl_atoms (MOVMuxCencContext *ctx, AVIOContext *pb)
 Write the cenc atoms that should reside inside stbl. More...
 
static int mov_cenc_write_schi_tag (AVIOContext *pb, uint8_t *kid)
 
int ff_mov_cenc_write_sinf_tag (MOVTrack *track, AVIOContext *pb, uint8_t *kid)
 Write the sinf atom, contained inside stsd. More...
 
int ff_mov_cenc_init (MOVMuxCencContext *ctx, uint8_t *encryption_key, int use_subsamples, int bitexact)
 Initialize a CENC context. More...
 
void ff_mov_cenc_free (MOVMuxCencContext *ctx)
 Free a CENC context. More...
 

Function Documentation

static int auxiliary_info_alloc_size ( MOVMuxCencContext ctx,
int  size 
)
static

Definition at line 27 of file movenccenc.c.

Referenced by auxiliary_info_add_subsample(), and auxiliary_info_write().

static int auxiliary_info_write ( MOVMuxCencContext ctx,
const uint8_t buf_in,
int  size 
)
static

Definition at line 43 of file movenccenc.c.

Referenced by mov_cenc_start_packet().

static int auxiliary_info_add_subsample ( MOVMuxCencContext ctx,
uint16_t  clear_bytes,
uint32_t  encrypted_bytes 
)
static
static void mov_cenc_write_encrypted ( MOVMuxCencContext ctx,
AVIOContext pb,
const uint8_t buf_in,
int  size 
)
static

Encrypt the input buffer and write using avio_write.

Definition at line 89 of file movenccenc.c.

Referenced by ff_mov_cenc_avc_parse_nal_units(), ff_mov_cenc_avc_write_nal_units(), and ff_mov_cenc_write_packet().

static int mov_cenc_start_packet ( MOVMuxCencContext ctx)
static

Start writing a packet.

Definition at line 109 of file movenccenc.c.

Referenced by ff_mov_cenc_avc_parse_nal_units(), ff_mov_cenc_avc_write_nal_units(), and ff_mov_cenc_write_packet().

static int mov_cenc_end_packet ( MOVMuxCencContext ctx)
static

Finalize a packet.

Definition at line 137 of file movenccenc.c.

Referenced by ff_mov_cenc_avc_parse_nal_units(), ff_mov_cenc_avc_write_nal_units(), and ff_mov_cenc_write_packet().

int ff_mov_cenc_write_packet ( MOVMuxCencContext ctx,
AVIOContext pb,
const uint8_t buf_in,
int  size 
)

Write a fully encrypted packet.

Definition at line 167 of file movenccenc.c.

Referenced by ff_mov_write_packet().

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 body is encrypted.

Definition at line 192 of file movenccenc.c.

Referenced by ff_mov_write_packet().

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 body is encrypted.

Definition at line 232 of file movenccenc.c.

Referenced by ff_mov_write_packet().

static int64_t update_size ( AVIOContext pb,
int64_t  pos 
)
static
static int mov_cenc_write_senc_tag ( MOVMuxCencContext ctx,
AVIOContext pb,
int64_t *  auxiliary_info_offset 
)
static

Definition at line 292 of file movenccenc.c.

Referenced by ff_mov_cenc_write_stbl_atoms().

static int mov_cenc_write_saio_tag ( AVIOContext pb,
int64_t  auxiliary_info_offset 
)
static

Definition at line 306 of file movenccenc.c.

Referenced by ff_mov_cenc_write_stbl_atoms().

static int mov_cenc_write_saiz_tag ( MOVMuxCencContext ctx,
AVIOContext pb 
)
static

Definition at line 325 of file movenccenc.c.

Referenced by ff_mov_cenc_write_stbl_atoms().

void ff_mov_cenc_write_stbl_atoms ( MOVMuxCencContext ctx,
AVIOContext pb 
)

Write the cenc atoms that should reside inside stbl.

Definition at line 339 of file movenccenc.c.

Referenced by mov_write_stbl_tag().

static int mov_cenc_write_schi_tag ( AVIOContext pb,
uint8_t kid 
)
static

Definition at line 348 of file movenccenc.c.

Referenced by ff_mov_cenc_write_sinf_tag().

int ff_mov_cenc_write_sinf_tag ( MOVTrack track,
AVIOContext pb,
uint8_t kid 
)

Write the sinf atom, contained inside stsd.

Definition at line 364 of file movenccenc.c.

Referenced by mov_write_audio_tag(), and mov_write_video_tag().

int ff_mov_cenc_init ( MOVMuxCencContext ctx,
uint8_t encryption_key,
int  use_subsamples,
int  bitexact 
)

Initialize a CENC context.

Parameters
keyencryption key, must have a length of AES_CTR_KEY_SIZE
use_subsampleswhen enabled parts of a packet can be encrypted, otherwise the whole packet is encrypted

Definition at line 388 of file movenccenc.c.

Referenced by mov_write_header().

void ff_mov_cenc_free ( MOVMuxCencContext ctx)

Free a CENC context.

Definition at line 412 of file movenccenc.c.

Referenced by mov_free().