package com.ifpdos.player;

import android.content.Context;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.ifpdos.player.base.IPlayer;

/* JADX INFO: loaded from: classes.dex */
public abstract class BasePlayer implements IPlayer {
    public static final Companion Companion = new Companion(null);
    public static final int ERROR_FALLBACK_TO_MEDIA_PLAYER = -9527;
    public static final int ERROR_FALLBACK_TO_PLATFORM_PLAYER = -9528;
    public static final int ERROR_NEED_TO_RECREATE_SURFACE = -9529;
    public static final int ERROR_NEED_TO_RECREATE_SURFACE_EXTRA_PLAY = -1;
    public static final int INFO_AUDIO_UN_SUPPORT = -5001;
    private static final String TAG = "BasePlayer";
    private final Context context;
    private int mRotation;

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

        private Companion() {
        }
    }

    public BasePlayer(Context context) {
        kotlin.jvm.internal.l.e(context, "context");
        this.context = context;
    }

    protected final int getMRotation() {
        return this.mRotation;
    }

    @Override // com.ifpdos.player.base.IPlayer
    public String getPlayerKernel() {
        String simpleName = getClass().getSimpleName();
        kotlin.jvm.internal.l.d(simpleName, "getSimpleName(...)");
        return simpleName;
    }

    @Override // com.ifpdos.player.base.IPlayer
    public int getRotation() {
        return this.mRotation;
    }

    protected final int getVideoRotation(Uri uri) {
        kotlin.jvm.internal.l.e(uri, "uri");
        if (T0.a.f1662a == 9) {
            try {
                MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
                if (E1.g.l("content", uri.getScheme(), true)) {
                    ParcelFileDescriptor parcelFileDescriptorOpenFileDescriptor = this.context.getContentResolver().openFileDescriptor(uri, "r");
                    kotlin.jvm.internal.l.b(parcelFileDescriptorOpenFileDescriptor);
                    mediaMetadataRetriever.setDataSource(parcelFileDescriptorOpenFileDescriptor.getFileDescriptor());
                } else {
                    mediaMetadataRetriever.setDataSource(uri.getPath());
                }
                Object objExtractMetadata = mediaMetadataRetriever.extractMetadata(24);
                if (objExtractMetadata == null) {
                    objExtractMetadata = 0;
                }
                Log.v(TAG, "rotate:" + objExtractMetadata);
                return Integer.parseInt(objExtractMetadata.toString());
            } catch (Exception e2) {
                Log.v(TAG, e2.getMessage(), e2);
            }
        }
        return 0;
    }

    @Override // com.ifpdos.player.base.IPlayer
    public void setDataSource(Uri fileDescriptor) {
        kotlin.jvm.internal.l.e(fileDescriptor, "fileDescriptor");
        try {
            this.mRotation = getVideoRotation(fileDescriptor);
        } catch (Exception e2) {
            Log.d(TAG, "setDataSource: ", e2);
        }
    }

    protected final void setMRotation(int i2) {
        this.mRotation = i2;
    }
}
