package com.ss.android.ttve.vealgorithm;

import X.IDD;
import X.IDE;
import X.IDi;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ttve.vealgorithm.params.VEAlgorithmParam;
import com.ss.android.ttve.vealgorithm.params.VEAlgorithmResult;
import com.ss.android.ttve.vealgorithm.params.VEAlgorithmType;

public class VEAlgorithm {
    public IDD mErrorListener;
    public long mHandle;
    public IDE mListener;

    static {
        Covode.recordClassIndex(49494);
    }

    public native int nativeAlgorithmCancel(long j);

    public native long nativeAlgorithmCreate(Object obj);

    public native int nativeAlgorithmDestroy(long j);

    public native Object nativeAlgorithmGetRandomResult(long j);

    public native Object nativeAlgorithmGetResult(long j);

    public native int nativeAlgorithmStart(long j);

    public void nativeCallback_onError(int i, String str) {
    }

    public void nativeCallback_onProcess(float f, boolean z) {
    }

    public int cancel() {
        MethodCollector.i(12657);
        long j = this.mHandle;
        if (j == 0) {
            MethodCollector.o(12657);
            return -112;
        }
        int nativeAlgorithmCancel = nativeAlgorithmCancel(j);
        MethodCollector.o(12657);
        return nativeAlgorithmCancel;
    }

    public int destroy() {
        MethodCollector.i(12888);
        long j = this.mHandle;
        if (j == 0) {
            MethodCollector.o(12888);
            return -112;
        }
        int nativeAlgorithmDestroy = nativeAlgorithmDestroy(j);
        this.mHandle = 0;
        MethodCollector.o(12888);
        return nativeAlgorithmDestroy;
    }

    public void finalize() {
        if (this.mHandle != 0) {
            IDi.LIZLLL("VEAlgorithm", "not destroy algorithm object:" + this.mHandle);
        }
    }

    public VEAlgorithmResult getResult() {
        MethodCollector.i(12887);
        long j = this.mHandle;
        if (j == 0) {
            MethodCollector.o(12887);
            return null;
        }
        VEAlgorithmResult vEAlgorithmResult = (VEAlgorithmResult) nativeAlgorithmGetResult(j);
        MethodCollector.o(12887);
        return vEAlgorithmResult;
    }

    public int start() {
        MethodCollector.i(12413);
        long j = this.mHandle;
        if (j == 0) {
            MethodCollector.o(12413);
            return -112;
        }
        int nativeAlgorithmStart = nativeAlgorithmStart(j);
        MethodCollector.o(12413);
        return nativeAlgorithmStart;
    }

    public void setErrorListener(IDD idd) {
        this.mErrorListener = idd;
    }

    public void setProcessListener(IDE ide) {
        this.mListener = ide;
    }

    public int init(VEAlgorithmParam vEAlgorithmParam) {
        MethodCollector.i(12194);
        int i = vEAlgorithmParam.type;
        if (i == VEAlgorithmType.VE_ALGORITHM_TYPE_INVALID) {
            IDi.LIZLLL("VEAlgorithm", "invalid algorithm type:".concat(String.valueOf(i)));
            MethodCollector.o(12194);
            return -100;
        }
        long nativeAlgorithmCreate = nativeAlgorithmCreate(vEAlgorithmParam);
        this.mHandle = nativeAlgorithmCreate;
        if (nativeAlgorithmCreate == 0) {
            IDi.LIZLLL("VEAlgorithm", "nativeAlgorithmCreate failed!");
            MethodCollector.o(12194);
            return -1;
        }
        MethodCollector.o(12194);
        return 0;
    }
}
