98 lines
2.7 KiB
Java
98 lines
2.7 KiB
Java
package c.i.a.c.h2;
|
|
|
|
import android.net.Uri;
|
|
import android.util.Base64;
|
|
import androidx.annotation.Nullable;
|
|
import c.d.b.a.a;
|
|
import c.i.a.c.i2.f0;
|
|
import c.i.b.a.c;
|
|
import com.google.android.exoplayer2.ParserException;
|
|
import com.google.android.exoplayer2.upstream.DataSourceException;
|
|
import java.io.IOException;
|
|
import java.net.URLDecoder;
|
|
/* compiled from: DataSchemeDataSource */
|
|
public final class g extends e {
|
|
@Nullable
|
|
public l e;
|
|
@Nullable
|
|
public byte[] f;
|
|
public int g;
|
|
public int h;
|
|
|
|
public g() {
|
|
super(false);
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public long a(l lVar) throws IOException {
|
|
q(lVar);
|
|
this.e = lVar;
|
|
this.h = (int) lVar.f;
|
|
Uri uri = lVar.a;
|
|
String scheme = uri.getScheme();
|
|
if ("data".equals(scheme)) {
|
|
String[] G = f0.G(uri.getSchemeSpecificPart(), ",");
|
|
if (G.length == 2) {
|
|
String str = G[1];
|
|
if (G[0].contains(";base64")) {
|
|
try {
|
|
this.f = Base64.decode(str, 0);
|
|
} catch (IllegalArgumentException e) {
|
|
throw new ParserException(a.s("Error while parsing Base64 encoded string: ", str), e);
|
|
}
|
|
} else {
|
|
this.f = f0.w(URLDecoder.decode(str, c.a.name()));
|
|
}
|
|
long j = lVar.g;
|
|
int length = j != -1 ? ((int) j) + this.h : this.f.length;
|
|
this.g = length;
|
|
if (length > this.f.length || this.h > length) {
|
|
this.f = null;
|
|
throw new DataSourceException(0);
|
|
}
|
|
r(lVar);
|
|
return ((long) this.g) - ((long) this.h);
|
|
}
|
|
throw new ParserException("Unexpected URI format: " + uri);
|
|
}
|
|
throw new ParserException(a.s("Unsupported scheme: ", scheme));
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public void close() {
|
|
if (this.f != null) {
|
|
this.f = null;
|
|
p();
|
|
}
|
|
this.e = null;
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
@Nullable
|
|
public Uri m() {
|
|
l lVar = this.e;
|
|
if (lVar != null) {
|
|
return lVar.a;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.f
|
|
public int read(byte[] bArr, int i, int i2) {
|
|
if (i2 == 0) {
|
|
return 0;
|
|
}
|
|
int i3 = this.g - this.h;
|
|
if (i3 == 0) {
|
|
return -1;
|
|
}
|
|
int min = Math.min(i2, i3);
|
|
byte[] bArr2 = this.f;
|
|
int i4 = f0.a;
|
|
System.arraycopy(bArr2, this.h, bArr, i, min);
|
|
this.h += min;
|
|
o(min);
|
|
return min;
|
|
}
|
|
}
|