射射AV v6.8.3版本的 MD5 值为:4b0475341d3c62fa7e762c41558fd25f
以下内容为反编译后的 g.java 源代码,内容仅作参考
package com.danikula.videocache;
import android.content.Context;
import android.net.Uri;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import tv.danmaku.ijk.media.player.IjkMediaMeta;
public class g {
private final Object a;
private final ExecutorService b;
private final Map<String, h> c;
private final ServerSocket f3782d;
private final int f3783e;
private final Thread f3784f;
private final com.danikula.videocache.c f3785g;
private final k f3786h;
public static final class b {
private File a;
private com.danikula.videocache.t.c f3787d;
private com.danikula.videocache.r.a c = new com.danikula.videocache.r.h(IjkMediaMeta.AV_CH_STEREO_LEFT);
private com.danikula.videocache.r.c b = new com.danikula.videocache.r.f();
private com.danikula.videocache.s.b f3788e = new com.danikula.videocache.s.a();
public b(Context context) {
this.f3787d = com.danikula.videocache.t.d.b(context);
this.a = q.c(context);
}
private com.danikula.videocache.c b() {
return new com.danikula.videocache.c(this.a, this.b, this.c, this.f3787d, this.f3788e);
}
public g a() {
return new g(b());
}
public b c(File file) {
l.d(file);
this.a = file;
return this;
}
public b d(com.danikula.videocache.r.c cVar) {
l.d(cVar);
this.b = cVar;
return this;
}
public b e(com.danikula.videocache.s.b bVar) {
l.d(bVar);
this.f3788e = bVar;
return this;
}
public b f(int i2) {
this.c = new com.danikula.videocache.r.g(i2);
return this;
}
public b g(long j2) {
this.c = new com.danikula.videocache.r.h(j2);
return this;
}
}
public final class c implements Runnable {
private final Socket a;
public c(Socket socket) {
this.a = socket;
}
@Override
public void run() {
g.this.o(this.a);
}
}
private final class d implements Runnable {
private final CountDownLatch a;
public d(CountDownLatch countDownLatch) {
this.a = countDownLatch;
}
@Override
public void run() {
this.a.countDown();
g.this.v();
}
}
private String c(String str) {
return String.format(Locale.US, "http://%s:%d/%s", "127.0.0.1", Integer.valueOf(this.f3783e), n.f(str));
}
private void d(Socket socket) {
try {
if (socket.isClosed()) {
return;
}
socket.close();
} catch (IOException unused) {
}
}
private void e(Socket socket) {
try {
if (socket.isInputShutdown()) {
return;
}
socket.shutdownInput();
} catch (SocketException | IOException unused) {
}
}
private void f(Socket socket) {
try {
if (socket.isOutputShutdown()) {
return;
}
socket.shutdownOutput();
} catch (IOException e2) {
f.g("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e2.getMessage());
}
}
private File g(String str) {
com.danikula.videocache.c cVar = this.f3785g;
return new File(cVar.a, cVar.b.a(str));
}
private h h(String str) throws ProxyCacheException {
h hVar;
synchronized (this.a) {
hVar = this.c.get(str);
if (hVar == null) {
hVar = new h(str, this.f3785g);
this.c.put(str, hVar);
}
}
return hVar;
}
private int i() {
int i2;
synchronized (this.a) {
i2 = 0;
Iterator<h> it = this.c.values().iterator();
while (it.hasNext()) {
i2 += it.next().b();
}
}
return i2;
}
private boolean l() {
return this.f3786h.e(3, 70);
}
private void n(Throwable th) {
f.c("HttpProxyCacheServer error", th.getMessage());
}
public void o(Socket socket) {
StringBuilder sb;
try {
try {
com.danikula.videocache.d c2 = com.danikula.videocache.d.c(socket.getInputStream());
String e2 = n.e(c2.a);
if (this.f3786h.d(e2)) {
this.f3786h.g(socket);
} else {
h(e2).d(c2, socket);
}
q(socket);
sb = new StringBuilder();
} catch (Throwable th) {
q(socket);
f.d("Opened connections: " + i());
throw th;
}
} catch (ProxyCacheException e3) {
e = e3;
n(new ProxyCacheException("Error processing request", e));
q(socket);
sb = new StringBuilder();
} catch (SocketException unused) {
q(socket);
sb = new StringBuilder();
} catch (IOException e4) {
e = e4;
n(new ProxyCacheException("Error processing request", e));
q(socket);
sb = new StringBuilder();
}
sb.append("Opened connections: ");
sb.append(i());
f.d(sb.toString());
}
private void q(Socket socket) {
e(socket);
f(socket);
d(socket);
}
private void s() {
synchronized (this.a) {
Iterator<h> it = this.c.values().iterator();
while (it.hasNext()) {
it.next().f();
}
this.c.clear();
}
}
private void t(File file) {
try {
this.f3785g.c.a(file);
} catch (IOException e2) {
f.b("Error touching file " + file, e2);
}
}
public void v() {
while (!Thread.currentThread().isInterrupted()) {
try {
this.b.submit(new c(this.f3782d.accept()));
} catch (IOException e2) {
n(new ProxyCacheException("Error during waiting connection", e2));
return;
}
}
}
public String j(String str) {
return k(str, true);
}
public String k(String str, boolean z) {
if (!z || !m(str)) {
return l() ? c(str) : str;
}
File g2 = g(str);
t(g2);
return Uri.fromFile(g2).toString();
}
public boolean m(String str) {
l.e(str, "Url can't be null!");
return g(str).exists();
}
public void p(com.danikula.videocache.b bVar, String str) {
l.a(bVar, str);
synchronized (this.a) {
try {
h(str).e(bVar);
} catch (ProxyCacheException e2) {
f.g("Error registering cache listener", e2.getMessage());
}
}
}
public void r() {
f.d("Shutdown proxy server");
s();
this.f3785g.f3775d.release();
this.f3784f.interrupt();
try {
if (this.f3782d.isClosed()) {
return;
}
this.f3782d.close();
} catch (IOException e2) {
n(new ProxyCacheException("Error shutting down proxy server", e2));
}
}
public void u(com.danikula.videocache.b bVar) {
l.d(bVar);
synchronized (this.a) {
Iterator<h> it = this.c.values().iterator();
while (it.hasNext()) {
it.next().h(bVar);
}
}
}
private g(com.danikula.videocache.c cVar) {
this.a = new Object();
this.b = Executors.newFixedThreadPool(8);
this.c = new ConcurrentHashMap();
l.d(cVar);
this.f3785g = cVar;
try {
ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
this.f3782d = serverSocket;
int localPort = serverSocket.getLocalPort();
this.f3783e = localPort;
j.a("127.0.0.1", localPort);
CountDownLatch countDownLatch = new CountDownLatch(1);
Thread thread = new Thread(new d(countDownLatch));
this.f3784f = thread;
thread.start();
countDownLatch.await();
this.f3786h = new k("127.0.0.1", localPort);
f.d("Proxy cache server started. Is it alive? " + l());
} catch (IOException | InterruptedException e2) {
this.b.shutdown();
throw new IllegalStateException("Error starting local proxy server", e2);
}
}
}