Mercurial > libavformat.hg
changeset 1646:52215d40cb3f libavformat
Make seeking work in files that contain encrypted tracks.
author | reimar |
---|---|
date | Sun, 14 Jan 2007 21:23:32 +0000 |
parents | 9aa27a785d1f |
children | 0a990429e524 |
files | mxf.c |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mxf.c Sun Jan 14 16:10:05 2007 +0000 +++ b/mxf.c Sun Jan 14 21:23:32 2007 +0000 @@ -141,6 +141,7 @@ UID content_storage_uid; MXFMetadataSet **metadata_sets; int metadata_sets_count; + uint8_t *sync_key; AVFormatContext *fc; } MXFContext; @@ -174,6 +175,8 @@ /* partial keys to match */ static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 }; static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 }; +/* complete keys to match */ +static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -248,6 +251,7 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) { + MXFContext *mxf = s->priv_data; KLVPacket klv; while (!url_feof(&s->pb)) { @@ -258,6 +262,11 @@ #ifdef DEBUG PRINT_KEY("read packet", klv.key); #endif + if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) { + mxf->sync_key = mxf_encrypted_triplet_key; + av_log(s, AV_LOG_ERROR, "encrypted triplet not supported\n"); + return -1; + } if (IS_KLV_KEY(klv.key, mxf_essence_element_key)) { int index = mxf_get_stream_index(s, &klv); if (index < 0) { @@ -856,6 +865,7 @@ MXFContext *mxf = s->priv_data; KLVPacket klv; + mxf->sync_key = mxf_essence_element_key; if (!mxf_read_sync(&s->pb, mxf_header_partition_pack_key, 14)) { av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n"); return -1; @@ -942,6 +952,7 @@ /* XXX: use MXF Index */ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags) { + MXFContext *mxf = s->priv_data; AVStream *st = s->streams[stream_index]; int64_t seconds; @@ -951,7 +962,7 @@ sample_time = 0; seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); url_fseek(&s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); - if (!mxf_read_sync(&s->pb, mxf_essence_element_key, 12)) + if (!mxf_read_sync(&s->pb, mxf->sync_key, 12)) return -1; /* found KLV key */