- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
145 lines
5.7 KiB
Java
145 lines
5.7 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.upstream;
|
|
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
import android.util.Log;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
|
|
import java.io.IOException;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class DefaultDataSource implements DataSource {
|
|
private static final String SCHEME_ASSET = "asset";
|
|
private static final String SCHEME_CONTENT = "content";
|
|
private static final String SCHEME_RAW = "rawresource";
|
|
private static final String SCHEME_RTMP = "rtmp";
|
|
private static final String TAG = "DefaultDataSource";
|
|
private DataSource assetDataSource;
|
|
private final DataSource baseDataSource;
|
|
private DataSource contentDataSource;
|
|
private final Context context;
|
|
private DataSource dataSchemeDataSource;
|
|
private DataSource dataSource;
|
|
private DataSource fileDataSource;
|
|
private final TransferListener<? super DataSource> listener;
|
|
private DataSource rawResourceDataSource;
|
|
private DataSource rtmpDataSource;
|
|
|
|
public DefaultDataSource(Context context, TransferListener<? super DataSource> transferListener, String str, boolean z) {
|
|
this(context, transferListener, str, 8000, 8000, z);
|
|
}
|
|
|
|
public DefaultDataSource(Context context, TransferListener<? super DataSource> transferListener, String str, int i, int i2, boolean z) {
|
|
this(context, transferListener, new DefaultHttpDataSource(str, null, transferListener, i, i2, z, null));
|
|
}
|
|
|
|
public DefaultDataSource(Context context, TransferListener<? super DataSource> transferListener, DataSource dataSource) {
|
|
this.context = context.getApplicationContext();
|
|
this.listener = transferListener;
|
|
this.baseDataSource = (DataSource) Assertions.checkNotNull(dataSource);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final long open(DataSpec dataSpec) throws IOException {
|
|
Assertions.checkState(this.dataSource == null);
|
|
String scheme = dataSpec.uri.getScheme();
|
|
if (Util.isLocalFileUri(dataSpec.uri)) {
|
|
if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
|
|
this.dataSource = getAssetDataSource();
|
|
} else {
|
|
this.dataSource = getFileDataSource();
|
|
}
|
|
} else if (SCHEME_ASSET.equals(scheme)) {
|
|
this.dataSource = getAssetDataSource();
|
|
} else if ("content".equals(scheme)) {
|
|
this.dataSource = getContentDataSource();
|
|
} else if (SCHEME_RTMP.equals(scheme)) {
|
|
this.dataSource = getRtmpDataSource();
|
|
} else if ("data".equals(scheme)) {
|
|
this.dataSource = getDataSchemeDataSource();
|
|
} else if ("rawresource".equals(scheme)) {
|
|
this.dataSource = getRawResourceDataSource();
|
|
} else {
|
|
this.dataSource = this.baseDataSource;
|
|
}
|
|
return this.dataSource.open(dataSpec);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final int read(byte[] bArr, int i, int i2) throws IOException {
|
|
return this.dataSource.read(bArr, i, i2);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final Uri getUri() {
|
|
DataSource dataSource = this.dataSource;
|
|
if (dataSource == null) {
|
|
return null;
|
|
}
|
|
return dataSource.getUri();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource
|
|
public final void close() throws IOException {
|
|
DataSource dataSource = this.dataSource;
|
|
if (dataSource != null) {
|
|
try {
|
|
dataSource.close();
|
|
} finally {
|
|
this.dataSource = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
private DataSource getFileDataSource() {
|
|
if (this.fileDataSource == null) {
|
|
this.fileDataSource = new FileDataSource(this.listener);
|
|
}
|
|
return this.fileDataSource;
|
|
}
|
|
|
|
private DataSource getAssetDataSource() {
|
|
if (this.assetDataSource == null) {
|
|
this.assetDataSource = new AssetDataSource(this.context, this.listener);
|
|
}
|
|
return this.assetDataSource;
|
|
}
|
|
|
|
private DataSource getContentDataSource() {
|
|
if (this.contentDataSource == null) {
|
|
this.contentDataSource = new ContentDataSource(this.context, this.listener);
|
|
}
|
|
return this.contentDataSource;
|
|
}
|
|
|
|
private DataSource getRtmpDataSource() {
|
|
if (this.rtmpDataSource == null) {
|
|
try {
|
|
this.rtmpDataSource = (DataSource) Class.forName("com.mbridge.msdk.playercommon.exoplayer2.ext.rtmp.RtmpDataSource").getConstructor(new Class[0]).newInstance(new Object[0]);
|
|
} catch (ClassNotFoundException unused) {
|
|
Log.w(TAG, "Attempting to play RTMP stream without depending on the RTMP extension");
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("Error instantiating RTMP extension", e);
|
|
}
|
|
if (this.rtmpDataSource == null) {
|
|
this.rtmpDataSource = this.baseDataSource;
|
|
}
|
|
}
|
|
return this.rtmpDataSource;
|
|
}
|
|
|
|
private DataSource getDataSchemeDataSource() {
|
|
if (this.dataSchemeDataSource == null) {
|
|
this.dataSchemeDataSource = new DataSchemeDataSource();
|
|
}
|
|
return this.dataSchemeDataSource;
|
|
}
|
|
|
|
private DataSource getRawResourceDataSource() {
|
|
if (this.rawResourceDataSource == null) {
|
|
this.rawResourceDataSource = new RawResourceDataSource(this.context, this.listener);
|
|
}
|
|
return this.rawResourceDataSource;
|
|
}
|
|
}
|