[FFmpeg-devel] [PATCH 3/3] avformat/mov: Expose encryption info to the app.
Jacob Trimble
modmaker at google.com
Fri Jan 5 21:49:28 EET 2018
This exposes encryption info from the container to the app. This
includes key ID, IV, and subsample byte ranges. The info is passed
using the new side-data AV_PKT_DATA_ENCRYPTION_INIT_DATA.
Signed-off-by: Jacob Trimble <modmaker at google.com>
---
libavformat/mov.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 554b2be8bd..abd59d8c7b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5994,6 +5994,32 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
+static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+ AVStream *st;
+ uint8_t* side_data;
+ size_t size;
+
+ if (c->fc->nb_streams < 1)
+ return 0;
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ size = atom.size + 8;
+ side_data = av_stream_new_side_data(st, AV_PKT_DATA_ENCRYPTION_INIT_DATA, size);
+ if (!side_data) {
+ return AVERROR(ENOMEM);
+ }
+
+ AV_WB32(side_data, size);
+ AV_WL32(side_data + 4, MKTAG('p','s','s','h'));
+ if (avio_read(pb, side_data + 8, atom.size) != atom.size) {
+ av_log(c->fc, AV_LOG_ERROR, "failed to read the pssh atom\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ return 0;
+}
+
static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -6233,6 +6259,8 @@ static int cenc_filter(MOVContext *mov, MOVStreamContext *sc, AVPacket *pkt, int
if (mov->decryption_key) {
return cenc_decrypt(mov, sc, encrypted_sample, pkt->data, pkt->size);
+ } else {
+ return av_encryption_info_add_side_data(pkt, encrypted_sample);
}
}
@@ -6366,6 +6394,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('s','e','n','c'), mov_read_senc },
{ MKTAG('s','a','i','z'), mov_read_saiz },
{ MKTAG('s','a','i','o'), mov_read_saio },
+{ MKTAG('p','s','s','h'), mov_read_pssh },
{ MKTAG('s','c','h','m'), mov_read_schm },
{ MKTAG('s','c','h','i'), mov_read_default },
{ MKTAG('t','e','n','c'), mov_read_tenc },
--
2.16.0.rc0.223.g4a4ac83678-goog
More information about the ffmpeg-devel
mailing list