Class BaseDataSource
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.BaseDataSource
-
- All Implemented Interfaces:
DataReader
,DataSource
- Direct Known Subclasses:
AssetDataSource
,ByteArrayDataSource
,ContentDataSource
,CronetDataSource
,DataSchemeDataSource
,DefaultHttpDataSource
,FakeDataSource
,FileDataSource
,OkHttpDataSource
,RawResourceDataSource
,RtmpDataSource
,UdpDataSource
public abstract class BaseDataSource extends Object implements DataSource
BaseDataSource
implementation to keep a list ofTransferListener
s.Subclasses must call
transferInitializing(DataSpec)
,transferStarted(DataSpec)
,bytesTransferred(int)
, andtransferEnded()
to inform listeners of data transfers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.DataSource
DataSource.Factory
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseDataSource(boolean isNetwork)
Creates base data source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTransferListener(TransferListener transferListener)
Adds aTransferListener
to listen to data transfers.protected void
bytesTransferred(int bytesTransferred)
Notifies listeners that bytes were transferred.protected void
transferEnded()
Notifies listeners that a transfer ended.protected void
transferInitializing(DataSpec dataSpec)
Notifies listeners that data transfer for the specifiedDataSpec
is being initialized.protected void
transferStarted(DataSpec dataSpec)
Notifies listeners that data transfer for the specifiedDataSpec
started.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.upstream.DataReader
read
-
Methods inherited from interface com.google.android.exoplayer2.upstream.DataSource
close, getResponseHeaders, getUri, open
-
-
-
-
Method Detail
-
addTransferListener
public final void addTransferListener(TransferListener transferListener)
Description copied from interface:DataSource
Adds aTransferListener
to listen to data transfers. This method is not thread-safe.- Specified by:
addTransferListener
in interfaceDataSource
- Parameters:
transferListener
- ATransferListener
.
-
transferInitializing
protected final void transferInitializing(DataSpec dataSpec)
Notifies listeners that data transfer for the specifiedDataSpec
is being initialized.- Parameters:
dataSpec
-DataSpec
describing the data for initializing transfer.
-
transferStarted
protected final void transferStarted(DataSpec dataSpec)
Notifies listeners that data transfer for the specifiedDataSpec
started.- Parameters:
dataSpec
-DataSpec
describing the data being transferred.
-
bytesTransferred
protected final void bytesTransferred(int bytesTransferred)
Notifies listeners that bytes were transferred.- Parameters:
bytesTransferred
- The number of bytes transferred since the previous call to this method (or if the first call, since the transfer was started).
-
transferEnded
protected final void transferEnded()
Notifies listeners that a transfer ended.
-
-