package com.tencent.mm.plugin.record.b;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.i.c;
import com.tencent.mm.i.d;
import com.tencent.mm.i.g.a;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.record.a.i;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.io.ByteArrayOutputStream;
import java.io.File;

class i$1 implements a {
    final /* synthetic */ i pJF;

    i$1(i iVar) {
        this.pJF = iVar;
    }

    public final int a(String str, int i, c cVar, d dVar, boolean z) {
        AppMethodBeat.i(135670);
        ab.v("MicroMsg.RecordMsgCDNService", "cdn transfer callback, startRet[%d], mediaId[%s]", new Object[]{Integer.valueOf(i), str});
        if (cVar != null) {
            ab.v("MicroMsg.RecordMsgCDNService", "cdn transfer callback, mediaid[%s], totallen[%d], offset[%d]", new Object[]{cVar.cHr, Integer.valueOf(cVar.field_toltalLength), Integer.valueOf(cVar.field_finishedLength)});
        }
        if (i == -21006 || i == -21005) {
            this.pJF.ceG();
            AppMethodBeat.o(135670);
            return 0;
        }
        i VH = ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().VH(str);
        if (VH == null) {
            ab.w("MicroMsg.RecordMsgCDNService", "onCdnCallback info null, mediaId[%s]", new Object[]{str});
            this.pJF.ceG();
            AppMethodBeat.o(135670);
            return 0;
        }
        if (i != 0) {
            ab.w("MicroMsg.RecordMsgCDNService", "[record] tran fail, startRet[%d], mediaId[%s], type[%d]", new Object[]{Integer.valueOf(i), str, Integer.valueOf(VH.field_type)});
            if (-5103059 == i) {
                VH.field_status = 4;
            } else {
                VH.field_status = 3;
            }
            VH.field_errCode = i;
            ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().b(VH, new String[]{"localId"});
        } else {
            if (cVar != null) {
                VH.field_offset = cVar.field_finishedLength;
                VH.field_totalLen = cVar.field_toltalLength;
                VH.field_status = 1;
                ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().b(VH, new String[]{"localId"});
            } else if (dVar != null) {
                String str2 = "MicroMsg.RecordMsgCDNService";
                String str3 = "[record] summersafecdn cdnCallback upload attach by cdn, retCode:%d isHitCacheUpload: %d, onlyCheckExist[%b], exist[%b], aesKey[%s], md5[%s], mediaId:%s, isDownload:%b";
                Object[] objArr = new Object[8];
                objArr[0] = Integer.valueOf(dVar.field_retCode);
                objArr[1] = Integer.valueOf(dVar.field_UploadHitCacheType);
                objArr[2] = Boolean.valueOf(z);
                objArr[3] = Boolean.valueOf(dVar.field_exist_whencheck);
                objArr[4] = bo.anv(dVar.field_aesKey);
                objArr[5] = dVar.field_filemd5;
                objArr[6] = str;
                objArr[7] = Boolean.valueOf(1 == VH.field_type);
                ab.i(str2, str3, objArr);
                if (dVar.field_retCode >= 0) {
                    VH.field_status = 2;
                    if (1 == VH.field_type) {
                        String str4 = VH.field_path + ".temp";
                        str2 = VH.field_path;
                        if (bo.isNullOrNil(str4) || bo.isNullOrNil(str2)) {
                            ab.w("MicroMsg.RecordMsgCDNService", "do rename and copy file, but path error");
                        } else {
                            File file = new File(str4);
                            File file2 = new File(str2);
                            if (file.exists()) {
                                boolean renameTo = file.renameTo(file2);
                                ab.v("MicroMsg.RecordMsgCDNService", "rename file suc:%b, old:%s, new:%s", new Object[]{Boolean.valueOf(renameTo), str4, file2});
                            }
                        }
                        ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().a(VH, new String[]{"localId"});
                    } else {
                        ab.i("MicroMsg.RecordMsgCDNService", "transfer done, mediaid=%s, md5=%s", new Object[]{dVar.cHr, str});
                        ab.d("MicroMsg.RecordMsgCDNService", "transfer done, completeInfo=%s", new Object[]{dVar});
                        ab.d("MicroMsg.RecordMsgCDNService", "summersafecdn cdnCallback upload field_aesKey[%s], field_fileId[%s]", new Object[]{dVar.field_aesKey, dVar.field_fileId});
                        if (dVar.Jm()) {
                            ab.i("MicroMsg.RecordMsgCDNService", "summersafecdn isUploadBySafeCDNWithMD5 field_upload_by_safecdn[%b], field_UploadHitCacheType[%d], crc[%d], aeskey[%s], newmd5[%s]", new Object[]{Boolean.valueOf(dVar.field_upload_by_safecdn), Integer.valueOf(dVar.field_UploadHitCacheType), Integer.valueOf(dVar.field_filecrc), dVar.field_aesKey, dVar.field_mp4identifymd5});
                            g.RO().eJo.a(new d(dVar.field_fileId, dVar.field_filemd5, dVar.field_mp4identifymd5, dVar.field_filecrc, new 1(this, VH, dVar)), 0);
                            AppMethodBeat.o(135670);
                            return 0;
                        }
                        VH.field_cdnKey = dVar.field_aesKey;
                        VH.field_cdnUrl = dVar.field_fileId;
                        ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().b(VH, new String[]{"localId"});
                    }
                } else {
                    ab.e("MicroMsg.RecordMsgCDNService", "transfer error, mediaid=%s, retCode:%d", new Object[]{dVar.cHr, Integer.valueOf(dVar.field_retCode)});
                    if (-5103059 == dVar.field_retCode) {
                        VH.field_status = 4;
                    } else {
                        VH.field_status = 3;
                    }
                    VH.field_errCode = dVar.field_retCode;
                    ((com.tencent.mm.plugin.record.a.a) g.M(com.tencent.mm.plugin.record.a.a.class)).getRecordMsgCDNStorage().b(VH, new String[]{"localId"});
                }
            }
            AppMethodBeat.o(135670);
            return 0;
        }
        this.pJF.ceG();
        AppMethodBeat.o(135670);
        return 0;
    }

    public final void a(String str, ByteArrayOutputStream byteArrayOutputStream) {
    }

    public final byte[] l(String str, byte[] bArr) {
        return null;
    }
}
