summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorWang Yaqiang <wangyaqiang03@kuaishou.com>2022-09-01 21:29:03 +0800
committerSteven Liu <lq@chinaffmpeg.org>2022-09-21 13:58:40 +0800
commit0744782de3ee37fc2b8d9db73ec15d774165b4e5 (patch)
tree2b3f7f93a164cb8f80ffb6c5a62de1477993724a /libavformat
parent3ade6a8644ab519fcd7caa7ef457dd406162bc14 (diff)
avformat/mov: get the correct fragment stsd_id when decrypting the sample
When determining whether a packet should be decrypted, should use the stsd_id of the fragment where the current packet is located. Reviewed-by: Zhao Zhili <zhilizhao@tencent.com> Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/isom.h1
-rw-r--r--libavformat/mov.c7
2 files changed, 5 insertions, 3 deletions
diff --git a/libavformat/isom.h b/libavformat/isom.h
index fd236b985f..64fb7065d5 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -139,6 +139,7 @@ typedef struct MOVFragmentStreamInfo {
int index_base;
int index_entry;
MOVEncryptionIndex *encryption_index;
+ int stsd_id; // current fragment stsd_id
} MOVFragmentStreamInfo;
typedef struct MOVFragmentIndexItem {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 720a72f3ec..1f436e21d6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4958,9 +4958,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_log(c->fc, AV_LOG_TRACE, "frag flags 0x%x\n", frag->flags);
frag_stream_info = get_current_frag_stream_info(&c->frag_index);
- if (frag_stream_info)
+ if (frag_stream_info) {
frag_stream_info->next_trun_dts = AV_NOPTS_VALUE;
-
+ frag_stream_info->stsd_id = frag->stsd_id;
+ }
return 0;
}
@@ -7225,7 +7226,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa
encryption_index = NULL;
if (frag_stream_info) {
// Note this only supports encryption info in the first sample descriptor.
- if (mov->fragment.stsd_id == 1) {
+ if (frag_stream_info->stsd_id == 1) {
if (frag_stream_info->encryption_index) {
encrypted_index = current_index - frag_stream_info->index_base;
encryption_index = frag_stream_info->encryption_index;