新浪彩票 v0.96.37版本的 MD5 值为:0c7ddce345383506e2959f5d75bdceab
以下内容为反编译后的 j.java 源代码,内容仅作参考
package com.netease.nrtc.monitor;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.LongSparseArray;
import com.ddtx.dingdatacontact.main.activity.WelcomeActivity;
import com.netease.nrtc.engine.rawapi.VideoRxStatistics;
import com.netease.nrtc.engine.rawapi.VideoRxSubscribeModel;
import com.netease.nrtc.engine.rawapi.VoiceRxStatistics;
import com.netease.nrtc.engine.rawapi.VoiceTxStatistics;
import com.netease.nrtc.monitor.j;
import com.netease.nrtc.monitor.statistics.c;
import com.netease.nrtc.monitor.statistics.d;
import com.netease.nrtc.sdk.common.statistics.RtcStats;
import com.netease.nrtc.sdk.common.statistics.SessionStats;
import com.netease.nrtc.stats.AVSyncStat;
import com.netease.nrtc.stats.AudioRxInfo;
import com.netease.yunxin.base.annotation.GuardedBy;
import com.netease.yunxin.base.http.HttpStack;
import com.netease.yunxin.base.thread.ThreadUtils;
import com.netease.yunxin.base.trace.Trace;
import com.netease.yunxin.base.utils.Checker;
import com.netease.yunxin.base.utils.LooperUtils;
import com.netease.yunxin.base.utils.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.HttpHost;
import org.apache.http.protocol.HTTP;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class j {
private static final ArrayList<String> a;
private b c;
private g d;
private i e;
private k f;
private AtomicInteger g;
private final com.netease.nrtc.monitor.statistics.d h;
private final List<com.netease.nrtc.monitor.statistics.b> j;
private final a k;
private Handler l;
@GuardedBy("mStatsLock")
private LongSparseArray<VoiceRxStatistics> m;
@GuardedBy("mStatsLock")
private LongSparseArray<VoiceRxStatistics> n;
@GuardedBy("mStatsLock")
private LongSparseArray<VideoRxSubscribeModel> o;
@GuardedBy("mStatsLock")
private LongSparseArray<VideoRxStatistics> p;
@GuardedBy("mStatsLock")
private LongSparseArray<VideoRxStatistics> q;
@GuardedBy("mStatsLock")
private LongSparseArray<AVSyncStat> r;
@GuardedBy("mStatsLock")
private LongSparseArray<AVSyncStat> s;
@GuardedBy("mStatsLock")
private VoiceTxStatistics t;
@GuardedBy("mStatsLock")
private SessionStats u;
@GuardedBy("mStatsLock")
private VoiceRxStatistics v;
@GuardedBy("mStatsLock")
private VoiceRxStatistics w;
@GuardedBy("mStatsLock")
private SessionStats x;
@GuardedBy("mStatsLock")
private Runnable y;
private final Object z;
private String b = "https://statistic.live.126.net/statistic/realtime/sdkinfo";
private final com.netease.nrtc.monitor.statistics.c i = new com.netease.nrtc.monitor.statistics.c();
public interface a {
int a(long[] jArr);
AudioRxInfo a(long j);
void a(c.a aVar);
void a(d.a aVar);
void a(SessionStats sessionStats);
void a(com.netease.nrtc.utility.d dVar, boolean z);
boolean a();
AVSyncStat b(long j);
HashSet<Long> b();
com.netease.nrtc.video.a.g c(long j);
boolean c();
}
static {
ArrayList<String> arrayList = new ArrayList<>();
a = arrayList;
arrayList.add("v_lost");
arrayList.add("v_cap_fps");
arrayList.add("real_v_res");
arrayList.add("set_v_kbps");
arrayList.add("vfkm");
}
public j(String str, String str2, a aVar) {
ArrayList arrayList = new ArrayList();
this.j = arrayList;
this.z = new Object();
Checker.checkNotNull(aVar);
this.k = aVar;
this.g = new AtomicInteger(3);
com.netease.nrtc.monitor.statistics.d dVar = new com.netease.nrtc.monitor.statistics.d();
this.h = dVar;
arrayList.add(dVar);
arrayList.add(new com.netease.nrtc.monitor.statistics.a(str));
this.n = new LongSparseArray<>();
this.o = new LongSparseArray<>();
this.m = new LongSparseArray<>();
this.t = new VoiceTxStatistics();
this.x = new SessionStats();
this.p = new LongSparseArray<>();
this.q = new LongSparseArray<>();
this.r = new LongSparseArray<>();
this.s = new LongSparseArray<>();
this.c = new b();
this.d = new g();
this.e = new i();
this.f = new k();
a(str2);
}
private void f(long j) {
this.p.delete(j);
}
private void g(long j) {
com.netease.nrtc.video.a.g c = this.k.c(j);
if (c != null) {
long j2 = c.a;
long j3 = c.b;
synchronized (this.z) {
VideoRxStatistics videoRxStatistics = this.p.get(j);
if (videoRxStatistics == null) {
this.p.remove(j);
Trace.w("StatisticsMonitor", "collect video raw stats error, stat is null");
return;
}
long max = Math.max(j2 - videoRxStatistics.receivePacketCount, 0L);
long max2 = Math.max(j3 - videoRxStatistics.decodedPacketCount, 0L);
videoRxStatistics.receivePacketCount = (int) j2;
videoRxStatistics.decodedPacketCount = (int) j3;
videoRxStatistics.receivePacketCountPeriod = (int) max;
videoRxStatistics.decodedPacketCountPeriod = (int) max2;
this.p.put(j, videoRxStatistics);
}
}
}
private void h(long j) {
AudioRxInfo a2 = this.k.a(j);
if (a2 != null) {
int a3 = (int) a2.a();
int d = (int) a2.d();
int b = (int) a2.b();
int c = (int) a2.c();
int e = (int) a2.e();
int f = (int) a2.f();
synchronized (this.z) {
VoiceRxStatistics voiceRxStatistics = this.m.get(j);
if (voiceRxStatistics == null) {
this.m.remove(j);
Trace.w("StatisticsMonitor", "collect voice raw stats error, stat is null");
return;
}
int max = Math.max(a3 - voiceRxStatistics.gapPacketCount, 0);
int max2 = Math.max(d - voiceRxStatistics.outOfDatePacketCount, 0);
int max3 = Math.max(b - voiceRxStatistics.normalPacketCount, 0);
int max4 = Math.max(c - voiceRxStatistics.plcPacketCount, 0);
int i = max + max3 + max4;
int i2 = i > 0 ? (max * 100) / i : 0;
voiceRxStatistics.gapPacketCount = a3;
voiceRxStatistics.normalPacketCount = b;
voiceRxStatistics.plcPacketCount = c;
voiceRxStatistics.outOfDatePacketCount = d;
voiceRxStatistics.freezeSessionRate = e;
voiceRxStatistics.gapPacketCountPeriod = max;
voiceRxStatistics.normalPacketCountPeriod = max3;
voiceRxStatistics.plcPacketCountPeriod = max4;
voiceRxStatistics.outOfDatePacketCountPeriod = max2;
voiceRxStatistics.freezeSessionRatePeriod = i2;
voiceRxStatistics.stuckTimeInterval = f;
voiceRxStatistics.sessionDuration = SystemClock.elapsedRealtime() - voiceRxStatistics.joinedTimestamp;
voiceRxStatistics.jbFramelistSize = (int) a2.i();
voiceRxStatistics.jbFramelistEffSize = (int) a2.j();
voiceRxStatistics.jbFramelistEffSize95 = (int) a2.g();
voiceRxStatistics.jbLoss400 = (int) a2.h();
voiceRxStatistics.jbEffLevel = (int) a2.k();
voiceRxStatistics.jbNormal = (int) a2.l();
voiceRxStatistics.jbPlc = (int) a2.m();
voiceRxStatistics.jbBlank = (int) a2.o();
voiceRxStatistics.jbCng = (int) a2.n();
voiceRxStatistics.jbFec = (int) a2.p();
voiceRxStatistics.jbMiss = (int) a2.q();
voiceRxStatistics.jbDelay = (int) a2.r();
voiceRxStatistics.jbPutInPktNum = a2.s();
this.m.put(j, voiceRxStatistics);
a2.recycle();
}
}
}
private void i() {
Trace.i("StatisticsMonitor", "upload last packet");
this.l.post(new Runnable() {
@Override
public final void run() {
j.this.q();
}
});
}
public void j() {
synchronized (this.z) {
this.k.a(this.h.c());
this.k.a(new com.netease.nrtc.utility.d() {
@Override
public final void accept(long j) {
j.this.j(j);
}
}, true);
long[] jArr = new long[10];
int a2 = this.k.a(jArr);
a(this.k.b(), jArr, a2, this.k.c());
a(jArr, a2);
b(jArr, a2);
c(jArr, a2);
g();
k();
}
}
private void k() {
this.x.rxAudioPacketsPerSecond = this.h.i().c();
this.x.txAudioPacketsPerSecond = this.h.j().c();
this.x.txAudioEncodedBitrate = this.h.j().d();
this.x.txAudioSentBitrate = this.h.d();
this.x.rxVideoPacketsPerSecond = this.h.h().c();
this.x.simulcastVideos = this.h.e();
this.x.sysCpuRate = this.c.b();
this.x.appCpuRate = this.c.c();
this.x.appCpuFreq = this.c.d();
this.x.sysMemoryAvailable = this.d.c();
this.x.appMemoryUse = this.d.b();
}
private void l() {
this.h.a();
this.f.a();
}
private void m() {
this.c.a();
this.h.c().a(this.c.b(), this.c.c());
}
private void n() {
this.g.compareAndSet(2, 3);
int size = this.o.size();
for (int i = 0; i < size; i++) {
this.o.valueAt(i).nextReportPoint();
}
}
private void o() {
try {
JSONObject jSONObject = new JSONObject();
for (com.netease.nrtc.monitor.statistics.b bVar : this.j) {
bVar.a(jSONObject);
}
a(jSONObject);
String jSONObject2 = jSONObject.toString();
if (StringUtils.isNotEmpty(jSONObject2)) {
b(jSONObject2);
}
} catch (Exception e) {
e.printStackTrace();
l();
}
}
public void p() {
this.k.a(this.h.c());
o();
}
public void q() {
o();
l();
LooperUtils.quitSafely(this.l);
Trace.i("StatisticsMonitor", "Statistic monitor stopped");
}
public void d() {
b(1);
}
public void e() {
ThreadUtils.runOnThread(this.l, new Runnable() {
@Override
public final void run() {
j.this.p();
}
});
}
private RtcStats e(long j) {
RtcStats rtcStats = new RtcStats();
rtcStats.uid = j;
synchronized (this.z) {
a(j, rtcStats);
f(j);
}
return rtcStats;
}
public void b() {
synchronized (this.z) {
Runnable runnable = this.y;
if (runnable != null) {
this.l.removeCallbacks(runnable);
b(2);
this.y = null;
i();
}
}
}
public void c() {
synchronized (this.z) {
this.k.a(this.i.a());
this.j.add(this.i);
}
}
public RtcStats d(long j) {
return e(j);
}
public VoiceRxStatistics f() {
VoiceRxStatistics voiceRxStatistics = new VoiceRxStatistics();
VoiceRxStatistics voiceRxStatistics2 = new VoiceRxStatistics();
synchronized (this.z) {
int i = 0;
int i2 = Integer.MAX_VALUE;
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = 0;
for (int i7 = 0; i7 < this.m.size(); i7++) {
VoiceRxStatistics valueAt = this.m.valueAt(i7);
int i8 = valueAt.freezeSessionRate;
if (i8 <= i2) {
voiceRxStatistics = valueAt;
i2 = i8;
}
if (i8 >= i6) {
voiceRxStatistics2 = valueAt;
i6 = i8;
}
i3 += valueAt.gapPacketCount;
i4 += valueAt.normalPacketCount;
i5 += valueAt.plcPacketCount;
}
int i9 = i4 + i3 + i5;
SessionStats sessionStats = this.u;
if (sessionStats != null) {
i3 += sessionStats.audioGapPacket;
i9 += sessionStats.audioTotalPacket;
}
VoiceRxStatistics voiceRxStatistics3 = this.v;
if (voiceRxStatistics3 != null && voiceRxStatistics3.freezeSessionRate <= i2) {
voiceRxStatistics = voiceRxStatistics3;
}
VoiceRxStatistics voiceRxStatistics4 = this.w;
if (voiceRxStatistics4 != null && voiceRxStatistics4.freezeSessionRate >= i6) {
voiceRxStatistics2 = voiceRxStatistics4;
}
SessionStats sessionStats2 = this.x;
if (i9 != 0) {
i = (i3 * 100) / i9;
}
sessionStats2.audioFreeze = i;
sessionStats2.rxBytes = this.h.f();
this.x.txBytes = this.h.g();
SessionStats sessionStats3 = this.x;
sessionStats3.audioGapPacket = i3;
sessionStats3.audioTotalPacket = i9;
sessionStats3.sessionDuration = SystemClock.elapsedRealtime() - this.t.joinedTimestamp;
Trace.i("StatisticsMonitor", "best " + voiceRxStatistics.toString());
Trace.i("StatisticsMonitor", "worst " + voiceRxStatistics2.toString());
Trace.i("StatisticsMonitor", this.x.toString());
}
return voiceRxStatistics;
}
private void a(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
if (str.startsWith(HttpHost.DEFAULT_SCHEME_NAME) || str.startsWith("https")) {
this.b = str;
}
}
private void i(long j) {
AVSyncStat b = this.k.b(j);
if (b != null) {
synchronized (this.z) {
AVSyncStat aVSyncStat = this.r.get(j);
if (aVSyncStat == null) {
this.r.remove(j);
Trace.w("StatisticsMonitor", "collect video raw stats error, avStat is null");
return;
}
aVSyncStat.a(b);
this.r.put(j, aVSyncStat);
b.recycle();
}
}
}
public void a() {
synchronized (this.z) {
if (this.y == null) {
HandlerThread handlerThread = new HandlerThread("nrtc_monitor");
handlerThread.start();
this.l = new Handler(handlerThread.getLooper());
Runnable runnable = new Runnable() {
@Override
public void run() {
long currentThreadTimeMillis = SystemClock.currentThreadTimeMillis();
if (j.this.k.a()) {
j.this.j();
j.this.b(0);
}
j.this.l.postDelayed(this, Math.max(WelcomeActivity.f10696 - (SystemClock.currentThreadTimeMillis() - currentThreadTimeMillis), 0L));
}
};
this.y = runnable;
this.l.postDelayed(runnable, WelcomeActivity.f10696);
Trace.i("StatisticsMonitor", "start session stats");
}
}
Trace.i("StatisticsMonitor", "Statistics monitor started");
}
public void c(long j) {
h(j);
}
public void c(int i) {
this.h.c().a(i);
}
private void c(long[] jArr, int i) {
this.s.clear();
if (i > 0) {
for (int i2 = 0; i2 < i; i2++) {
AVSyncStat aVSyncStat = this.r.get(jArr[i2]);
if (aVSyncStat != null) {
this.s.put(jArr[i2], aVSyncStat);
}
}
}
this.h.b(this.s);
}
public void b(long j) {
synchronized (this.z) {
VoiceTxStatistics voiceTxStatistics = this.t;
voiceTxStatistics.uid = j;
voiceTxStatistics.joinedTimestamp = SystemClock.elapsedRealtime();
}
}
public void c(String str) {
try {
HashMap hashMap = new HashMap();
hashMap.put(HTTP.CONTENT_TYPE, "application/json;charset=utf-8");
hashMap.put("Content-Encoding", "gzip");
HttpStack.HttpStackResponse doPost = HttpStack.doPost(this.b, hashMap, str.getBytes("UTF-8"), 10000);
StringBuilder sb = new StringBuilder();
sb.append("upload res:");
sb.append(doPost == null ? "null" : doPost.toString());
Trace.i("StatisticsMonitor", sb.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
public synchronized void b(int i) {
long j = this.t.joinedTimestamp;
SessionStats sessionStats = this.x;
sessionStats.sessionState = i;
long j2 = 0;
if (j != 0) {
j2 = SystemClock.elapsedRealtime() - j;
}
sessionStats.sessionDuration = j2;
this.k.a(this.x.fork());
}
public void j(long j) {
h(j);
g(j);
i(j);
}
public void a(long j) {
synchronized (this.z) {
e(j);
long elapsedRealtime = SystemClock.elapsedRealtime();
if (this.m.get(j) == null) {
VoiceRxStatistics voiceRxStatistics = new VoiceRxStatistics();
voiceRxStatistics.uid = j;
voiceRxStatistics.joinedTimestamp = elapsedRealtime;
this.m.put(j, voiceRxStatistics);
}
if (this.p.get(j) == null) {
VideoRxStatistics videoRxStatistics = new VideoRxStatistics();
videoRxStatistics.uid = j;
videoRxStatistics.joinedTimestamp = elapsedRealtime;
this.p.put(j, videoRxStatistics);
}
if (this.r.get(j) == null) {
AVSyncStat obtain = AVSyncStat.obtain();
obtain.a(j);
obtain.b(elapsedRealtime);
this.r.put(j, obtain);
}
}
}
public void g() {
h.a++;
m();
this.d.a();
this.e.a(this.c.b(), this.c.d(), this.d.b());
this.f.b();
if (this.h.b()) {
o();
n();
}
}
private void b(long[] jArr, int i) {
this.q.clear();
if (i > 0) {
for (int i2 = 0; i2 < i; i2++) {
VideoRxStatistics videoRxStatistics = this.p.get(jArr[i2]);
if (videoRxStatistics != null) {
this.q.put(jArr[i2], videoRxStatistics);
}
}
}
this.h.a(this.q, this.o);
}
private void b(final String str) {
ThreadUtils.runOnThread(com.netease.nrtc.utility.j.c().f(), new Runnable() {
@Override
public final void run() {
j.this.c(str);
}
});
}
public void a(final int i) {
ThreadUtils.runOnThread(this.l, new Runnable() {
@Override
public final void run() {
j.this.c(i);
}
});
}
private void a(HashSet<Long> hashSet, long[] jArr, int i, boolean z) {
if (z) {
this.g.set(1);
} else {
this.g.compareAndSet(1, 2);
}
if (i <= 0) {
return;
}
for (int i2 = 0; i2 < i; i2++) {
long j = jArr[i2];
VideoRxSubscribeModel videoRxSubscribeModel = this.o.get(j);
if (videoRxSubscribeModel == null) {
videoRxSubscribeModel = new VideoRxSubscribeModel(j);
this.o.put(j, videoRxSubscribeModel);
}
videoRxSubscribeModel.updateStatus(hashSet.contains(Long.valueOf(j)));
}
}
private void a(long[] jArr, int i) {
int i2;
int i3;
this.n.clear();
if (i > 0) {
i2 = 0;
i3 = 0;
for (int i4 = 0; i4 < i; i4++) {
VoiceRxStatistics voiceRxStatistics = this.m.get(jArr[i4]);
if (voiceRxStatistics != null) {
this.n.put(jArr[i4], voiceRxStatistics);
int i5 = voiceRxStatistics.gapPacketCountPeriod;
i2 += i5;
i3 += i5 + voiceRxStatistics.normalPacketCountPeriod + voiceRxStatistics.plcPacketCountPeriod;
}
}
} else {
i2 = 0;
i3 = 0;
}
this.x.rxBytes = this.h.f();
this.x.txBytes = this.h.g();
this.x.audioFreeze = i3 != 0 ? (i2 * 100) / i3 : 0;
this.h.a(this.n);
}
public com.netease.nrtc.monitor.statistics.d h() {
return this.h;
}
private void a(long j, RtcStats rtcStats) {
VoiceRxStatistics voiceRxStatistics = this.m.get(j);
this.m.delete(j);
if (voiceRxStatistics != null) {
long elapsedRealtime = SystemClock.elapsedRealtime() - voiceRxStatistics.joinedTimestamp;
voiceRxStatistics.sessionDuration = elapsedRealtime;
int i = voiceRxStatistics.freezeSessionRate;
rtcStats.freezeSessionRate = i;
rtcStats.duration = elapsedRealtime;
VoiceRxStatistics voiceRxStatistics2 = this.w;
if (voiceRxStatistics2 == null || voiceRxStatistics2.freezeSessionRate < i) {
this.w = voiceRxStatistics;
}
VoiceRxStatistics voiceRxStatistics3 = this.v;
if (voiceRxStatistics3 == null || voiceRxStatistics3.freezeSessionRate > i) {
this.v = voiceRxStatistics;
}
if (this.u == null) {
this.u = new SessionStats();
}
int i2 = voiceRxStatistics.gapPacketCount;
int i3 = voiceRxStatistics.normalPacketCount + i2 + voiceRxStatistics.plcPacketCount;
SessionStats sessionStats = this.u;
sessionStats.audioGapPacket += i2;
sessionStats.audioTotalPacket += i3;
}
}
private void a(JSONObject jSONObject) {
JSONObject jSONObject2;
JSONObject jSONObject3;
int optInt = jSONObject.optInt("samples");
if (optInt == 0 || (jSONObject2 = (JSONObject) jSONObject.opt("rx")) == null) {
return;
}
try {
JSONArray jSONArray = (JSONArray) jSONObject2.opt("video");
if (jSONArray != null) {
int length = jSONArray.length();
if (length != optInt) {
JSONArray jSONArray2 = new JSONArray();
for (int i = 0; i < optInt - length; i++) {
jSONArray2.put(new JSONObject());
}
for (int i2 = 0; i2 < length; i2++) {
jSONArray2.put(jSONArray.get(i2));
}
jSONObject2.put("video", jSONArray2);
}
String str = "video array len = " + jSONArray.length() + " , samples = " + optInt;
}
JSONArray jSONArray3 = (JSONArray) jSONObject2.opt("audio");
if (jSONArray3 != null) {
int length2 = jSONArray3.length();
if (length2 != optInt) {
JSONArray jSONArray4 = new JSONArray();
for (int i3 = 0; i3 < optInt - length2; i3++) {
jSONArray4.put(new JSONObject());
}
for (int i4 = 0; i4 < length2; i4++) {
jSONArray4.put(jSONArray3.get(i4));
}
jSONObject2.put("audio", jSONArray4);
}
String str2 = "audio array len = " + jSONArray3.length() + " , samples = " + optInt;
}
JSONArray jSONArray5 = (JSONArray) jSONObject2.opt("net");
if (jSONArray5 != null) {
int length3 = jSONArray5.length();
if (length3 != optInt) {
JSONArray jSONArray6 = new JSONArray();
for (int i5 = 0; i5 < optInt - length3; i5++) {
jSONArray6.put(new JSONObject());
}
for (int i6 = 0; i6 < length3; i6++) {
jSONArray6.put(jSONArray5.get(i6));
}
jSONObject2.put("net", jSONArray6);
}
String str3 = "net array len = " + jSONArray5.length() + " , samples = " + optInt;
}
} catch (JSONException e) {
e.printStackTrace();
}
JSONArray jSONArray7 = (JSONArray) jSONObject.opt("multi_pub_video");
if (jSONArray7 != null) {
try {
int length4 = jSONArray7.length();
if (length4 != optInt) {
JSONArray jSONArray8 = new JSONArray();
for (int i7 = 0; i7 < optInt - length4; i7++) {
jSONArray8.put(new JSONObject());
}
for (int i8 = 0; i8 < length4; i8++) {
jSONArray8.put(jSONArray7.get(i8));
}
jSONObject.put("multi_pub_video", jSONArray8);
}
String str4 = "pub video array len = " + jSONArray7.length() + " , samples = " + optInt;
} catch (Exception e2) {
e2.printStackTrace();
}
}
if (this.g.get() != 3 || (jSONObject3 = (JSONObject) jSONObject.opt("tx")) == null) {
return;
}
Iterator<String> it = a.iterator();
while (it.hasNext()) {
jSONObject3.remove(it.next());
}
}
}