libgpac
Documentation of the core library of GPAC
encrypt_cenc_isma.c File Reference
#include <gpac/filters.h>
#include <gpac/constants.h>
#include <gpac/crypt_tools.h>
#include <gpac/crypt.h>
#include <gpac/base_coding.h>
#include <gpac/download.h>
#include <gpac/xml.h>
#include <gpac/internal/isomedia_dev.h>
#include <gpac/internal/media_dev.h>
+ Include dependency graph for encrypt_cenc_isma.c:

Data Structures

struct  CENC_MKey
 
struct  OBURange
 
struct  GF_CENCStream
 
struct  GF_CENCEncCtx
 

Macros

#define OFFS(_n)   #_n, offsetof(GF_CENCEncCtx, _n)
 

Enumerations

enum  { ISMAEA_STATE_ERROR , ISMAEA_STATE_SETUP , ISMAEA_STATE_PLAY }
 
enum  CENCCodecMode {
  CENC_FULL_SAMPLE =1 , CENC_AVC , CENC_HEVC , CENC_AV1 ,
  CENC_VPX , CENC_VVC
}
 

Functions

static GF_Err isma_enc_configure (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, Bool is_isma, const char *scheme_uri, const char *kms_uri)
 
static GF_Err adobe_enc_configure (GF_CENCEncCtx *ctx, GF_CENCStream *cstr)
 
static GF_Err cenc_parse_pssh (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, const char *cfile_name)
 
static void cenc_pid_reset_codec_states (GF_CENCStream *cstr)
 
static GF_Err cenc_enc_configure (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, const char *cfile_name)
 
static void cenc_free_pid_context (GF_CENCStream *cstr)
 
void cenc_gen_bin128 (bin128 data)
 
static GF_Err cenc_enc_configure_pid (GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)
 
static GF_Err isma_process (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, GF_FilterPacket *pck)
 
static GF_Err adobe_process (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, GF_FilterPacket *pck)
 
static void increase_counter (char *x, int x_size)
 
static void cenc_resync_IV (GF_Crypt *mc, char IV[16], u8 IV_size)
 
static u32 cenc_get_clear_bytes (GF_CENCStream *cstr, GF_BitStream *plaintext_bs, char *samp_data, u32 nal_size, u32 bytes_in_nalhr)
 
static GF_Err cenc_encrypt_packet (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, GF_FilterPacket *pck)
 
static GF_Err cenc_process (GF_CENCEncCtx *ctx, GF_CENCStream *cstr, GF_FilterPacket *pck)
 
static GF_Err cenc_enc_process (GF_Filter *filter)
 
static GF_Err cenc_enc_initialize (GF_Filter *filter)
 
static void cenc_enc_finalize (GF_Filter *filter)
 
const GF_FilterRegister * cecrypt_register (GF_FilterSession *session)
 

Variables

static const GF_FilterCapability CENCEncCaps []
 
static const GF_FilterArgs GF_CENCEncArgs []
 
GF_FilterRegister CENCEncRegister
 

Data Structure Documentation

◆ CENC_MKey

struct CENC_MKey
Data Fields
GF_Crypt * crypt
char IV[16]
bin128 key
u32 IV_size

◆ OBURange

struct OBURange
Data Fields
u32 clear
u32 encrypted

◆ GF_CENCStream

struct GF_CENCStream
+ Collaboration diagram for GF_CENCStream:
Data Fields
Bool passthrough
GF_CryptInfo * cinfo
GF_FilterPid * ipid
GF_FilterPid * opid
GF_TrackCryptInfo * tci
u32 crypt_byte_block
u32 skip_byte_block
u32 nb_keys
CENC_MKey * keys
Bool multi_key
u32 codec_id
u32 nb_pck
u32 nalu_size_length
u32 dsi_crc
Bool isma_oma
u64 BSO
u64 range_end
Bool prev_pck_encrypted
u32 KI_length
u32 isma_IV_size
Bool has_crypted_pck
Bool is_adobe
CENCCodecMode cenc_codec
u32 bytes_in_nal_hdr
Bool use_subsamples
Bool cenc_init
u32 nb_pck_encrypted
u32 kidx
u32 nb_saps
u32 nb_segments
u32 nb_periods
Bool ctr_mode
Bool is_saes
Bool rap_roll
Bool warned_clear
AVCState * avc_state
HEVCState * hevc_state
AV1State * av1_state
OBURange * av1_vpx_ranges
GF_VPConfig * vp9_cfg
u32 * vpx_frame_sizes
VVCState * vvc_state
Bool slice_header_clear
GF_PropUIntList mkey_indices
u32 pssh_template_plus_one
GF_List * pssh_templates
u64 num_block_crypted

