mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Update remaining DataSource's with new addTransferListener method.
The new method allows to add TransferListeners after the DataSource has been created. Most implementations just forward to their wrapped upstream DataSource. Implementation which directly read data implement BaseDataSource instead. Also removes the temporary default no-op implementation in DataSource. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=206289986
This commit is contained in:
parent
3b61a400c5
commit
d3c2cb2aa4
3 changed files with 12 additions and 5 deletions
|
|
@ -44,9 +44,7 @@ public interface DataSource {
|
|||
*
|
||||
* @param transferListener A {@link TransferListener}.
|
||||
*/
|
||||
default void addTransferListener(TransferListener transferListener) {
|
||||
// TODO: Make non-default once all DataSources implement this method.
|
||||
}
|
||||
void addTransferListener(TransferListener transferListener);
|
||||
|
||||
/**
|
||||
* Opens the source to read the specified data.
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package com.google.android.exoplayer2.upstream;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
|
@ -35,6 +36,11 @@ public final class DummyDataSource implements DataSource {
|
|||
|
||||
private DummyDataSource() {}
|
||||
|
||||
@Override
|
||||
public void addTransferListener(TransferListener transferListener) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public long open(DataSpec dataSpec) throws IOException {
|
||||
throw new IOException("Dummy source");
|
||||
|
|
@ -46,7 +52,7 @@ public final class DummyDataSource implements DataSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getUri() {
|
||||
public @Nullable Uri getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -54,5 +60,4 @@ public final class DummyDataSource implements DataSource {
|
|||
public void close() throws IOException {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import android.net.Uri;
|
|||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||
import com.google.android.exoplayer2.upstream.TransferListener;
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -76,6 +77,9 @@ public class Aes128DataSourceTest {
|
|||
public boolean opened;
|
||||
public boolean closedCalled;
|
||||
|
||||
@Override
|
||||
public void addTransferListener(TransferListener transferListener) {}
|
||||
|
||||
@Override
|
||||
public long open(DataSpec dataSpec) throws IOException {
|
||||
opened = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue