Description
Issue description
Playing 8-byte IV content after 16-byte IV content on a single instance of ExoPlayer results in a garbled video.
Reproduction steps
Let's assuming we have 2 DASH content items: one with 16-byte IV and the second with 8-byte IV.
Create an instance of ExoPlayerImpl and play both items in order on a single ExoPlayerImpl instance.
I.e.
a) prepare the 16-byte IV item
b) play it
c) stop
d) prepare the 8-byte IV item
Here the playback breaks.
Link to test content
Was observed on a proprietary content.
A full bug report captured from the device
N/A
Version of ExoPlayer being used
2.9.4 and 2.10.6
Device(s) and version(s) of Android being used
Was observed on many devices. For example on FireTv 4K stick.
NOTE: Location of the issue in the code:
The com.google.android.exoplayer2.source.SampleQueue.readEncryptionData()
method allocates buffer.cryptoInfo.iv if one is not already allocated.
However, if buffer.cryptoInfo.iv is already allocated and contains an old IV, the array is not cleaned.
So, if ivSize in readData(offset, buffer.cryptoInfo.iv, ivSize) is smaller than it was for the previous IVs
we get a wrong value for IV