思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c
以下内容为反编译后的 MediaPlayer.java 源代码,内容仅作参考
package com.qiniu.qplayer.mediaEngine;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.view.Surface;
import android.view.SurfaceHolder;
import com.pili.pldroid.player.AVOptions;
import com.pili.pldroid.player.PLMediaPlayer;
import com.pili.pldroid.player.PLOnAudioFrameListener;
import com.pili.pldroid.player.PLOnBufferingUpdateListener;
import com.pili.pldroid.player.PLOnCompletionListener;
import com.pili.pldroid.player.PLOnErrorListener;
import com.pili.pldroid.player.PLOnImageCapturedListener;
import com.pili.pldroid.player.PLOnInfoListener;
import com.pili.pldroid.player.PLOnPreparedListener;
import com.pili.pldroid.player.PLOnSeekCompleteListener;
import com.pili.pldroid.player.PLOnVideoFrameListener;
import com.pili.pldroid.player.PLOnVideoSizeChangedListener;
import com.pili.pldroid.player.PlayerState;
import com.pili.pldroid.player.ResponseInfo;
import com.pili.pldroid.player.common.Config;
import com.pili.pldroid.player.common.Logger;
import com.pili.pldroid.player.common.Util;
import com.taobao.weex.common.Constants;
import com.umeng.socialize.utils.DeviceConfigInternal;
import java.lang.ref.WeakReference;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Queue;
import org.json.JSONException;
import org.json.JSONObject;
import org.webrtc.MediaStreamTrack;
public class MediaPlayer {
public static final String ACTION_NET = "android.net.conn.CONNECTIVITY_CHANGE";
public static final String TAG = "QPlayer";
public static ResponseInfo mResponseInfo;
public String mApkPath;
public Context mAppContext;
public int mAudioBitrate;
public int mAudioChannels;
public int mAudioFps;
public z mAudioRender;
public int mAudioSampleRate;
public long mBufferingStartTime;
public int mCurrentOpenRetryTimes;
public a0 mCurrentTask;
public boolean mEnableAnal;
public BigInteger mHttpBufferSize;
public boolean mIsAudioDataCallback;
public boolean mIsAudioRenderExternal;
public boolean mIsFastOpen;
public boolean mIsFirstAudioRendered;
public boolean mIsFirstVideoRendered;
public boolean mIsHardwareDecode;
public boolean mIsLiveStreaming;
public boolean mIsLooping;
public boolean mIsNeedChaseFrame;
public boolean mIsOpenConnectFailed;
public boolean mIsReadyToSeek;
public boolean mIsRunningPendingTasks;
public boolean mIsVideoDataCallback;
public boolean mIsVideoRenderExternal;
public JSONObject mMetadata;
public long mNativeContext;
public String mNetworkName;
public BroadcastReceiver mNetworkStatusReceiver;
public PLOnAudioFrameListener mOnAudioFrameListener;
public PLOnBufferingUpdateListener mOnBufferingUpdateListener;
public PLOnCompletionListener mOnCompletionListener;
public PLOnErrorListener mOnErrorListener;
public PLOnImageCapturedListener mOnImageCapturedListener;
public PLOnInfoListener mOnInfoListener;
public PLOnPreparedListener mOnPreparedListener;
public PLOnSeekCompleteListener mOnSeekCompleteListener;
public PLOnVideoFrameListener mOnVideoFrameListener;
public PLOnVideoSizeChangedListener mOnVideoSizeChangedListener;
public int mOpenRetryTimes;
public Queue<a0> mPendingTasks;
public PlayerState mPlayerState;
public int mSeekMode;
public long mStartTimestampMs;
public Surface mSurface;
public int mVideoBitrate;
public int mVideoFps;
public int mVideoHeight;
public String mVideoPath;
public int mVideoWidth;
public int mVolume;
public PowerManager.WakeLock mWakeLock;
public int streamtype;
public class a implements Runnable {
public a() {
}
@Override
public void run() {
MediaPlayer.this.getRtmpVideoTimestamp();
}
}
public class a0 {
public Runnable a;
public String b;
public boolean c = false;
public a0(Runnable runnable, String str) {
this.a = runnable;
this.b = str;
}
}
public class b implements Runnable {
public final int a;
public b(int i) {
this.a = i;
}
@Override
public void run() {
MediaPlayer.this.setPlaySpeed(this.a);
}
}
public class c implements Runnable {
public final float a;
public c(float f) {
this.a = f;
}
@Override
public void run() {
MediaPlayer.this.setVolume(this.a);
}
}
public class d implements Runnable {
public final String a;
public d(String str) {
this.a = str;
}
@Override
public void run() {
MediaPlayer.this.addCache(this.a);
}
}
public class e implements Runnable {
public final String a;
public e(String str) {
this.a = str;
}
@Override
public void run() {
MediaPlayer.this.delCache(this.a);
}
}
public class f implements Runnable {
public final String a;
public f(String str) {
this.a = str;
}
@Override
public void run() {
MediaPlayer.this.addIOCache(this.a);
}
}
public class g implements Runnable {
public final String a;
public g(String str) {
this.a = str;
}
@Override
public void run() {
MediaPlayer.this.delIOCache(this.a);
}
}
public class h implements Runnable {
public final Long a;
public h(Long l) {
this.a = l;
}
@Override
public void run() {
MediaPlayer.this.setIOCacheSize(this.a);
}
}
public class i implements Runnable {
public final boolean a;
public i(boolean z) {
this.a = z;
}
@Override
public void run() {
MediaPlayer.this.setVideoEnabled(this.a);
}
}
public class j implements Runnable {
public final int a;
public j(int i) {
this.a = i;
}
@Override
public void run() {
if (MediaPlayer.this.mOnPreparedListener != null) {
MediaPlayer.this.mOnPreparedListener.onPrepared(this.a);
}
}
}
public class k extends BroadcastReceiver {
public k() {
}
@Override
@TargetApi(11)
public void onReceive(Context context, Intent intent) {
if (MediaPlayer.ACTION_NET.equals(intent.getAction())) {
String stringExtra = intent.getStringExtra("extraInfo");
if (stringExtra != null && !stringExtra.equals(MediaPlayer.this.mNetworkName)) {
Logger.i(MediaPlayer.TAG, "onNetworkChanged !");
MediaPlayer.this.recordNetworkInfo();
MediaPlayer.this.setParam(536870912, 0);
}
MediaPlayer.this.mNetworkName = stringExtra;
}
}
}
public class l implements Runnable {
public final int a;
public final int b;
public l(int i, int i2) {
this.a = i;
this.b = i2;
}
@Override
public void run() {
synchronized (this) {
if (MediaPlayer.this.mOnInfoListener != null && MediaPlayer.this.mPlayerState != PlayerState.DESTROYED) {
Logger.i(MediaPlayer.TAG, "onInfo: " + this.a + ", " + this.b);
MediaPlayer.this.mOnInfoListener.onInfo(this.a, this.b);
}
}
}
}
public class m implements Runnable {
public m() {
}
@Override
public void run() {
if (MediaPlayer.this.mOnCompletionListener == null || MediaPlayer.this.mPlayerState == PlayerState.DESTROYED) {
return;
}
MediaPlayer.this.mOnCompletionListener.onCompletion();
}
}
public class n implements Runnable {
public final int a;
public n(int i) {
this.a = i;
}
@Override
public void run() {
if (this.a != -2003) {
if (MediaPlayer.this.mOnErrorListener == null || MediaPlayer.this.mPlayerState == PlayerState.DESTROYED) {
return;
}
MediaPlayer.this.mOnErrorListener.onError(this.a);
return;
}
MediaPlayer mediaPlayer = MediaPlayer.this;
mediaPlayer.nativeUninit(mediaPlayer.mNativeContext);
MediaPlayer mediaPlayer2 = MediaPlayer.this;
mediaPlayer2.mNativeContext = mediaPlayer2.nativeInit(new WeakReference(mediaPlayer2), MediaPlayer.this.mApkPath, 0, MediaPlayer.this.mEnableAnal);
MediaPlayer.this.prepareAsync();
}
}
public class o implements Runnable {
public final int a;
public o(int i) {
this.a = i;
}
@Override
public void run() {
if (MediaPlayer.this.mOnBufferingUpdateListener == null || MediaPlayer.this.mPlayerState == PlayerState.DESTROYED) {
return;
}
MediaPlayer.this.mOnBufferingUpdateListener.onBufferingUpdate(this.a);
}
}
public class p implements Runnable {
public final int a;
public final int b;
public p(int i, int i2) {
this.a = i;
this.b = i2;
}
@Override
public void run() {
if (MediaPlayer.this.mOnVideoSizeChangedListener != null) {
MediaPlayer.this.mOnVideoSizeChangedListener.onVideoSizeChanged(this.a, this.b);
}
}
}
public class q implements Runnable {
public q() {
}
@Override
public void run() {
if (MediaPlayer.this.mOnSeekCompleteListener != null) {
MediaPlayer.this.mOnSeekCompleteListener.onSeekComplete();
}
}
}
public class r implements Runnable {
public final String a;
public final Map b;
public r(String str, Map map) {
this.a = str;
this.b = map;
}
@Override
public void run() {
MediaPlayer.this.setDataSource(this.a, this.b);
}
}
public class s implements Runnable {
public final Surface a;
public s(Surface surface) {
this.a = surface;
}
@Override
public void run() {
MediaPlayer.this.setSurface(this.a);
}
}
public class t implements Runnable {
public t() {
}
@Override
public void run() {
MediaPlayer.this.prepareAsync();
}
}
public class u implements Runnable {
public u() {
}
@Override
public void run() {
MediaPlayer.this.start();
}
}
public class v implements Runnable {
public v() {
}
@Override
public void run() {
MediaPlayer.this.pause();
}
}
public class w implements Runnable {
public w() {
}
@Override
public void run() {
MediaPlayer.this.stop();
}
}
public class x implements Runnable {
public final int a;
public x(int i) {
this.a = i;
}
@Override
public void run() {
MediaPlayer.this.seekTo(this.a);
}
}
public class y implements Runnable {
public y() {
}
@Override
public void run() {
MediaPlayer.this.getRtmpAudioTimestamp();
}
}
static {
System.loadLibrary(TAG);
}
public MediaPlayer(Context context) {
this(context, null);
}
public static void audioDataFromNative(Object obj, byte[] bArr, int i2, long j2) {
MediaPlayer mediaPlayer = (MediaPlayer) ((WeakReference) obj).get();
if (mediaPlayer != null) {
if (mediaPlayer.mAudioRender.b() != null) {
mediaPlayer.mAudioRender.a(bArr, i2);
}
mediaPlayer.onAudioFrameAvailable(bArr, i2, mediaPlayer.getAudioSampleRate(), mediaPlayer.getAudioChannels(), 16, j2);
}
}
private String getNetworkName() {
String netType = Util.netType(this.mAppContext);
if (netType.equals(DeviceConfigInternal.UNKNOW) || netType.equals("None") || netType.isEmpty()) {
return null;
}
return Util.netType(this.mAppContext).equals("WIFI") ? Util.getWifiInfo(this.mAppContext)[0] : Util.getPhoneInfo(this.mAppContext)[0];
}
private int getParam(int i2, int i3) {
return nativeGetParam(this.mNativeContext, i2, i3, null);
}
private void init(Context context, boolean z2) {
Logger.i(TAG, "init: 2.2.2, QPlayer-v1.1.0.82, 16842834");
this.mEnableAnal = z2;
this.mAppContext = context.getApplicationContext();
this.mApkPath = context.getFilesDir().getAbsolutePath();
String str = this.mApkPath;
this.mApkPath = str.substring(0, str.lastIndexOf(47));
this.mApkPath += "/lib/";
this.mNativeContext = nativeInit(new WeakReference(this), this.mApkPath, this.mIsHardwareDecode ? 16777216 : 0, this.mEnableAnal);
this.mAudioRender = new z(this.mAppContext, this);
this.mNetworkName = getNetworkName();
recordBasicInfo();
this.mPlayerState = PlayerState.IDLE;
if (16842834 != getParam(272, 0)) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_VERSION_NOT_MATCH);
return;
}
Logger.i(TAG, "init done: " + this.mNativeContext);
}
private boolean isPending(String str) {
a0 a0Var = this.mCurrentTask;
if (a0Var == null || !a0Var.b.equals(str) || this.mCurrentTask.c) {
return this.mPlayerState == PlayerState.PREPARING || this.mIsRunningPendingTasks;
}
this.mCurrentTask.c = true;
return false;
}
private native long nativeGetDuration(long j2);
private native int nativeGetParam(long j2, int i2, int i3, Object obj);
private native long nativeGetPos(long j2);
public native long nativeInit(Object obj, String str, int i2, boolean z2);
private native int nativeOpen(long j2, String str, int i2);
private native int nativePause(long j2);
private native int nativePlay(long j2);
private native int nativeSetParam(long j2, int i2, int i3, Object obj);
private native int nativeSetPos(long j2, long j3);
private native int nativeSetView(long j2, Object obj);
private native int nativeStop(long j2);
public native int nativeUninit(long j2);
private void onAudioFrameAvailable(byte[] bArr, int i2, int i3, int i4, int i5, long j2) {
PLOnAudioFrameListener pLOnAudioFrameListener = this.mOnAudioFrameListener;
if (pLOnAudioFrameListener != null) {
pLOnAudioFrameListener.onAudioFrameAvailable(bArr, i2, i3, i4, i5, j2);
}
}
private void onBufferingUpdate(int i2) {
Logger.i(TAG, "onBufferingUpdate: " + i2);
new Handler(Looper.getMainLooper()).post(new o(i2));
}
private void onCompletion(MediaPlayer mediaPlayer) {
new Handler(Looper.getMainLooper()).post(new m());
}
private void onError(int i2) {
Logger.e(TAG, "onError: " + i2);
if (i2 == -4) {
this.mIsReadyToSeek = true;
}
new Handler(Looper.getMainLooper()).post(new n(i2));
}
private void onImageCaptured(byte[] bArr) {
PLOnImageCapturedListener pLOnImageCapturedListener = this.mOnImageCapturedListener;
if (pLOnImageCapturedListener != null) {
pLOnImageCapturedListener.onImageCaptured(bArr);
}
}
private void onInfo(MediaPlayer mediaPlayer, int i2, int i3) {
new Handler(Looper.getMainLooper()).post(new l(i2, i3));
}
private void onPrepared() {
this.mPlayerState = PlayerState.PREPARED;
this.mIsOpenConnectFailed = false;
this.mCurrentOpenRetryTimes = this.mOpenRetryTimes;
recordNetworkInfo();
int currentTimeMillis = (int) (System.currentTimeMillis() - this.mStartTimestampMs);
Logger.i(TAG, "onPrepared: " + currentTimeMillis + " ms");
int i2 = this.mVolume;
if (i2 >= 0) {
setParam(257, i2);
}
int i3 = this.mSeekMode;
if (i3 != -1) {
setParam(285212705, i3);
}
new Handler(Looper.getMainLooper()).post(new j(currentTimeMillis));
runPendingTasks(false);
}
private void onSeekComplete() {
Logger.i(TAG, "onSeekComplete");
this.mIsReadyToSeek = true;
new Handler(Looper.getMainLooper()).post(new q());
}
private void onVideoFrameAvailable(byte[] bArr, int i2, int i3, int i4, int i5, long j2) {
int i6 = i5 != 0 ? i5 != 32 ? -1 : 2 : 0;
PLOnVideoFrameListener pLOnVideoFrameListener = this.mOnVideoFrameListener;
if (pLOnVideoFrameListener != null) {
pLOnVideoFrameListener.onVideoFrameAvailable(bArr, i2, i3, i4, i6, j2);
}
}
private void onVideoSizeChanged(int i2, int i3) {
Logger.i(TAG, "onVideoSizeChanged");
setParam(256, 0);
new Handler(Looper.getMainLooper()).post(new p(i2, i3));
}
public static void postEventFromNative(Object obj, int i2, int i3, int i4, Object obj2) {
MediaPlayer mediaPlayer = (MediaPlayer) ((WeakReference) obj).get();
Logger.i(TAG, "postEventFromNative: " + Integer.toHexString(i2) + ", " + i3 + ", " + i4);
if (mResponseInfo == null) {
mResponseInfo = new ResponseInfo();
}
if (mediaPlayer != null) {
switch (i2) {
case vf0.X:
mResponseInfo.setConnectStart(i3);
return;
case 285212674:
case 285212752:
case vf0.j0:
case vf0.n0:
case vf0.p0:
case vf0.q0:
if (mediaPlayer.mPlayerState != PlayerState.PREPARING) {
mediaPlayer.mPlayerState = PlayerState.RECONNECTING;
}
mediaPlayer.onError(-3);
return;
case 285212675:
mResponseInfo.setConnectSuccess(i3);
ResponseInfo responseInfo = mResponseInfo;
responseInfo.setConnectTime(responseInfo.getConnectSuccess() - mResponseInfo.getConnectStart());
mediaPlayer.onInfo(mediaPlayer, 200, i3);
return;
case vf0.a0:
mResponseInfo.setDnsStart(i3);
return;
case 285212677:
mResponseInfo.setDnsDone(i3);
if (obj2 != null) {
mResponseInfo.setIp(obj2.toString());
}
ResponseInfo responseInfo2 = mResponseInfo;
responseInfo2.setDnsTime(responseInfo2.getDnsDone() - mResponseInfo.getDnsStart());
return;
case 285212678:
mResponseInfo.setDnsDone(i3);
if (obj2 != null) {
mResponseInfo.setIp(obj2.toString());
}
ResponseInfo responseInfo3 = mResponseInfo;
responseInfo3.setDnsTime(responseInfo3.getDnsDone() - mResponseInfo.getDnsStart());
return;
case vf0.d0:
mResponseInfo.setGetHeadData(i3);
ResponseInfo responseInfo4 = mResponseInfo;
responseInfo4.setResponseTime(responseInfo4.getGetHeadData() - mResponseInfo.getConnectStart());
return;
case vf0.s0:
mResponseInfo.setResponseCode(i3);
return;
case vf0.k0:
case vf0.o0:
case vf0.r0:
mediaPlayer.onInfo(mediaPlayer, 200, i3);
return;
case 285212768:
if (mediaPlayer.mPlayerState != PlayerState.DESTROYED) {
mediaPlayer.onBufferingUpdate(100);
return;
}
return;
case 285212769:
ResponseInfo responseInfo5 = mResponseInfo;
responseInfo5.setReceiveBytes((responseInfo5.getContentSize() * i3) / 100);
if (mediaPlayer.mPlayerState != PlayerState.DESTROYED) {
mediaPlayer.onBufferingUpdate(i3);
return;
}
return;
case 285212770:
mResponseInfo.setContentSize(i3);
return;
case 285212771:
mediaPlayer.mHttpBufferSize = new BigInteger(Integer.toBinaryString(i4) + Integer.toBinaryString(i3), 2);
return;
case vf0.w0:
if (obj2 != null) {
mResponseInfo.setContentType(obj2.toString());
return;
}
return;
case vf0.x0:
mResponseInfo.setSendBytes(i3);
return;
case vf0.z0:
try {
mediaPlayer.mMetadata = new JSONObject((String) obj2);
Logger.i(TAG, "length = " + mediaPlayer.mMetadata.length());
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_METADATA, 0);
return;
} catch (JSONException unused) {
Logger.e(TAG, "JsonException when parsing metadata");
return;
}
case vf0.A0:
mResponseInfo.setFirstByteDone(i3);
ResponseInfo responseInfo6 = mResponseInfo;
responseInfo6.setFirstPacketTime(responseInfo6.getFirstByteDone() - mResponseInfo.getConnectSuccess());
return;
case vf0.B0:
if (i3 == 2) {
mediaPlayer.onInfo(mediaPlayer, 701, 0);
return;
}
return;
case vf0.C0:
mResponseInfo.setSslStart(i3);
return;
case vf0.E0:
mResponseInfo.setSslDone(i3);
ResponseInfo responseInfo7 = mResponseInfo;
responseInfo7.setSslTime(responseInfo7.getSslDone() - mResponseInfo.getSslStart());
return;
case vf0.I0:
mediaPlayer.mPlayerState = PlayerState.ERROR;
mediaPlayer.onError(PLOnErrorListener.ERROR_CODE_HW_DECODE_FAILURE);
return;
case vf0.J0:
if (!mediaPlayer.mIsFirstAudioRendered) {
mediaPlayer.mIsFirstAudioRendered = true;
mediaPlayer.onInfo(mediaPlayer, 10002, (int) (System.currentTimeMillis() - mediaPlayer.mStartTimestampMs));
}
mediaPlayer.onInfo(mediaPlayer, 702, 0);
return;
case vf0.K0:
if (i3 <= 0 || i4 <= 0) {
return;
}
mediaPlayer.mAudioSampleRate = i3;
mediaPlayer.mAudioChannels = i4;
if (mediaPlayer.mAudioRender.a(i3, i4) != 0 || mediaPlayer.mAudioRender.b().getState() == 0) {
mediaPlayer.onError(PLOnErrorListener.ERROR_CODE_PLAYER_CREATE_AUDIO_FAILED);
return;
}
return;
case vf0.L0:
mediaPlayer.onInfo(mediaPlayer, 10005, i3);
if (mediaPlayer.mPlayerState == PlayerState.RECONNECTING) {
mediaPlayer.mPlayerState = PlayerState.PLAYING_CACHE;
return;
} else {
mediaPlayer.mPlayerState = PlayerState.PLAYING;
return;
}
case vf0.M0:
if (!mediaPlayer.mIsFirstVideoRendered) {
mediaPlayer.mIsFirstVideoRendered = true;
mediaPlayer.onInfo(mediaPlayer, 3, (int) (System.currentTimeMillis() - mediaPlayer.mStartTimestampMs));
}
mediaPlayer.onInfo(mediaPlayer, 702, 0);
return;
case vf0.N0:
if (i3 <= 0 || i4 <= 0) {
return;
}
mediaPlayer.mVideoWidth = i3;
mediaPlayer.mVideoHeight = i4;
mediaPlayer.onVideoSizeChanged(i3, i4);
return;
case vf0.O0:
mediaPlayer.onInfo(mediaPlayer, 10004, i3);
if (mediaPlayer.mPlayerState == PlayerState.RECONNECTING) {
mediaPlayer.mPlayerState = PlayerState.PLAYING_CACHE;
return;
} else {
mediaPlayer.mPlayerState = PlayerState.PLAYING;
return;
}
case vf0.P0:
mediaPlayer.onInfo(mediaPlayer, 10001, i3);
return;
case vf0.V0:
mediaPlayer.onPrepared();
return;
case vf0.W0:
if (mediaPlayer.mCurrentOpenRetryTimes <= 0 || i3 != -2147483632) {
mediaPlayer.mIsOpenConnectFailed = false;
mediaPlayer.mPlayerState = PlayerState.ERROR;
}
if (i3 == -2147483632) {
mediaPlayer.mIsOpenConnectFailed = true;
}
mediaPlayer.onError(-2);
return;
case vf0.Y0:
mediaPlayer.onSeekComplete();
return;
case vf0.Z0:
mediaPlayer.mPlayerState = PlayerState.ERROR;
mediaPlayer.onError(-4);
return;
case vf0.X0:
if (i3 == 0) {
mediaPlayer.mPlayerState = PlayerState.COMPLETED;
mediaPlayer.onCompletion(mediaPlayer);
return;
} else if (i3 != 1) {
return;
} else {
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_CACHED_COMPLETE, 0);
return;
}
case vf0.a1:
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_LOOP_DONE, i3);
return;
case vf0.b1:
mediaPlayer.onInfo(mediaPlayer, 901, 0);
return;
case vf0.c1:
if (mediaPlayer.mPlayerState != PlayerState.DESTROYED) {
mediaPlayer.onError(-5);
return;
}
return;
case vf0.f1:
mediaPlayer.onInfo(mediaPlayer, 10003, i3);
return;
case vf0.g1:
mediaPlayer.mVideoFps = i3;
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_VIDEO_FPS, i3);
return;
case vf0.h1:
mediaPlayer.mAudioFps = i3;
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_AUDIO_FPS, i3);
return;
case vf0.i1:
mediaPlayer.mVideoBitrate = i3;
mediaPlayer.onInfo(mediaPlayer, 20001, i3);
return;
case vf0.j1:
mediaPlayer.mAudioBitrate = i3;
mediaPlayer.onInfo(mediaPlayer, PLOnInfoListener.MEDIA_INFO_AUDIO_BITRATE, i3);
return;
case vf0.k1:
mediaPlayer.mPlayerState = PlayerState.BUFFERING;
mediaPlayer.mBufferingStartTime = System.currentTimeMillis();
mediaPlayer.onInfo(mediaPlayer, 701, i3);
return;
case vf0.l1:
mediaPlayer.mPlayerState = PlayerState.PLAYING;
mediaPlayer.onInfo(mediaPlayer, 702, (int) (System.currentTimeMillis() - mediaPlayer.mBufferingStartTime));
return;
default:
return;
}
}
}
private void recordBasicInfo() {
String replaceNull = Util.replaceNull(Util.getDeviceId(this.mAppContext));
String replaceNull2 = Util.replaceNull(Util.appName(this.mAppContext));
String replaceNull3 = Util.replaceNull(Util.appVersion(this.mAppContext));
setParam(vf0.I1, replaceNull);
setParam(vf0.J1, Config.VERSION);
setParam(vf0.H1, replaceNull2);
setParam(vf0.G1, replaceNull3);
}
public void recordNetworkInfo() {
String[] phoneInfo;
int parseInt;
String str;
String netType = Util.netType(this.mAppContext);
boolean equals = netType.equals("WIFI");
boolean equals2 = netType.equals("None");
String str2 = null;
int i2 = 0;
if (equals) {
String[] wifiInfo = Util.getWifiInfo(this.mAppContext);
if (wifiInfo != null && wifiInfo.length >= 2) {
str = wifiInfo[0];
if (Util.isNumber(wifiInfo[1])) {
i2 = Integer.parseInt(wifiInfo[1]);
}
parseInt = 0;
setParam(vf0.B1, Util.replaceNull(netType));
setParam(vf0.C1, Util.replaceNull(str2));
setParam(vf0.D1, Util.replaceNull(str));
setParam(vf0.E1, i2);
setParam(vf0.F1, parseInt);
Logger.i(TAG, "network info: " + netType + ", " + str2 + ", " + str + ", " + i2 + ", " + parseInt);
}
} else if (!equals2 && (phoneInfo = Util.getPhoneInfo(this.mAppContext)) != null && phoneInfo.length >= 2) {
String str3 = phoneInfo[0];
parseInt = Util.isNumber(phoneInfo[1]) ? Integer.parseInt(phoneInfo[1]) : 0;
str2 = str3;
str = null;
setParam(vf0.B1, Util.replaceNull(netType));
setParam(vf0.C1, Util.replaceNull(str2));
setParam(vf0.D1, Util.replaceNull(str));
setParam(vf0.E1, i2);
setParam(vf0.F1, parseInt);
Logger.i(TAG, "network info: " + netType + ", " + str2 + ", " + str + ", " + i2 + ", " + parseInt);
}
str = null;
parseInt = 0;
setParam(vf0.B1, Util.replaceNull(netType));
setParam(vf0.C1, Util.replaceNull(str2));
setParam(vf0.D1, Util.replaceNull(str));
setParam(vf0.E1, i2);
setParam(vf0.F1, parseInt);
Logger.i(TAG, "network info: " + netType + ", " + str2 + ", " + str + ", " + i2 + ", " + parseInt);
}
private void runPendingTasks(boolean z2) {
int i2;
if (z2 && this.mIsOpenConnectFailed && (i2 = this.mCurrentOpenRetryTimes) > 0) {
this.mCurrentOpenRetryTimes = i2 - 1;
Logger.i(TAG, "reconnect on open failed, " + this.mCurrentOpenRetryTimes + " times left");
prepareAsync();
return;
}
while (!this.mPendingTasks.isEmpty()) {
this.mIsRunningPendingTasks = true;
this.mCurrentTask = this.mPendingTasks.poll();
this.mCurrentTask.a.run();
if (this.mCurrentTask.b.equals("prepareAsync")) {
return;
}
}
this.mIsRunningPendingTasks = false;
}
public void setParam(int i2, int i3) {
nativeSetParam(this.mNativeContext, i2, i3, null);
}
public static void videoDataFromNative(Object obj, byte[] bArr, int i2, long j2, int i3) {
MediaPlayer mediaPlayer = (MediaPlayer) ((WeakReference) obj).get();
if (mediaPlayer != null) {
if (i3 == 16) {
mediaPlayer.onImageCaptured(bArr);
Logger.i(TAG, "captureImage -");
return;
}
mediaPlayer.onVideoFrameAvailable(bArr, i2, mediaPlayer.getVideoWidth(), mediaPlayer.getVideoHeight(), i3, j2);
}
}
public void addCache(String str) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("addCache")) {
this.mPendingTasks.add(new a0(new d(str), "addCache"));
Logger.i(TAG, "addCache *");
} else {
setParam(vf0.M, str);
Logger.i(TAG, "add Cache: " + str);
}
}
public void addIOCache(String str) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("addIOCache")) {
this.mPendingTasks.add(new a0(new f(str), "addIOCache"));
Logger.i(TAG, "addIOCache *");
} else {
setParam(vf0.O, str);
Logger.i(TAG, "add IOCache: " + str);
}
}
public void captureImage(long j2) {
Logger.i(TAG, "captureImage +");
setParam(vf0.G, j2);
}
public void delCache(String str) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("delCache")) {
this.mPendingTasks.add(new a0(new e(str), "delCache"));
Logger.i(TAG, "delCache *");
} else {
setParam(vf0.N, str);
Logger.i(TAG, "del Cache: " + str);
}
}
public void delIOCache(String str) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("delIOCache")) {
this.mPendingTasks.add(new a0(new g(str), "delIOCache"));
Logger.i(TAG, "delIOCache *");
} else {
setParam(vf0.P, str);
Logger.i(TAG, "del IOCache: " + str);
}
}
public int getAudioBitrate() {
return this.mAudioBitrate;
}
public int getAudioChannels() {
return this.mAudioChannels;
}
public int getAudioFps() {
return this.mAudioFps;
}
public int getAudioSampleRate() {
return this.mAudioSampleRate;
}
public long getCurrentPosition() {
return nativeGetPos(this.mNativeContext);
}
public String getDataSource() {
return this.mVideoPath;
}
public long getDuration() {
return nativeGetDuration(this.mNativeContext);
}
public BigInteger getHttpBufferSize() {
return this.mHttpBufferSize;
}
public HashMap<String, String> getMetadata() {
if (this.mMetadata == null) {
Logger.e(TAG, "Null metadata");
return null;
}
HashMap<String, String> hashMap = new HashMap<>();
Iterator<String> keys = this.mMetadata.keys();
while (keys.hasNext()) {
try {
String next = keys.next();
hashMap.put(next, this.mMetadata.getString(next));
} catch (JSONException unused) {
Logger.e(TAG, "Error when parsing metadata");
}
}
return hashMap;
}
public PlayerState getPlayerState() {
return this.mPlayerState;
}
public String getResponseInfo() {
return mResponseInfo.toString();
}
public long getRtmpAudioTimestamp() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
return -1L;
} else if (isPending("getRtmpAudioTimestamp")) {
this.mPendingTasks.add(new a0(new y(), "getRtmpAudioTimestamp"));
Logger.i(TAG, "getRtmpAudioTimestamp *");
return -1L;
} else {
return getParam(vf0.C, 0);
}
}
public long getRtmpVideoTimestamp() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
return -1L;
} else if (isPending("getRtmpVideoTimestamp")) {
this.mPendingTasks.add(new a0(new a(), "getRtmpVideoTimestamp"));
Logger.i(TAG, "getRtmpVideoTimestamp *");
return -1L;
} else {
return getParam(vf0.D, 0);
}
}
public int getVideoBitrate() {
return this.mVideoBitrate;
}
public int getVideoFps() {
return this.mVideoFps;
}
public int getVideoHeight() {
return this.mVideoHeight;
}
public int getVideoWidth() {
return this.mVideoWidth;
}
public boolean isLooping() {
return this.mIsLooping;
}
public boolean isPlaying() {
PlayerState playerState = this.mPlayerState;
return playerState == PlayerState.PLAYING || playerState == PlayerState.PLAYING_CACHE;
}
public void pause() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("pause")) {
this.mPendingTasks.add(new a0(new v(), "pause"));
Logger.i(TAG, "pause *");
} else {
Logger.i(TAG, "pause + State: " + this.mPlayerState);
if (nativePause(this.mNativeContext) == 0) {
this.mPlayerState = PlayerState.PAUSED;
onInfo(this, PLOnInfoListener.MEDIA_INFO_STATE_CHANGED_PAUSED, 0);
}
if (this.mIsLiveStreaming) {
this.mIsNeedChaseFrame = true;
}
Logger.i(TAG, "pause -");
}
}
public void prepareAsync() {
if (this.mVideoPath != null) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
return;
} else if (isPending("prepareAsync")) {
this.mPendingTasks.add(new a0(new t(), "prepareAsync"));
Logger.i(TAG, "prepareAsync *");
return;
} else {
Logger.i(TAG, "prepareAsync State: " + this.mPlayerState);
this.mIsFirstVideoRendered = false;
this.mIsFirstAudioRendered = false;
this.mStartTimestampMs = System.currentTimeMillis();
this.mPlayerState = PlayerState.PREPARING;
setSurface(this.mSurface);
int nativeOpen = nativeOpen(this.mNativeContext, this.mVideoPath, this.mIsFastOpen ? 33554432 : 0);
mResponseInfo = new ResponseInfo();
mResponseInfo.setUrl(this.mVideoPath);
if (this.mVideoPath.lastIndexOf(63) != -1) {
String str = this.mVideoPath;
mResponseInfo.setQuery(str.substring(str.lastIndexOf(63) + 1));
}
if (nativeOpen != 0) {
Logger.e(TAG, "Invalid surfaceHolder");
onError(-1);
return;
}
Logger.i(TAG, "nativeOpen: " + nativeOpen);
if (this.mIsVideoDataCallback || this.mIsVideoRenderExternal) {
setParam(vf0.V, this.mIsVideoRenderExternal ? 1 : 0);
}
if (this.mIsAudioDataCallback || this.mIsAudioRenderExternal) {
setParam(vf0.W, this.mIsAudioRenderExternal ? 1 : 0);
return;
}
return;
}
}
throw new IllegalStateException("must call setDataSource first !");
}
public void release() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
return;
}
Logger.i(TAG, "release + State: " + this.mPlayerState);
synchronized (this) {
if (this.mAppContext != null && this.mNetworkStatusReceiver != null) {
this.mAppContext.unregisterReceiver(this.mNetworkStatusReceiver);
this.mNetworkStatusReceiver = null;
this.mAppContext = null;
}
if (nativeUninit(this.mNativeContext) == 0) {
onInfo(this, PLOnInfoListener.MEDIA_INFO_STATE_CHANGED_RELEASED, 0);
this.mPlayerState = PlayerState.DESTROYED;
}
if (this.mAudioRender != null) {
this.mAudioRender.a();
this.mAudioRender = null;
}
this.mPendingTasks.clear();
this.mCurrentTask = null;
this.mIsRunningPendingTasks = false;
if (this.mOnPreparedListener != null) {
this.mOnPreparedListener = null;
}
if (this.mOnInfoListener != null) {
this.mOnInfoListener = null;
}
if (this.mOnCompletionListener != null) {
this.mOnCompletionListener = null;
}
if (this.mOnErrorListener != null) {
this.mOnErrorListener = null;
}
if (this.mOnBufferingUpdateListener != null) {
this.mOnBufferingUpdateListener = null;
}
if (this.mOnVideoSizeChangedListener != null) {
this.mOnVideoSizeChangedListener = null;
}
if (this.mOnSeekCompleteListener != null) {
this.mOnSeekCompleteListener = null;
}
if (this.mOnVideoFrameListener != null) {
this.mOnVideoFrameListener = null;
}
if (this.mOnAudioFrameListener != null) {
this.mOnAudioFrameListener = null;
}
if (this.mOnImageCapturedListener != null) {
this.mOnImageCapturedListener = null;
}
}
Logger.i(TAG, "release -");
}
public void seekTo(int i2) {
PlayerState playerState = this.mPlayerState;
if (playerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (!this.mIsReadyToSeek) {
onInfo(this, 565, 0);
} else if (playerState == PlayerState.PREPARING) {
this.mPendingTasks.add(new a0(new x(i2), "seekTo"));
Logger.i(TAG, "seekTo *");
} else {
Logger.i(TAG, "seekTo " + i2);
this.mStartTimestampMs = System.currentTimeMillis();
this.mIsReadyToSeek = false;
nativeSetPos(this.mNativeContext, (long) i2);
Logger.i(TAG, "seekTo -");
}
}
public void setAVOptions(AVOptions aVOptions) {
String[] stringArray;
if (aVOptions == null) {
Logger.i(TAG, "Null AVOptions param");
return;
}
if (aVOptions.containsKey(AVOptions.KEY_LOG_LEVEL)) {
int integer = aVOptions.getInteger(AVOptions.KEY_LOG_LEVEL, 2);
Logger.setLevel(integer);
Logger.i(TAG, "log level: " + integer);
if (integer == -1) {
setParam(vf0.T, 5);
} else {
setParam(vf0.T, Logger.LEVEL_NUM - integer);
}
}
if (aVOptions.containsKey(AVOptions.KEY_DNS_SERVER)) {
setParam(vf0.E, aVOptions.getString(AVOptions.KEY_DNS_SERVER));
Logger.i(TAG, "setAVOptions dns server: " + aVOptions.getString(AVOptions.KEY_DNS_SERVER));
}
if (aVOptions.containsKey(AVOptions.KEY_DOMAIN_LIST) && (stringArray = aVOptions.getStringArray(AVOptions.KEY_DOMAIN_LIST)) != null && stringArray.length > 0) {
for (String str : stringArray) {
setParam(vf0.F, str);
}
}
if (aVOptions.containsKey(AVOptions.KEY_OPEN_RETRY_TIMES)) {
this.mOpenRetryTimes = aVOptions.getInteger(AVOptions.KEY_OPEN_RETRY_TIMES);
this.mCurrentOpenRetryTimes = aVOptions.getInteger(AVOptions.KEY_OPEN_RETRY_TIMES);
Logger.i(TAG, "setAVOptions open retry times: " + this.mCurrentOpenRetryTimes);
}
if (aVOptions.containsKey(AVOptions.KEY_SEEK_MODE)) {
this.mSeekMode = aVOptions.getInteger(AVOptions.KEY_SEEK_MODE);
Logger.i(TAG, "setAVOptions seek mode " + this.mSeekMode);
}
if (aVOptions.containsKey(AVOptions.KEY_LIVE_STREAMING)) {
this.mIsLiveStreaming = aVOptions.getInteger(AVOptions.KEY_LIVE_STREAMING, 0) == 1;
}
if (aVOptions.containsKey(AVOptions.KEY_PREPARE_TIMEOUT)) {
int integer2 = aVOptions.getInteger(AVOptions.KEY_PREPARE_TIMEOUT);
setParam(vf0.H, integer2);
Logger.i(TAG, "setAVOptions KEY_PREPARE_TIMEOUT: " + integer2);
}
if (aVOptions.containsKey(AVOptions.KEY_CACHE_BUFFER_DURATION)) {
int integer3 = aVOptions.getInteger(AVOptions.KEY_CACHE_BUFFER_DURATION, 500);
setParam(vf0.L, integer3);
Logger.i(TAG, "setAVOptions KEY_CACHE_BUFFER_DURATION: " + integer3);
}
if (aVOptions.containsKey(AVOptions.KEY_MAX_CACHE_BUFFER_DURATION)) {
int integer4 = aVOptions.getInteger(AVOptions.KEY_MAX_CACHE_BUFFER_DURATION, 2000);
setParam(vf0.K, integer4);
Logger.i(TAG, "setAVOptions KEY_MAX_CACHE_BUFFER_DURATION: " + integer4);
}
if (aVOptions.containsKey(AVOptions.KEY_DRM_KEY)) {
nativeSetParam(this.mNativeContext, vf0.R, 0, aVOptions.getByteArray(AVOptions.KEY_DRM_KEY));
Logger.i(TAG, "setAVOptions KEY_DRM_KEY");
}
if (aVOptions.containsKey(AVOptions.KEY_COMP_DRM_KEY)) {
setParam(vf0.S, aVOptions.getString(AVOptions.KEY_COMP_DRM_KEY));
Logger.i(TAG, "setAVOptions COMP_DRM_KEY");
}
if (aVOptions.containsKey(AVOptions.KEY_CACHE_DIR)) {
String string = aVOptions.getString(AVOptions.KEY_CACHE_DIR);
if (aVOptions.containsKey(AVOptions.KEY_CACHE_EXT)) {
String string2 = aVOptions.getString(AVOptions.KEY_CACHE_EXT);
setParam(285212770, string2);
Logger.i(TAG, "setAVOptions cache ext: " + string2);
}
if (aVOptions.containsKey(AVOptions.KEY_CACHE_FILE_NAME_ENCODE)) {
int integer5 = aVOptions.getInteger(AVOptions.KEY_CACHE_FILE_NAME_ENCODE);
setParam(285212771, integer5);
Logger.i(TAG, "setAVOptions cache file name encode: " + integer5);
}
setParam(285212768, 6);
setParam(285212769, string);
Logger.i(TAG, "setAVOptions cache dir: " + string);
}
if (aVOptions.containsKey(AVOptions.KEY_PREFER_FORMAT)) {
int integer6 = aVOptions.getInteger(AVOptions.KEY_PREFER_FORMAT);
setParam(285212752, integer6);
Logger.i(TAG, "setAVOptions prefer format: " + integer6);
}
if (aVOptions.containsKey(AVOptions.KEY_FAST_OPEN)) {
this.mIsFastOpen = true;
}
if (aVOptions.containsKey(AVOptions.KEY_START_POSITION)) {
int integer7 = aVOptions.getInteger(AVOptions.KEY_START_POSITION);
setParam(285212706, integer7);
Logger.i(TAG, "setAVOptions start pos: " + integer7);
}
if (aVOptions.containsKey(AVOptions.KEY_MP4_PRELOAD)) {
int integer8 = aVOptions.getInteger(AVOptions.KEY_MP4_PRELOAD);
setParam(vf0.d, integer8);
Logger.i(TAG, "setAVOptions mp4 preload: " + integer8);
}
if (aVOptions.containsKey(AVOptions.KEY_SDK_ID)) {
String string3 = aVOptions.getString(AVOptions.KEY_SDK_ID);
SharedPreferences.Editor edit = this.mAppContext.getSharedPreferences(mn3.d, 0).edit();
edit.putString("deviceId", string3);
edit.commit();
Logger.i(TAG, "setAVOptions sdk id: " + string3);
}
this.mIsVideoDataCallback = aVOptions.getInteger(AVOptions.KEY_VIDEO_DATA_CALLBACK, 0) == 1;
this.mIsAudioDataCallback = aVOptions.getInteger(AVOptions.KEY_AUDIO_DATA_CALLBACK, 0) == 1;
this.mIsVideoRenderExternal = aVOptions.getInteger(AVOptions.KEY_VIDEO_RENDER_EXTERNAL, 0) == 1;
this.mIsAudioRenderExternal = aVOptions.getInteger(AVOptions.KEY_AUDIO_RENDER_EXTERNAL, 0) == 1;
Logger.i(TAG, "setAVOptions [v_callback, a_callback, v_render, a_render]: " + this.mIsVideoDataCallback + ", " + this.mIsAudioDataCallback + ", " + this.mIsVideoRenderExternal + ", " + this.mIsAudioRenderExternal);
}
public void setBufferingEnabled(boolean z2) {
Logger.i(TAG, "setBufferingEnabled +");
setParam(vf0.r, !z2 ? 1 : 0);
Logger.i(TAG, "setBufferingEnabled -");
}
public void setDataSource(String str) {
setDataSource(str, null);
}
public void setDisplay(SurfaceHolder surfaceHolder) {
if (surfaceHolder == null) {
setSurface(null);
this.mSurface = null;
return;
}
this.mSurface = surfaceHolder.getSurface();
setSurface(surfaceHolder.getSurface());
}
public void setIOCacheSize(Long l2) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("setIOCacheSize")) {
this.mPendingTasks.add(new a0(new h(l2), "setIOCacheSize"));
Logger.i(TAG, "setIOCacheSize *");
} else if (l2.longValue() >= 0) {
setParam(vf0.Q, l2.longValue());
Logger.i(TAG, "set IOCache size: " + l2);
} else {
Logger.e(TAG, "Invalid size value");
}
}
public void setLooping(boolean z2) {
Logger.i(TAG, "setLooping " + z2);
this.mIsLooping = z2;
setParam(vf0.U, z2 ? 1 : 0);
}
public void setOnAudioFrameListener(PLOnAudioFrameListener pLOnAudioFrameListener) {
this.mOnAudioFrameListener = pLOnAudioFrameListener;
}
public void setOnBufferingUpdateListener(PLOnBufferingUpdateListener pLOnBufferingUpdateListener) {
this.mOnBufferingUpdateListener = pLOnBufferingUpdateListener;
}
public void setOnCompletionListener(PLOnCompletionListener pLOnCompletionListener) {
this.mOnCompletionListener = pLOnCompletionListener;
}
public void setOnErrorListener(PLOnErrorListener pLOnErrorListener) {
this.mOnErrorListener = pLOnErrorListener;
}
public void setOnImageCapturedListener(PLOnImageCapturedListener pLOnImageCapturedListener) {
this.mOnImageCapturedListener = pLOnImageCapturedListener;
}
public void setOnInfoListener(PLOnInfoListener pLOnInfoListener) {
this.mOnInfoListener = pLOnInfoListener;
}
public void setOnPreparedListener(PLOnPreparedListener pLOnPreparedListener) {
this.mOnPreparedListener = pLOnPreparedListener;
}
public void setOnSeekCompleteListener(PLOnSeekCompleteListener pLOnSeekCompleteListener) {
this.mOnSeekCompleteListener = pLOnSeekCompleteListener;
}
public void setOnVideoFrameListener(PLOnVideoFrameListener pLOnVideoFrameListener) {
this.mOnVideoFrameListener = pLOnVideoFrameListener;
}
public void setOnVideoSizeChangedListener(PLOnVideoSizeChangedListener pLOnVideoSizeChangedListener) {
this.mOnVideoSizeChangedListener = pLOnVideoSizeChangedListener;
}
public boolean setPlaySpeed(int i2) {
if (this.mNativeContext == 0 || this.mIsLiveStreaming) {
return false;
}
if (isPending("setPlaySpeed")) {
this.mPendingTasks.add(new a0(new b(i2), "setPlaySpeed"));
Logger.i(TAG, "setPlaySpeed *");
return false;
}
setParam(285212674, i2);
Logger.i(TAG, "setPlaySpeed: " + Integer.toHexString(i2));
return true;
}
public void setSurface(Surface surface) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("setSurface")) {
this.mPendingTasks.add(new a0(new s(surface), "setSurface"));
Logger.i(TAG, "setSurface *");
} else {
Logger.i(TAG, "setSurface + State: " + this.mPlayerState);
this.mSurface = surface;
nativeSetView(this.mNativeContext, surface);
Logger.i(TAG, "setSurface -");
}
}
public void setVideoArea(int i2, int i3, int i4, int i5) {
Logger.i(TAG, "setVideoArea +");
nativeSetParam(this.mNativeContext, vf0.l, 0, new int[]{i2, i3, i4, i5});
Logger.i(TAG, "setVideoArea -");
}
public void setVideoEnabled(boolean z2) {
if (isPending("setVideoEnabled")) {
this.mPendingTasks.add(new a0(new i(z2), "setVideoEnabled"));
Logger.i(TAG, "setVideoEnabled *");
return;
}
setParam(285212675, !z2 ? 1 : 0);
}
public void setVolume(float f2) {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("setVolume")) {
this.mPendingTasks.add(new a0(new c(f2), "setVolume"));
Logger.i(TAG, "setVolume *");
} else if (f2 >= 0.0f) {
this.mVolume = (int) (f2 * 100.0f);
setParam(257, this.mVolume);
} else {
Logger.e(TAG, "Invalid volume value");
}
}
public void setWakeMode(Context context, int i2) {
boolean z2;
PowerManager.WakeLock wakeLock = this.mWakeLock;
if (wakeLock != null) {
if (wakeLock.isHeld()) {
z2 = true;
this.mWakeLock.release();
} else {
z2 = false;
}
this.mWakeLock = null;
} else {
z2 = false;
}
this.mWakeLock = ((PowerManager) context.getSystemService("power")).newWakeLock(i2 | 536870912, PLMediaPlayer.class.getName());
this.mWakeLock.setReferenceCounted(false);
if (z2) {
this.mWakeLock.acquire();
}
}
public void start() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("start")) {
this.mPendingTasks.add(new a0(new u(), "start"));
Logger.i(TAG, "start *");
} else {
Logger.i(TAG, "start + State: " + this.mPlayerState);
this.mPlayerState = PlayerState.PLAYING;
if (this.mIsLiveStreaming && this.mIsNeedChaseFrame) {
setParam(vf0.p, 0);
this.mIsNeedChaseFrame = false;
}
nativePlay(this.mNativeContext);
Logger.i(TAG, "start -");
}
}
public void stop() {
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending(Constants.Value.STOP)) {
this.mPendingTasks.add(new a0(new w(), Constants.Value.STOP));
Logger.i(TAG, "stop *");
} else {
Logger.i(TAG, "stop + State: " + this.mPlayerState);
this.mPlayerState = PlayerState.COMPLETED;
this.mIsReadyToSeek = true;
nativeStop(this.mNativeContext);
Logger.i(TAG, "stop -");
}
}
public MediaPlayer(Context context, AVOptions aVOptions) {
this.streamtype = 3;
if (aVOptions != null && aVOptions.containsKey("AUDIO_STREAM_TYPE")) {
this.streamtype = aVOptions.getInteger("AUDIO_STREAM_TYPE");
}
this.mNativeContext = 0L;
this.mIsFastOpen = false;
this.mIsHardwareDecode = false;
this.mIsLooping = false;
this.mStartTimestampMs = -1L;
this.mPlayerState = PlayerState.DESTROYED;
this.mBufferingStartTime = -1L;
this.mIsLiveStreaming = false;
this.mIsNeedChaseFrame = false;
this.mVolume = -1;
this.mSeekMode = -1;
this.mEnableAnal = true;
this.mOpenRetryTimes = 0;
this.mCurrentOpenRetryTimes = 0;
this.mVideoWidth = 0;
this.mVideoHeight = 0;
this.mVideoBitrate = 0;
this.mAudioBitrate = 0;
this.mVideoFps = 0;
this.mAudioFps = 0;
this.mHttpBufferSize = new BigInteger("0");
this.mIsVideoDataCallback = false;
this.mIsAudioDataCallback = false;
this.mIsVideoRenderExternal = false;
this.mIsAudioRenderExternal = false;
this.mIsFirstVideoRendered = false;
this.mIsFirstAudioRendered = false;
this.mIsReadyToSeek = true;
this.mIsOpenConnectFailed = false;
this.mNetworkName = null;
this.mWakeLock = null;
this.mIsRunningPendingTasks = false;
this.mNetworkStatusReceiver = new k();
if (aVOptions != null && aVOptions.containsKey(AVOptions.KEY_MEDIACODEC)) {
int integer = aVOptions.getInteger(AVOptions.KEY_MEDIACODEC);
if (integer == 2 || integer == 1) {
this.mIsHardwareDecode = true;
}
Logger.i(TAG, "setAVOptions Hardware Decode: " + this.mIsHardwareDecode);
}
init(context, true);
setAVOptions(aVOptions);
BroadcastReceiver broadcastReceiver = this.mNetworkStatusReceiver;
if (broadcastReceiver != null) {
context.registerReceiver(broadcastReceiver, new IntentFilter(ACTION_NET));
}
this.mPendingTasks = new ArrayDeque();
}
private void setParam(int i2, long j2) {
nativeSetParam(this.mNativeContext, i2, 0, Long.valueOf(j2));
}
public void setDataSource(String str, Map<String, String> map) {
this.mPendingTasks.clear();
if (this.mPlayerState == PlayerState.DESTROYED) {
onError(PLOnErrorListener.ERROR_CODE_PLAYER_DESTROYED);
} else if (isPending("setDataSource")) {
this.mPendingTasks.add(new a0(new r(str, map), "setDataSource"));
Logger.i(TAG, "setDataSource *");
} else {
if (map != null) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : map.entrySet()) {
sb.append(entry.getKey());
sb.append(": ");
sb.append(entry.getValue());
sb.append("\r\n");
}
setParam(vf0.J, sb.toString());
}
this.mIsNeedChaseFrame = false;
this.mVideoPath = str;
Logger.i(TAG, "setDataSource: " + this.mVideoPath + " State: " + this.mPlayerState);
}
}
private void setParam(int i2, String str) {
nativeSetParam(this.mNativeContext, i2, 0, str);
}
public class z {
public MediaPlayer a;
public AudioTrack b = null;
public int c;
public z(Context context, MediaPlayer mediaPlayer) {
this.c = 0;
this.a = mediaPlayer;
AudioManager audioManager = (AudioManager) context.getSystemService(MediaStreamTrack.AUDIO_TRACK_KIND);
if (audioManager == null || !audioManager.isBluetoothA2dpOn()) {
return;
}
this.c = 250;
}
public int a(int i, int i2) {
if (this.b != null) {
a();
}
int i3 = i2 == 1 ? 2 : 3;
int minBufferSize = AudioTrack.getMinBufferSize(i, i3, 2);
if (minBufferSize == -2 || minBufferSize == -1) {
return -1;
}
int i4 = minBufferSize * 2;
if (i4 < 8192) {
i4 = 8192;
}
this.b = new AudioTrack(MediaPlayer.this.streamtype, i, i3, 2, i4, 1);
this.a.setParam((int) vf0.m, Integer.MIN_VALUE | ((i4 * 1000) / ((i * i2) * 2)));
AudioTrack audioTrack = this.b;
if (audioTrack == null || audioTrack.getState() != 1) {
return 0;
}
this.b.play();
return 0;
}
public AudioTrack b() {
return this.b;
}
public void a(byte[] bArr, long j) {
AudioTrack audioTrack = this.b;
if (audioTrack == null || j <= 0) {
return;
}
audioTrack.write(bArr, 0, (int) j);
}
public void a() {
AudioTrack audioTrack = this.b;
if (audioTrack == null || audioTrack.getState() != 1) {
return;
}
this.b.stop();
this.b.release();
this.b = null;
}
}
}