JeffMony / JeffVideoCache

Better than AndroidVideoCache, it supports M3U8 and MP4
Apache License 2.0
290 stars 65 forks source link

多段缓存时,Mp4CacheTask.getRequestRange() 返回的分段问题 #19

Open IHaveALittleMouse opened 2 years ago

IHaveALittleMouse commented 2 years ago

当有多段缓存时,Mp4CacheTask.getRequestRange() 返回的分段会忽略一部分已经缓存的分段。 以下图为例,当一个视频具有三段缓存时,如果 position 在 cache1 和 cache2 之间,则最终返回的分段的起点为 position,终点为 cache3 的起点,cache2 会被忽略,被再缓存一次。

ProblemOfGetRequestRange

以我目前的理解,正确的返回值应该是 VideoRange(finalStart, firstEnd),即起点为 position,终点为 cache2 的起点。缓存完这一段后,Mp4VideoCacheThread.notifyOnCacheRangeCompleted()会被调用去缓存下一段,补上所有的“洞”。