libgpac
Documentation of the core library of GPAC
decrypt_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/network.h>
#include <gpac/internal/media_dev.h>
+ Include dependency graph for decrypt_cenc_isma.c:

Data Structures

struct  CENCDecKey
 
struct  GF_CENCDecCtx
 
struct  GF_CENCDecStream
 

Macros

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

Enumerations

enum  { DECRYPT_STATE_ERROR =1 , DECRYPT_STATE_SETUP , DECRYPT_STATE_PLAY }
 
enum  {
  DECRYPT_FULL =0 , DECRYPT_NOKEY , DECRYPT_SKIP , DECRYPT_PAD0 ,
  DECRYPT_PAD1 , DECRYPT_PADSC
}
 

Functions

static GF_Err cenc_dec_setup_isma (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, u32 scheme_type, u32 scheme_version, const char *scheme_uri, const char *kms_uri)
 
static GF_Err cenc_dec_access_isma (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, Bool is_play)
 
static GF_Err cenc_dec_process_isma (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, GF_FilterPacket *in_pck)
 
static GF_Err cenc_dec_load_keys (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr)
 
static GF_Err rfmt_dec_b64 (u8 *data, u8 *output, u32 osize)
 
static GF_Err cenc_dec_set_clearkey (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, char *ck_url, u8 *ck_kid)
 
static GF_Err cenc_dec_set_hls_key (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, char *key_url, u8 *key_IV)
 
static GF_Err cenc_dec_push_iv (GF_CENCDecStream *cstr, u32 key_idx, u8 *IV, u32 iv_size, u32 const_iv_size, const u8 *const_iv)
 
static GF_Err cenc_dec_load_pssh (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, const GF_PropertyValue *pssh_prop, Bool is_pck_pssh, const GF_PropertyValue *cinfo_prop)
 
static GF_Err cenc_dec_setup_cenc (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, u32 scheme_type, u32 scheme_version, const char *scheme_uri, const char *kms_uri)
 
static GF_Err cenc_dec_hls_saes (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, u32 scheme_type, u32 scheme_version, const char *scheme_uri, const char *kms_uri)
 
static GF_Err cenc_dec_setup_adobe (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, u32 scheme_type, u32 scheme_version, const char *scheme_uri, const char *kms_uri)
 
static GF_Err cenc_dec_access_cenc (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, Bool is_play)
 
static GF_Err cenc_dec_access_adobe (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, Bool is_play)
 
u8 key_info_get_iv_size (const u8 *key_info, u32 nb_keys, u32 idx, u8 *const_iv_size, const u8 **const_iv)
 
static GFINLINE void cenc_decrypt_block (GF_CENCDecCtx *ctx, GF_Crypt *crypt, Bool valid_key, u8 *data, u32 size)
 
static GF_Err cenc_dec_process_cenc (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, GF_FilterPacket *in_pck)
 
static GF_Err cenc_dec_process_hls_saes (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, GF_FilterPacket *in_pck)
 
static GF_Err cenc_dec_process_adobe (GF_CENCDecCtx *ctx, GF_CENCDecStream *cstr, GF_FilterPacket *in_pck)
 
static void cenc_dec_stream_del (GF_CENCDecStream *cstr)
 
static GF_Err cenc_dec_configure_pid (GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)
 
static Bool cenc_dec_process_event (GF_Filter *filter, const GF_FilterEvent *evt)
 
static GF_Err cenc_dec_process (GF_Filter *filter)
 
static GF_Err cenc_dec_initialize (GF_Filter *filter)
 
static void cenc_dec_finalize (GF_Filter *filter)
 
const GF_FilterRegister * cdcrypt_register (GF_FilterSession *session)
 

Variables

static const GF_FilterCapability CENCDecCaps []
 
static const GF_FilterArgs GF_CENCDecArgs []
 
GF_FilterRegister CENCDecRegister
 

Data Structure Documentation

◆ CENCDecKey