◆ GF_CENCEncCtx

struct GF_CENCEncCtx
+ Collaboration diagram for GF_CENCEncCtx:
Data Fields
const char * cfile
Bool allc
Bool bk_stats
Bool bk_skip
GF_CryptInfo * cinfo
GF_List * streams
GF_BitStream * bs_w
GF_BitStream * bs_r

Macro Definition Documentation

◆ OFFS

#define OFFS (   _n)    #_n, offsetof(GF_CENCEncCtx, _n)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ISMAEA_STATE_ERROR 
ISMAEA_STATE_SETUP 
ISMAEA_STATE_PLAY 

◆ CENCCodecMode

Enumerator
CENC_FULL_SAMPLE 
CENC_AVC 
CENC_HEVC 
CENC_AV1 
CENC_VPX 
CENC_VVC 

Function Documentation

◆ isma_enc_configure()

static GF_Err isma_enc_configure ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
Bool  is_isma,
const char *  scheme_uri,
const char *  kms_uri 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adobe_enc_configure()

static GF_Err adobe_enc_configure ( GF_CENCEncCtx ctx,
GF_CENCStream cstr 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_parse_pssh()

static GF_Err cenc_parse_pssh ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
const char *  cfile_name 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_pid_reset_codec_states()

static void cenc_pid_reset_codec_states ( GF_CENCStream cstr)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_enc_configure()

static GF_Err cenc_enc_configure ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
const char *  cfile_name 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_free_pid_context()

static void cenc_free_pid_context ( GF_CENCStream cstr)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_gen_bin128()

void cenc_gen_bin128 ( bin128  data)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_enc_configure_pid()

static GF_Err cenc_enc_configure_pid ( GF_Filter *  filter,
GF_FilterPid *  pid,
Bool  is_remove 
)
static
+ Here is the call graph for this function:

◆ isma_process()

static GF_Err isma_process ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
GF_FilterPacket *  pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adobe_process()

static GF_Err adobe_process ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
GF_FilterPacket *  pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ increase_counter()

static void increase_counter ( char *  x,
int  x_size 
)
static
+ Here is the caller graph for this function:

◆ cenc_resync_IV()

static void cenc_resync_IV ( GF_Crypt *  mc,
char  IV[16],
u8  IV_size 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_get_clear_bytes()

static u32 cenc_get_clear_bytes ( GF_CENCStream cstr,
GF_BitStream *  plaintext_bs,
char *  samp_data,
u32  nal_size,
u32  bytes_in_nalhr 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_encrypt_packet()

static GF_Err cenc_encrypt_packet ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
GF_FilterPacket *  pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_process()

static GF_Err cenc_process ( GF_CENCEncCtx ctx,
GF_CENCStream cstr,
GF_FilterPacket *  pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_enc_process()

static GF_Err cenc_enc_process ( GF_Filter *  filter)
static
+ Here is the call graph for this function:

◆ cenc_enc_initialize()

static GF_Err cenc_enc_initialize ( GF_Filter *  filter)
static
+ Here is the call graph for this function:

◆ cenc_enc_finalize()

static void cenc_enc_finalize ( GF_Filter *  filter)
static
+ Here is the call graph for this function:

◆ cecrypt_register()

const GF_FilterRegister* cecrypt_register ( GF_FilterSession *  session)
+ Here is the call graph for this function:

Variable Documentation

◆ CENCEncCaps

const GF_FilterCapability CENCEncCaps[]
static
Initial value:
=
{
}
@ GF_CODECID_RAW
Definition: constants.h:600
@ GF_STREAM_ENCRYPTED
Definition: constants.h:102
@ GF_STREAM_FILE
Definition: constants.h:104
#define GF_CAPS_OUTPUT
Definition: filters.h:2232
#define CAP_UINT(_f, _a, _b)
Definition: filters.h:2172
#define GF_CAPS_INPUT_EXCLUDED
Definition: filters.h:2228
#define GF_CAPS_OUTPUT_EXCLUDED
Definition: filters.h:2236
#define CAP_BOOL(_f, _a, _b)
Definition: filters.h:2180
@ GF_PROP_PID_CODECID
Definition: filters.h:1116
@ GF_PROP_PID_STREAM_TYPE
Definition: filters.h:1112
@ GF_PROP_PID_UNFRAMED
Definition: filters.h:1118
@ GF_TRUE
Definition: setup.h:474

◆ GF_CENCEncArgs

const GF_FilterArgs GF_CENCEncArgs[]
static
Initial value:
=
{
{ OFFS(cfile), "crypt file location", GF_PROP_STRING, NULL, NULL, 0},
{ OFFS(allc), "throw error if no DRM config file is found for a PID", GF_PROP_BOOL, NULL, NULL, 0},
{ OFFS(bk_stats), "print number of encrypted blocks to stdout upon exit", GF_PROP_BOOL, NULL, NULL, 0},
{ OFFS(bk_skip), "skip encryption but performs all other tasks (test mode)", GF_PROP_BOOL, NULL, NULL, GF_FS_ARG_HINT_EXPERT},
{0}
}
#define OFFS(_n)
Definition: encrypt_cenc_isma.c:2730
@ GF_FS_ARG_HINT_EXPERT
Definition: filters.h:2104
@ GF_PROP_BOOL
Definition: filters.h:858
@ GF_PROP_STRING
Definition: filters.h:876

◆ CENCEncRegister

GF_FilterRegister CENCEncRegister
Initial value:
= {
.name = "cecrypt",
GF_FS_SET_HELP("The CENC encryptor supports CENC, ISMA and Adobe encryption. It uses a DRM config file for declaring keys.\n"
"The syntax is available at https://wiki.gpac.io/xmlformats/Common-Encryption\n"
"The DRM config file can be set per PID using the property `CryptInfo`, or set at the filter level using [-cfile]().\n"
"When the DRM config file is set per PID, the first `CrypTrack` in the DRM config file with the same ID is used, otherwise the first `CrypTrack` is used (regardless of the `CrypTrack` ID).\n"
"When the DRM config file is set globally (not per PID), the first `CrypTrack` in the DRM config file with the same ID is used, otherwise the first `CrypTrack` with ID 0 or not set is used.\n"
"If no DRM config file is defined for a given PID, this PID will not be encrypted, or an error will be thrown if [-allc]() is specified.\n"
)
.private_size = sizeof(GF_CENCEncCtx),
.max_extra_pids=-1,
.configure_pid = cenc_enc_configure_pid,
.initialize = cenc_enc_initialize,
.finalize = cenc_enc_finalize,
.process = cenc_enc_process,
.hint_class_type = GF_FS_CLASS_CRYPTO
}
static GF_Err cenc_enc_process(GF_Filter *filter)
Definition: encrypt_cenc_isma.c:2646
static void cenc_enc_finalize(GF_Filter *filter)
Definition: encrypt_cenc_isma.c:2701
static GF_Err cenc_enc_initialize(GF_Filter *filter)
Definition: encrypt_cenc_isma.c:2684
static const GF_FilterArgs GF_CENCEncArgs[]
Definition: encrypt_cenc_isma.c:2731
static const GF_FilterCapability CENCEncCaps[]
Definition: encrypt_cenc_isma.c:2720
static GF_Err cenc_enc_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)
Definition: encrypt_cenc_isma.c:1127
Definition: encrypt_cenc_isma.c:140
#define GF_FS_SET_HELP(_help)
Definition: filters.h:2372
#define SETCAPS(__struct)
Definition: filters.h:2364
@ GF_FS_REG_EXPLICIT_ONLY
Definition: filters.h:2393
@ GF_FS_CLASS_CRYPTO
Definition: filters.h:2457
attribute Array args
Definition: jsf.idl:24