- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
64 lines
2.0 KiB
Java
64 lines
2.0 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.upstream;
|
|
|
|
import android.net.Uri;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import java.io.IOException;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class ByteArrayDataSource implements DataSource {
|
|
private int bytesRemaining;
|
|
private final byte[] data;
|
|
private int readPosition;
|
|
private Uri uri;
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final void close() throws IOException {
|
|
this.uri = null;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final Uri getUri() {
|
|
return this.uri;
|
|
}
|
|
|
|
public ByteArrayDataSource(byte[] bArr) {
|
|
Assertions.checkNotNull(bArr);
|
|
Assertions.checkArgument(bArr.length > 0);
|
|
this.data = bArr;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final long open(DataSpec dataSpec) throws IOException {
|
|
this.uri = dataSpec.uri;
|
|
long j = dataSpec.position;
|
|
int i = (int) j;
|
|
this.readPosition = i;
|
|
long j2 = dataSpec.length;
|
|
if (j2 == -1) {
|
|
j2 = this.data.length - j;
|
|
}
|
|
int i2 = (int) j2;
|
|
this.bytesRemaining = i2;
|
|
if (i2 > 0 && i + i2 <= this.data.length) {
|
|
return i2;
|
|
}
|
|
throw new IOException("Unsatisfiable range: [" + this.readPosition + ", " + dataSpec.length + "], length: " + this.data.length);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final int read(byte[] bArr, int i, int i2) throws IOException {
|
|
if (i2 == 0) {
|
|
return 0;
|
|
}
|
|
int i3 = this.bytesRemaining;
|
|
if (i3 == 0) {
|
|
return -1;
|
|
}
|
|
int min = Math.min(i2, i3);
|
|
System.arraycopy(this.data, this.readPosition, bArr, i, min);
|
|
this.readPosition += min;
|
|
this.bytesRemaining -= min;
|
|
return min;
|
|
}
|
|
}
|