package com.tencent.mm.plugin.story.proxy;

import a.f.a.q;
import a.f.b.j;
import a.f.b.k;
import a.l;
import a.y;
import android.content.Context;
import android.os.Process;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.hardcoder.WXHardCoderJNI;
import com.tencent.mm.loader.g.c;
import com.tencent.mm.model.cb;
import com.tencent.mm.plugin.story.e.a;
import com.tencent.mm.plugin.story.g.f;
import com.tencent.mm.plugin.story.g.h;
import com.tencent.mm.plugin.story.h.d;
import com.tencent.mm.plugin.story.model.audio.AudioCacheInfo;
import com.tencent.mm.plugin.story.model.audio.g;
import com.tencent.mm.protocal.protobuf.cee;
import com.tencent.mm.protocal.protobuf.cei;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;

@l(dWo = {1, 1, 13}, dWp = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u000b\u001a\u00020\fH\u0016J\b\u0010\r\u001a\u00020\fH\u0002J\b\u0010\u000e\u001a\u00020\u000fH\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0007\u001a\u0004\u0018\u00010\bX\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u000e¢\u0006\u0002\n\u0000¨\u0006\u0010"}, dWq = {"Lcom/tencent/mm/plugin/story/proxy/StoryMixHandler$MixTask;", "Lcom/tencent/mm/loader/loader/IWorkTask;", "editorData", "Lcom/tencent/mm/plugin/story/storage/StoryEditorData;", "(Lcom/tencent/mm/plugin/story/storage/StoryEditorData;)V", "isCaptureVideo", "", "location", "Lcom/tencent/mm/protocal/protobuf/StoryLocation;", "startPerformance", "", "call", "", "runMix", "uniqueId", "", "plugin-story_release"})
public final class c$c extends c {
    int ehv;
    private boolean fbV;
    private cei rWk;
    d saW;

    @l(dWo = {1, 1, 13}, dWp = {"\u0000\u001c\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u0006H\n¢\u0006\u0002\b\u0007¨\u0006\b"}, dWq = {"<anonymous>", "", "mixVideoPath", "", "mixThumb", "ret", "", "invoke", "com/tencent/mm/plugin/story/proxy/StoryMixHandler$MixTask$runMix$1$1"})
    static final class b extends k implements q<String, String, Boolean, y> {
        final /* synthetic */ ArrayList rYM;
        final /* synthetic */ c$c saX;
        final /* synthetic */ a saY;
        final /* synthetic */ cee saZ;

        b(a aVar, ArrayList arrayList, c$c c_c, cee cee) {
            this.saY = aVar;
            this.rYM = arrayList;
            this.saX = c_c;
            this.saZ = cee;
            super(3);
        }

        /* JADX WARNING: Removed duplicated region for block: B:22:0x010f  */
        /* JADX WARNING: Missing block: B:18:0x00f4, code skipped:
            if (r4 < ((long) r0)) goto L_0x00f6;
     */
        public final /* synthetic */ java.lang.Object g(java.lang.Object r12, java.lang.Object r13, java.lang.Object r14) {
            /*
            r11 = this;
            r10 = 109743; // 0x1acaf float:1.53783E-40 double:5.422E-319;
            r3 = 1;
            r2 = 0;
            com.tencent.matrix.trace.core.AppMethodBeat.i(r10);
            r12 = (java.lang.String) r12;
            r13 = (java.lang.String) r13;
            r14 = (java.lang.Boolean) r14;
            r4 = r14.booleanValue();
            r0 = "mixVideoPath";
            a.f.b.j.p(r12, r0);
            r0 = "mixThumb";
            a.f.b.j.p(r13, r0);
            r0 = com.tencent.mm.plugin.story.proxy.c.saU;
            r0 = com.tencent.mm.plugin.story.proxy.c$a.getTAG();
            r1 = new java.lang.StringBuilder;
            r5 = "mixer task done ";
            r1.<init>(r5);
            r5 = r11.saX;
            r5 = r5.saW;
            r6 = r5.xDa;
            r1 = r1.append(r6);
            r5 = " ret ";
            r1 = r1.append(r5);
            r1 = r1.append(r4);
            r5 = " mixVideoPath ";
            r1 = r1.append(r5);
            r1 = r1.append(r12);
            r5 = " mixThumb ";
            r1 = r1.append(r5);
            r1 = r1.append(r13);
            r1 = r1.toString();
            com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
            r0 = r11.saX;
            r0 = r0.ehv;
            if (r0 == 0) goto L_0x0086;
        L_0x0064:
            r0 = com.tencent.mm.hardcoder.WXHardCoderJNI.hcEncodeVideoEnable;
            r1 = r11.saX;
            r1 = r1.ehv;
            com.tencent.mm.hardcoder.WXHardCoderJNI.stopPerformance(r0, r1);
            r0 = "MicroMsg.Media.StoryVideoMixer";
            r1 = "hardcoder summerPerformance stopPerformance %s";
            r5 = new java.lang.Object[r3];
            r6 = r11.saX;
            r6 = r6.ehv;
            r6 = java.lang.Integer.valueOf(r6);
            r5[r2] = r6;
            com.tencent.mm.sdk.platformtools.ab.i(r0, r1, r5);
            r0 = r11.saX;
            r0.ehv = r2;
        L_0x0086:
            r0 = java.lang.System.currentTimeMillis();
            r5 = com.tencent.mm.plugin.story.g.h.scu;
            r5 = com.tencent.mm.plugin.story.g.h.cAC();
            r6 = r5.Ft();
            r6 = r0 - r6;
            r0 = com.tencent.mm.plugin.story.g.h.scu;
            r0 = com.tencent.mm.plugin.story.g.h.cAC();
            r0.aT(r6);
            r0 = com.tencent.mm.plugin.story.g.h.scu;
            r5 = com.tencent.mm.plugin.story.g.h.cAC();
            if (r4 == 0) goto L_0x013d;
        L_0x00a7:
            r0 = 0;
        L_0x00a9:
            r5.aU(r0);
            r0 = com.tencent.mm.plugin.story.g.h.scu;
            r0 = com.tencent.mm.plugin.story.g.h.cAC();
            r8 = java.lang.System.currentTimeMillis();
            r0.aV(r8);
            if (r4 == 0) goto L_0x0145;
        L_0x00bb:
            r0 = com.tencent.mm.plugin.story.g.h.scu;
            r0 = r11.saX;
            r0 = r0.saW;
            r0 = r0.field_storyLocalId;
            com.tencent.mm.plugin.story.g.h.bl(r0, r12);
            r0 = com.tencent.mm.plugin.story.e.c.rRS;
            r0 = r11.saY;
            r0 = r0.fbT;
            r0 = com.tencent.mm.plugin.story.e.c.a.aaj(r0);
            r1 = r11.saY;
            r1 = r1.fbV;
            if (r1 != 0) goto L_0x00f6;
        L_0x00d6:
            r1 = r11.saY;
            r1 = r1.fbV;
            if (r1 != 0) goto L_0x0143;
        L_0x00dc:
            r1 = r11.rYM;
            r1 = r1.size();
            if (r1 > 0) goto L_0x00f6;
        L_0x00e4:
            r1 = r11.saY;
            r4 = r1.rRH;
            r1 = r11.saY;
            r8 = r1.rRG;
            r4 = r4 - r8;
            if (r0 == 0) goto L_0x0141;
        L_0x00ef:
            r0 = r0.duration;
        L_0x00f1:
            r0 = (long) r0;
            r0 = (r4 > r0 ? 1 : (r4 == r0 ? 0 : -1));
            if (r0 >= 0) goto L_0x0143;
        L_0x00f6:
            r0 = r3;
        L_0x00f7:
            r1 = com.tencent.mm.plugin.story.f.l.sac;
            r1 = r11.saX;
            r1 = r1.saW;
            r2 = r1.xDa;
            com.tencent.mm.plugin.story.f.l.a(r2, r12, r13, r0);
            r0 = com.tencent.mm.plugin.story.model.j.rST;
            r0 = com.tencent.mm.plugin.story.model.j.a.cya();
            r0.czx();
            r0 = r11.saZ;
            if (r0 == 0) goto L_0x0130;
        L_0x010f:
            r0 = com.tencent.mm.plugin.story.g.f.sbT;
            r0 = r11.saZ;
            r0 = r0.fbV;
            com.tencent.mm.plugin.story.g.f.lH(r0);
            r0 = com.tencent.mm.plugin.story.g.f.sbT;
            r0 = r11.saZ;
            r0 = r0.fbV;
            com.tencent.mm.plugin.story.g.f.f(r0, r6);
            r0 = com.tencent.mm.plugin.story.g.f.sbT;
            r0 = r11.saX;
            r0 = r0.saW;
            r0 = r0.field_mixRetryTime;
            r1 = r11.saZ;
            r1 = r1.fbV;
            com.tencent.mm.plugin.story.g.f.ai(r0, r1);
        L_0x0130:
            r0 = r11.saX;
            r1 = com.tencent.mm.loader.g.h.eRj;
            r0.a(r1);
        L_0x0137:
            r0 = a.y.AUy;
            com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
            return r0;
        L_0x013d:
            r0 = -1;
            goto L_0x00a9;
        L_0x0141:
            r0 = r2;
            goto L_0x00f1;
        L_0x0143:
            r0 = r2;
            goto L_0x00f7;
        L_0x0145:
            r0 = r11.saX;
            r1 = com.tencent.mm.loader.g.h.eRl;
            r0.a(r1);
            goto L_0x0137;
            */
            throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.story.proxy.c$c$b.g(java.lang.Object, java.lang.Object, java.lang.Object):java.lang.Object");
        }
    }

    public c$c(d dVar) {
        j.p(dVar, "editorData");
        AppMethodBeat.i(109746);
        this.saW = dVar;
        AppMethodBeat.o(109746);
    }

    public final void Pa() {
        AppMethodBeat.i(109744);
        com.tencent.mm.sdk.g.d.xDG.b((Runnable) new a(this), "StoryMixHandler");
        AppMethodBeat.o(109744);
    }

    public final String Pc() {
        AppMethodBeat.i(109745);
        String str = "mixTask_" + this.saW + ".localId";
        AppMethodBeat.o(109745);
        return str;
    }

    public static final /* synthetic */ void a(c$c c_c) {
        com.tencent.mm.plugin.story.f.l lVar;
        AppMethodBeat.i(109747);
        c$a c_a = c.saU;
        ab.i(c$a.getTAG(), "runMix from StoryMixHandler");
        g.a aVar = g.rUG;
        g.cyW().cancelAll();
        com.tencent.mm.bt.a aVar2 = (com.tencent.mm.bt.a) new cee();
        try {
            aVar2.parseFrom(c_c.saW.field_baseItemData);
        } catch (Exception e) {
            ab.b("safeParser", BuildConfig.FLAVOR, new Object[]{e});
            aVar2 = null;
        }
        cee cee = (cee) aVar2;
        if (cee != null) {
            Object obj;
            lVar = com.tencent.mm.plugin.story.f.l.sac;
            j.p(cee, "storyEditorProtoData");
            String str = cee.videoPath;
            j.o(str, "storyEditorProtoData.videoPath");
            if (com.tencent.mm.plugin.story.f.l.gA(str, cee.xdY.xdN)) {
                str = cee.thumbPath;
                j.o(str, "storyEditorProtoData.thumbPath");
                if (com.tencent.mm.plugin.story.f.l.gA(str, cee.xdY.xdQ)) {
                    if (cee.xdR != null) {
                        str = cee.xdR;
                        j.o(str, "storyEditorProtoData.backgroundPath");
                        if (!com.tencent.mm.plugin.story.f.l.gA(str, cee.xdY.xdP)) {
                            ab.i("MicroMsg.Media.StoryDataProtoUtil", "now the background path md5 is unequal as befor is" + cee.xdY.xdP + "and now is " + com.tencent.xweb.util.d.cz(cee.xdR));
                            obj = null;
                        }
                    }
                    if (cee.eYi != null) {
                        str = cee.eYi;
                        j.o(str, "storyEditorProtoData.musicPath");
                        if (!com.tencent.mm.plugin.story.f.l.gA(str, cee.xdY.xdO)) {
                            ab.i("MicroMsg.Media.StoryDataProtoUtil", "now the music path md5 is unequal as befor is" + cee.xdY.xdO + "and now is " + com.tencent.xweb.util.d.cz(cee.eYi));
                            obj = null;
                        }
                    }
                    obj = 1;
                } else {
                    ab.i("MicroMsg.Media.StoryDataProtoUtil", "now the thumb path md5 is unequal as befor is" + cee.xdY.xdQ + "and now is " + com.tencent.xweb.util.d.cz(cee.thumbPath));
                    obj = null;
                }
            } else {
                ab.i("MicroMsg.Media.StoryDataProtoUtil", "now the video path md5 is unequal as befor is" + cee.xdY.xdN + "and now is " + com.tencent.xweb.util.d.cz(cee.videoPath));
                obj = null;
            }
            if (obj != null) {
                AudioCacheInfo audioCacheInfo;
                lVar = com.tencent.mm.plugin.story.f.l.sac;
                j.p(cee, "storyEditorProtoData");
                a aVar3 = new a();
                j.p(cee, "storyEditorProtoData");
                if (cee.eTb == 0 || cee.eTb == 1) {
                    audioCacheInfo = null;
                } else {
                    audioCacheInfo = new AudioCacheInfo();
                    audioCacheInfo.musicUrl = cee.musicUrl;
                    audioCacheInfo.rTW = cee.rTW;
                    audioCacheInfo.aIM = cee.aIM;
                    audioCacheInfo.rTZ = cee.rTZ;
                    audioCacheInfo.cachePath = cee.eYi;
                    audioCacheInfo.position = cee.xdZ;
                    audioCacheInfo.rUb = cee.xea;
                }
                aVar3.rRJ = audioCacheInfo;
                aVar3.rRI = cee.eTb;
                aVar3.rRG = cee.startTime;
                aVar3.rRH = cee.endTime;
                str = cee.videoPath;
                j.o(str, "storyEditorProtoData.videoPath");
                aVar3.aad(str);
                str = cee.thumbPath;
                j.o(str, "storyEditorProtoData.thumbPath");
                aVar3.aae(str);
                aVar3.fbV = cee.fbV;
                lVar = com.tencent.mm.plugin.story.f.l.sac;
                Context context = ah.getContext();
                j.o(context, "MMApplicationContext.getContext()");
                ArrayList a = com.tencent.mm.plugin.story.f.l.a(cee, context);
                lVar = com.tencent.mm.plugin.story.f.l.sac;
                float[] a2 = com.tencent.mm.plugin.story.f.l.a(cee);
                long aaE = cb.aaE();
                com.tencent.mm.plugin.story.model.e.b bVar = new com.tencent.mm.plugin.story.model.e.b(aVar3, a, a2, com.tencent.mm.plugin.story.model.l.aau(String.valueOf(aaE)), com.tencent.mm.plugin.story.model.l.aav(String.valueOf(aaE)), (byte) 0);
                c_c.rWk = cee.smk;
                c_c.fbV = cee.fbV;
                h hVar = h.scu;
                h.cAC().aT(System.currentTimeMillis());
                hVar = h.scu;
                h.g(c_c.saW.field_storyLocalId, aVar3.fbT, aVar3.fbV);
                c_c.ehv = WXHardCoderJNI.startPerformance(WXHardCoderJNI.hcEncodeVideoEnable, WXHardCoderJNI.hcEncodeVideoDelay, WXHardCoderJNI.hcEncodeVideoCPU, WXHardCoderJNI.hcEncodeVideoIO, WXHardCoderJNI.hcEncodeVideoThr ? Process.myTid() : 0, 35000, 603, WXHardCoderJNI.hcEncodeVideoAction, "MicroMsg.Media.StoryVideoMixer");
                ab.i("MicroMsg.Media.StoryVideoMixer", "hardcoder summerPerformance startPerformance: %s", new Object[]{Integer.valueOf(c_c.ehv)});
                bVar.a((q) new b(aVar3, a, c_c, cee));
                AppMethodBeat.o(109747);
                return;
            }
        }
        f fVar = f.sbT;
        f.cAh();
        lVar = com.tencent.mm.plugin.story.f.l.sac;
        com.tencent.mm.plugin.story.f.l.lf(c_c.saW.xDa);
        c_c.a(com.tencent.mm.loader.g.h.eRk);
        AppMethodBeat.o(109747);
    }
}
