Timestamp Offset calculations are now done exclusively by the Media Source
components which allow to recalculate them on the fly. By abstracting those
offsets it remove the need for the sub-decoders to handle them (which allows
to add WebM support).
Under some circumstances, it was possible for shutdown to have completed
right before the initialization task got to run. Resulting in a null
dereference.
Under some circumstances, it was possible for a cancelled queued task to run
and the following one would have been cancelled.
Also add more robust handling in cancelling the trackbuffer initialization
task.
YouTube continues to call appendBuffer even when the previous call failed.
So we attempt to re-create a decoder where we can should it be a temporary
failure.
Now that we rely on appendBuffer to scan the init segment, it has become
imperative to handle partial segments as it could otherwise lead to
appendBuffer never firing update/updateend
Also change the relationship between SourceBufferResource object and its callee.
Data is now required to be removed or added via the SourceBufferDecoder.
This fixes a potential race between the time we add data to the resource and
the time we retrieve the buffered time ranges.
Fixes a bug in the SourceBufferResource eviction code where it was
using the mOffset of the resource as the min bound for what to evict.
This offset is almost always zero though due to ReadFromCache being
used which never updates the offset. This prevented eviction from
happening in most cases.
Moves the code to remove old decoders so that it does this during
the same loop as that which remove data from existing decoders.
This more aggressively prunes old decoders and is more likely to
keep data in the current playing decoder around for seeking, etc.
Prevent removing any decoder that the MediaSourceReader is
currently using for playback to prevent RemoveDecoder crashes.
Add a threshold to subtract from the current time when working out
the time bound to evict before to make it less likely to evict
current data that is needed for current playback.
Remove all data from evicted decoders in the initial iteration then
iterate after to remove empty decoders to put the RemoveDecoder
logic in one place.
Iterate decoders in order that they were added rather than sorted
by time so the logic that removes entire decoders can do it only
to those old decoders that existed before the existing one was
created.
Keeps track of the time that was evicted from the current decoder
and uses that as the time to EvictBefore for all decoders in the
track buffer when doing MediaSource::NotifyEvict.