Commit d3c2cb2a by tonihei Committed by Oliver Woodman

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
parent 3b61a400
......@@ -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;
/**
......@@ -36,6 +37,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;
......@@ -77,6 +78,9 @@ public class Aes128DataSourceTest {
public boolean closedCalled;
@Override
public void addTransferListener(TransferListener transferListener) {}
@Override
public long open(DataSpec dataSpec) throws IOException {
opened = true;
return C.LENGTH_UNSET;
......
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