CacheDataSource.Factory


class CacheDataSource.Factory : DataSource.Factory


DataSource.Factory for CacheDataSource instances.

Summary

Public constructors

Public functions

CacheDataSource!

Creates a DataSource instance.

CacheDataSource!

Returns an instance suitable for downloading content.

CacheDataSource!

Returns an instance suitable for reading cached content as part of removing a download.

CacheDataSource.Factory!

Sets the DataSource.Factory for DataSources for reading from the cache.

CacheDataSource.Factory!

Sets the DataSink.Factory for generating DataSinks for writing data to the cache.

CacheDataSource.Factory!

Sets the {link EventListener} to which events are delivered.

CacheDataSource.Factory!

Sets the CacheDataSource.Flags.

CacheDataSource.Factory!

Sets the DataSource.Factory for upstream DataSources, which are used to read data in the case of a cache miss.

CacheDataSource.Factory!

Sets the C.Priority to use when requesting data from upstream.

Public constructors

Factory

Factory()

Public functions

createDataSource

fun createDataSource(): CacheDataSource!

Creates a DataSource instance.

createDataSourceForDownloading

fun createDataSourceForDownloading(): CacheDataSource!

Returns an instance suitable for downloading content. The created instance is equivalent to one that would be created by createDataSource, except:

Returns
CacheDataSource!

An instance suitable for downloading content.

createDataSourceForRemovingDownload

fun createDataSourceForRemovingDownload(): CacheDataSource!

Returns an instance suitable for reading cached content as part of removing a download. The created instance is equivalent to one that would be created by createDataSource, except:

  • The upstream is overridden to be null, since when removing content we don't want to request anything that's not already cached.
  • The FLAG_BLOCK_ON_CACHE is always set.
  • The task priority is overridden to be PRIORITY_DOWNLOAD.
Returns
CacheDataSource!

An instance suitable for reading cached content as part of removing a download.

setCacheReadDataSourceFactory

@CanIgnoreReturnValue
fun setCacheReadDataSourceFactory(
    cacheReadDataSourceFactory: DataSource.Factory!
): CacheDataSource.Factory!

Sets the DataSource.Factory for DataSources for reading from the cache.

The default is a FileDataSource.Factory in its default configuration.

Parameters
cacheReadDataSourceFactory: DataSource.Factory!

The DataSource.Factory for reading from the cache.

Returns
CacheDataSource.Factory!

This factory.

setCacheWriteDataSinkFactory

@CanIgnoreReturnValue
fun setCacheWriteDataSinkFactory(
    cacheWriteDataSinkFactory: DataSink.Factory?
): CacheDataSource.Factory!

Sets the DataSink.Factory for generating DataSinks for writing data to the cache. Passing null causes the cache to be read-only.

The default is a CacheDataSink.Factory in its default configuration.

Parameters
cacheWriteDataSinkFactory: DataSink.Factory?

The DataSink.Factory for generating DataSinks for writing data to the cache, or null to disable writing.

Returns
CacheDataSource.Factory!

This factory.

setEventListener

@CanIgnoreReturnValue
fun setEventListener(eventListener: CacheDataSource.EventListener?): CacheDataSource.Factory!

Sets the {link EventListener} to which events are delivered.

The default is null.

Parameters
eventListener: CacheDataSource.EventListener?

The EventListener.

Returns
CacheDataSource.Factory!

This factory.

setFlags

@CanIgnoreReturnValue
fun setFlags(@CacheDataSource.Flags flags: Int): CacheDataSource.Factory!

Sets the CacheDataSource.Flags.

The default is 0.

Returns
CacheDataSource.Factory!

This factory.

setUpstreamDataSourceFactory

@CanIgnoreReturnValue
fun setUpstreamDataSourceFactory(
    upstreamDataSourceFactory: DataSource.Factory?
): CacheDataSource.Factory!

Sets the DataSource.Factory for upstream DataSources, which are used to read data in the case of a cache miss.

The default is null, and so this method must be called before the factory is used in order for data to be read from upstream in the case of a cache miss.

Parameters
upstreamDataSourceFactory: DataSource.Factory?

The upstream DataSource for reading data not in the cache, or null to cause failure in the case of a cache miss.

Returns
CacheDataSource.Factory!

This factory.

setUpstreamPriority

@CanIgnoreReturnValue
fun setUpstreamPriority(@C.Priority upstreamPriority: Int): CacheDataSource.Factory!

Sets the C.Priority to use when requesting data from upstream. The priority is only used if a PriorityTaskManager is set by calling setUpstreamPriorityTaskManager.

The default is PRIORITY_PLAYBACK.

Parameters
@C.Priority upstreamPriority: Int

The C.Priority to use when requesting data from upstream.

Returns
CacheDataSource.Factory!

This factory.

Public properties

cacheKeyFactory

var cacheKeyFactoryCacheKeyFactory!

upstreamPriorityTaskManager

var upstreamPriorityTaskManagerPriorityTaskManager?