Commit a4c10058 by olly Committed by Oliver Woodman

Move CachedRegionTracker to upstream root

PiperOrigin-RevId: 403914807
parent 18cf01cd
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
`com.google.android.exoplayer2.DeviceInfo`. `com.google.android.exoplayer2.DeviceInfo`.
* Move `com.google.android.exoplayer2.drm.DecryptionException` to * Move `com.google.android.exoplayer2.drm.DecryptionException` to
`com.google.android.exoplayer2.decoder.CryptoException`. `com.google.android.exoplayer2.decoder.CryptoException`.
* Move `com.google.android.exoplayer2.upstream.cache.CachedRegionTracker`
to `com.google.android.exoplayer2.upstream.CachedRegionTracker`.
* Make `ExoPlayer.Builder` return a `SimpleExoPlayer` instance. * Make `ExoPlayer.Builder` return a `SimpleExoPlayer` instance.
* Deprecate `SimpleExoPlayer.Builder`. Use `ExoPlayer.Builder` instead. * Deprecate `SimpleExoPlayer.Builder`. Use `ExoPlayer.Builder` instead.
* Remove `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED`. Use * Remove `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED`. Use
......
...@@ -13,10 +13,12 @@ ...@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheSpan;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.Arrays; import java.util.Arrays;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
...@@ -23,7 +23,8 @@ import static org.mockito.Mockito.when; ...@@ -23,7 +23,8 @@ import static org.mockito.Mockito.when;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheSpan;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -56,7 +57,6 @@ public final class CachedRegionTrackerTest { ...@@ -56,7 +57,6 @@ public final class CachedRegionTrackerTest {
@Mock private Cache cache; @Mock private Cache cache;
private CachedRegionTracker tracker; private CachedRegionTracker tracker;
private CachedContentIndex index;
private File cacheDir; private File cacheDir;
@Before @Before
...@@ -66,7 +66,6 @@ public final class CachedRegionTrackerTest { ...@@ -66,7 +66,6 @@ public final class CachedRegionTrackerTest {
tracker = new CachedRegionTracker(cache, CACHE_KEY, CHUNK_INDEX); tracker = new CachedRegionTracker(cache, CACHE_KEY, CHUNK_INDEX);
cacheDir = cacheDir =
Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest"); Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
index = new CachedContentIndex(TestUtil.getInMemoryDatabaseProvider());
} }
@After @After
...@@ -128,14 +127,13 @@ public final class CachedRegionTrackerTest { ...@@ -128,14 +127,13 @@ public final class CachedRegionTrackerTest {
} }
private CacheSpan newCacheSpan(int position, int length) throws IOException { private CacheSpan newCacheSpan(int position, int length) throws IOException {
int id = index.assignIdForKey(CACHE_KEY); File cacheFile = createCacheSpanFile(cacheDir, position, length);
File cacheFile = createCacheSpanFile(cacheDir, id, position, length, 0); return new CacheSpan(CACHE_KEY, position, length, /* lastTouchTimestamp= */ 0, cacheFile);
return SimpleCacheSpan.createCacheEntry(cacheFile, length, index);
} }
public static File createCacheSpanFile( public static File createCacheSpanFile(File cacheDir, long position, int length)
File cacheDir, int id, long offset, int length, long lastTouchTimestamp) throws IOException { throws IOException {
File cacheFile = SimpleCacheSpan.getCacheFile(cacheDir, id, offset, lastTouchTimestamp); File cacheFile = new File(cacheDir, "test." + position);
createTestFile(cacheFile, length); createTestFile(cacheFile, length);
return cacheFile; return cacheFile;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment