When determining whether a packet should be decrypted, should use the stsd_id of the fragment where the current packet is located.
Unified · Split
| @@ -139,6 +139,7 @@ typedef struct MOVFragmentStreamInfo { · 138 unmodified lines | ||
| 139 | 139 | int index_base; |
| 140 | 140 | int index_entry; |
| 141 | 141 | MOVEncryptionIndex *encryption_index; |
| 142 | + int stsd_id; // current fragment stsd_id | |
| 142 | 143 | } MOVFragmentStreamInfo; |
| 143 | 144 | |
| 144 | 145 | typedef struct MOVFragmentIndexItem { |
| @@ -4958,9 +4958,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 4957 unmodified lines | ||
| 4958 | 4958 | av_log(c->fc, AV_LOG_TRACE, "frag flags 0x%x\n", frag->flags); |
| 4959 | 4959 | |
| 4960 | 4960 | frag_stream_info = get_current_frag_stream_info(&c->frag_index); |
| 4961 | − if (frag_stream_info) | |
| 4961 | + if (frag_stream_info) { | |
| 4962 | 4962 | frag_stream_info->next_trun_dts = AV_NOPTS_VALUE; |
| 4963 | − | |
| 4963 | + frag_stream_info->stsd_id = frag->stsd_id; | |
| 4964 | + } | |
| 4964 | 4965 | return 0; |
| 4965 | 4966 | } |
| 4966 | 4967 | |
| @@ -7225,7 +7226,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa · 2258 unmodified lines | ||
| 7225 | 7226 | encryption_index = NULL; |
| 7226 | 7227 | if (frag_stream_info) { |
| 7227 | 7228 | // Note this only supports encryption info in the first sample descriptor. |
| 7228 | − if (mov->fragment.stsd_id == 1) { | |
| 7229 | + if (frag_stream_info->stsd_id == 1) { | |
| 7229 | 7230 | if (frag_stream_info->encryption_index) { |
| 7230 | 7231 | encrypted_index = current_index - frag_stream_info->index_base; |
| 7231 | 7232 | encryption_index = frag_stream_info->encryption_index; |