QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 AVPreloadPlayerService.java 源代码,内容仅作参考
package com.tencent.ilivesdk.avpreloadplayerservice;
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.widget.FrameLayout;
import com.tencent.falco.base.libapi.generalinfo.AppGeneralInfoService;
import com.tencent.falco.utils.NetworkUtil;
import com.tencent.falco.utils.PreloadUtil;
import com.tencent.falco.utils.ThreadCenter;
import com.tencent.ilivesdk.avplayerservice.AVPlayerService;
import com.tencent.ilivesdk.avplayerservice_interface.AVPlayerPreloadAdapter;
import com.tencent.ilivesdk.avplayerservice_interface.PlayerParams;
import com.tencent.ilivesdk.avplayerservice_interface.PlayerStatusListener;
import com.tencent.ilivesdk.avpreloadplayerservice.report.AVPreloadReport;
import com.tencent.ilivesdk.avpreloadservice_interface.AVPreloadTaskInterface;
import com.tencent.livesdk.livesdkplayer.IMediaPlayerMgr;
import com.tencent.livesdk.livesdkplayer.LiveSdkPlayerHelper;
import com.tencent.livesdk.livesdkplayer.LogAdapter;
import com.tencent.livesdk.livesdkplayer.renderview.ITPPlayerVideoViewBase;
import com.tencent.map.geolocation.util.DateUtils;
public class AVPreloadPlayerService extends AVPlayerService implements ThreadCenter.HandlerKeyable {
private static long n;
private LiveSdkPlayerHelper g;
private PlayerStatusListener h;
private long i = 0;
private int j = 0;
private AVPreloadReport.ReportData k = new AVPreloadReport.ReportData();
private long l = 0;
private String m = qb.business.BuildConfig.JACOCO_INSTRUMENT_TYPE;
AVPlayerPreloadAdapter.AVPreloadListener f = new AVPlayerPreloadAdapter.AVPreloadListener() {
@Override
public void a(String str, long j, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskGapTime url=" + str, new Object[0]);
AVPreloadPlayerService.this.k.C = j;
}
@Override
public void a(String str, AVPreloadTaskInterface.TaskReportInfo taskReportInfo, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskPreloadFinish url=" + str, new Object[0]);
if (taskReportInfo != null) {
AVPreloadPlayerService.this.k.B = taskReportInfo.d() / 1024;
AVPreloadPlayerService.this.k.r = taskReportInfo.b();
AVPreloadPlayerService.this.k.q = taskReportInfo.a();
AVPreloadPlayerService.this.k.D = taskReportInfo.c();
}
AVPreloadPlayerService.this.k.j = aVPreloadTaskInterface.b();
AVPreloadPlayerService.this.k.k = aVPreloadTaskInterface.c();
AVPreloadPlayerService.this.k.u = aVPreloadTaskInterface.l();
AVPreloadPlayerService.this.k.E = "" + aVPreloadTaskInterface.t();
AVPreloadPlayerService.this.k.F = aVPreloadTaskInterface.f();
AVPreloadPlayerService.this.k.G = aVPreloadTaskInterface.i() / 1024;
}
@Override
public void a(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.k.j = aVPreloadTaskInterface.b();
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskPreloadStart url=" + str, new Object[0]);
}
@Override
public void b(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskFailed url=" + str, new Object[0]);
AVPreloadPlayerService.this.k.z = aVPreloadTaskInterface.o();
}
@Override
public void c(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskCompleted url=" + str, new Object[0]);
}
@Override
public void d(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskStop url=" + str, new Object[0]);
AVPreloadPlayerService.this.k.l = aVPreloadTaskInterface.d();
}
@Override
public void e(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskFirstFrame url=" + str, new Object[0]);
AVPreloadPlayerService.this.k.o = aVPreloadTaskInterface.e();
AVPreloadPlayerService.this.k.s = aVPreloadTaskInterface.m();
AVPreloadPlayerService.this.k.t = aVPreloadTaskInterface.n();
if (AVPreloadPlayerService.this.e != null) {
AVPreloadPlayerService.this.e.a(aVPreloadTaskInterface);
}
}
@Override
public void f(String str, AVPreloadTaskInterface aVPreloadTaskInterface) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "preload---onTaskCanPlay url=" + str, new Object[0]);
}
};
private Runnable o = new Runnable() {
@Override
public void run() {
AVPreloadPlayerService.this.m();
AVPreloadPlayerService.this.g();
AVPreloadPlayerService.this.q();
AVPreloadPlayerService.this.d(false);
AVPreloadPlayerService.G(AVPreloadPlayerService.this);
AVPreloadPlayerService.this.f12581a.a().c("AVPreload|Core", "retry play time " + AVPreloadPlayerService.this.j, new Object[0]);
}
};
static int G(AVPreloadPlayerService aVPreloadPlayerService) {
int i = aVPreloadPlayerService.j;
aVPreloadPlayerService.j = i + 1;
return i;
}
public void a() {
String str = this.g.q().f14555c;
this.k.x = str.startsWith("http://127.0.0.1");
this.k.p = System.currentTimeMillis() - this.i;
this.k.w = this.g.q().f14554b;
this.k.e = this.g.q().j;
String str2 = this.k.x ? "命中缓存" : "未命中缓存";
String str3 = str.startsWith("rtmp:") ? "rtmp" : "flv";
String str4 = ":首帧耗时 " + this.k.p;
this.f12581a.a().c("AVPreloadPlayerService", str2 + str3 + str4, new Object[0]);
}
private void a(AVPreloadTaskInterface aVPreloadTaskInterface) {
if (aVPreloadTaskInterface != null) {
this.f12581a.a().c("AVPreload|Core", "initReportData taskId: " + aVPreloadTaskInterface.t(), new Object[0]);
this.k.j = aVPreloadTaskInterface.b();
AVPreloadTaskInterface.TaskReportInfo a2 = aVPreloadTaskInterface.a();
if (a2 != null) {
this.k.B = a2.d() / 1024;
this.k.r = a2.b();
this.k.q = a2.a();
this.k.D = a2.c();
}
this.k.j = aVPreloadTaskInterface.b();
this.k.k = aVPreloadTaskInterface.c();
this.k.u = aVPreloadTaskInterface.l();
this.k.E = "" + aVPreloadTaskInterface.t();
this.k.z = aVPreloadTaskInterface.o();
this.k.l = aVPreloadTaskInterface.d();
this.k.C = aVPreloadTaskInterface.j();
this.k.s = aVPreloadTaskInterface.m();
this.k.t = aVPreloadTaskInterface.n();
this.k.o = aVPreloadTaskInterface.e();
this.k.w = aVPreloadTaskInterface.u();
this.k.F = aVPreloadTaskInterface.f();
this.k.G = aVPreloadTaskInterface.i() / 1024;
}
}
private long b(Context context) {
long j = 0;
try {
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
if (Build.VERSION.SDK_INT < 16) {
return 0L;
}
j = (memoryInfo.totalMem / 1024) / 1024;
Log.i("AVPreloadPlayerService", "memoryInfo.totalMem: " + memoryInfo.totalMem);
return j;
} catch (Exception e) {
e.printStackTrace();
return j;
}
}
private LiveSdkPlayerHelper.PlayerParams b(PlayerParams playerParams) {
LiveSdkPlayerHelper.PlayerParams playerParams2 = new LiveSdkPlayerHelper.PlayerParams();
if (playerParams == null) {
return playerParams2;
}
playerParams2.f14553a = playerParams.f12614a;
playerParams2.f14554b = playerParams.f12615b;
playerParams2.f14555c = playerParams.f12615b;
playerParams2.e = playerParams.f12617d;
playerParams2.f14556d = playerParams.f12616c;
playerParams2.g = playerParams.f;
playerParams2.h = playerParams.g;
playerParams2.i = playerParams.h;
playerParams2.f = playerParams.e;
if (this.f12581a == null) {
return playerParams2;
}
playerParams2.g = this.f12581a.i();
if (this.f12581a.e() != null && this.f12581a.e().a() != null) {
playerParams2.j = "" + this.f12581a.e().a().f10859a;
}
playerParams2.k = playerParams.j;
return playerParams2;
}
public void d(boolean z) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
String c2 = liveSdkPlayerHelper.c();
if (this.f12582b != null && !c2.startsWith("http://127.0.0.1") && z) {
this.g.q().f14555c = this.f12582b.e(c2);
}
StringBuffer stringBuffer = new StringBuffer("preparePlay()---preparePlay remote url= ");
stringBuffer.append(c2);
stringBuffer.append(" local url= ");
stringBuffer.append(this.g.q().f14555c);
this.f12581a.a().c("AVPreload|Core", stringBuffer.toString(), new Object[0]);
if (this.f12582b != null) {
this.f12582b.d(c2);
}
this.i = System.currentTimeMillis();
AVPreloadReport.ReportData reportData = this.k;
reportData.w = c2;
reportData.i = this.i;
this.g.g();
}
}
private String u() {
String str = this.g.q().f14555c;
if (str.startsWith("http://127.0.0.1")) {
this.f12581a.a().e("AVPreload|Core", "------local url play error url=" + str, new Object[0]);
} else {
this.f12581a.a().e("AVPreload|Core", "------remote url play error url=" + str, new Object[0]);
}
String str2 = this.g.q().f14554b;
if (this.f12582b == null || !str2.startsWith("http://127.0.0.1")) {
return str2;
}
String f = this.f12582b.f(str2);
this.f12581a.a().e("AVPreload|Core", "------play error exchangeRemoteServerPlayUrl url=" + str, new Object[0]);
return f;
}
public void v() {
this.g.q().f14555c = u();
ThreadCenter.b(this, this.o);
if (this.j < 3) {
ThreadCenter.a(this, this.o, 1000L);
} else {
this.j = 0;
}
}
private String w() {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.l < DateUtils.ONE_MINUTE) {
return this.m;
}
int b2 = NetworkUtil.b(this.f12584d);
this.m = b2 != 1 ? b2 != 2 ? b2 != 3 ? b2 != 4 ? b2 != 5 ? qb.business.BuildConfig.JACOCO_INSTRUMENT_TYPE : "mobile" : "4G" : "3G" : "2G" : "wifi";
this.l = currentTimeMillis;
return this.m;
}
@Override
public void a(int i) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.c(i);
}
}
@Override
public void a(int i, String[] strArr, int[] iArr) {
}
@Override
public void a(Context context) {
super.a(context);
}
@Override
public void a(Context context, FrameLayout frameLayout) {
super.a(context, frameLayout);
this.g = new LiveSdkPlayerHelper();
this.g.a(new LogAdapter() {
@Override
public void a(String str, String str2, Object... objArr) {
AVPreloadPlayerService.this.f12581a.a().a(str, str2, objArr);
}
@Override
public void b(String str, String str2, Object... objArr) {
AVPreloadPlayerService.this.f12581a.a().b(str, str2, objArr);
}
@Override
public void c(String str, String str2, Object... objArr) {
AVPreloadPlayerService.this.f12581a.a().c(str, str2, objArr);
}
@Override
public void d(String str, String str2, Object... objArr) {
AVPreloadPlayerService.this.f12581a.a().d(str, str2, objArr);
}
@Override
public void e(String str, String str2, Object... objArr) {
AVPreloadPlayerService.this.f12581a.a().e(str, str2, objArr);
}
});
this.g.a(this.f12581a.d().m(), this.f12581a.d().n(), this.f12581a.d().o());
this.g.a(context);
this.g.a(frameLayout, false);
}
@Override
public void a(FrameLayout frameLayout, boolean z) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.a(frameLayout, z);
}
}
@Override
public void a(PlayerParams playerParams) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.a(b(playerParams));
this.g.b(playerParams.i);
}
if (this.f12582b != null) {
a(this.f12582b.h(playerParams.a()));
}
}
@Override
public void a(PlayerParams playerParams, PlayerStatusListener playerStatusListener) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
this.h = playerStatusListener;
liveSdkPlayerHelper.a(playerParams.f12615b);
}
}
@Override
public void a(final PlayerStatusListener playerStatusListener) {
if (this.e == playerStatusListener) {
this.f12581a.a().c("AVPreloadPlayerService", "setPlayerStatusListener is same return", new Object[0]);
return;
}
super.a(playerStatusListener);
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.a(new LiveSdkPlayerHelper.PlayerStatusListener() {
@Override
public void a() {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "onNetworkAnomaly 网络异常", new Object[0]);
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.i();
}
}
@Override
public void a(int i) {
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.a(i);
}
}
@Override
public void a(IMediaPlayerMgr iMediaPlayerMgr) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "onReadyCompleted", new Object[0]);
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.a();
}
}
@Override
public void a(IMediaPlayerMgr iMediaPlayerMgr, int i, String str) {
AVPreloadPlayerService.this.f12581a.a().e("AVPreload|Core", "------play error errorCode: " + i + " msg: " + str, new Object[0]);
AVPreloadPlayerService.this.v();
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.a(i, str);
}
if (AVPreloadPlayerService.this.h != null) {
AVPreloadPlayerService.this.h.a(i, str);
AVPreloadPlayerService.this.h = null;
}
}
@Override
public void a(ITPPlayerVideoViewBase iTPPlayerVideoViewBase, int i, int i2) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "videoWidth = " + i + " videoHeight=" + i2, new Object[0]);
}
@Override
public long b() {
if (AVPreloadPlayerService.this.f12581a != null) {
return AVPreloadPlayerService.this.f12581a.i();
}
return 0L;
}
@Override
public void b(IMediaPlayerMgr iMediaPlayerMgr) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreload|AVPreloadService", "onFirstFrameCome", new Object[0]);
AVPreloadPlayerService.this.a();
if (AVPreloadPlayerService.this.f12582b != null) {
AVPreloadPlayerService.this.f12582b.g(AVPreloadPlayerService.this.g.q().f14554b);
}
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.b();
}
}
@Override
public void c() {
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.k();
}
}
@Override
public void c(IMediaPlayerMgr iMediaPlayerMgr) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "onPlayCompleted", new Object[0]);
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.c();
}
}
@Override
public void d() {
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.l();
}
}
@Override
public void d(IMediaPlayerMgr iMediaPlayerMgr) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "onStartBuffer", new Object[0]);
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.g();
}
}
@Override
public void e() {
if (AVPreloadPlayerService.this.h != null) {
AVPreloadPlayerService.this.h.a();
AVPreloadPlayerService.this.h = null;
}
}
@Override
public void e(IMediaPlayerMgr iMediaPlayerMgr) {
AVPreloadPlayerService.this.f12581a.a().c("AVPreloadPlayerService", "onStopBuffer", new Object[0]);
PlayerStatusListener playerStatusListener2 = playerStatusListener;
if (playerStatusListener2 != null) {
playerStatusListener2.h();
}
}
});
}
}
@Override
public void a(boolean z) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.a(z);
}
}
@Override
public void b() {
super.b();
if (this.g != null) {
if (this.f12582b != null) {
this.f12582b.c(this.g.c());
this.f12582b.b(this.g.c());
this.f12582b.a(this.f);
}
this.g.a((LiveSdkPlayerHelper.PlayerStatusListener) null);
this.g.a();
}
this.j = 0;
ThreadCenter.a(this);
}
@Override
public void b(boolean z) {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.b(z);
}
}
@Override
public void c() {
if (this.g == null || this.f12582b == null) {
return;
}
this.f12581a.a().c("AVPreload|Core", "preload()---preload start url= " + this.g.c(), new Object[0]);
this.f12582b.a(this.g.c(), this.f);
this.f12582b.a(this.g.c());
}
@Override
public void c(boolean z) {
this.k.m = w();
if (this.k.q > 0 && this.k.r > 0) {
AVPreloadReport.ReportData reportData = this.k;
reportData.v = reportData.r / this.k.q;
}
this.k.l = System.currentTimeMillis();
this.k.f12633d = this.f12581a.m();
this.k.f12632c = "" + this.f12581a.i();
this.k.g = "" + this.f12581a.h();
this.k.A = "event_close_room";
AppGeneralInfoService d2 = this.f12581a.d();
if (d2 != null) {
this.k.f12631b = d2.b();
this.k.f12630a = d2.v();
this.k.f = d2.u();
this.k.h = d2.a().getPackageName();
}
if (n == 0) {
n = b(this.f12584d);
}
AVPreloadReport.ReportData reportData2 = this.k;
reportData2.H = n;
reportData2.I = z;
AVPreloadReport aVPreloadReport = new AVPreloadReport();
aVPreloadReport.a(this.f12581a.l());
aVPreloadReport.a(this.k);
aVPreloadReport.a(this.f12581a.a());
aVPreloadReport.b();
}
@Override
public void e() {
}
@Override
public void f() {
d(true);
}
@Override
public void g() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.b();
}
}
@Override
public boolean h() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
return liveSdkPlayerHelper.i();
}
return false;
}
@Override
public boolean i() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
return liveSdkPlayerHelper.j();
}
return false;
}
@Override
public void j() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.n();
}
}
@Override
public void k() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.k();
}
}
@Override
public void l() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.m();
}
}
@Override
public void m() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.l();
}
}
@Override
public int n() {
return this.g.d();
}
@Override
public int o() {
return this.g.e();
}
@Override
public Rect p() {
return this.g.f();
}
@Override
public void q() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
liveSdkPlayerHelper.h();
}
}
@Override
public long r() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
return liveSdkPlayerHelper.o();
}
return 0L;
}
@Override
public long s() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
return liveSdkPlayerHelper.p();
}
return 0L;
}
@Override
public boolean t() {
LiveSdkPlayerHelper liveSdkPlayerHelper = this.g;
if (liveSdkPlayerHelper != null) {
return PreloadUtil.a(liveSdkPlayerHelper.c(), this.g.q().k);
}
return false;
}
}