struct CENCDecKey
Data Fields
GF_Crypt * crypt
bin128 key
u32 key_valid

◆ GF_CENCDecCtx

struct GF_CENCDecCtx
+ Collaboration diagram for GF_CENCDecCtx:
Data Fields
const char * cfile
u32 decrypt
GF_PropUIntList drop_keys
GF_PropStringList kids
GF_PropStringList keys
GF_CryptInfo * cinfo
Bool hls_cenc_patch_iv
GF_Filter * filter
GF_List * streams
GF_BitStream * bs_r
GF_DownloadManager * dm
u32 pending_keys

◆ GF_CENCDecStream

struct GF_CENCDecStream
+ Collaboration diagram for GF_CENCDecStream:
Data Fields
GF_CENCDecCtx * ctx
GF_FilterPid * ipid
GF_FilterPid * opid
u32 state
u32 pssh_crc
u32 scheme_type
u32 scheme_version
GF_Err key_error
CENCDecKey * crypts
u32 nb_crypts
char salt[8]
u64 last_IV
u32 nb_allow_play
Bool is_oma
Bool is_adobe
u32 preview_range
Bool is_nalu
Bool selective_encryption
u32 IV_length
u32 KI_length
Bool is_cenc
Bool is_cbc
u32 KID_count
Bool inband_keys
bin128 * KIDs
bin128 * keys
const GF_PropertyValue * cenc_ki
u32 multikey
const GF_PropertyValue * cenc_pattern
Bool crypt_init
Bool is_hls
bin128 hls_IV
char * hls_key_url
Bool is_hls_saes
u32 codec_id
Bool force_hls_iv
Bool gpac_master_leaf
bin128 master_key
u32 clearkey_crc
char * body
u32 res_size
Bool hdr_done
GF_DownloadSession * sess
u32 rep_crc
u32 per_crc
u32 as_id

Macro Definition Documentation

◆ OFFS

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DECRYPT_STATE_ERROR 
DECRYPT_STATE_SETUP 
DECRYPT_STATE_PLAY 

◆ anonymous enum

anonymous enum
Enumerator
DECRYPT_FULL 
DECRYPT_NOKEY 
DECRYPT_SKIP 
DECRYPT_PAD0 
DECRYPT_PAD1 
DECRYPT_PADSC 

Function Documentation

◆ cenc_dec_setup_isma()

static GF_Err cenc_dec_setup_isma ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
u32  scheme_type,
u32  scheme_version,
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:

◆ cenc_dec_access_isma()

static GF_Err cenc_dec_access_isma ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
Bool  is_play 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_process_isma()

static GF_Err cenc_dec_process_isma ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
GF_FilterPacket *  in_pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_load_keys()

static GF_Err cenc_dec_load_keys ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr 
)
static
+ Here is the caller graph for this function:

◆ rfmt_dec_b64()

static GF_Err rfmt_dec_b64 ( u8 data,
u8 output,
u32  osize 
)
static
+ Here is the call graph for this function:

◆ cenc_dec_set_clearkey()

static GF_Err cenc_dec_set_clearkey ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
char *  ck_url,
u8 ck_kid 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_set_hls_key()

static GF_Err cenc_dec_set_hls_key ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
char *  key_url,
u8 key_IV 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_push_iv()

