package com.ss.android.ttve.nativePort;

import X.IHP;
import X.IL0;
import com.bytedance.covode.number.Covode;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class TEVideoUtilsCallback {
    public IL0 frameDataListener;
    public IHP frameListener;

    static {
        Covode.recordClassIndex(49452);
    }

    public IHP getFrameAvailableListener() {
        return this.frameListener;
    }

    public void setFrameDataListener(Object obj) {
        this.frameDataListener = (IL0) obj;
    }

    public void setListener(Object obj) {
        this.frameListener = (IHP) obj;
    }

    public static ByteBuffer allocateBuffer(int i) {
        return ByteBuffer.allocateDirect(i).order(ByteOrder.LITTLE_ENDIAN);
    }

    public static ByteBuffer allocateFrame(int i, int i2) {
        return ByteBuffer.allocateDirect(i * i2 * 4).order(ByteOrder.LITTLE_ENDIAN);
    }

    public boolean onFrameAvailable(ByteBuffer byteBuffer, int i, int i2, int i3) {
        IHP ihp = this.frameListener;
        if (ihp == null || !ihp.processFrame(byteBuffer, i, i2, i3)) {
            return false;
        }
        return true;
    }

    public static boolean onFrameAvailable(Object obj, ByteBuffer byteBuffer, int i, int i2, int i3) {
        TEVideoUtilsCallback tEVideoUtilsCallback;
        IHP ihp;
        if (!(obj instanceof TEVideoUtilsCallback) || (tEVideoUtilsCallback = (TEVideoUtilsCallback) obj) == null || (ihp = tEVideoUtilsCallback.frameListener) == null || !ihp.processFrame(byteBuffer, i, i2, i3)) {
            return false;
        }
        return true;
    }

    public static boolean onFrameAvailable2(Object obj, byte[] bArr, int i, int i2, int i3) {
        TEVideoUtilsCallback tEVideoUtilsCallback;
        IHP ihp;
        if (!(obj instanceof TEVideoUtilsCallback) || (tEVideoUtilsCallback = (TEVideoUtilsCallback) obj) == null || (ihp = tEVideoUtilsCallback.frameListener) == null || !ihp.processFrame(ByteBuffer.wrap(bArr), i, i2, i3)) {
            return false;
        }
        return true;
    }

    public static boolean onFrameDataAvailable(Object obj, ByteBuffer byteBuffer, int i, int i2, int i3, int i4) {
        TEVideoUtilsCallback tEVideoUtilsCallback;
        IL0 il0;
        if (!(obj instanceof TEVideoUtilsCallback) || (tEVideoUtilsCallback = (TEVideoUtilsCallback) obj) == null || (il0 = tEVideoUtilsCallback.frameDataListener) == null || !il0.LIZ()) {
            return false;
        }
        return true;
    }
}
