package com.seewo.vtv.impl;

import android.os.SystemProperties;
import com.seewo.sdk.util.BoardTypeUtils;

/* JADX INFO: loaded from: classes.dex */
public class ScreenRecordHelper {
    public static final ScreenRecordHelper INSTANCE = new ScreenRecordHelper();
    private volatile boolean mIsRecording;

    public static native boolean finishRecordScreen();

    public static native int getRecordScreenData(byte[] bArr);

    public static native boolean startRecordScreen(int i, int i2);

    public static native boolean startRecordScreen(int i, int i2, boolean z);

    static {
        if (BoardTypeUtils.isHISIMachine()) {
            System.loadLibrary("screen_record");
        }
    }

    public void startRecord() {
        if (this.mIsRecording) {
            throw new RuntimeException("You have started record, must call finishRecord first.");
        }
        this.mIsRecording = true;
        if (isScreenVertical()) {
            recordVertical();
        } else {
            startRecordScreen(720, 1280, true);
        }
    }

    private boolean isScreenVertical() {
        String str = SystemProperties.get("persist.sys.screenorientation", "");
        return (str.equals("portrait") || str.equals("upsideDown")) ? false : true;
    }

    private void recordVertical() {
        if (BoardTypeUtils.is510Machine() || BoardTypeUtils.is551Machine()) {
            startRecordScreen(1280, 720);
        } else {
            startRecordScreen(1920, 1080);
        }
    }

    public int getRecordData(byte[] bArr) {
        return getRecordScreenData(bArr);
    }

    public void stopRecord() {
        this.mIsRecording = false;
        finishRecordScreen();
    }
}
