124 int data_rate, fscod, acmod, lfeon;
177 const uint8_t *nalu_start =
ctx->buf_ptr;
179 if (
ctx->buf_end -
ctx->buf_ptr >= 4 &&
AV_RB32(
ctx->buf_ptr) == 0x00000001)
181 else if (
ctx->buf_end -
ctx->buf_ptr >= 3 &&
AV_RB24(
ctx->buf_ptr) == 0x000001)
188 while (
ctx->buf_ptr <
ctx->buf_end) {
189 if (
ctx->buf_end -
ctx->buf_ptr >= 4 &&
AV_RB32(
ctx->buf_ptr) == 0x00000001)
191 else if (
ctx->buf_end -
ctx->buf_ptr >= 3 &&
AV_RB24(
ctx->buf_ptr) == 0x000001)
218 rem_bytes = nalu->
length - 32;
220 memcpy(iv, crypto_ctx->
iv, 16);
222 while (rem_bytes > 0) {
223 if (rem_bytes > 16) {
229 rem_bytes -=
FFMIN(144, rem_bytes);
243 memset(&
ctx, 0,
sizeof(
ctx));
247 data_ptr =
pkt->data;
249 while (
ctx.buf_ptr <
ctx.buf_end) {
250 memset(&nalu, 0,
sizeof(nalu));
254 if ((nalu.
type == 0x01 || nalu.
type == 0x05) && nalu.
length > 48) {
255 int encrypted_nalu_length = nalu.
length;
259 move_nalu = nalu.
length != encrypted_nalu_length;
278 while (
ctx->buf_ptr <
ctx->buf_end - 1) {
279 if (*
ctx->buf_ptr == 0xFF && (*(
ctx->buf_ptr + 1) & 0xF0) == 0xF0)
284 if (
ctx->buf_ptr >=
ctx->buf_end - 1)
287 frame->data = (uint8_t*)
ctx->buf_ptr;
308 while (
ctx->buf_ptr <
ctx->buf_end - 1) {
309 if (*
ctx->buf_ptr == 0x0B && *(
ctx->buf_ptr + 1) == 0x77)
314 if (
ctx->buf_ptr >=
ctx->buf_end - 1)
317 frame->data = (uint8_t*)
ctx->buf_ptr;
318 frame->header_length = 0;
347 int num_of_encrypted_blocks;
355 num_of_encrypted_blocks = (
frame->length -
frame->header_length - 16)/16;
368 memset(&
ctx, 0,
sizeof(
ctx));
372 while (
ctx.buf_ptr <
ctx.buf_end) {
380 "Sample-AES: declared frame length %d exceeds packet data\n",
384 if (
frame.length -
frame.header_length > 31) {
const uint16_t ff_ac3_channel_layout_tab[8]
Map audio coding mode (acmod) to channel layout mask.
int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size)
#define AV_AAC_ADTS_HEADER_SIZE
static AVFormatContext * ctx
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CH_LOW_FREQUENCY
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int eac3_sample_rate_tab[]
int ff_hls_senc_decrypt_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AVPacket *pkt)
static int decrypt_video_frame(HLSCryptoContext *crypto_ctx, AVPacket *pkt)
int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
static void remove_scep_3_bytes(NALUnit *nalu)
static int get_next_adts_frame(CodecParserContext *ctx, AudioFrame *frame)
static int decrypt_sync_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AudioFrame *frame)
static int decrypt_nal_unit(HLSCryptoContext *crypto_ctx, NALUnit *nalu)
static int decrypt_audio_frame(enum AVCodecID codec_id, HLSCryptoContext *crypto_ctx, AVPacket *pkt)
static int get_next_nal_unit(CodecParserContext *ctx, NALUnit *nalu)
void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *buf, size_t size)
static int get_next_sync_frame(enum AVCodecID codec_id, CodecParserContext *ctx, AudioFrame *frame)
static int get_next_ac3_eac3_sync_frame(CodecParserContext *ctx, AudioFrame *frame)
Apple HTTP Live Streaming Sample Encryption https://developer.apple.com/library/ios/documentation/Aud...
#define HLS_MAX_AUDIO_SETUP_DATA_LEN
static const uint16_t mask[17]
#define MKTAG(a, b, c, d)
Memory handling functions.
AVChannelLayout ch_layout
The channel layout and number of channels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN+AV_INPUT_BUFFER_PADDING_SIZE]
uint8_t setup_data_length