Rabbit-R1/original r1/java/sources/androidx/media3/datasource/StatsDataSource.java

77 lines
2.3 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.media3.datasource;
import android.net.Uri;
import androidx.media3.common.util.Assertions;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/* loaded from: classes2.dex */
public final class StatsDataSource implements DataSource {
private long bytesRead;
private final DataSource dataSource;
private Uri lastOpenedUri = Uri.EMPTY;
private Map<String, List<String>> lastResponseHeaders = Collections.emptyMap();
public long getBytesRead() {
return this.bytesRead;
}
public Uri getLastOpenedUri() {
return this.lastOpenedUri;
}
public Map<String, List<String>> getLastResponseHeaders() {
return this.lastResponseHeaders;
}
public void resetBytesRead() {
this.bytesRead = 0L;
}
public StatsDataSource(DataSource dataSource) {
this.dataSource = (DataSource) Assertions.checkNotNull(dataSource);
}
@Override // androidx.media3.datasource.DataSource
public void addTransferListener(TransferListener transferListener) {
Assertions.checkNotNull(transferListener);
this.dataSource.addTransferListener(transferListener);
}
@Override // androidx.media3.datasource.DataSource
public long open(DataSpec dataSpec) throws IOException {
this.lastOpenedUri = dataSpec.uri;
this.lastResponseHeaders = Collections.emptyMap();
long open = this.dataSource.open(dataSpec);
this.lastOpenedUri = (Uri) Assertions.checkNotNull(getUri());
this.lastResponseHeaders = getResponseHeaders();
return open;
}
@Override // androidx.media3.common.DataReader
public int read(byte[] bArr, int i, int i2) throws IOException {
int read = this.dataSource.read(bArr, i, i2);
if (read != -1) {
this.bytesRead += read;
}
return read;
}
@Override // androidx.media3.datasource.DataSource
public Uri getUri() {
return this.dataSource.getUri();
}
@Override // androidx.media3.datasource.DataSource
public Map<String, List<String>> getResponseHeaders() {
return this.dataSource.getResponseHeaders();
}
@Override // androidx.media3.datasource.DataSource
public void close() throws IOException {
this.dataSource.close();
}
}