正在查看: Spermatid Pro v6.4.3 应用的 DataLoaderHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Spermatid Pro v6.4.3 应用的 DataLoaderHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.bykv.vk.component.ttvideo;
import android.content.Context;
import android.text.TextUtils;
import cn.hutool.setting.AbsSetting;
import com.bumptech.glide.load.Key;
import com.bykv.vk.component.ttvideo.log.VideoEventEngineUploader;
import com.bykv.vk.component.ttvideo.mediakit.medialoader.AVMDLDataLoader;
import com.bykv.vk.component.ttvideo.mediakit.medialoader.AVMDLDataLoaderConfigure;
import com.bykv.vk.component.ttvideo.mediakit.medialoader.AVMDLDataLoaderListener;
import com.bykv.vk.component.ttvideo.mediakit.medialoader.AVMDLDataLoaderNotifyInfo;
import com.bykv.vk.component.ttvideo.mediakit.medialoader.AVMDLStartCompleteListener;
import com.bykv.vk.component.ttvideo.utils.Error;
import com.bykv.vk.component.ttvideo.utils.TTVideoEngineLog;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
public class DataLoaderHelper implements AVMDLDataLoaderListener, AVMDLStartCompleteListener {
public static final int DATALOADER_KEY_ENABLE_ALOG = 512;
public static final int DATALOADER_KEY_INT_MAXCACHESIZE = 1;
public static final int DATALOADER_KEY_INT_OPENTIMEOUT = 3;
public static final int DATALOADER_KEY_INT_PARALLEL_NUM = 11;
public static final int DATALOADER_KEY_INT_RWTIMEOUT = 2;
public static final int DATALOADER_KEY_INT_TRYCOUNT = 4;
public static final int DATALOADER_KEY_SET_MDL_PROTOCOL_ENABLE = 1005;
public static final int DATALOADER_KEY_STRING_CACHEDIR = 0;
public static final int IsClose = 1;
public static final int IsPlayTask = 1;
public static final int IsPreloadTask = 2;
public static final int IsStart = 0;
public static final int IsUnknown = 0;
public static final String MDL_PREFIX = "mdl://";
private static final DataLoaderHelper p = new DataLoaderHelper();
private static int f1387q = 0;
private static int f1388r = 0;
private static int s = 0;
private final d b;
private final d c;
private final d d;
private final d e;
private AVMDLDataLoader f1391i;
private VideoEventEngineUploader k;
private boolean f1392m;
private final ConcurrentHashMap<String, c> f1389f = new ConcurrentHashMap<>();
private final HashMap<String, ArrayList<TTVideoEngine>> g = new HashMap<>();
private final ReentrantLock f1390h = new ReentrantLock();
private boolean l = true;
private int f1393n = 0;
private final ReentrantLock o = new ReentrantLock();
private volatile int a = 1;
private AVMDLDataLoaderConfigure j = AVMDLDataLoaderConfigure.getDefaultonfigure();
public class d {
private final ReentrantLock a;
private final ArrayList<b> b;
private long c;
private d(DataLoaderHelper dataLoaderHelper) {
this.a = new ReentrantLock();
this.b = new ArrayList<>();
this.c = 0L;
}
private Boolean e() {
if (this.c >= 1) {
return Boolean.valueOf(((long) this.b.size()) >= this.c);
}
return Boolean.FALSE;
}
public b a() {
this.a.lock();
if (this.b.size() == 0) {
this.a.unlock();
return null;
}
b bVar = this.b.get(r0.size() - 1);
this.a.unlock();
return bVar;
}
public void a(long j) {
this.c = j;
}
public boolean a(b bVar) {
Boolean bool;
if (bVar == null || bVar.e.size() == 0) {
return false;
}
this.a.lock();
if (e().booleanValue()) {
bool = Boolean.FALSE;
} else {
this.b.add(bVar);
bool = Boolean.TRUE;
}
this.a.unlock();
return bool.booleanValue();
}
public boolean a(String str) {
int i3 = 0;
if (TextUtils.isEmpty(str)) {
return false;
}
Boolean bool = Boolean.FALSE;
this.a.lock();
while (true) {
if (i3 >= this.b.size()) {
break;
}
if (this.b.get(i3).b(str) != null) {
bool = Boolean.TRUE;
break;
}
i3++;
}
this.a.unlock();
return bool.booleanValue();
}
public long b() {
this.a.lock();
long size = this.b.size();
this.a.unlock();
return size;
}
public b b(b bVar) {
b bVar2;
if (TextUtils.isEmpty(bVar.a)) {
bVar2 = null;
} else {
bVar2 = d(bVar.a);
if (bVar2 != null) {
return bVar2;
}
}
Iterator it = bVar.e.iterator();
while (it.hasNext() && (bVar2 = c(((DataLoaderHelper$b$a) it.next()).a)) == null) {
}
return bVar2;
}
public b b(String str) {
b bVar = null;
if (TextUtils.isEmpty(str)) {
return null;
}
this.a.lock();
int i3 = 0;
while (true) {
if (i3 >= this.b.size()) {
break;
}
b bVar2 = this.b.get(i3);
if (bVar2.b(str) != null) {
bVar = bVar2;
break;
}
i3++;
}
this.a.unlock();
return bVar;
}
public b c() {
this.a.lock();
if (this.b.size() == 0) {
this.a.unlock();
return null;
}
b bVar = this.b.get(r0.size() - 1);
this.b.remove(bVar);
this.a.unlock();
return bVar;
}
public b c(String str) {
b bVar = null;
if (TextUtils.isEmpty(str)) {
return null;
}
this.a.lock();
int i3 = 0;
while (true) {
if (i3 >= this.b.size()) {
break;
}
b bVar2 = this.b.get(i3);
if (bVar2.b(str) != null) {
bVar = bVar2;
break;
}
i3++;
}
if (bVar != null) {
this.b.remove(bVar);
}
this.a.unlock();
return bVar;
}
public b d(String str) {
b bVar = null;
if (TextUtils.isEmpty(str)) {
return null;
}
this.a.lock();
int i3 = 0;
while (true) {
if (i3 >= this.b.size()) {
break;
}
b bVar2 = this.b.get(i3);
if (!TextUtils.isEmpty(bVar2.a) && bVar2.a.equals(str)) {
bVar = bVar2;
break;
}
i3++;
}
if (bVar != null) {
this.b.remove(bVar);
}
this.a.unlock();
return bVar;
}
public ArrayList<b> d() {
try {
this.a.lock();
return new ArrayList<>(this.b);
} finally {
this.a.unlock();
}
}
}
private DataLoaderHelper() {
this.b = new d();
this.c = new d();
this.d = new d();
this.e = new d();
}
private String a(String str, String str2, long j, long j2, String[] strArr, String str3) {
String str4;
if (TextUtils.isEmpty(str) || strArr == null || strArr.length <= 0) {
return null;
}
String[] strArr2 = (String[]) strArr.clone();
if (j2 <= 0) {
j2 = 0;
}
for (String str5 : strArr2) {
if (!c(str5)) {
return null;
}
}
String[] a2 = a(strArr2);
String encodeUrl = encodeUrl(str);
if (TextUtils.isEmpty(encodeUrl)) {
return null;
}
TTVideoEngineLog.i("DataLoaderHelper", "preloadProxyQuery: key = " + str + ", rawKey = " + str2);
if (!TextUtils.isEmpty(str2)) {
str = str2;
}
String encodeUrl2 = encodeUrl(str);
if (TextUtils.isEmpty(encodeUrl2)) {
encodeUrl2 = "videoId";
}
StringBuffer stringBuffer = new StringBuffer("?rk=");
stringBuffer.append(encodeUrl2);
stringBuffer.append("&k=");
stringBuffer.append(encodeUrl);
if (j2 > 0) {
stringBuffer.append("&s=");
stringBuffer.append(j + j2);
}
if (!TextUtils.isEmpty(str3)) {
try {
str4 = URLEncoder.encode(str3, Key.STRING_CHARSET_NAME);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
str4 = null;
}
if (!TextUtils.isEmpty(str4)) {
stringBuffer.append("&p=");
stringBuffer.append(str4);
}
}
StringBuffer stringBuffer2 = new StringBuffer();
for (int i3 = 0; i3 < a2.length; i3++) {
String encodeUrlByQuery = encodeUrlByQuery(a2[i3]);
StringBuffer stringBuffer3 = new StringBuffer();
if (!TextUtils.isEmpty(encodeUrlByQuery)) {
stringBuffer3.append("&u");
stringBuffer3.append(i3);
stringBuffer3.append("=");
stringBuffer3.append(encodeUrlByQuery);
}
if (stringBuffer.length() + stringBuffer2.length() + stringBuffer3.length() + 32 > 3096) {
break;
}
stringBuffer2.append(stringBuffer3);
}
if (stringBuffer2.length() <= 0) {
return null;
}
stringBuffer.append(stringBuffer2);
return stringBuffer.toString();
}
private ArrayList<TTVideoEngine> a(String str) {
ArrayList<TTVideoEngine> arrayList = null;
if (TextUtils.isEmpty(str)) {
return null;
}
try {
this.f1390h.lock();
ArrayList<TTVideoEngine> arrayList2 = this.g.get(str);
if (arrayList2 != null) {
arrayList = new ArrayList<>(arrayList2);
TTVideoEngineLog.i("DataLoaderHelper", "get engine ref,rawKey = " + str + " engine ref count: " + arrayList.size());
}
return arrayList;
} finally {
this.f1390h.unlock();
}
}
private void a() {
if (this.f1391i == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] need load mdl first.");
return;
}
b a2 = this.b.a();
if (a2 != null && this.c.a(a2)) {
this.b.c();
if (a2.c != null) {
b(a2);
}
}
}
private void a(b bVar) {
boolean z4;
ArrayList<TTVideoEngine> a2;
ArrayList<b> d2 = this.e.d();
int i3 = 0;
while (true) {
if (i3 >= d2.size()) {
z4 = true;
break;
}
b bVar2 = d2.get(i3);
if (!TextUtils.isEmpty(bVar2.a) && !TextUtils.isEmpty(bVar.a) && bVar2.a.equals(bVar.a)) {
z4 = false;
break;
}
i3++;
}
if (!z4 || (a2 = a(bVar.a)) == null || a2.size() == 0) {
return;
}
for (int i4 = 0; i4 < a2.size(); i4++) {
a2.get(i4).a();
}
}
private void a(b bVar, DataLoaderHelper$b$a dataLoaderHelper$b$a) {
if (bVar == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] start mdl preload task fail. item is null");
return;
}
if (dataLoaderHelper$b$a == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] start mdl preload task fail. track is null");
notifyPreloadError(bVar.c, -100004);
return;
}
TTVideoEngineLog.i("DataLoaderHelper", "[preload] start mdl preload task. key = " + dataLoaderHelper$b$a.a);
String str = dataLoaderHelper$b$a.a;
String[] strArr = dataLoaderHelper$b$a.c;
if (strArr != null) {
String a2 = a(str, bVar.a, dataLoaderHelper$b$a.f1394f, 0L, strArr, dataLoaderHelper$b$a.d);
dataLoaderHelper$b$a.b = a2;
if (!TextUtils.isEmpty(a2)) {
this.d.a(bVar);
if (dataLoaderHelper$b$a.f1394f > 0) {
long j = dataLoaderHelper$b$a.e;
if (j > 0) {
this.f1391i.preloadResource(dataLoaderHelper$b$a.b, (int) j);
}
this.f1391i.preloadResource(dataLoaderHelper$b$a.b, (int) dataLoaderHelper$b$a.f1394f, (int) dataLoaderHelper$b$a.g);
} else {
this.f1391i.preloadResource(dataLoaderHelper$b$a.b, (int) dataLoaderHelper$b$a.g);
}
TTVideoEngineLog.i("DataLoaderHelper", String.format("[preload] exect preload task ,key is %s; videoId = %s", dataLoaderHelper$b$a.a, bVar.a));
return;
}
}
bVar.a(-100001);
}
private void a(AVMDLDataLoaderNotifyInfo aVMDLDataLoaderNotifyInfo, boolean z4, boolean z5) {
b b;
d dVar;
if (aVMDLDataLoaderNotifyInfo == null || TextUtils.isEmpty(aVMDLDataLoaderNotifyInfo.logInfo)) {
return;
}
String[] split = aVMDLDataLoaderNotifyInfo.logInfo.split(AbsSetting.DEFAULT_DELIMITER);
if (split.length < 4) {
return;
}
boolean z6 = false;
try {
long longValue = Long.valueOf(split[0]).longValue();
long longValue2 = Long.valueOf(split[1]).longValue();
if (longValue2 <= 0 && !z5) {
TTVideoEngineLog.i("DataLoaderHelper", "[preload] mediaSize <= 0 return " + aVMDLDataLoaderNotifyInfo.logInfo);
return;
}
String str = split[2];
String str2 = split[3];
if (z4 || z5) {
b = this.d.b(str);
if (b == null) {
TTVideoEngineLog.i("DataLoaderHelper", "[preload] preload temItem == null return " + aVMDLDataLoaderNotifyInfo.logInfo);
return;
}
dVar = this.d;
z6 = true;
} else {
b = this.e.b(str);
if (b == null) {
TTVideoEngineLog.i("DataLoaderHelper", "[preload] play temItem == null return " + aVMDLDataLoaderNotifyInfo.logInfo);
return;
}
dVar = this.e;
}
DataLoaderHelper$b$a b2 = b.b(str);
if (b2 != null) {
b2.f1395h = longValue2;
b2.f1396i = longValue;
b2.d = str2;
}
String str3 = TextUtils.isEmpty(b.a) ? str : b.a;
c loadProgressByRawKey = getLoadProgressByRawKey(str3);
if (loadProgressByRawKey == null) {
loadProgressByRawKey = new c(this);
}
loadProgressByRawKey.a = b.a;
loadProgressByRawKey.b = z4 ? 2 : 1;
loadProgressByRawKey.a(b);
putByRawKey(str3, loadProgressByRawKey);
if (loadProgressByRawKey.b() || z5) {
if (!z6) {
dVar.c(str);
}
removeLoadProgressByRawKey(str3);
if (!z4) {
a(b);
}
if (b.a() == null || !z5) {
return;
}
s++;
dVar.c(str);
DataLoaderTaskProgressInfo dataLoaderTaskProgressInfo = new DataLoaderTaskProgressInfo();
dataLoaderTaskProgressInfo.mCacheSizeFromZero = longValue;
dataLoaderTaskProgressInfo.mMediaSize = longValue2;
dataLoaderTaskProgressInfo.mKey = str;
dataLoaderTaskProgressInfo.mLocalFilePath = str2;
dataLoaderTaskProgressInfo.mVideoId = b.a;
dataLoaderTaskProgressInfo.mTaskType = loadProgressByRawKey.b;
PreLoaderItemCallBackInfo preLoaderItemCallBackInfo = new PreLoaderItemCallBackInfo(2);
preLoaderItemCallBackInfo.preloadDataInfo = dataLoaderTaskProgressInfo;
preLoaderItemCallBackInfo.loadProgress = loadProgressByRawKey;
b.a().preloadItemInfo(preLoaderItemCallBackInfo);
TTVideoEngineLog.i("DataLoaderHelper", "[preload] notify end cache size = " + loadProgressByRawKey.a());
}
} catch (Exception unused) {
}
}
private void a(String str, String str2, long j, PreloaderURLItem preloaderURLItem) {
if (TextUtils.isEmpty(str)) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] key invalid.");
notifyPreloadError(preloaderURLItem, -100001);
return;
}
if (this.f1391i == null || this.a != 0) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] need load mdl first.");
notifyPreloadError(preloaderURLItem, -100002);
} else {
if (this.c.a(str) || this.b.a(str)) {
notifyPreloadError(preloaderURLItem, -100003);
return;
}
b bVar = new b(this);
bVar.a(str, j);
bVar.a = str2;
bVar.c = preloaderURLItem;
this.b.a(bVar);
a();
}
}
private boolean a(d dVar) {
boolean z4 = false;
if (dVar.b() > 0) {
while (true) {
b c = dVar.c();
if (c == null) {
break;
}
z4 = true;
c(c);
}
}
return z4;
}
private String[] a(String[] strArr) {
if (strArr == null || strArr.length <= 1) {
return strArr;
}
ArrayList arrayList = new ArrayList();
arrayList.add(strArr[0]);
for (int i3 = 1; i3 < strArr.length; i3++) {
String str = strArr[i3];
Boolean bool = Boolean.TRUE;
int size = arrayList.size() - 1;
while (true) {
if (size < 0) {
break;
}
if (((String) arrayList.get(size)).equals(str)) {
bool = Boolean.FALSE;
break;
}
size--;
}
if (bool.booleanValue()) {
arrayList.add(str);
}
}
String[] strArr2 = new String[arrayList.size()];
arrayList.toArray(strArr2);
return strArr2;
}
private DataLoaderCacheInfo b(String str) {
DataLoaderCacheInfo dataLoaderCacheInfo = null;
if (str == null) {
return null;
}
String[] split = str.split(AbsSetting.DEFAULT_DELIMITER);
if (split.length >= 4) {
dataLoaderCacheInfo = new DataLoaderCacheInfo(this);
dataLoaderCacheInfo.mLocalFilePath = split[3];
if (!TextUtils.isEmpty(split[0])) {
dataLoaderCacheInfo.mCacheSizeFromZero = Long.parseLong(split[0]);
}
if (!TextUtils.isEmpty(split[1])) {
dataLoaderCacheInfo.mMediaSize = Long.parseLong(split[1]);
}
}
return dataLoaderCacheInfo;
}
private void b(b bVar) {
if (bVar == null) {
a();
return;
}
if (this.f1391i == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] need load mdl first.");
return;
}
this.c.b(bVar);
long j = bVar.b;
PreloaderURLItem preloaderURLItem = bVar.c;
if (preloaderURLItem != null && preloaderURLItem.getUrls() != null && bVar.c.getUrls().length > 0) {
DataLoaderHelper$b$a dataLoaderHelper$b$a = (DataLoaderHelper$b$a) bVar.e.get(0);
dataLoaderHelper$b$a.c = bVar.c.getUrls();
dataLoaderHelper$b$a.g = bVar.b;
dataLoaderHelper$b$a.d = bVar.c.getFilePath();
a(bVar, dataLoaderHelper$b$a);
}
if (bVar.a() != null) {
PreLoaderItemCallBackInfo preLoaderItemCallBackInfo = new PreLoaderItemCallBackInfo(6);
preLoaderItemCallBackInfo.preloadType = 0;
preLoaderItemCallBackInfo.videoPreloadSize = j;
preLoaderItemCallBackInfo.audioPreloadSize = 0L;
bVar.a().preloadItemInfo(preLoaderItemCallBackInfo);
TTVideoEngineLog.i("DataLoaderHelper", "[preload] notify info. type = 0");
}
a();
}
public static int c() {
int i3 = s;
s = i3 + 1;
return i3;
}
private void c(b bVar) {
if (bVar == null || bVar.d) {
return;
}
bVar.d = true;
if (bVar.a() != null) {
s++;
bVar.a().preloadItemInfo(new PreLoaderItemCallBackInfo(5));
}
}
private boolean c(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
String lowerCase = str.toLowerCase();
return (lowerCase.startsWith("http://127.0.0.1") || lowerCase.startsWith("http://localhost") || lowerCase.startsWith(MDL_PREFIX) || lowerCase.startsWith("file://") || lowerCase.startsWith("/") || lowerCase.endsWith(".mpd") || lowerCase.contains(".mpd?")) ? false : true;
}
private boolean d() {
if (this.f1391i != null) {
return true;
}
if (AVMDLDataLoader.init(false, false) != 0) {
TTVideoEngineLog.e("DataLoaderHelper", "library has not been loaded");
return false;
}
try {
AVMDLDataLoader aVMDLDataLoader = AVMDLDataLoader.getInstance();
this.f1391i = aVMDLDataLoader;
aVMDLDataLoader.setConfigure(this.j);
this.f1391i.setListener(this);
this.f1391i.setStartCompleteListener(this);
return true;
} catch (Exception unused) {
return false;
}
}
public static String encodeUrl(String str) {
if (TextUtils.isEmpty(str)) {
return str;
}
try {
return URLEncoder.encode(str, Key.STRING_CHARSET_NAME);
} catch (UnsupportedEncodingException unused) {
return null;
}
}
public static String encodeUrlByQuery(String str) {
if (TextUtils.isEmpty(str)) {
return str;
}
try {
String queryComponentEncode = AVMDLDataLoader.queryComponentEncode(str);
return TextUtils.isEmpty(queryComponentEncode) ? URLEncoder.encode(str, Key.STRING_CHARSET_NAME) : queryComponentEncode;
} catch (UnsupportedEncodingException unused) {
return null;
}
}
public static DataLoaderHelper getDataLoader() {
return p;
}
public void _addEngine(TTVideoEngine tTVideoEngine, String str) {
if (TextUtils.isEmpty(str)) {
return;
}
try {
this.f1390h.lock();
ArrayList<TTVideoEngine> arrayList = this.g.get(str);
if (arrayList == null) {
arrayList = new ArrayList<>();
this.g.put(str, arrayList);
}
if (!arrayList.contains(tTVideoEngine)) {
arrayList.add(tTVideoEngine);
TTVideoEngineLog.i("DataLoaderHelper", "add engine ref,rawKey = " + str + " engine ref count: " + arrayList.size());
}
} finally {
this.f1390h.unlock();
}
}
public String _proxyUrl(String str, String str2, long j, String[] strArr, String str3) {
if (this.a != 0 || TextUtils.isEmpty(str) || strArr == null || strArr.length <= 0) {
return null;
}
String[] strArr2 = (String[]) strArr.clone();
for (String str4 : strArr2) {
if (!c(str4)) {
return str4;
}
}
if (this.f1391i == null) {
TTVideoEngineLog.e("DataLoaderHelper", "start mdl first");
return null;
}
this.o.lock();
try {
String localAddr = this.f1391i.getLocalAddr();
if (TextUtils.isEmpty(localAddr)) {
TTVideoEngineLog.e("DataLoaderHelper", "local host error");
return null;
}
String a2 = a(str, str2, 0L, j, strArr2, str3);
if (TextUtils.isEmpty(a2)) {
return null;
}
StringBuffer stringBuffer = new StringBuffer();
int i3 = this.f1393n;
this.f1393n = i3 + 1;
StringBuffer stringBuffer2 = new StringBuffer();
TTVideoEngineLog.i("DataLoaderHelper", "proxy url, mInvalidMdlProcotol: " + this.l);
if (this.l || !this.f1392m) {
stringBuffer.append("http://");
stringBuffer.append(localAddr);
stringBuffer.append("/");
stringBuffer.append(i3);
} else {
stringBuffer.append("mdl://id");
stringBuffer.append(i3);
stringBuffer.append("/");
}
stringBuffer.append(a2);
stringBuffer2.append(a2);
String auth = this.f1391i.getAuth(a2);
if (!TextUtils.isEmpty(auth)) {
stringBuffer.append("&ah=");
stringBuffer.append(auth);
stringBuffer.append("&ah=");
stringBuffer.append(auth);
}
String stringBuffer3 = stringBuffer.toString();
TTVideoEngineLog.i("DataLoaderHelper", "_proxyUrl: ".concat(String.valueOf(stringBuffer3)));
this.o.unlock();
b d2 = this.e.d(str2);
if (d2 == null) {
d2 = new b(this);
}
DataLoaderHelper$b$a a3 = d2.a(str);
if (a3 != null) {
a3.a = str;
d2.a = str2;
a3.b = stringBuffer3;
a3.c = strArr2;
a3.d = str3;
this.e.a(d2);
}
return stringBuffer3;
} finally {
this.o.unlock();
}
}
public void _removeEngine(TTVideoEngine tTVideoEngine, String str) {
if (TextUtils.isEmpty(str)) {
return;
}
try {
this.f1390h.lock();
ArrayList<TTVideoEngine> arrayList = this.g.get(str);
if (arrayList != null) {
arrayList.remove(tTVideoEngine);
TTVideoEngineLog.i("DataLoaderHelper", "remove engine ref,rawKey = " + str + " engine ref count: " + arrayList.size());
if (arrayList.size() == 0) {
this.g.remove(str);
}
}
} finally {
this.f1390h.unlock();
}
}
public void _removePlayTask(String str) {
this.e.c(str);
}
public void addTask(PreloaderURLItem preloaderURLItem) {
f1387q++;
if (preloaderURLItem == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] url item invalid");
return;
}
this.o.lock();
try {
a(preloaderURLItem.getKey(), preloaderURLItem.getVideoId(), preloaderURLItem.getPreloadSize(), preloaderURLItem);
} finally {
this.o.unlock();
}
}
public void cancelAllTasks() {
if (this.f1391i == null || this.a != 0) {
TTVideoEngineLog.e("DataLoaderHelper", "need start mdl first");
return;
}
this.o.lock();
try {
cancelAllTasksInternal();
this.o.unlock();
} catch (Throwable unused) {
this.o.unlock();
}
}
public void cancelAllTasksInternal() {
a(this.c);
a(this.b);
if (a(this.d)) {
this.f1391i.cancelAll();
}
}
public void cancelTask(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
if (this.f1391i == null || this.a != 0) {
TTVideoEngineLog.e("DataLoaderHelper", "need start mdl first");
return;
}
this.o.lock();
try {
b c = this.b.c(str);
if (c == null && (c = this.c.c(str)) == null) {
c = this.d.c(str);
if (c != null) {
this.f1391i.cancel(str);
}
TTVideoEngineLog.i("DataLoaderHelper", "[preload] cancel preload task. key = ".concat(String.valueOf(str)));
this.o.unlock();
}
c(c);
TTVideoEngineLog.i("DataLoaderHelper", "[preload] cancel preload task. key = ".concat(String.valueOf(str)));
this.o.unlock();
} catch (Throwable unused) {
this.o.unlock();
}
}
public void clearAllCaches() {
if (this.a != 0) {
return;
}
this.o.lock();
try {
AVMDLDataLoader aVMDLDataLoader = this.f1391i;
if (aVMDLDataLoader == null) {
TTVideoEngineLog.e("DataLoaderHelper", "mInnerDataLoader == null");
} else {
aVMDLDataLoader.clearAllCaches();
}
} finally {
try {
} finally {
}
}
}
public void close() {
this.o.lock();
try {
if (this.a == 1) {
TTVideoEngineLog.e("DataLoaderHelper", "DataLoader not started, not need close");
} else {
this.f1391i.close();
cancelAllTasksInternal();
this.a = 1;
}
} finally {
this.o.unlock();
}
}
public DataLoaderCacheInfo getCacheInfoByFilePath(String str, String str2) {
this.o.lock();
try {
AVMDLDataLoader aVMDLDataLoader = this.f1391i;
if (aVMDLDataLoader != null) {
DataLoaderCacheInfo b = b(aVMDLDataLoader.getStringCacheInfo(str, str2));
this.o.unlock();
return b;
}
} catch (Throwable unused) {
}
this.o.unlock();
return null;
}
public long getCacheSize(String str) {
long j = 0;
if (this.a != 0) {
return 0L;
}
this.o.lock();
try {
AVMDLDataLoader aVMDLDataLoader = this.f1391i;
if (aVMDLDataLoader != null) {
long cacheSize = aVMDLDataLoader.getCacheSize(str);
if (cacheSize > 0) {
j = cacheSize;
}
}
} finally {
try {
return j;
} finally {
}
}
return j;
}
public long getCacheSizeByFilePath(String str, String str2) {
this.o.lock();
long j = 0;
try {
DataLoaderCacheInfo cacheInfoByFilePath = getCacheInfoByFilePath(str, str2);
if (cacheInfoByFilePath != null) {
j = cacheInfoByFilePath.mCacheSizeFromZero;
}
} catch (Throwable unused) {
}
this.o.unlock();
return j;
}
public String getCheckSumInfo(String str) {
return null;
}
public long getInt64Value(int i3, long j) {
return 0L;
}
public c getLoadProgressByRawKey(String str) {
if (!TextUtils.isEmpty(str)) {
return this.f1389f.get(str);
}
TTVideoEngineLog.e("DataLoaderHelper", "[preload] get, param is invalid key is null");
return null;
}
public String getStringValue(int i3, long j, String str) {
return null;
}
public void notifyPreloadError(PreloaderURLItem preloaderURLItem, int i3) {
IPreLoaderItemCallBackListener callBackListener = preloaderURLItem.getCallBackListener();
if (callBackListener != null) {
s++;
PreLoaderItemCallBackInfo preLoaderItemCallBackInfo = new PreLoaderItemCallBackInfo(3);
preLoaderItemCallBackInfo.preloadError = new Error("kTTVideoErrorDomainDataLoaderPreload", i3);
callBackListener.preloadItemInfo(preLoaderItemCallBackInfo);
}
}
public void onNotify(AVMDLDataLoaderNotifyInfo aVMDLDataLoaderNotifyInfo) {
String str;
b b;
if (aVMDLDataLoaderNotifyInfo == null) {
return;
}
int i3 = aVMDLDataLoaderNotifyInfo.what;
if (i3 != 0 && i3 != 15) {
if (i3 != 20) {
if (i3 == 3 || i3 == 4) {
if (i3 == 4) {
f1388r++;
}
if (aVMDLDataLoaderNotifyInfo.logInfo != null) {
long j = aVMDLDataLoaderNotifyInfo.parameter;
if (j != 3) {
a(aVMDLDataLoaderNotifyInfo, j == 2, i3 == 4);
return;
}
return;
}
return;
}
if (i3 == 7) {
f1388r++;
if (TextUtils.isEmpty(aVMDLDataLoaderNotifyInfo.logInfo)) {
return;
}
String[] split = aVMDLDataLoaderNotifyInfo.logInfo.split(AbsSetting.DEFAULT_DELIMITER);
if (split.length < 4) {
return;
}
String str2 = split[2];
b b2 = this.d.b(str2);
this.d.c(str2);
c(b2);
return;
}
if (i3 != 8) {
if (i3 != 10 && i3 != 11) {
return;
}
}
}
if (i3 == 8) {
f1388r++;
}
String str3 = aVMDLDataLoaderNotifyInfo.logInfo;
if ((str3 == null || aVMDLDataLoaderNotifyInfo.parameter != 3) && str3 != null) {
TTVideoEngineLog.i("DataLoaderHelper", " task fail log = " + aVMDLDataLoaderNotifyInfo.logInfo + ", code = " + aVMDLDataLoaderNotifyInfo.code + ", task type = " + aVMDLDataLoaderNotifyInfo.parameter);
String[] split2 = aVMDLDataLoaderNotifyInfo.logInfo.split(AbsSetting.DEFAULT_DELIMITER);
if (split2.length > 0 && (b = this.d.b((str = split2[0]))) != null) {
d dVar = this.d;
Error error = new Error("kTTVideoErrorDomainDataLoaderPreload", (int) aVMDLDataLoaderNotifyInfo.code, aVMDLDataLoaderNotifyInfo.logInfo);
String str4 = TextUtils.isEmpty(b.a) ? str : b.a;
c loadProgressByRawKey = getLoadProgressByRawKey(str4);
if (loadProgressByRawKey == null) {
loadProgressByRawKey = new c(this);
}
loadProgressByRawKey.a = b.a;
loadProgressByRawKey.b = (int) aVMDLDataLoaderNotifyInfo.parameter;
loadProgressByRawKey.a(b);
loadProgressByRawKey.a(str, error);
putByRawKey(str4, loadProgressByRawKey);
if (!loadProgressByRawKey.b() && !loadProgressByRawKey.c()) {
loadProgressByRawKey.b();
loadProgressByRawKey.c();
return;
}
dVar.c(str);
TTVideoEngineLog.i("DataLoaderHelper", "pop all task item. videoId = " + b.a + " key = " + str);
removeLoadProgressByRawKey(str4);
if (b.a() == null || aVMDLDataLoaderNotifyInfo.parameter != 2) {
return;
}
PreLoaderItemCallBackInfo preLoaderItemCallBackInfo = new PreLoaderItemCallBackInfo(3);
preLoaderItemCallBackInfo.preloadError = error;
preLoaderItemCallBackInfo.loadProgress = loadProgressByRawKey;
preLoaderItemCallBackInfo.preloadDataInfo = null;
s++;
b.a().preloadItemInfo(preLoaderItemCallBackInfo);
return;
}
return;
}
return;
}
VideoEventEngineUploader videoEventEngineUploader = this.k;
if (videoEventEngineUploader != null) {
videoEventEngineUploader.onEvent(aVMDLDataLoaderNotifyInfo.logType, aVMDLDataLoaderNotifyInfo.jsonLog);
}
}
public void onStartComplete() {
}
public void putByRawKey(String str, c cVar) {
if (TextUtils.isEmpty(str) || cVar == null) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] param is invalid");
} else {
this.f1389f.put(str, cVar);
}
}
public void removeCacheFile(String str, boolean z4) {
if (TextUtils.isEmpty(str)) {
return;
}
this.o.lock();
try {
if (this.f1391i == null) {
TTVideoEngineLog.e("DataLoaderHelper", "mInnerDataLoader == null");
} else {
TTVideoEngineLog.i("DataLoaderHelper", "remove mdl file. key ".concat(String.valueOf(str)));
if (z4) {
this.f1391i.forceRemoveFileCache(str);
} else {
this.f1391i.removeFileCache(str);
}
}
} catch (Throwable unused) {
}
this.o.unlock();
}
public void removeLoadProgressByRawKey(String str) {
if (TextUtils.isEmpty(str)) {
TTVideoEngineLog.e("DataLoaderHelper", "[preload] remove, param is invalid key is null");
} else {
this.f1389f.remove(str);
}
}
public void setCacheInfoLists(String[] strArr, long[] jArr) {
Arrays.toString(strArr);
Arrays.toString(jArr);
this.o.lock();
try {
this.j.setCacheInfoList(strArr, jArr);
} finally {
this.o.unlock();
}
}
public void setContext(Context context) {
this.o.lock();
this.o.unlock();
}
public synchronized void setEngineUploader(VideoEventEngineUploader videoEventEngineUploader) {
this.k = videoEventEngineUploader;
}
public void setIntValue(int i3, int i4) {
this.o.lock();
try {
try {
} catch (Exception e) {
e.printStackTrace();
}
if (i3 == 11) {
this.j.mPreloadParallelNum = i4;
AVMDLDataLoader aVMDLDataLoader = this.f1391i;
if (aVMDLDataLoader != null) {
aVMDLDataLoader.setIntValue(102, i4);
}
} else if (i3 != 512) {
boolean z4 = true;
if (i3 == 1005) {
if (i4 != 1) {
z4 = false;
}
this.f1392m = z4;
TTVideoEngineLog.i("DataLoaderHelper", "config DATALOADER_KEY_SET_MDL_PROTOCOL_ENABLE: " + this.f1392m);
} else if (i3 == 1) {
this.j.mMaxCacheSize = i4;
} else if (i3 == 2) {
this.j.mRWTimeOut = i4;
} else {
if (i3 != 3) {
if (i3 == 4) {
this.j.mTryCount = i4;
}
}
this.j.mOpenTimeOut = i4;
}
} else {
this.j.mAlogEnable = i4;
AVMDLDataLoader aVMDLDataLoader2 = this.f1391i;
if (aVMDLDataLoader2 != null) {
aVMDLDataLoader2.setIntValue(AVMDLDataLoader.KeyIsAlogEnable, i4);
}
}
} finally {
this.o.unlock();
}
}
public void setStringValue(int i3, String str) {
this.o.lock();
if (i3 == 0) {
try {
this.j.mCacheDir = str;
} catch (Exception unused) {
} catch (Throwable th) {
this.o.unlock();
throw th;
}
}
this.o.unlock();
}
public void start() {
this.o.lock();
try {
if (this.a == 0) {
TTVideoEngineLog.e("DataLoaderHelper", "DataLoader has started not need start");
} else {
if (!d()) {
throw new Exception("init data loader fail");
}
this.c.a(4L);
if (this.j == null) {
this.j = AVMDLDataLoaderConfigure.getDefaultonfigure();
}
if (this.k != null) {
this.j.mEnableReportTaskLog = 1;
}
this.f1391i.setConfigure(this.j);
if (this.f1391i.start() < 0) {
throw new Exception("start data loader fail");
}
if (this.f1391i.getLongValue(AVMDLDataLoader.KeyIsGetMdlProtocolHandle) == -1) {
this.l = true;
}
this.a = 0;
}
} finally {
this.o.unlock();
}
}
}