public final class

CacheDataSink.Factory

extends java.lang.Object

implements DataSink.Factory

 java.lang.Object

↳androidx.media3.datasource.cache.CacheDataSink.Factory

Overview

for CacheDataSink instances.

Summary

Constructors
publicFactory()

Creates an instance.

Methods
public DataSinkcreateDataSink()

public CacheDataSink.FactorysetBufferSize(int bufferSize)

Sets the size of an in-memory buffer used when writing to a cache file.

public CacheDataSink.FactorysetCache(Cache cache)

Sets the cache to which data will be written.

public CacheDataSink.FactorysetFragmentSize(long fragmentSize)

Sets the cache file fragment size.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Factory()

Creates an instance.

Methods

public CacheDataSink.Factory setCache(Cache cache)

Sets the cache to which data will be written.

Must be called before the factory is used.

Parameters:

cache: The cache to which data will be written.

Returns:

This factory.

public CacheDataSink.Factory setFragmentSize(long fragmentSize)

Sets the cache file fragment size. For requests that should be fragmented into multiple cache files, this is the maximum size of a cache file in bytes. If set to C.LENGTH_UNSET then no fragmentation will occur. Using a small value allows for finer-grained cache eviction policies, at the cost of increased overhead both on the cache implementation and the file system. Values under (2 * 1024 * 1024) are not recommended.

The default value is CacheDataSink.DEFAULT_FRAGMENT_SIZE.

Parameters:

fragmentSize: The fragment size in bytes, or C.LENGTH_UNSET to disable fragmentation.

Returns:

This factory.

public CacheDataSink.Factory setBufferSize(int bufferSize)

Sets the size of an in-memory buffer used when writing to a cache file. A zero or negative value disables buffering.

The default value is CacheDataSink.DEFAULT_BUFFER_SIZE.

Parameters:

bufferSize: The buffer size in bytes.

Returns:

This factory.

public DataSink createDataSink()