[FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

Nachiket Tarate nachiket.tarate at outlook.com
Sat Oct 10 18:15:44 EEST 2020



________________________________
From: Nachiket Tarate <nachiket.tarate at outlook.com>
Sent: Saturday, October 10, 2020 8:30 PM
To: ffmpeg-devel at ffmpeg.org <ffmpeg-devel at ffmpeg.org>
Subject: [PATCH] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer

Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate <nachiket.tarate at outlook.com>
---
 +
+static int get_next_adts_frame (AVParserContext *ctx, AudioFrame *frame)
+{
+    int ret = 0;
+
+    AACADTSHeaderInfo *adts_hdr = NULL;
+
+    /* Find next sync word 0xFFF */
+    while (ctx->buf_in < ctx->buf_end - 1) {
+        if (*ctx->buf_in == 0xFF && *(ctx->buf_in + 1) & 0xF0 == 0xF0)
+            break;
+        ctx->buf_in++;
+    }
+
+    if (ctx->buf_in >= ctx->buf_end - 1) {
+        return -1;
+    }
+
+    frame->data = (uint8_t*)ctx->buf_in;
+
+    ret = avpriv_adts_header_parse (&adts_hdr, frame->data, ctx->buf_end - frame->data);
+    if (ret < 0) {
+        return ret;
+    }
+
+    frame->header_length = adts_hdr->crc_absent ? AV_AAC_ADTS_HEADER_SIZE : AV_AAC_ADTS_HEADER_SIZE + 2;
+    frame->length = adts_hdr->frame_length;
+
+    av_free(adts_hdr);
+
+    return 0;
+}

@Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

Here, frame_length field and avpriv_adts_header_parse() function are being used.

--
Best Regards,
Nachiket Tarate


More information about the ffmpeg-devel mailing list