package com.tencent.mm.al;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.a.lp;
import com.tencent.mm.i.c;
import com.tencent.mm.i.d;
import com.tencent.mm.i.h;
import com.tencent.mm.modelvideo.s;
import com.tencent.mm.modelvideo.u;
import com.tencent.mm.plugin.appbrand.jsapi.ba;
import com.tencent.mm.sdk.b.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;

class e$2 implements Runnable {
    final /* synthetic */ String IN;
    final /* synthetic */ c fyU;
    final /* synthetic */ d fyV;
    final /* synthetic */ e fzs;

    e$2(e eVar, String str, c cVar, d dVar) {
        this.fzs = eVar;
        this.IN = str;
        this.fyU = cVar;
        this.fyV = dVar;
    }

    public final void run() {
        AppMethodBeat.i(50559);
        h hVar = (h) this.fzs.fyM.get(this.IN);
        if (hVar == null) {
            AppMethodBeat.o(50559);
        } else if (hVar.egK != null) {
            ab.i("MicroMsg.OnlineVideoService", "cdn callback %s route to videoCallback", new Object[]{this.IN});
            if (this.fyU != null) {
                hVar.egK.h(this.IN, this.fyU.field_finishedLength, this.fyU.field_toltalLength);
                AppMethodBeat.o(50559);
            } else if (this.fyV != null) {
                ab.i("MicroMsg.OnlineVideoService", "cdn callback %s route to videoCallback, sceneResult.retCode:%s", new Object[]{this.IN, Integer.valueOf(this.fyV.field_retCode)});
                hVar.egK.a(this.IN, this.fyV.field_retCode, this.fyV);
                this.fzs.fyM.remove(this.IN);
                if (this.fyV.field_retCode == 0) {
                    this.fzs.fzq.put(hVar.field_mediaId, hVar);
                    this.fzs.fzr.put(hVar.field_mediaId, this.fyV);
                }
                AppMethodBeat.o(50559);
            } else {
                AppMethodBeat.o(50559);
            }
        } else {
            s ut = u.ut(hVar.filename);
            lp lpVar;
            if (ut == null) {
                ab.w("MicroMsg.OnlineVideoService", "stream download video callback, but video info is null.[%s]", new Object[]{hVar.filename});
                AppMethodBeat.o(50559);
            } else if (hVar.egl != null) {
                hVar.egl.a(this.IN, 0, this.fyU, this.fyV, hVar.field_onlycheckexist);
                if (this.fyV != null) {
                    this.fzs.fyM.remove(this.IN);
                }
                AppMethodBeat.o(50559);
            } else if (this.fyU == null) {
                if (this.fyV != null) {
                    ab.i("MicroMsg.OnlineVideoService", "callback result info " + this.fyV.field_retCode + ", filesize:" + this.fyV.field_fileLength + ",recved:" + this.fyV.field_recvedBytes);
                    if (this.fyV.field_retCode != 0) {
                        if (this.fyV.field_retCode != -10012) {
                            u.um(ut.getFileName());
                        }
                        boolean Jr = hVar.Jr();
                        int i = this.fyV.field_retCode;
                        int i2 = hVar.egD;
                        if (Jr) {
                            if (i2 == 1) {
                                if (i == -5103059) {
                                    com.tencent.mm.plugin.report.service.h.pYm.a(354, 111, 1, false);
                                } else if (i == -5103087) {
                                    com.tencent.mm.plugin.report.service.h.pYm.a(354, 112, 1, false);
                                } else if (i == -10012) {
                                    com.tencent.mm.plugin.report.service.h.pYm.a(354, 113, 1, false);
                                } else {
                                    com.tencent.mm.plugin.report.service.h.pYm.a(354, 114, 1, false);
                                }
                            } else if (i == -5103059) {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 116, 1, false);
                            } else if (i == -5103087) {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 117, 1, false);
                            } else if (i == -10012) {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 118, 1, false);
                            } else {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 119, 1, false);
                            }
                            com.tencent.mm.plugin.report.service.h.pYm.e(13836, new Object[]{Integer.valueOf(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_EXTRA_SUBTITLE_COUNT), Long.valueOf(bo.anT()), Integer.valueOf(i)});
                        } else {
                            com.tencent.mm.plugin.report.service.h.pYm.a(354, 213, 1, false);
                            if (i2 == 1) {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 214, 1, false);
                            } else {
                                com.tencent.mm.plugin.report.service.h.pYm.a(354, 215, 1, false);
                            }
                            com.tencent.mm.plugin.report.service.h.pYm.e(13836, new Object[]{Integer.valueOf(ba.CTRL_INDEX), Long.valueOf(bo.anT()), Integer.valueOf(i)});
                        }
                    } else {
                        e.a(ut, this.fyV.field_fileLength, hVar.egB);
                        this.fzs.fzq.put(hVar.field_mediaId, hVar);
                        this.fzs.fzr.put(hVar.field_mediaId, this.fyV);
                    }
                    lpVar = new lp();
                    lpVar.cHq.cAd = 4;
                    lpVar.cHq.cHr = this.IN;
                    lpVar.cHq.offset = 0;
                    lpVar.cHq.retCode = this.fyV.field_retCode;
                    lpVar.cHq.length = this.fyV.field_fileLength;
                    a.xxA.m(lpVar);
                    this.fzs.fyM.remove(this.IN);
                }
                AppMethodBeat.o(50559);
            } else if (this.fyU.field_finishedLength == ut.frO) {
                ab.i("MicroMsg.OnlineVideoService", "stream download finish.");
                AppMethodBeat.o(50559);
            } else if (ut.status == 130 || ut.fWY <= this.fyU.field_finishedLength) {
                ab.i("MicroMsg.OnlineVideoService", "callback progress info " + this.fyU.field_finishedLength);
                ut.fXb = bo.anT();
                ut.fWY = this.fyU.field_finishedLength;
                ut.bJt = 1040;
                u.f(ut);
                lpVar = new lp();
                lpVar.cHq.cAd = 5;
                lpVar.cHq.cHr = this.IN;
                lpVar.cHq.offset = this.fyU.field_finishedLength;
                lpVar.cHq.length = this.fyU.field_toltalLength;
                a.xxA.m(lpVar);
                AppMethodBeat.o(50559);
            } else {
                ab.w("MicroMsg.OnlineVideoService", "set video error. db now size %d, cdn callback %d.", new Object[]{Integer.valueOf(ut.fWY), Integer.valueOf(this.fyU.field_finishedLength)});
                AppMethodBeat.o(50559);
            }
        }
    }
}
