214 lines
6.4 KiB
Java
214 lines
6.4 KiB
Java
package c.i.a.c.h2;
|
|
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.c.i2.f0;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.google.android.exoplayer2.upstream.AssetDataSource;
|
|
import com.google.android.exoplayer2.upstream.ContentDataSource;
|
|
import com.google.android.exoplayer2.upstream.FileDataSource;
|
|
import com.google.android.exoplayer2.upstream.RawResourceDataSource;
|
|
import com.google.android.exoplayer2.upstream.UdpDataSource;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
/* compiled from: DefaultDataSource */
|
|
public final class o implements j {
|
|
public final Context a;
|
|
public final List<x> b = new ArrayList();
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final j f897c;
|
|
@Nullable
|
|
public j d;
|
|
@Nullable
|
|
public j e;
|
|
@Nullable
|
|
public j f;
|
|
@Nullable
|
|
public j g;
|
|
@Nullable
|
|
public j h;
|
|
@Nullable
|
|
public j i;
|
|
@Nullable
|
|
public j j;
|
|
@Nullable
|
|
public j k;
|
|
|
|
public o(Context context, j jVar) {
|
|
this.a = context.getApplicationContext();
|
|
Objects.requireNonNull(jVar);
|
|
this.f897c = jVar;
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public long a(l lVar) throws IOException {
|
|
boolean z2 = true;
|
|
AnimatableValueParser.D(this.k == null);
|
|
String scheme = lVar.a.getScheme();
|
|
Uri uri = lVar.a;
|
|
int i = f0.a;
|
|
String scheme2 = uri.getScheme();
|
|
if (!TextUtils.isEmpty(scheme2) && !"file".equals(scheme2)) {
|
|
z2 = false;
|
|
}
|
|
if (z2) {
|
|
String path = lVar.a.getPath();
|
|
if (path == null || !path.startsWith("/android_asset/")) {
|
|
if (this.d == null) {
|
|
FileDataSource fileDataSource = new FileDataSource();
|
|
this.d = fileDataSource;
|
|
o(fileDataSource);
|
|
}
|
|
this.k = this.d;
|
|
} else {
|
|
if (this.e == null) {
|
|
AssetDataSource assetDataSource = new AssetDataSource(this.a);
|
|
this.e = assetDataSource;
|
|
o(assetDataSource);
|
|
}
|
|
this.k = this.e;
|
|
}
|
|
} else if (ModelAuditLogEntry.CHANGE_KEY_ASSET.equals(scheme)) {
|
|
if (this.e == null) {
|
|
AssetDataSource assetDataSource2 = new AssetDataSource(this.a);
|
|
this.e = assetDataSource2;
|
|
o(assetDataSource2);
|
|
}
|
|
this.k = this.e;
|
|
} else if ("content".equals(scheme)) {
|
|
if (this.f == null) {
|
|
ContentDataSource contentDataSource = new ContentDataSource(this.a);
|
|
this.f = contentDataSource;
|
|
o(contentDataSource);
|
|
}
|
|
this.k = this.f;
|
|
} else if ("rtmp".equals(scheme)) {
|
|
if (this.g == null) {
|
|
try {
|
|
j jVar = (j) Class.forName("com.google.android.exoplayer2.ext.rtmp.RtmpDataSource").getConstructor(new Class[0]).newInstance(new Object[0]);
|
|
this.g = jVar;
|
|
o(jVar);
|
|
} catch (ClassNotFoundException unused) {
|
|
Log.w("DefaultDataSource", "Attempting to play RTMP stream without depending on the RTMP extension");
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("Error instantiating RTMP extension", e);
|
|
}
|
|
if (this.g == null) {
|
|
this.g = this.f897c;
|
|
}
|
|
}
|
|
this.k = this.g;
|
|
} else if ("udp".equals(scheme)) {
|
|
if (this.h == null) {
|
|
UdpDataSource udpDataSource = new UdpDataSource();
|
|
this.h = udpDataSource;
|
|
o(udpDataSource);
|
|
}
|
|
this.k = this.h;
|
|
} else if ("data".equals(scheme)) {
|
|
if (this.i == null) {
|
|
g gVar = new g();
|
|
this.i = gVar;
|
|
o(gVar);
|
|
}
|
|
this.k = this.i;
|
|
} else if ("rawresource".equals(scheme) || "android.resource".equals(scheme)) {
|
|
if (this.j == null) {
|
|
RawResourceDataSource rawResourceDataSource = new RawResourceDataSource(this.a);
|
|
this.j = rawResourceDataSource;
|
|
o(rawResourceDataSource);
|
|
}
|
|
this.k = this.j;
|
|
} else {
|
|
this.k = this.f897c;
|
|
}
|
|
return this.k.a(lVar);
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public void close() throws IOException {
|
|
j jVar = this.k;
|
|
if (jVar != null) {
|
|
j jVar2 = null;
|
|
try {
|
|
jVar.close();
|
|
} finally {
|
|
this.k = jVar2;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public void d(x xVar) {
|
|
Objects.requireNonNull(xVar);
|
|
this.f897c.d(xVar);
|
|
this.b.add(xVar);
|
|
j jVar = this.d;
|
|
if (jVar != null) {
|
|
jVar.d(xVar);
|
|
}
|
|
j jVar2 = this.e;
|
|
if (jVar2 != null) {
|
|
jVar2.d(xVar);
|
|
}
|
|
j jVar3 = this.f;
|
|
if (jVar3 != null) {
|
|
jVar3.d(xVar);
|
|
}
|
|
j jVar4 = this.g;
|
|
if (jVar4 != null) {
|
|
jVar4.d(xVar);
|
|
}
|
|
j jVar5 = this.h;
|
|
if (jVar5 != null) {
|
|
jVar5.d(xVar);
|
|
}
|
|
j jVar6 = this.i;
|
|
if (jVar6 != null) {
|
|
jVar6.d(xVar);
|
|
}
|
|
j jVar7 = this.j;
|
|
if (jVar7 != null) {
|
|
jVar7.d(xVar);
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
public Map<String, List<String>> j() {
|
|
j jVar = this.k;
|
|
return jVar == null ? Collections.emptyMap() : jVar.j();
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.j
|
|
@Nullable
|
|
public Uri m() {
|
|
j jVar = this.k;
|
|
if (jVar == null) {
|
|
return null;
|
|
}
|
|
return jVar.m();
|
|
}
|
|
|
|
public final void o(j jVar) {
|
|
for (int i = 0; i < this.b.size(); i++) {
|
|
jVar.d(this.b.get(i));
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.h2.f
|
|
public int read(byte[] bArr, int i, int i2) throws IOException {
|
|
j jVar = this.k;
|
|
Objects.requireNonNull(jVar);
|
|
return jVar.read(bArr, i, i2);
|
|
}
|
|
}
|