1489 lines
52 KiB
Java
1489 lines
52 KiB
Java
package com.baidu.cloud.media.player;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Rect;
|
|
import android.media.MediaCodecInfo;
|
|
import android.media.MediaCodecList;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import android.os.ParcelFileDescriptor;
|
|
import android.os.PowerManager;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.Surface;
|
|
import android.view.SurfaceHolder;
|
|
import com.baidu.cloud.media.download.LocalHlsSec;
|
|
import com.baidu.cloud.media.player.b;
|
|
import com.baidu.cloud.media.player.misc.IMediaDataSource;
|
|
import com.baidu.license.LicenseManager;
|
|
import com.ubt.jimu.unity.bluetooth.MyUnityListener;
|
|
import java.io.FileDescriptor;
|
|
import java.io.IOException;
|
|
import java.lang.ref.WeakReference;
|
|
import java.lang.reflect.Field;
|
|
import java.security.InvalidParameterException;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Iterator;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Timer;
|
|
import java.util.TimerTask;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class BDCloudMediaPlayer extends AbstractMediaPlayer {
|
|
public static final int DECODE_AUTO = 0;
|
|
public static final int DECODE_SW = 1;
|
|
private static final BDCloudLibLoader J = new BDCloudLibLoader() { // from class: com.baidu.cloud.media.player.BDCloudMediaPlayer.1
|
|
@Override // com.baidu.cloud.media.player.BDCloudLibLoader
|
|
public void loadLibrary(String str) throws UnsatisfiedLinkError, SecurityException {
|
|
System.loadLibrary(str);
|
|
}
|
|
};
|
|
private static volatile boolean K = false;
|
|
public static final int PLAY_TYPE_LIVE = 1;
|
|
public static final int PLAY_TYPE_VOD = 0;
|
|
public static final String SDK_VERSION = "2.3.5";
|
|
public static final int SOURCE_SWITCH_NORMAL_MODE = 0;
|
|
public static final int SOURCE_SWITCH_SMOOTH_HLS_MODE = 2;
|
|
public static final int SOURCE_SWITCH_SMOOTH_MODE = 1;
|
|
private static final String a = "com.baidu.cloud.media.player.BDCloudMediaPlayer";
|
|
private static String b = "";
|
|
private static String c = "";
|
|
private static String d = "";
|
|
private static String e = "";
|
|
private static boolean f = false;
|
|
private static boolean g = false;
|
|
private static String h;
|
|
private long A;
|
|
private int B;
|
|
private int C;
|
|
private int D;
|
|
private boolean E;
|
|
private volatile boolean F;
|
|
private Timer G;
|
|
private Context H;
|
|
private String I;
|
|
private int L;
|
|
private OnControlMessageListener M;
|
|
private OnNativeInvokeListener N;
|
|
private OnMediaCodecSelectListener O;
|
|
private int i;
|
|
private SurfaceHolder j;
|
|
private b k;
|
|
private PowerManager.WakeLock l;
|
|
private boolean m;
|
|
private int mListenerContext;
|
|
private long mNativeAndroidIO;
|
|
private long mNativeMediaDataSource;
|
|
private long mNativeMediaPlayer;
|
|
private int mNativeSurfaceTexture;
|
|
private boolean n;
|
|
private int o;
|
|
private int p;
|
|
private int q;
|
|
private int r;
|
|
private String s;
|
|
private int t;
|
|
private int u;
|
|
private long v;
|
|
private JSONArray w;
|
|
private Date x;
|
|
private long y;
|
|
private boolean z;
|
|
|
|
private interface OnControlMessageListener {
|
|
String onControlResolveSegmentUrl(int i);
|
|
}
|
|
|
|
private interface OnMediaCodecSelectListener {
|
|
String onMediaCodecSelect(IMediaPlayer iMediaPlayer, String str, int i, int i2);
|
|
}
|
|
|
|
private interface OnNativeInvokeListener {
|
|
public static final String ARG_ERROR = "error";
|
|
public static final String ARG_FAMILIY = "family";
|
|
public static final String ARG_FD = "fd";
|
|
public static final String ARG_HTTP_CODE = "http_code";
|
|
public static final String ARG_IP = "ip";
|
|
public static final String ARG_OFFSET = "offset";
|
|
public static final String ARG_PORT = "port";
|
|
public static final String ARG_RETRY_COUNTER = "retry_counter";
|
|
public static final String ARG_SEGMENT_INDEX = "segment_index";
|
|
public static final String ARG_URL = "url";
|
|
public static final int CTRL_DID_TCP_OPEN = 131074;
|
|
public static final int CTRL_WILL_CONCAT_RESOLVE_SEGMENT = 131079;
|
|
public static final int CTRL_WILL_HTTP_OPEN = 131075;
|
|
public static final int CTRL_WILL_LIVE_OPEN = 131077;
|
|
public static final int CTRL_WILL_TCP_OPEN = 131073;
|
|
public static final int EVENT_DID_HTTP_OPEN = 2;
|
|
public static final int EVENT_DID_HTTP_SEEK = 4;
|
|
public static final int EVENT_WILL_HTTP_OPEN = 1;
|
|
public static final int EVENT_WILL_HTTP_SEEK = 3;
|
|
|
|
boolean onNativeInvoke(int i, Bundle bundle);
|
|
}
|
|
|
|
private static class a implements OnMediaCodecSelectListener {
|
|
public static final a a = new a();
|
|
|
|
private a() {
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.BDCloudMediaPlayer.OnMediaCodecSelectListener
|
|
public String onMediaCodecSelect(IMediaPlayer iMediaPlayer, String str, int i, int i2) {
|
|
String[] supportedTypes;
|
|
com.baidu.cloud.media.player.a a2;
|
|
if (Build.VERSION.SDK_INT < 16 || TextUtils.isEmpty(str)) {
|
|
return null;
|
|
}
|
|
com.baidu.cloud.media.player.b.a.b(BDCloudMediaPlayer.a, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", str, Integer.valueOf(i), Integer.valueOf(i2)));
|
|
ArrayList arrayList = new ArrayList();
|
|
int codecCount = MediaCodecList.getCodecCount();
|
|
for (int i3 = 0; i3 < codecCount; i3++) {
|
|
MediaCodecInfo codecInfoAt = MediaCodecList.getCodecInfoAt(i3);
|
|
com.baidu.cloud.media.player.b.a.d(BDCloudMediaPlayer.a, String.format(Locale.US, " found codec: %s", codecInfoAt.getName()));
|
|
if (!codecInfoAt.isEncoder() && (supportedTypes = codecInfoAt.getSupportedTypes()) != null) {
|
|
for (String str2 : supportedTypes) {
|
|
if (!TextUtils.isEmpty(str2)) {
|
|
com.baidu.cloud.media.player.b.a.d(BDCloudMediaPlayer.a, String.format(Locale.US, " mime: %s", str2));
|
|
if (str2.equalsIgnoreCase(str) && (a2 = com.baidu.cloud.media.player.a.a(codecInfoAt, str)) != null) {
|
|
arrayList.add(a2);
|
|
com.baidu.cloud.media.player.b.a.b(BDCloudMediaPlayer.a, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfoAt.getName(), Integer.valueOf(a2.b)));
|
|
a2.a(str);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (arrayList.isEmpty()) {
|
|
return null;
|
|
}
|
|
com.baidu.cloud.media.player.a aVar = (com.baidu.cloud.media.player.a) arrayList.get(0);
|
|
Iterator it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
com.baidu.cloud.media.player.a aVar2 = (com.baidu.cloud.media.player.a) it.next();
|
|
if (aVar2.b > aVar.b) {
|
|
aVar = aVar2;
|
|
}
|
|
}
|
|
if (aVar.b < 600) {
|
|
Log.w(BDCloudMediaPlayer.a, String.format(Locale.US, "unaccetable codec: %s", aVar.a.getName()));
|
|
return null;
|
|
}
|
|
com.baidu.cloud.media.player.b.a.b(BDCloudMediaPlayer.a, String.format(Locale.US, "selected codec: %s rank=%d", aVar.a.getName(), Integer.valueOf(aVar.b)));
|
|
return aVar.a.getName();
|
|
}
|
|
}
|
|
|
|
private static class b extends Handler {
|
|
private final WeakReference<BDCloudMediaPlayer> a;
|
|
|
|
public b(BDCloudMediaPlayer bDCloudMediaPlayer, Looper looper) {
|
|
super(looper);
|
|
this.a = new WeakReference<>(bDCloudMediaPlayer);
|
|
}
|
|
|
|
@Override // android.os.Handler
|
|
public void handleMessage(Message message) {
|
|
String str;
|
|
String str2;
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = this.a.get();
|
|
if (bDCloudMediaPlayer != null) {
|
|
long j = 0;
|
|
if (bDCloudMediaPlayer.mNativeMediaPlayer != 0) {
|
|
int i = message.what;
|
|
if (i == 99) {
|
|
if (message.obj == null) {
|
|
bDCloudMediaPlayer.a((BDTimedText) null);
|
|
return;
|
|
} else {
|
|
bDCloudMediaPlayer.a(new BDTimedText(new Rect(0, 0, 1, 1), (String) message.obj));
|
|
return;
|
|
}
|
|
}
|
|
if (i == 100) {
|
|
com.baidu.cloud.media.player.b.a.a(BDCloudMediaPlayer.a, "Error (" + message.arg1 + "," + message.arg2 + ")");
|
|
bDCloudMediaPlayer.c(message.arg1, message.arg2);
|
|
bDCloudMediaPlayer.d();
|
|
if (!bDCloudMediaPlayer.a(message.arg1, message.arg2)) {
|
|
bDCloudMediaPlayer.b();
|
|
}
|
|
bDCloudMediaPlayer.a(false);
|
|
return;
|
|
}
|
|
if (i == 200) {
|
|
int i2 = message.arg1;
|
|
if (i2 == 3) {
|
|
str = BDCloudMediaPlayer.a;
|
|
str2 = "Info: MEDIA_INFO_VIDEO_RENDERING_START\n";
|
|
} else {
|
|
if (i2 != 10005) {
|
|
if (i2 == 10006) {
|
|
str = BDCloudMediaPlayer.a;
|
|
str2 = "Info: MEDIA_INFO_MEDIA_CHANGE_END : " + message.arg1 + "\n";
|
|
}
|
|
bDCloudMediaPlayer.f(message.arg1, message.arg2);
|
|
bDCloudMediaPlayer.b(message.arg1, message.arg2);
|
|
return;
|
|
}
|
|
str = BDCloudMediaPlayer.a;
|
|
str2 = "Info: MEDIA_INFO_MEDIA_CHANGE_START\n";
|
|
}
|
|
com.baidu.cloud.media.player.b.a.b(str, str2);
|
|
bDCloudMediaPlayer.f(message.arg1, message.arg2);
|
|
bDCloudMediaPlayer.b(message.arg1, message.arg2);
|
|
return;
|
|
}
|
|
if (i == 10001) {
|
|
bDCloudMediaPlayer.q = message.arg1;
|
|
bDCloudMediaPlayer.r = message.arg2;
|
|
bDCloudMediaPlayer.a(bDCloudMediaPlayer.o, bDCloudMediaPlayer.p, bDCloudMediaPlayer.q, bDCloudMediaPlayer.r);
|
|
return;
|
|
}
|
|
if (i == 77824) {
|
|
Bundle bundle = (Bundle) message.obj;
|
|
bDCloudMediaPlayer.a(bundle);
|
|
for (String str3 : bundle.keySet()) {
|
|
if (str3.equals("playID") && !bundle.get(str3).equals("")) {
|
|
bDCloudMediaPlayer.a(bundle.getString(str3));
|
|
String unused = BDCloudMediaPlayer.e = bundle.getString(str3);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (i == 81920) {
|
|
bDCloudMediaPlayer.b(message.arg1);
|
|
return;
|
|
}
|
|
if (i == 196610) {
|
|
bDCloudMediaPlayer.a(message.arg1);
|
|
return;
|
|
}
|
|
switch (i) {
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
bDCloudMediaPlayer.setOption(4, "seek-at-start", 0L);
|
|
bDCloudMediaPlayer.h();
|
|
bDCloudMediaPlayer.a();
|
|
break;
|
|
case 2:
|
|
break;
|
|
case 3:
|
|
bDCloudMediaPlayer.a(false);
|
|
bDCloudMediaPlayer.d(message.arg1, message.arg2);
|
|
bDCloudMediaPlayer.d();
|
|
bDCloudMediaPlayer.b();
|
|
break;
|
|
case 4:
|
|
long j2 = message.arg1;
|
|
if (j2 < 0) {
|
|
j2 = 0;
|
|
}
|
|
long duration = bDCloudMediaPlayer.getDuration();
|
|
if (duration > 0) {
|
|
if (duration - j2 < 1000) {
|
|
j2 += 1000;
|
|
}
|
|
j = (j2 * 100) / duration;
|
|
}
|
|
if (j >= 100) {
|
|
j = 100;
|
|
}
|
|
bDCloudMediaPlayer.a((int) j);
|
|
break;
|
|
case 5:
|
|
bDCloudMediaPlayer.c();
|
|
break;
|
|
case 6:
|
|
bDCloudMediaPlayer.o = message.arg1;
|
|
bDCloudMediaPlayer.p = message.arg2;
|
|
bDCloudMediaPlayer.a(bDCloudMediaPlayer.o, bDCloudMediaPlayer.p, bDCloudMediaPlayer.q, bDCloudMediaPlayer.r);
|
|
break;
|
|
default:
|
|
com.baidu.cloud.media.player.b.a.a(BDCloudMediaPlayer.a, "Unknown message type " + message.what);
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
com.baidu.cloud.media.player.b.a.c(BDCloudMediaPlayer.a, "BDCloudMediaPlayer went away with unhandled events");
|
|
}
|
|
}
|
|
|
|
public BDCloudMediaPlayer(Context context) {
|
|
this(context, J);
|
|
}
|
|
|
|
public BDCloudMediaPlayer(Context context, BDCloudLibLoader bDCloudLibLoader) {
|
|
this.i = 0;
|
|
this.l = null;
|
|
this.t = 15000000;
|
|
this.u = 0;
|
|
this.v = 0L;
|
|
this.w = new JSONArray();
|
|
this.x = null;
|
|
this.y = -1L;
|
|
this.z = false;
|
|
this.A = 0L;
|
|
this.B = 0;
|
|
this.C = 0;
|
|
this.D = 0;
|
|
this.F = true;
|
|
this.G = null;
|
|
this.H = null;
|
|
this.I = null;
|
|
this.L = 0;
|
|
this.H = context.getApplicationContext();
|
|
LicenseManager.a(this.H, d);
|
|
com.baidu.cloud.media.player.a.b.a(false);
|
|
com.baidu.cloud.media.player.a.b.a(c);
|
|
this.z = true;
|
|
a(bDCloudLibLoader);
|
|
}
|
|
|
|
private native String _getAudioCodecInfo();
|
|
|
|
private static native String _getColorFormatName(int i);
|
|
|
|
private native int _getLoopCount();
|
|
|
|
private native Bundle _getMediaMeta();
|
|
|
|
private native float _getPropertyFloat(int i, float f2);
|
|
|
|
private native long _getPropertyLong(int i, long j);
|
|
|
|
private native String _getVideoCodecInfo();
|
|
|
|
private native void _pause() throws IllegalStateException;
|
|
|
|
private native void _prepareAsync() throws IllegalStateException;
|
|
|
|
private native void _release();
|
|
|
|
private native void _reset();
|
|
|
|
private native void _seekTo(long j) throws IllegalStateException;
|
|
|
|
private native void _setDataSource(IMediaDataSource iMediaDataSource) throws IllegalArgumentException, SecurityException, IllegalStateException;
|
|
|
|
private native void _setDataSource(String str, String[] strArr, String[] strArr2) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
|
|
|
|
private native void _setDataSourceFd(int i) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
|
|
|
|
private native void _setLoopCount(int i);
|
|
|
|
private native void _setOption(int i, String str, long j);
|
|
|
|
private native void _setOption(int i, String str, String str2);
|
|
|
|
private native void _setPropertyFloat(int i, float f2);
|
|
|
|
private native void _setPropertyLong(int i, long j);
|
|
|
|
private native void _setStreamSelected(int i, boolean z);
|
|
|
|
private native void _setVideoSurface(Surface surface);
|
|
|
|
private native void _start() throws IllegalStateException;
|
|
|
|
private native void _stop() throws IllegalStateException;
|
|
|
|
private void a(BDCloudLibLoader bDCloudLibLoader) {
|
|
b bVar;
|
|
loadLibrariesOnce(bDCloudLibLoader);
|
|
Looper myLooper = Looper.myLooper();
|
|
if (myLooper != null) {
|
|
bVar = new b(this, myLooper);
|
|
} else {
|
|
Looper mainLooper = Looper.getMainLooper();
|
|
if (mainLooper == null) {
|
|
this.k = null;
|
|
native_init(new WeakReference(this));
|
|
setDecodeMode(0);
|
|
setOption(4, "start-on-prepared", 0L);
|
|
setOption(4, "max-fps", 30L);
|
|
setOption(4, "framedrop", 1L);
|
|
setOption(4, "framechasing", 0L);
|
|
setOption(4, "soundtouch", 1L);
|
|
setOption(4, "subtitle", 1L);
|
|
setOption(4, "max-buffer-size", 15728640L);
|
|
setOption(4, "max-buffer-duration", 5000L);
|
|
setOption(4, "enable-accurate-seek", 1L);
|
|
setLogEnabled(false);
|
|
}
|
|
bVar = new b(this, mainLooper);
|
|
}
|
|
this.k = bVar;
|
|
native_init(new WeakReference(this));
|
|
setDecodeMode(0);
|
|
setOption(4, "start-on-prepared", 0L);
|
|
setOption(4, "max-fps", 30L);
|
|
setOption(4, "framedrop", 1L);
|
|
setOption(4, "framechasing", 0L);
|
|
setOption(4, "soundtouch", 1L);
|
|
setOption(4, "subtitle", 1L);
|
|
setOption(4, "max-buffer-size", 15728640L);
|
|
setOption(4, "max-buffer-duration", 5000L);
|
|
setOption(4, "enable-accurate-seek", 1L);
|
|
setLogEnabled(false);
|
|
}
|
|
|
|
private void a(FileDescriptor fileDescriptor, long j, long j2) throws IOException, IllegalArgumentException, IllegalStateException {
|
|
setDataSource(fileDescriptor);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(boolean z) {
|
|
PowerManager.WakeLock wakeLock = this.l;
|
|
if (wakeLock != null) {
|
|
if (z && !wakeLock.isHeld()) {
|
|
this.l.acquire();
|
|
} else if (!z && this.l.isHeld()) {
|
|
this.l.release();
|
|
}
|
|
}
|
|
this.n = z;
|
|
k();
|
|
}
|
|
|
|
private boolean c(String str) {
|
|
if (str == null) {
|
|
return false;
|
|
}
|
|
return str.startsWith("file://") || str.startsWith("/");
|
|
}
|
|
|
|
private native String getCdnIp();
|
|
|
|
public static String getColorFormatName(int i) {
|
|
return _getColorFormatName(i);
|
|
}
|
|
|
|
public static String getSdkVersion() {
|
|
return SDK_VERSION;
|
|
}
|
|
|
|
private void j() {
|
|
setOption(1, "reconnect", 1L);
|
|
setOption(1, "timeout", this.t);
|
|
native_setup();
|
|
}
|
|
|
|
private void k() {
|
|
SurfaceHolder surfaceHolder = this.j;
|
|
if (surfaceHolder != null) {
|
|
surfaceHolder.setKeepScreenOn(this.m && this.n);
|
|
}
|
|
}
|
|
|
|
public static void loadLibrariesOnce(BDCloudLibLoader bDCloudLibLoader) {
|
|
synchronized (BDCloudMediaPlayer.class) {
|
|
if (!K) {
|
|
if (bDCloudLibLoader == null) {
|
|
bDCloudLibLoader = J;
|
|
}
|
|
bDCloudLibLoader.loadLibrary("stlport_shared");
|
|
bDCloudLibLoader.loadLibrary("bdsoundutils");
|
|
bDCloudLibLoader.loadLibrary("bdplayer");
|
|
K = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private native void native_finalize();
|
|
|
|
private native void native_init(Object obj);
|
|
|
|
private native void native_message_loop(Object obj);
|
|
|
|
private static native void native_profileBegin(String str);
|
|
|
|
private static native void native_profileEnd();
|
|
|
|
private static native void native_setLogLevel(int i);
|
|
|
|
private native void native_setup();
|
|
|
|
private static boolean onNativeInvoke(Object obj, int i, Bundle bundle) {
|
|
OnControlMessageListener onControlMessageListener;
|
|
com.baidu.cloud.media.player.b.a.a(a, "onNativeInvoke %x", Integer.valueOf(i));
|
|
if (obj == null || !(obj instanceof WeakReference)) {
|
|
throw new IllegalStateException("<null weakThiz>.onNativeInvoke()");
|
|
}
|
|
BDCloudMediaPlayer bDCloudMediaPlayer = (BDCloudMediaPlayer) ((WeakReference) obj).get();
|
|
if (bDCloudMediaPlayer == null) {
|
|
throw new IllegalStateException("<null weakPlayer>.onNativeInvoke()");
|
|
}
|
|
OnNativeInvokeListener onNativeInvokeListener = bDCloudMediaPlayer.N;
|
|
if (onNativeInvokeListener != null && onNativeInvokeListener.onNativeInvoke(i, bundle)) {
|
|
return true;
|
|
}
|
|
if (i != 131079 || (onControlMessageListener = bDCloudMediaPlayer.M) == null) {
|
|
return false;
|
|
}
|
|
int i2 = bundle.getInt(OnNativeInvokeListener.ARG_SEGMENT_INDEX, -1);
|
|
if (i2 < 0) {
|
|
throw new InvalidParameterException("onNativeInvoke(invalid segment index)");
|
|
}
|
|
String onControlResolveSegmentUrl = onControlMessageListener.onControlResolveSegmentUrl(i2);
|
|
if (onControlResolveSegmentUrl == null) {
|
|
throw new RuntimeException(new IOException("onNativeInvoke() = <NULL newUrl>"));
|
|
}
|
|
bundle.putString("url", onControlResolveSegmentUrl);
|
|
return true;
|
|
}
|
|
|
|
private static String onSelectCodec(Object obj, String str, int i, int i2) {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer;
|
|
if (obj == null || !(obj instanceof WeakReference) || (bDCloudMediaPlayer = (BDCloudMediaPlayer) ((WeakReference) obj).get()) == null) {
|
|
return null;
|
|
}
|
|
OnMediaCodecSelectListener onMediaCodecSelectListener = bDCloudMediaPlayer.O;
|
|
if (onMediaCodecSelectListener == null) {
|
|
onMediaCodecSelectListener = a.a;
|
|
}
|
|
return onMediaCodecSelectListener.onMediaCodecSelect(bDCloudMediaPlayer, str, i, i2);
|
|
}
|
|
|
|
private static void postEventFromNative(Object obj, int i, int i2, int i3, Object obj2) {
|
|
BDCloudMediaPlayer bDCloudMediaPlayer;
|
|
if (obj == null || (bDCloudMediaPlayer = (BDCloudMediaPlayer) ((WeakReference) obj).get()) == null) {
|
|
return;
|
|
}
|
|
if (i == 200 && i2 == 2) {
|
|
bDCloudMediaPlayer.start();
|
|
}
|
|
b bVar = bDCloudMediaPlayer.k;
|
|
if (bVar != null) {
|
|
bDCloudMediaPlayer.k.sendMessage(bVar.obtainMessage(i, i2, i3, obj2));
|
|
}
|
|
}
|
|
|
|
public static void setAK(String str) {
|
|
b = str;
|
|
}
|
|
|
|
public static void setAppId(String str) {
|
|
d = str;
|
|
}
|
|
|
|
public static void setCuid(String str) {
|
|
c = str;
|
|
com.baidu.cloud.media.player.a.b.a(str);
|
|
}
|
|
|
|
public static void setLocalCacheEnabled(boolean z, String str) {
|
|
g = z;
|
|
h = str;
|
|
if (g && TextUtils.isEmpty(h)) {
|
|
throw new IllegalArgumentException("cachePath can not be empty if enabled local cache");
|
|
}
|
|
}
|
|
|
|
protected void a(long j) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(j / 1000);
|
|
}
|
|
|
|
protected void a(long j, long j2) {
|
|
try {
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put(MyUnityListener.CALLER, j);
|
|
jSONObject.put("to", j2);
|
|
com.baidu.cloud.media.player.a.b.a(this.H).c(jSONObject);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
protected void a(String str) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).d(str);
|
|
}
|
|
|
|
protected void b(int i) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(i);
|
|
}
|
|
|
|
protected void c(int i, int i2) {
|
|
try {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(i, i2, 1);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
protected void d() {
|
|
String str;
|
|
if (this.F) {
|
|
return;
|
|
}
|
|
this.F = true;
|
|
try {
|
|
if (this.w != null) {
|
|
str = this.w.toString();
|
|
this.w = new JSONArray();
|
|
} else {
|
|
str = null;
|
|
}
|
|
if (this.G != null) {
|
|
this.G.cancel();
|
|
this.G = null;
|
|
}
|
|
if (this.v != 0) {
|
|
int currentTimeMillis = ((int) (System.currentTimeMillis() - this.v)) / 1000;
|
|
this.v = 0L;
|
|
this.u += currentTimeMillis;
|
|
}
|
|
int i = this.u;
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("playInterval", i);
|
|
jSONObject.put("buffering", new JSONArray(str));
|
|
com.baidu.cloud.media.player.a.b.a(this.H).b(jSONObject);
|
|
this.u = 0;
|
|
} catch (Exception e2) {
|
|
Log.d(a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
protected void d(int i, int i2) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(i, i2, 2);
|
|
}
|
|
|
|
public void deselectTrack(int i) {
|
|
_setStreamSelected(i, false);
|
|
}
|
|
|
|
protected void e() {
|
|
this.v = System.currentTimeMillis();
|
|
this.A = System.currentTimeMillis();
|
|
com.baidu.cloud.media.player.a.b.a(this.H).b(this.s);
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(SDK_VERSION, "hw", b);
|
|
}
|
|
|
|
protected void e(int i, int i2) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(i, i2, 3);
|
|
}
|
|
|
|
protected void f() {
|
|
if (this.v != 0) {
|
|
int currentTimeMillis = ((int) (System.currentTimeMillis() - this.v)) / 1000;
|
|
this.v = 0L;
|
|
this.u += currentTimeMillis;
|
|
}
|
|
try {
|
|
if (this.G != null) {
|
|
this.G.cancel();
|
|
this.G = null;
|
|
}
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(getCurrentPosition() / 1000.0f);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
protected void f(int i, int i2) {
|
|
try {
|
|
if (i == 701) {
|
|
this.x = new Date();
|
|
this.y = getCurrentPosition();
|
|
com.baidu.cloud.media.player.a.b.a(this.H).e();
|
|
} else if (i == 702) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).f();
|
|
if (this.x != null) {
|
|
Date date = new Date();
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("startPosition", this.y / 1000.0f);
|
|
jSONObject.put("endPosition", getCurrentPosition() / 1000.0f);
|
|
jSONObject.put("startTimestamp", this.x.getTime());
|
|
jSONObject.put("endTimestamp", date.getTime());
|
|
this.w.put(jSONObject);
|
|
this.x = null;
|
|
this.y = -1L;
|
|
}
|
|
} else if (i == 3) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).b(this.v);
|
|
} else if (i == 10003) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).c();
|
|
} else if (i != 10004) {
|
|
} else {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).d();
|
|
}
|
|
} catch (Exception e2) {
|
|
Log.d(a, "buffer stat exception :" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
protected void finalize() throws Throwable {
|
|
super.finalize();
|
|
native_finalize();
|
|
}
|
|
|
|
protected void g() {
|
|
this.F = false;
|
|
if (this.v == 0) {
|
|
this.v = System.currentTimeMillis();
|
|
}
|
|
try {
|
|
if (this.G != null) {
|
|
this.G.cancel();
|
|
this.G = null;
|
|
}
|
|
this.G = new Timer();
|
|
this.G.schedule(new TimerTask() { // from class: com.baidu.cloud.media.player.BDCloudMediaPlayer.2
|
|
@Override // java.util.TimerTask, java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
com.baidu.cloud.media.player.a.b.a(BDCloudMediaPlayer.this.H).g();
|
|
long downloadSpeed = BDCloudMediaPlayer.this.getDownloadSpeed();
|
|
if (downloadSpeed > 0) {
|
|
com.baidu.cloud.media.player.a.b.a(BDCloudMediaPlayer.this.H).b((int) downloadSpeed);
|
|
}
|
|
} catch (Exception e2) {
|
|
Log.d(BDCloudMediaPlayer.a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
}, 0L, 60000L);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "" + e2.getMessage());
|
|
}
|
|
if (this.z) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).b();
|
|
this.z = false;
|
|
}
|
|
}
|
|
|
|
public long getAsyncStatisticBufBackwards() {
|
|
return _getPropertyLong(20201, 0L);
|
|
}
|
|
|
|
public long getAsyncStatisticBufCapacity() {
|
|
return _getPropertyLong(20203, 0L);
|
|
}
|
|
|
|
public long getAsyncStatisticBufForwards() {
|
|
return _getPropertyLong(20202, 0L);
|
|
}
|
|
|
|
public long getAudioCachedBytes() {
|
|
return _getPropertyLong(20008, 0L);
|
|
}
|
|
|
|
public long getAudioCachedDuration() {
|
|
return _getPropertyLong(20006, 0L);
|
|
}
|
|
|
|
public long getAudioCachedPackets() {
|
|
return _getPropertyLong(20010, 0L);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public native int getAudioSessionId();
|
|
|
|
public long getBitRate() {
|
|
return _getPropertyLong(20100, 0L);
|
|
}
|
|
|
|
public long getCacheStatisticBufForwards() {
|
|
return _getPropertyLong(20206, 0L);
|
|
}
|
|
|
|
public long getCacheStatisticCountBytes() {
|
|
return _getPropertyLong(20208, 0L);
|
|
}
|
|
|
|
public long getCacheStatisticFilePos() {
|
|
return _getPropertyLong(20207, 0L);
|
|
}
|
|
|
|
public long getCacheStatisticPhysicalPos() {
|
|
return _getPropertyLong(20205, 0L);
|
|
}
|
|
|
|
public native int getCurrentMediaIndex();
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public native long getCurrentPosition();
|
|
|
|
public native int getCurrentVariantIndex();
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public String getDataSource() {
|
|
return this.s;
|
|
}
|
|
|
|
public int getDecodeMode() {
|
|
return this.L;
|
|
}
|
|
|
|
public long getDownloadSpeed() {
|
|
return _getPropertyLong(20200, 0L);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public native long getDuration();
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public c getMediaInfo() {
|
|
c cVar = new c();
|
|
cVar.a = "bdcloudplayer";
|
|
String _getVideoCodecInfo = _getVideoCodecInfo();
|
|
if (!TextUtils.isEmpty(_getVideoCodecInfo)) {
|
|
String[] split = _getVideoCodecInfo.split(",");
|
|
if (split.length >= 2) {
|
|
cVar.b = split[0];
|
|
cVar.c = split[1];
|
|
} else if (split.length >= 1) {
|
|
cVar.b = split[0];
|
|
cVar.c = "";
|
|
}
|
|
}
|
|
String _getAudioCodecInfo = _getAudioCodecInfo();
|
|
if (!TextUtils.isEmpty(_getAudioCodecInfo)) {
|
|
String[] split2 = _getAudioCodecInfo.split(",");
|
|
if (split2.length >= 2) {
|
|
cVar.d = split2[0];
|
|
cVar.e = split2[1];
|
|
} else if (split2.length >= 1) {
|
|
cVar.d = split2[0];
|
|
cVar.e = "";
|
|
}
|
|
}
|
|
try {
|
|
cVar.f = com.baidu.cloud.media.player.b.a(_getMediaMeta());
|
|
} catch (Throwable th) {
|
|
th.printStackTrace();
|
|
}
|
|
return cVar;
|
|
}
|
|
|
|
public native String[] getMediaItems();
|
|
|
|
public Bundle getMediaMeta() {
|
|
return _getMediaMeta();
|
|
}
|
|
|
|
public long getSeekLoadDuration() {
|
|
return _getPropertyLong(20300, 0L);
|
|
}
|
|
|
|
public int getSelectedTrack(int i) {
|
|
int i2;
|
|
if (i == 1) {
|
|
i2 = 20001;
|
|
} else if (i == 2) {
|
|
i2 = 20002;
|
|
} else {
|
|
if (i != 3) {
|
|
return -1;
|
|
}
|
|
i2 = 20011;
|
|
}
|
|
return (int) _getPropertyLong(i2, -1L);
|
|
}
|
|
|
|
public float getSpeed(float f2) {
|
|
return _getPropertyFloat(IMediaPlayer.MEDIA_INFO_FRAMECHASING_START, 0.0f);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public com.baidu.cloud.media.player.misc.a[] getTrackInfo() {
|
|
com.baidu.cloud.media.player.b a2;
|
|
int i;
|
|
Bundle mediaMeta = getMediaMeta();
|
|
if (mediaMeta == null || (a2 = com.baidu.cloud.media.player.b.a(mediaMeta)) == null || a2.f == null) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<b.a> it = a2.f.iterator();
|
|
while (it.hasNext()) {
|
|
b.a next = it.next();
|
|
com.baidu.cloud.media.player.misc.a aVar = new com.baidu.cloud.media.player.misc.a(next);
|
|
if (next.c.equalsIgnoreCase("video")) {
|
|
i = 1;
|
|
} else if (next.c.equalsIgnoreCase("audio")) {
|
|
i = 2;
|
|
} else if (next.c.equalsIgnoreCase("timedtext")) {
|
|
i = 3;
|
|
} else {
|
|
arrayList.add(aVar);
|
|
}
|
|
aVar.a(i);
|
|
arrayList.add(aVar);
|
|
}
|
|
return (com.baidu.cloud.media.player.misc.a[]) arrayList.toArray(new com.baidu.cloud.media.player.misc.a[arrayList.size()]);
|
|
}
|
|
|
|
public long getTrafficStatisticByteCount() {
|
|
return _getPropertyLong(20204, 0L);
|
|
}
|
|
|
|
public native String[] getVariantInfo();
|
|
|
|
public long getVideoCachedBytes() {
|
|
return _getPropertyLong(20007, 0L);
|
|
}
|
|
|
|
public long getVideoCachedDuration() {
|
|
return _getPropertyLong(20005, 0L);
|
|
}
|
|
|
|
public long getVideoCachedPackets() {
|
|
return _getPropertyLong(20009, 0L);
|
|
}
|
|
|
|
public float getVideoDecodeFramesPerSecond() {
|
|
return _getPropertyFloat(10001, 0.0f);
|
|
}
|
|
|
|
public int getVideoDecoder() {
|
|
return (int) _getPropertyLong(20003, 0L);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public int getVideoHeight() {
|
|
return this.p;
|
|
}
|
|
|
|
public float getVideoOutputFramesPerSecond() {
|
|
return _getPropertyFloat(10002, 0.0f);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public int getVideoSarDen() {
|
|
return this.r;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public int getVideoSarNum() {
|
|
return this.q;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public int getVideoWidth() {
|
|
return this.o;
|
|
}
|
|
|
|
protected void h() {
|
|
try {
|
|
if (this.A > 0) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).c(System.currentTimeMillis() - this.A);
|
|
this.A = 0L;
|
|
}
|
|
String cdnIp = getCdnIp();
|
|
if (cdnIp != null && !cdnIp.equals("")) {
|
|
com.baidu.cloud.media.player.a.b.a(this.H).c(cdnIp);
|
|
}
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("videoUrl", this.s);
|
|
jSONObject.put("videoWidth", getVideoWidth());
|
|
jSONObject.put("videoHeight", getVideoHeight());
|
|
jSONObject.put("playerWidth", 0);
|
|
jSONObject.put("playerHeight", 0);
|
|
jSONObject.put("duration", getDuration());
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.put("maxCacheSize", this.B);
|
|
jSONObject2.put("cachePauseTime", this.C);
|
|
jSONObject2.put("firstBufferingTime", this.D);
|
|
jSONObject2.put("toggleFrameChasing", this.E);
|
|
jSONObject2.put("decodeMode", this.L);
|
|
jSONObject2.put("playbackRate", getSpeed(0.0f));
|
|
jSONObject2.put("enableLooping", isLooping());
|
|
jSONObject.put("settings", jSONObject2);
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a(jSONObject);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "APMEventHandle exception:" + e2.getMessage());
|
|
}
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public boolean isLooping() {
|
|
return _getLoopCount() != 1;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public boolean isPlayable() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public native boolean isPlaying();
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void pause() throws IllegalStateException {
|
|
a(false);
|
|
f();
|
|
_pause();
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void prepareAsync() throws IllegalStateException {
|
|
if (LicenseManager.b()) {
|
|
_prepareAsync();
|
|
} else {
|
|
a(IMediaPlayer.MEDIA_ERROR_AUTH_FAILURE, 0);
|
|
throw new IllegalStateException("Authentication failure, apply fo license please!");
|
|
}
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void release() {
|
|
a(false);
|
|
d();
|
|
k();
|
|
resetListeners();
|
|
com.baidu.cloud.media.player.a.b.a(this.H).a();
|
|
_release();
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void reset() {
|
|
a(false);
|
|
d();
|
|
_stop();
|
|
_reset();
|
|
this.k.removeCallbacksAndMessages(null);
|
|
this.o = 0;
|
|
this.p = 0;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.AbstractMediaPlayer
|
|
public void resetListeners() {
|
|
super.resetListeners();
|
|
this.O = null;
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void seekTo(long j) throws IllegalStateException {
|
|
a(getCurrentPosition() / 1000, j / 1000);
|
|
_seekTo(j);
|
|
}
|
|
|
|
public boolean selectMediaByIndex(int i) {
|
|
if (getCurrentMediaIndex() == i) {
|
|
Log.d(a, "Is the same index :" + i);
|
|
return false;
|
|
}
|
|
if (i >= 0 && i < getMediaItems().length) {
|
|
return setMediaItemIndex(i);
|
|
}
|
|
Log.d(a, "index is not in [0," + getMediaItems().length + ")");
|
|
return false;
|
|
}
|
|
|
|
public boolean selectResolutionByIndex(int i) {
|
|
if (getCurrentVariantIndex() == i) {
|
|
Log.d(a, "currentVariantIndex is equals to index setted~" + i);
|
|
return false;
|
|
}
|
|
if (i < 0 || i >= getVariantInfo().length) {
|
|
Log.d(a, "index is not in [0," + getVariantInfo().length + ")");
|
|
return false;
|
|
}
|
|
long currentPosition = getCurrentPosition();
|
|
stop();
|
|
native_setup();
|
|
setOption(1, "reconnect", 1L);
|
|
setOption(1, "timeout", this.t);
|
|
setOption(1, "cache_dir", g ? h : "");
|
|
if (!TextUtils.isEmpty(this.I)) {
|
|
setOption(1, "headers", this.I);
|
|
}
|
|
selectVariantByIndex(i);
|
|
setInitPlayPosition(currentPosition);
|
|
prepareAsync();
|
|
return true;
|
|
}
|
|
|
|
public void selectTrack(int i) {
|
|
_setStreamSelected(i, true);
|
|
}
|
|
|
|
public native void selectVariantByIndex(int i);
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setAudioStreamType(int i) {
|
|
}
|
|
|
|
public void setBufferSizeInBytes(int i) {
|
|
setOption(4, "buffer-size-in-bytes", i);
|
|
}
|
|
|
|
public void setBufferTimeInMs(int i) {
|
|
this.C = i;
|
|
setOption(4, "buffer-time-in-ms", i);
|
|
}
|
|
|
|
public native void setCustomizedPlayerIdForHLS(String str);
|
|
|
|
public native void setCustomizedPlayerKeyForHLS(String str);
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
|
|
setDataSource(context, uri, null);
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:31:0x007e, code lost:
|
|
|
|
if (0 == 0) goto L38;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:32:0x0087, code lost:
|
|
|
|
setDataSource(r9.toString(), r10);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:33:0x008e, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:34:0x0084, code lost:
|
|
|
|
r0.close();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:36:0x0082, code lost:
|
|
|
|
if (0 == 0) goto L38;
|
|
*/
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public void setDataSource(android.content.Context r8, android.net.Uri r9, java.util.Map<java.lang.String, java.lang.String> r10) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.IllegalStateException {
|
|
/*
|
|
r7 = this;
|
|
java.lang.String r0 = r9.getScheme()
|
|
java.lang.String r1 = "file"
|
|
boolean r1 = r1.equals(r0)
|
|
if (r1 == 0) goto L14
|
|
java.lang.String r8 = r9.getPath()
|
|
r7.setDataSource(r8)
|
|
return
|
|
L14:
|
|
java.lang.String r1 = "content"
|
|
boolean r0 = r1.equals(r0)
|
|
if (r0 == 0) goto L3b
|
|
java.lang.String r0 = r9.getAuthority()
|
|
java.lang.String r1 = "settings"
|
|
boolean r0 = r1.equals(r0)
|
|
if (r0 == 0) goto L3b
|
|
int r9 = android.media.RingtoneManager.getDefaultType(r9)
|
|
android.net.Uri r9 = android.media.RingtoneManager.getActualDefaultRingtoneUri(r8, r9)
|
|
if (r9 == 0) goto L33
|
|
goto L3b
|
|
L33:
|
|
java.io.FileNotFoundException r8 = new java.io.FileNotFoundException
|
|
java.lang.String r9 = "Failed to resolve default ringtone"
|
|
r8.<init>(r9)
|
|
throw r8
|
|
L3b:
|
|
r0 = 0
|
|
android.content.ContentResolver r8 = r8.getContentResolver() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
java.lang.String r1 = "r"
|
|
android.content.res.AssetFileDescriptor r0 = r8.openAssetFileDescriptor(r9, r1) // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
if (r0 != 0) goto L4e
|
|
if (r0 == 0) goto L4d
|
|
r0.close()
|
|
L4d:
|
|
return
|
|
L4e:
|
|
long r1 = r0.getDeclaredLength() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
r3 = 0
|
|
int r8 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1))
|
|
if (r8 >= 0) goto L60
|
|
java.io.FileDescriptor r8 = r0.getFileDescriptor() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
r7.setDataSource(r8) // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
goto L70
|
|
L60:
|
|
java.io.FileDescriptor r2 = r0.getFileDescriptor() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
long r3 = r0.getStartOffset() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
long r5 = r0.getDeclaredLength() // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
r1 = r7
|
|
r1.a(r2, r3, r5) // Catch: java.lang.Throwable -> L76 java.io.IOException -> L7d java.lang.SecurityException -> L81
|
|
L70:
|
|
if (r0 == 0) goto L75
|
|
r0.close()
|
|
L75:
|
|
return
|
|
L76:
|
|
r8 = move-exception
|
|
if (r0 == 0) goto L7c
|
|
r0.close()
|
|
L7c:
|
|
throw r8
|
|
L7d:
|
|
if (r0 == 0) goto L87
|
|
goto L84
|
|
L81:
|
|
if (r0 == 0) goto L87
|
|
L84:
|
|
r0.close()
|
|
L87:
|
|
java.lang.String r8 = r9.toString()
|
|
r7.setDataSource(r8, r10)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.baidu.cloud.media.player.BDCloudMediaPlayer.setDataSource(android.content.Context, android.net.Uri, java.util.Map):void");
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.AbstractMediaPlayer, com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setDataSource(IMediaDataSource iMediaDataSource) throws IllegalArgumentException, SecurityException, IllegalStateException {
|
|
j();
|
|
_setDataSource(iMediaDataSource);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setDataSource(FileDescriptor fileDescriptor) throws IOException, IllegalArgumentException, IllegalStateException {
|
|
j();
|
|
if (Build.VERSION.SDK_INT >= 12) {
|
|
ParcelFileDescriptor dup = ParcelFileDescriptor.dup(fileDescriptor);
|
|
try {
|
|
_setDataSourceFd(dup.getFd());
|
|
return;
|
|
} finally {
|
|
dup.close();
|
|
}
|
|
}
|
|
try {
|
|
Field declaredField = fileDescriptor.getClass().getDeclaredField("descriptor");
|
|
declaredField.setAccessible(true);
|
|
_setDataSourceFd(declaredField.getInt(fileDescriptor));
|
|
} catch (IllegalAccessException e2) {
|
|
throw new RuntimeException(e2);
|
|
} catch (NoSuchFieldException e3) {
|
|
throw new RuntimeException(e3);
|
|
}
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setDataSource(String str) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
|
|
this.s = str;
|
|
e();
|
|
j();
|
|
_setDataSource(str, null, null);
|
|
if (!c(str)) {
|
|
setOption(4, "enable_cache", g ? 1L : 0L);
|
|
setOption(1, "cache_dir", g ? h : "");
|
|
return;
|
|
}
|
|
String string = this.H.getSharedPreferences("__cyberplayer_dl_sec", 0).getString(str.replace("file://", ""), null);
|
|
if (string != null) {
|
|
try {
|
|
String decryptStr = LocalHlsSec.decryptStr(this.H, string);
|
|
if (decryptStr == null || decryptStr.length() <= 0) {
|
|
return;
|
|
}
|
|
setLocalDecryptKeyForHLS(decryptStr);
|
|
} catch (Exception e2) {
|
|
Log.d(a, "", e2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setDataSource(String str, Map<String, String> map) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
|
|
if (map == null || map.isEmpty()) {
|
|
this.I = null;
|
|
} else {
|
|
StringBuilder sb = new StringBuilder();
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
sb.append(entry.getKey());
|
|
sb.append(": ");
|
|
if (!TextUtils.isEmpty(entry.getValue())) {
|
|
sb.append(entry.getValue());
|
|
}
|
|
sb.append("\r\n");
|
|
}
|
|
this.I = sb.toString();
|
|
setOption(1, "headers", this.I);
|
|
}
|
|
setDataSource(str);
|
|
}
|
|
|
|
public void setDecodeMode(int i) {
|
|
if (i < 0 || i > 1) {
|
|
com.baidu.cloud.media.player.b.a.a(a, "decodeMode shoule be DECODE_AUTO or DECODE_SW");
|
|
return;
|
|
}
|
|
this.L = i;
|
|
long j = this.L == 0 ? 1L : 0L;
|
|
setOption(4, "mediacodec", j);
|
|
setOption(4, "mediacodec-all-videos", j);
|
|
setOption(4, "mediacodec-auto-rotate", j);
|
|
setOption(4, "mediacodec-handle-resolution-change", j);
|
|
}
|
|
|
|
public native void setDecryptTokenForHLS(String str);
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setDisplay(SurfaceHolder surfaceHolder) {
|
|
this.j = surfaceHolder;
|
|
_setVideoSurface(surfaceHolder != null ? surfaceHolder.getSurface() : null);
|
|
k();
|
|
}
|
|
|
|
public void setInitPlayPosition(long j) {
|
|
setOption(4, "seek-at-start", j);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setKeepInBackground(boolean z) {
|
|
}
|
|
|
|
protected native void setLocalDecryptKeyForHLS(String str);
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setLogEnabled(boolean z) {
|
|
boolean z2;
|
|
if (z) {
|
|
z2 = true;
|
|
native_setLogLevel(1);
|
|
} else {
|
|
native_setLogLevel(5);
|
|
z2 = false;
|
|
}
|
|
com.baidu.cloud.media.player.b.a.a(z2);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setLooping(boolean z) {
|
|
int i = !z ? 1 : 0;
|
|
setOption(4, "loop", i);
|
|
_setLoopCount(i);
|
|
}
|
|
|
|
public void setMaxCacheDuration(int i) {
|
|
setOption(4, "max-buffer-duration", i);
|
|
}
|
|
|
|
public void setMaxCacheSizeInBytes(int i) {
|
|
this.B = i;
|
|
setOption(4, "max-buffer-size", i);
|
|
}
|
|
|
|
public void setMaxProbeSize(int i) {
|
|
setOption(4, "max-probe-size", i);
|
|
}
|
|
|
|
public void setMaxProbeTime(int i) {
|
|
this.D = i;
|
|
setOption(4, "max-probe-time", i);
|
|
}
|
|
|
|
public void setMediaInputType(int i) {
|
|
if (i == 1) {
|
|
setOption(1, "adaptive_demuxer", "adapt_media");
|
|
setOption(1, "get_master_plist", 0L);
|
|
setOption(1, "smooth_switch_seek_flag", 0L);
|
|
} else if (i != 2) {
|
|
setOption(1, "adaptive_demuxer", (String) null);
|
|
} else {
|
|
setOption(1, "adaptive_demuxer", "adapt_media");
|
|
setOption(1, "get_master_plist", 1L);
|
|
}
|
|
}
|
|
|
|
public native boolean setMediaItemIndex(int i);
|
|
|
|
public native void setMediaItems(String[] strArr);
|
|
|
|
public void setOption(int i, String str, long j) {
|
|
_setOption(i, str, j);
|
|
}
|
|
|
|
public void setOption(int i, String str, String str2) {
|
|
_setOption(i, str, str2);
|
|
}
|
|
|
|
public void setPlayType(int i) {
|
|
this.i = i;
|
|
setOption(1, "livehook_demuxer", this.i == 1 ? "ijklivehook" : null);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setScreenOnWhilePlaying(boolean z) {
|
|
if (this.m != z) {
|
|
if (z && this.j == null) {
|
|
com.baidu.cloud.media.player.b.a.c(a, "setScreenOnWhilePlaying(true) is ineffective without a SurfaceHolder");
|
|
}
|
|
this.m = z;
|
|
k();
|
|
}
|
|
}
|
|
|
|
public void setSpeed(float f2) {
|
|
if (f2 == 0.0f) {
|
|
return;
|
|
}
|
|
_setPropertyFloat(IMediaPlayer.MEDIA_INFO_FRAMECHASING_START, f2);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setSurface(Surface surface) {
|
|
if (this.m && surface != null) {
|
|
com.baidu.cloud.media.player.b.a.c(a, "setScreenOnWhilePlaying(true) is ineffective for Surface");
|
|
}
|
|
this.j = null;
|
|
_setVideoSurface(surface);
|
|
k();
|
|
}
|
|
|
|
public void setTimeoutInUs(int i) {
|
|
if (i <= 0) {
|
|
i = this.t;
|
|
}
|
|
this.t = i;
|
|
setOption(1, "timeout", this.t);
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public native void setVolume(float f2, float f3);
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void setWakeMode(Context context, int i) {
|
|
boolean z;
|
|
PowerManager.WakeLock wakeLock = this.l;
|
|
if (wakeLock != null) {
|
|
if (wakeLock.isHeld()) {
|
|
z = true;
|
|
this.l.release();
|
|
} else {
|
|
z = false;
|
|
}
|
|
this.l = null;
|
|
} else {
|
|
z = false;
|
|
}
|
|
this.l = ((PowerManager) context.getSystemService("power")).newWakeLock(i | 536870912, BDCloudMediaPlayer.class.getName());
|
|
this.l.setReferenceCounted(false);
|
|
if (z) {
|
|
this.l.acquire();
|
|
}
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void start() throws IllegalStateException {
|
|
a(true);
|
|
g();
|
|
_start();
|
|
}
|
|
|
|
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
|
public void stop() throws IllegalStateException {
|
|
a(false);
|
|
e(0, 0);
|
|
d();
|
|
_stop();
|
|
}
|
|
|
|
public void toggleFrameChasing(boolean z) {
|
|
this.E = z;
|
|
setOption(4, "framechasing", z ? 1L : 0L);
|
|
}
|
|
}
|