static GF_Err cenc_dec_push_iv ( GF_CENCDecStream cstr,
u32  key_idx,
u8 IV,
u32  iv_size,
u32  const_iv_size,
const u8 const_iv 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_load_pssh()

static GF_Err cenc_dec_load_pssh ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
const GF_PropertyValue *  pssh_prop,
Bool  is_pck_pssh,
const GF_PropertyValue *  cinfo_prop 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_setup_cenc()

static GF_Err cenc_dec_setup_cenc ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
u32  scheme_type,
u32  scheme_version,
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:

◆ cenc_dec_hls_saes()

static GF_Err cenc_dec_hls_saes ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
u32  scheme_type,
u32  scheme_version,
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:

◆ cenc_dec_setup_adobe()

static GF_Err cenc_dec_setup_adobe ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
u32  scheme_type,
u32  scheme_version,
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:

◆ cenc_dec_access_cenc()

static GF_Err cenc_dec_access_cenc ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
Bool  is_play 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_access_adobe()

static GF_Err cenc_dec_access_adobe ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
Bool  is_play 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ key_info_get_iv_size()

u8 key_info_get_iv_size ( const u8 key_info,
u32  nb_keys,
u32  idx,
u8 const_iv_size,
const u8 **  const_iv 
)
+ Here is the caller graph for this function:

◆ cenc_decrypt_block()

static GFINLINE void cenc_decrypt_block ( GF_CENCDecCtx ctx,
GF_Crypt *  crypt,
Bool  valid_key,
u8 data,
u32  size 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_process_cenc()

static GF_Err cenc_dec_process_cenc ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
GF_FilterPacket *  in_pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_process_hls_saes()

static GF_Err cenc_dec_process_hls_saes ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
GF_FilterPacket *  in_pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_process_adobe()

static GF_Err cenc_dec_process_adobe ( GF_CENCDecCtx ctx,
GF_CENCDecStream cstr,
GF_FilterPacket *  in_pck 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cenc_dec_stream_del()

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

◆ cenc_dec_configure_pid()

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

◆ cenc_dec_process_event()

static Bool cenc_dec_process_event ( GF_Filter *  filter,
const GF_FilterEvent *  evt 
)
static
+ Here is the call graph for this function:

◆ cenc_dec_process()

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

◆ cenc_dec_initialize()

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

◆ cenc_dec_finalize()

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

◆ cdcrypt_register()

const GF_FilterRegister* cdcrypt_register ( GF_FilterSession *  session)

Variable Documentation

◆ CENCDecCaps

const GF_FilterCapability CENCDecCaps[]
static
Initial value:
=
{
}
#define GF_HLS_SAMPLE_AES_SCHEME
Definition: constants.h:1226
@ GF_CODECID_NONE
Definition: constants.h:383
@ GF_STREAM_ENCRYPTED
Definition: constants.h:102
@ GF_STREAM_FILE
Definition: constants.h:104
#define CAP_UINT(_f, _a, _b)
Definition: filters.h:2172
#define CAP_4CC(_f, _a, _b)
Definition: filters.h:2174
#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
#define GF_CAPS_INPUT
Definition: filters.h:2220
@ 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_PROP_PID_PROTECTION_SCHEME_TYPE
Definition: filters.h:1209
@ GF_ISOM_ADOBE_SCHEME
Definition: isomedia.h:5693
@ GF_ISOM_PIFF_SCHEME
Definition: isomedia.h:5699
@ GF_ISOM_CBCS_SCHEME
Definition: isomedia.h:5697
@ GF_ISOM_CENC_SCHEME
Definition: isomedia.h:5689
@ GF_ISOM_CBC_SCHEME
Definition: isomedia.h:5691
@ GF_ISOM_OMADRM_SCHEME
Definition: isomedia.h:5687
@ GF_ISOM_CENS_SCHEME
Definition: isomedia.h:5695
@ GF_ISOM_ISMACRYP_SCHEME
Definition: isomedia.h:5685
@ GF_TRUE
Definition: setup.h:474

◆ GF_CENCDecArgs

const GF_FilterArgs GF_CENCDecArgs[]
static
Initial value:
=
{
{ OFFS(cfile), "crypt file location", GF_PROP_STRING, NULL, NULL, 0},
{ OFFS(decrypt), "decrypt mode (CENC only)\n"
"- full: decrypt everything, throwing error if keys are not found\n"
"- nokey: decrypt everything for which a key is found, skip decryption otherwise\n"
"- skip: decrypt nothing\n"
"- pad0: decrypt nothing and replace all crypted bits with 0\n"
"- pad1: decrypt nothing and replace all crypted bits with 1\n"
"- padsc: decrypt nothing and replace all crypted bytes with start codes"
, GF_PROP_UINT, "full", "full|nokey|skip|pad0|pad1|padsc", GF_ARG_HINT_ADVANCED},
{ OFFS(drop_keys), "consider keys with given 1-based indexes as not available (multi-key debug)", GF_PROP_UINT_LIST, NULL, NULL, GF_ARG_HINT_EXPERT},
{ OFFS(kids), "define KIDs. If `keys` is empty, consider keys with given KID (as hex string) as not available (debug)", GF_PROP_STRING_LIST, NULL, NULL, GF_ARG_HINT_EXPERT},
{ OFFS(keys), "define key values for each of the specified KID", GF_PROP_STRING_LIST, NULL, NULL, GF_ARG_HINT_EXPERT},
{ OFFS(hls_cenc_patch_iv), "ignore IV updates in some broken HLS+CENC streams", GF_PROP_BOOL, "false", NULL, GF_ARG_HINT_EXPERT},
{0}
}
#define OFFS(_n)
Definition: decrypt_cenc_isma.c:2490
@ GF_PROP_BOOL
Definition: filters.h:858
@ GF_PROP_STRING
Definition: filters.h:876
@ GF_PROP_UINT_LIST
Definition: filters.h:897
@ GF_PROP_STRING_LIST
Definition: filters.h:895
@ GF_PROP_UINT
Definition: filters.h:852
#define GF_ARG_HINT_ADVANCED
Definition: main.h:121
#define GF_ARG_HINT_EXPERT
Definition: main.h:123

◆ CENCDecRegister

GF_FilterRegister CENCDecRegister
Initial value:
= {
.name = "cdcrypt",
GF_FS_SET_HELP("The CENC decryptor supports decrypting CENC, ISMA, HLS Sample-AES (MPEG2 ts) and Adobe streams.\n"
"\n"
"For HLS, key is retrieved according to the key URI in the manifest.\n"
"Otherwise, the filter uses a configuration file.\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 `DecryptInfo` (highest priority), `CryptInfo` (lower priority) "
"or set at the filter level using [-cfile]() (lowest priority).\n"
"When the file is set per PID, the first `CryptInfo` with the same ID is used, otherwise the first `CryptInfo` is used."
"When the 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"
)
.private_size = sizeof(GF_CENCDecCtx),
.max_extra_pids=-1,
.configure_pid = cenc_dec_configure_pid,
.initialize = cenc_dec_initialize,
.finalize = cenc_dec_finalize,
.process = cenc_dec_process,
.process_event = cenc_dec_process_event,
.hint_class_type = GF_FS_CLASS_CRYPTO
}
static const GF_FilterArgs GF_CENCDecArgs[]
Definition: decrypt_cenc_isma.c:2491
static GF_Err cenc_dec_initialize(GF_Filter *filter)
Definition: decrypt_cenc_isma.c:2429
static GF_Err cenc_dec_process(GF_Filter *filter)
Definition: decrypt_cenc_isma.c:2385
static Bool cenc_dec_process_event(GF_Filter *filter, const GF_FilterEvent *evt)
Definition: decrypt_cenc_isma.c:2351
static void cenc_dec_finalize(GF_Filter *filter)
Definition: decrypt_cenc_isma.c:2455
static GF_Err cenc_dec_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)
Definition: decrypt_cenc_isma.c:2176
static const GF_FilterCapability CENCDecCaps[]
Definition: decrypt_cenc_isma.c:2470
Definition: decrypt_cenc_isma.c:69
#define GF_FS_SET_HELP(_help)
Definition: filters.h:2372
#define SETCAPS(__struct)
Definition: filters.h:2364
@ GF_FS_REG_USE_SYNC_READ
Definition: filters.h:2424
@ GF_FS_CLASS_CRYPTO
Definition: filters.h:2457
attribute Array args
Definition: jsf.idl:24