package com.ifpdos.player.extractor;

import android.text.TextUtils;
import android.util.Log;
import java.io.OutputStream;
import java.util.List;
import kotlin.jvm.internal.g;
import kotlin.jvm.internal.l;

/* JADX INFO: loaded from: classes.dex */
public final class SubtitleExtractor {
    public static final Companion Companion = new Companion(null);
    private static final String TAG = "SubtitleExtractor";
    private OutputStream fileWriter;
    private long nativeExtractor;

    public static final class Companion {
        public /* synthetic */ Companion(g gVar) {
            this();
        }

        private Companion() {
        }
    }

    static {
        System.loadLibrary("native-extractor-subtitles");
    }

    private final native List<SubtitleData> nativeExtract(String str);

    private final native void nativeInit();

    private final native void nativeRelease();

    public final List<SubtitleData> extract(String videoPath) {
        l.e(videoPath, "videoPath");
        if (TextUtils.isEmpty(videoPath)) {
            return null;
        }
        try {
            nativeInit();
            return nativeExtract(videoPath);
        } catch (Throwable th) {
            Log.e(TAG, "extract failed: ", th);
            return null;
        }
    }

    public final boolean init() {
        try {
            nativeInit();
            return true;
        } catch (Throwable th) {
            Log.e(TAG, "init failed: ", th);
            return false;
        }
    }

    public final void release() {
        try {
            Log.d(TAG, "release()");
            nativeRelease();
            OutputStream outputStream = this.fileWriter;
            if (outputStream != null) {
                if (outputStream != null) {
                    outputStream.flush();
                }
                OutputStream outputStream2 = this.fileWriter;
                if (outputStream2 != null) {
                    outputStream2.close();
                }
                this.fileWriter = null;
            }
        } finally {
            try {
            } finally {
            }
        }
    }
}
