package z0;

import a0.k;
import a0.n;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.AudioMetadata;
import android.media.AudioMetadataReadMap;
import android.media.MediaPlayer;
import android.media.PlaybackParams;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import androidx.exifinterface.media.ExifInterface;
import androidx.media3.database.DatabaseProvider;
import b0.D;
import b0.o;
import b0.p;
import b0.q;
import com.jsyn.unitgen.u;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import n.C0643i;
import n.F;
import n.x;
import o.C0648b;
import okhttp3.HttpUrl;
import s.AbstractC0708a;
import s.C0710c;
import s.C0711d;
import t.C0717a;
import t.c;

/* JADX INFO: renamed from: z0.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0754e extends MediaPlayer implements c.b, c.a, p.a, p.b {
    private static final int AUDIO_INDICATOR_DOLBY_ATMOS = 2;
    private static final int AUDIO_INDICATOR_DOLBY_ATMOS_AC4 = 5;
    private static final int AUDIO_INDICATOR_DOLBY_AUDIO = 1;
    private static final int AUDIO_INDICATOR_DOLBY_AUDIO_AC4 = 4;
    private static final int AUDIO_INDICATOR_DOLBY_VISION = 3;
    private static final int AUDIO_INDICATOR_DTS = 11;
    private static final int AUDIO_INDICATOR_DTS_EXPRESS = 13;
    private static final int AUDIO_INDICATOR_DTS_HD = 12;
    private static final int AUDIO_INDICATOR_DTS_HD_MASTER_AUDIO = 14;
    private static final int AUDIO_INDICATOR_DTS_X = 15;
    private static final int AUDIO_INDICATOR_NOT_CARE = 0;
    private static final int AUDIO_INDICATOR_NOT_SET = -1;
    private static final String AUDIO_PARAMETER_DTS_VERSION = "AQ_DtsVersion";
    public static final int AUDIO_SESSION_ID_NOT_SET = -1;
    private static final String COOKIE_KEYWORD = "Cookie";
    private static final String DASH_HEADER = "application/dash+xml";
    private static final String DASH_MARLIN_HEADER = "application/vnd.marlin.drm.actiontoken+xml";
    private static final int DATA_SOURCE_TYPE_BESTV = 3;
    private static final int DATA_SOURCE_TYPE_DLNA = 1;
    private static final int DATA_SOURCE_TYPE_LOCAL = 0;
    private static final int DATA_SOURCE_TYPE_SAMBA = 2;
    private static final String DEBUG_LOG_LEVEL_PROPERTY_KEY = "mtk.exoplayer.debug.level";
    private static final String DEBUG_SUBTITLE_DEBUGGER_LEVEL = "vendor.mtk.subtitle.debugger.level";
    public static final int DRM_TYPE_MARLIN_INTERTRUST_BB = 5;
    public static final int DRM_TYPE_MARLIN_INTERTRUST_MS3 = 6;
    public static final int DRM_TYPE_MARLIN_NAUTILUS_BB = 3;
    public static final int DRM_TYPE_MARLIN_NAUTILUS_MS3 = 4;
    public static final int DRM_TYPE_PLAYREADY = 2;
    public static final int DRM_TYPE_UNKNOWN = 0;
    public static final int DRM_TYPE_WINDWINE = 1;
    private static final String DTS_VERSION_M6 = "DTS M6";
    private static final String DTS_VERSION_X = "DTS:X";
    private static final String EXOPLAYER_BROADCAST_PERMISSION = "com.mediatek.exoplayer.permission.BROADCAST";
    public static final String ExoPlayerString = "ExoPlayer fake";
    private static final String FOCUS_MODE_KEY = "vendor.mtk.exoplayer.focus.mode";
    private static final String HLS_HEADER = "application/vnd.apple.mpegurl";
    private static final String HLS_HEADER_V2 = "application/x-mpegURL";
    private static final String IMEDIA_PLAYER = "android.media.IMediaPlayer";
    private static final String INTENT_DOLBY_AUDIO_AC4 = "mtk.intent.action.audio.ac4";
    private static final String INTENT_DOLBY_AUDIO_OTHERS = "mtk.intent.action.audio.others";
    private static final String INTENT_DOLBY_LOGO_ATMOS = "mtk.intent.action.dolby.atmos";
    private static final String INTENT_DOLBY_LOGO_AUDIO = "mtk.intent.action.dolby.audio";
    private static final String INTENT_DOLBY_LOGO_HIDE = "mtk.intent.action.dolby.exit";
    private static final String INTENT_DOLBY_LOGO_VISION = "mtk.intent.action.dolby.version";
    private static final String INTENT_DOLBY_LOGO_VISION_ATMOS = "mtk.intent.action.dolby.vision_atmos";
    private static final String INTENT_DOLBY_LOGO_VISION_AUDIO = "mtk.intent.action.dolby.vision_audio";
    private static final String INTENT_LOGO_DTS = "mtk.intent.action.mm.logo.dts";
    private static final String INTENT_LOGO_DTS_EXPRESS = "mtk.intent.action.mm.logo.dts_express";
    private static final String INTENT_LOGO_DTS_HD = "mtk.intent.action.mm.logo.dts_hd";
    private static final String INTENT_LOGO_DTS_HD_MASTER_AUDIO = "mtk.intent.action.mm.logo.dts_hd_master";
    private static final String INTENT_LOGO_DTS_X = "mtk.intent.action.mm.logo.dts_x";
    public static final int MEDIA_ERROR_BT_MODE_NOT_SUPPORT = -5016;

    @Deprecated
    public static final int MEDIA_ERROR_DRM_NOT_SUPPORTED = 263;
    public static final int MEDIA_ERROR_FILE_CORRUPT = -5003;
    public static final int MEDIA_ERROR_FILE_NOT_SUPPORT = -5002;
    public static final int MEDIA_ERROR_RESOURCE_INTERRUPT = 4000;
    public static final int MEDIA_FOCUS_MODE_FOCUSED = 1;
    public static final int MEDIA_FOCUS_MODE_NONFOCUSED = 2;
    public static final int MEDIA_FOCUS_MODE_NORMAL = 0;
    public static final int MEDIA_INFO_AUDIO_ENCODE_FORMAT_UNSUPPORT = -5001;
    public static final int MEDIA_INFO_AUDIO_ONLY_SERVICE = -5008;
    public static final int MEDIA_INFO_ON_REPLAY = -5006;
    public static final int MEDIA_INFO_POSITION_UPDATE = -5007;
    public static final int MEDIA_INFO_VIDEO_CANNOTSEEK = 801;
    public static final int MEDIA_INFO_VIDEO_ENCODE_FORMAT_UNSUPPORT = -5000;
    public static final int MEDIA_INFO_VIDEO_REPLAY_DONE = -5100;
    private static final int MEDIA_PERIOD_UPDATE = 603;
    private static final int MEDIA_SEEKABLE_RANGE_UPDATE = 602;
    private static final String MEDIA_TUNNELING_MODE_KEY = "vendor.mtk.exoplayer.tunneling.mode";
    private static final String MSS_HEADER = "application/vnd.ms-sstr+xml";
    private static final int MTK_MEDIA_EXO_BASE = 6000;
    private static final int MTK_MEDIA_EXO_END = 6003;
    private static final int MTK_MEDIA_EXO_ON_CUES = 6005;
    private static final int MTK_MEDIA_EXO_ON_ERROR = 6007;
    private static final int MTK_MEDIA_EXO_ON_INFO = 6002;
    private static final int MTK_MEDIA_EXO_ON_SEEK_COMPLETE = 6006;
    private static final int MTK_MEDIA_EXO_PREPARE_DONE = 6001;
    private static final int MTK_MEDIA_EXO_VIDEO_SIZE_CHANGED = 6004;
    public static final int MTK_MEDIA_HTTP_REPONSE_ERROR = -5017;
    public static final int MTK_MEDIA_INFO_ON_CUES = -5015;
    public static final int MTK_MEDIA_INFO_VIDEO_ONLY_SERVICE = -5009;
    private static final String MTK_UA_KEYWORD = "User-Agent";
    public static final int TYPE_DASH = 0;
    public static final int TYPE_HLS = 2;
    public static final int TYPE_NATIVE = 1001;
    public static final int TYPE_OTHER = 3;
    public static final int TYPE_SS = 1;
    private static final String VIDEO_DECODER_TYPE_PROPERTY_KEY = "vendor.mtk.exoplayer.video.decoder.type";
    private static final String WEBINI_HEADER1 = "application/vnd.ms-playready.initiator+xml";
    private static final String WEBINI_HEADER2 = "application/xml";
    private static final String strOfOutputPath = "X-tv-output-path";
    private final String TAG;
    private C0648b audioCapabilities;
    private int contentType;
    private Uri contentUri;
    private Context context;
    private String cookie;
    private List<I.c> cues;
    private String customData;
    private n.b dataSource;
    private String drmHeader;
    private int drmType;
    private Message errMsg;
    private Handler eventHandler;
    private int focusMode;
    private boolean hasExternalSubtitle;
    private k.a httpDataSourceCallBack;
    private String laUrl;
    private A0.b mDataSource;
    private f mLastMemoryInfo;
    private boolean mScreenOnWhilePlaying;
    private volatile boolean mStayAwake;
    private SurfaceHolder mSurfaceHolder;
    private j mWebInterface;
    private String mimeType;
    private Looper myLooper;
    private g onAudioCodecFormatChangedListener;
    private MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener;
    private MediaPlayer.OnCompletionListener onCompletionListener;
    private MediaPlayer.OnErrorListener onErrorListener;
    private MediaPlayer.OnInfoListener onInfoListener;
    private MediaPlayer.OnPreparedListener onPreparedlistener;
    private MediaPlayer.OnSeekCompleteListener onSeekCompleteListener;
    private MediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener;
    private A0.a pcmMediaInfo;
    private PlaybackParams playbackParams;
    private t.c player;
    private Surface surface;
    private SurfaceHolder.Callback surfaceHolderCallback;
    private i timeRange;
    private int[][] trackIndexMap;
    private int tunnelingMode;
    private String userAgent;
    private q videoVendorParam;
    private int mDataSourceType = 0;
    private PowerManager.WakeLock mWakeLock = null;
    private int sessionId = -1;
    private List<String> mCAStore = new ArrayList();
    private boolean mUseCA = false;
    private InputStream mInputStream = null;
    private boolean mStallingSupport = true;
    private long mStreamDuration = 0;
    private int mSeamlessMode = -1;
    private int mSetVideoDegree = -1;
    private int mDispPath = -1;
    private Bundle vendCmdParams = null;
    private int mSeekType = 3;
    private String output = "OUTPUT_VIDEO_MAIN";
    private int videoWidth = 1;
    private int videoHeight = 1;
    private double bitRate = u.FALSE;
    private boolean prepared = false;
    private boolean asyncPreparing = false;
    private boolean audioStartRender = false;
    private boolean isSeeking = false;
    private boolean buffering = false;
    private boolean needReplay = false;
    private volatile boolean isSetLooping = false;
    private int currentSelectedProgramIndex = 0;
    private int currentAudioIndicator = -1;
    private String pqParams = null;
    private int videoGameMode = 0;
    private boolean aiVisionDPTZEnabled = false;
    private boolean aiVisionAISREnabled = false;
    private boolean aiVisionBokehEnabled = false;
    private int uniqueStreamId = -1;
    private AudioMetadataReadMap audioMapInfo = null;
    private boolean mIsAtmos = false;
    private String mAudioMime = null;
    private int tunnelingAudioSessionId = -1;
    private String dtsVersion = null;
    private int videoTrackCount = 0;
    private int audioTrackCount = 0;
    private int textTrackCount = 0;
    private Map<String, String> mHeaders = null;
    private boolean delaySendErr = false;

    /* JADX INFO: renamed from: z0.e$a */
    class a extends Thread {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ Map f7155b;

        a(Map map) {
            this.f7155b = map;
        }

        @Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            AbstractC0754e abstractC0754e = AbstractC0754e.this;
            abstractC0754e.mimeType = abstractC0754e.F(abstractC0754e.contentUri, this.f7155b);
            Log.d(AbstractC0754e.this.TAG, "mimeType=" + AbstractC0754e.this.mimeType);
            AbstractC0754e abstractC0754e2 = AbstractC0754e.this;
            abstractC0754e2.contentType = abstractC0754e2.E(abstractC0754e2.contentUri, AbstractC0754e.this.mimeType);
            Log.d(AbstractC0754e.this.TAG, "contentType=" + AbstractC0754e.this.contentType);
        }
    }

    /* JADX INFO: renamed from: z0.e$b */
    class b implements SurfaceHolder.Callback {
        b() {
        }

        @Override // android.view.SurfaceHolder.Callback
        public void surfaceChanged(SurfaceHolder surfaceHolder, int i2, int i3, int i4) {
        }

        @Override // android.view.SurfaceHolder.Callback
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
        }

        @Override // android.view.SurfaceHolder.Callback
        public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
            if (AbstractC0754e.this.player != null) {
                AbstractC0754e.this.player.u();
            }
        }
    }

    /* JADX INFO: renamed from: z0.e$c */
    class c extends Thread {
        c() {
        }

        @Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            Looper.prepare();
            AbstractC0754e.this.myLooper = Looper.myLooper();
            Log.d(AbstractC0754e.this.TAG, "[Performance]begin do prepareExo()");
            AbstractC0754e.this.S();
            synchronized (AbstractC0754e.this) {
                AbstractC0754e.this.asyncPreparing = false;
                AbstractC0754e.this.notifyAll();
            }
            AbstractC0754e.this.asyncPreparing = false;
            Looper.loop();
        }
    }

    /* JADX INFO: renamed from: z0.e$d */
    class d implements k.a {
        d() {
        }

        @Override // a0.k.a
        public String a(String str) {
            AbstractC0754e.e(AbstractC0754e.this);
            throw null;
        }

        @Override // a0.k.a
        public void b(String str, String[] strArr) {
            AbstractC0754e.e(AbstractC0754e.this);
            String str2 = strArr[0];
            throw null;
        }
    }

    /* JADX INFO: renamed from: z0.e$e, reason: collision with other inner class name */
    private class C0108e implements Handler.Callback {
        @Override // android.os.Handler.Callback
        public boolean handleMessage(Message message) {
            switch (message.what) {
                case 6001:
                    AbstractC0754e.this.z();
                    if (AbstractC0754e.this.onPreparedlistener == null) {
                        return true;
                    }
                    Log.d(AbstractC0754e.this.TAG, "onPrepared called");
                    AbstractC0754e.this.onPreparedlistener.onPrepared(AbstractC0754e.this);
                    return true;
                case 6002:
                    if (AbstractC0754e.this.onInfoListener == null) {
                        return true;
                    }
                    Log.d(AbstractC0754e.this.TAG, "onInfo called: arg1=" + message.arg1);
                    AbstractC0754e.this.onInfoListener.onInfo(AbstractC0754e.this, message.arg1, message.arg2);
                    return true;
                case 6003:
                    if (AbstractC0754e.this.context != null) {
                        AbstractC0754e.this.context.sendBroadcast(new Intent(AbstractC0754e.INTENT_DOLBY_LOGO_HIDE), AbstractC0754e.EXOPLAYER_BROADCAST_PERMISSION);
                    }
                    if (AbstractC0754e.this.onCompletionListener == null) {
                        return true;
                    }
                    Log.d(AbstractC0754e.this.TAG, "onCompletion called");
                    AbstractC0754e.this.onCompletionListener.onCompletion(AbstractC0754e.this);
                    return true;
                case 6004:
                    if (AbstractC0754e.this.onVideoSizeChangedListener == null) {
                        return true;
                    }
                    MediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener = AbstractC0754e.this.onVideoSizeChangedListener;
                    AbstractC0754e abstractC0754e = AbstractC0754e.this;
                    onVideoSizeChangedListener.onVideoSizeChanged(abstractC0754e, abstractC0754e.videoWidth, AbstractC0754e.this.videoHeight);
                    return true;
                case AbstractC0754e.MTK_MEDIA_EXO_ON_CUES /* 6005 */:
                    if (AbstractC0754e.this.onInfoListener == null) {
                        return true;
                    }
                    AbstractC0754e.this.onInfoListener.onInfo(AbstractC0754e.this, AbstractC0754e.MTK_MEDIA_INFO_ON_CUES, 0);
                    return true;
                case AbstractC0754e.MTK_MEDIA_EXO_ON_SEEK_COMPLETE /* 6006 */:
                    if (AbstractC0754e.this.onSeekCompleteListener == null) {
                        return true;
                    }
                    AbstractC0754e.this.onSeekCompleteListener.onSeekComplete(AbstractC0754e.this);
                    return true;
                case AbstractC0754e.MTK_MEDIA_EXO_ON_ERROR /* 6007 */:
                    if (AbstractC0754e.this.onErrorListener == null) {
                        return true;
                    }
                    Log.d(AbstractC0754e.this.TAG, "onError called: arg1=" + message.arg1 + ", arg2=" + message.arg2);
                    AbstractC0754e.this.onErrorListener.onError(AbstractC0754e.this, message.arg1, message.arg2);
                    return true;
                default:
                    return false;
            }
        }

        private C0108e() {
        }
    }

    /* JADX INFO: renamed from: z0.e$f */
    public static class f {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public long f7161a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f7162b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f7163c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public int f7164d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public long f7165e;

        public f(long j2, int i2, int i3, int i4, long j3) {
            this.f7161a = j2;
            this.f7162b = i2;
            this.f7163c = i3;
            this.f7164d = i4;
            this.f7165e = j3;
        }
    }

    /* JADX INFO: renamed from: z0.e$g */
    public interface g {
    }

    /* JADX INFO: renamed from: z0.e$h */
    public enum h {
        SPEED_FR_32X,
        SPEED_FR_16X,
        SPEED_FR_8X,
        SPEED_FR_4X,
        SPEED_FR_2X,
        SPEED_ZERO,
        SPEED_1X,
        SPEED_FF_2X,
        SPEED_FF_4X,
        SPEED_FF_8X,
        SPEED_FF_16X,
        SPEED_FF_32X,
        SPEED_SF_1_2X,
        SPEED_SF_1_4X,
        SPEED_SF_1_8X,
        SPEED_SF_1_16X,
        SPEED_SF_1_32X,
        SPEED_SR_1_2X,
        SPEED_SR_1_4X,
        SPEED_SR_1_8X,
        SPEED_SR_1_16X,
        SPEED_SR_1_32X
    }

    /* JADX INFO: renamed from: z0.e$i */
    public static class i {
    }

    /* JADX INFO: renamed from: z0.e$j */
    public interface j {
    }

    public AbstractC0754e() {
        int i2;
        int i3;
        int i4 = 0;
        this.focusMode = 0;
        int i5 = 1;
        this.playbackParams = null;
        this.tunnelingMode = 1;
        String tag = getTag();
        this.TAG = tag;
        StringBuilder sb = new StringBuilder();
        sb.append("[Performance]ExoMediaPlayer() Enter SDK Version:");
        int i6 = D.f2965a;
        sb.append(i6);
        Log.i(tag, sb.toString());
        if (i6 >= 30) {
            b0.n.g(1);
        }
        C0108e c0108e = new C0108e();
        Looper looperMyLooper = Looper.myLooper();
        if (looperMyLooper != null) {
            this.eventHandler = new Handler(looperMyLooper, c0108e);
        } else {
            Looper mainLooper = Looper.getMainLooper();
            if (mainLooper != null) {
                this.eventHandler = new Handler(mainLooper, c0108e);
            } else {
                this.eventHandler = null;
            }
        }
        try {
            i2 = Integer.parseInt(D.y(MEDIA_TUNNELING_MODE_KEY, "1"));
            try {
                Log.i(tag, "isTunnelingMode:" + i2);
            } catch (NumberFormatException e2) {
                e = e2;
                Log.e(this.TAG, "Invalid tunneling mode string. " + e.toString());
            }
        } catch (NumberFormatException e3) {
            e = e3;
            i2 = 1;
        }
        if (i2 == 0) {
            this.tunnelingMode = 0;
        }
        PlaybackParams playbackParams = new PlaybackParams();
        this.playbackParams = playbackParams;
        playbackParams.setSpeed(1.0f);
        try {
            i3 = Integer.parseInt(D.y(DEBUG_LOG_LEVEL_PROPERTY_KEY, "0"));
        } catch (NumberFormatException e4) {
            Log.e(this.TAG, "Invalid debug level string. " + e4.toString());
            i3 = 0;
        }
        o.e(i3);
        try {
            this.focusMode = Integer.parseInt(D.y(FOCUS_MODE_KEY, "0"));
        } catch (NumberFormatException e5) {
            Log.e(this.TAG, "Invalid focus mode string. " + e5.toString());
        }
        try {
            i5 = Integer.parseInt(D.y(VIDEO_DECODER_TYPE_PROPERTY_KEY, ExifInterface.GPS_MEASUREMENT_2D));
        } catch (NumberFormatException e6) {
            Log.e(this.TAG, "Invalid decoder type string. " + e6.toString());
        }
        b0.n.h(i5);
        try {
            i4 = Integer.parseInt(D.y(DEBUG_SUBTITLE_DEBUGGER_LEVEL, "0"));
        } catch (NumberFormatException e7) {
            Log.e(this.TAG, "Invalid debug level string. " + e7.toString());
        }
        I.h.b(i4);
        Log.i(this.TAG, "ExoMediaPlayer(): Leave");
    }

    private h A(int i2) {
        h hVar = h.SPEED_ZERO;
        switch (i2) {
            case 3:
                hVar = h.SPEED_1X;
                break;
            case 4:
                hVar = h.SPEED_FF_2X;
                break;
            case 5:
                hVar = h.SPEED_FF_4X;
                break;
            case 6:
                hVar = h.SPEED_FF_8X;
                break;
            case 7:
                hVar = h.SPEED_FF_16X;
                break;
            case 8:
                hVar = h.SPEED_FF_32X;
                break;
            case 10:
                hVar = h.SPEED_FR_2X;
                break;
            case 11:
                hVar = h.SPEED_FR_4X;
                break;
            case 12:
                hVar = h.SPEED_FR_8X;
                break;
            case 13:
                hVar = h.SPEED_FR_16X;
                break;
            case 14:
                hVar = h.SPEED_FR_32X;
                break;
            case 15:
                hVar = h.SPEED_SF_1_2X;
                break;
            case 16:
                hVar = h.SPEED_SF_1_4X;
                break;
            case 17:
                hVar = h.SPEED_SF_1_8X;
                break;
            case 18:
                hVar = h.SPEED_SF_1_16X;
                break;
            case 19:
                hVar = h.SPEED_SF_1_32X;
                break;
            case 20:
                hVar = h.SPEED_SR_1_2X;
                break;
            case 21:
                hVar = h.SPEED_SR_1_4X;
                break;
            case 22:
                hVar = h.SPEED_SR_1_8X;
                break;
            case 23:
                hVar = h.SPEED_SR_1_16X;
                break;
            case 24:
                hVar = h.SPEED_SR_1_32X;
                break;
        }
        Log.i(this.TAG, "getSpeed(): speed = " + hVar);
        return hVar;
    }

    private int B() {
        int i2;
        Exception e2;
        t.c cVar;
        Log.d(this.TAG, "getAllVideoTrackCount");
        int i3 = 0;
        try {
            cVar = this.player;
        } catch (Exception e3) {
            i2 = 0;
            e2 = e3;
        }
        if (cVar != null && cVar.y() != null) {
            List listO = this.player.y().o();
            i2 = 0;
            for (int i4 = 0; i4 < this.player.y().w(0); i4++) {
                try {
                    x xVarX = this.player.y().x(0, i4);
                    if (xVarX != null && (listO == null || listO.size() == 0 || xVarX.f5850n0 == ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue())) {
                        i2++;
                    }
                } catch (Exception e4) {
                    e2 = e4;
                    Log.d(this.TAG, e2.toString());
                }
            }
            i3 = i2;
        }
        Log.d(this.TAG, "getAllVideoTrackCount:" + i3);
        return i3;
    }

    private int C() {
        Context context;
        if (this.audioMapInfo == null || (context = this.context) == null) {
            return -1;
        }
        if (this.dtsVersion == null) {
            this.dtsVersion = ((AudioManager) context.getSystemService("audio")).getParameters(AUDIO_PARAMETER_DTS_VERSION);
        }
        x xVarF = this.player.F(1, this.player.D(1));
        if (xVarF != null && (xVarF.f5842g.contains("ac3") || xVarF.f5842g.contains("ac4"))) {
            boolean zContains = xVarF.f5842g.contains("ac4");
            if (this.mIsAtmos) {
                return zContains ? 5 : 2;
            }
            return zContains ? 4 : 1;
        }
        String str = this.mAudioMime;
        if (str == null || !str.contains("dts")) {
            return 0;
        }
        String str2 = this.mAudioMime;
        String strSubstring = str2.substring(str2.indexOf("dts"));
        strSubstring.hashCode();
        switch (strSubstring) {
            case "dts.hd; profile=lbr":
                if (this.dtsVersion == DTS_VERSION_M6) {
                    return 13;
                }
                break;
            case "dts":
            case "dts; profile=DTS96":
            case "dts; profile=DTSES":
                return 11;
            case "dts.hd; profile=DTSHR":
                if (this.dtsVersion == DTS_VERSION_M6) {
                    return 11;
                }
                break;
            case "dts.hd; profile=DTSMA":
                if (this.dtsVersion == DTS_VERSION_M6) {
                    return 14;
                }
                break;
            case "dts.uhd; profile=p2":
            case "dts.hd; profile=MULTI1":
            case "dts.hd; profile=MULTI2":
                return this.dtsVersion == DTS_VERSION_M6 ? 11 : 15;
            default:
                return -1;
        }
        return 12;
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x00d0 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private long D() throws java.lang.Throwable {
        /*
            Method dump skipped, instruction units count: 239
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: z0.AbstractC0754e.D():long");
    }

    /* JADX INFO: Access modifiers changed from: private */
    public int E(Uri uri, String str) {
        if (uri == null) {
            return 1001;
        }
        if (K(uri, str)) {
            return 0;
        }
        if (M(uri, str)) {
            return 1;
        }
        if (L(uri, str)) {
            return 2;
        }
        if ((WEBINI_HEADER1.equals(str) || WEBINI_HEADER2.equals(str) || uri.toString().contains("webinife")) && !TextUtils.isEmpty(null)) {
            throw null;
        }
        return 1001;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r5v10 */
    /* JADX WARN: Type inference failed for: r5v3 */
    /* JADX WARN: Type inference failed for: r5v4, types: [java.net.HttpURLConnection] */
    public String F(Uri uri, Map map) throws Throwable {
        String str;
        Throwable th;
        ?? r5;
        HttpURLConnection httpURLConnection;
        String strTrim = null;
        strTrim = null;
        strTrim = null;
        HttpURLConnection httpURLConnection2 = null;
        try {
            try {
                httpURLConnection = (HttpURLConnection) new URL(uri.toString()).openConnection();
            } catch (Throwable th2) {
                String str2 = strTrim;
                th = th2;
                r5 = str2;
            }
        } catch (IOException e2) {
            e = e2;
            str = null;
        }
        try {
            httpURLConnection.setConnectTimeout(3000);
            httpURLConnection.setReadTimeout(3000);
            if (!TextUtils.isEmpty(this.cookie)) {
                httpURLConnection.addRequestProperty(COOKIE_KEYWORD, this.cookie);
                httpURLConnection.addRequestProperty(MTK_UA_KEYWORD, this.userAgent);
            }
            httpURLConnection.connect();
            String contentType = httpURLConnection.getContentType();
            if (!TextUtils.isEmpty(contentType)) {
                strTrim = contentType.split(";")[0].trim();
                Log.i("getMimeHeader contentType: ", contentType);
            }
            httpURLConnection.disconnect();
        } catch (IOException e3) {
            e = e3;
            String str3 = strTrim;
            httpURLConnection2 = httpURLConnection;
            str = str3;
            Log.d("MyTest", e.toString());
            if (httpURLConnection2 != null) {
                httpURLConnection2.disconnect();
            }
            strTrim = str;
        } catch (Throwable th3) {
            th = th3;
            r5 = httpURLConnection;
            if (r5 != 0) {
                r5.disconnect();
            }
            throw th;
        }
        return strTrim;
    }

    private c.InterfaceC0095c G() {
        String tag = getTag();
        if (TextUtils.isEmpty(this.userAgent) && this.contentType != 1001) {
            this.userAgent = D.C(this.context, DatabaseProvider.TABLE_PREFIX);
        }
        int i2 = this.contentType;
        if (i2 != 0) {
            if (i2 == 1) {
                return new t.f(this.context, this.userAgent, this.contentUri.toString(), new s.f(this.laUrl), this.drmHeader, this.customData);
            }
            if (i2 == 2) {
                return new t.e(this.context, this.userAgent, this.contentUri.toString(), this.mHeaders);
            }
            if (i2 == 3) {
                return new t.d(this.context, this.userAgent, this.contentUri);
            }
            if (i2 == 1001) {
                return new t.b(this.context, this.contentUri, this.focusMode, tag.substring(tag.lastIndexOf(64)), this.mHeaders);
            }
            Log.d(this.TAG, "If crash, need APP add try catch");
            throw new IllegalStateException("Unsupported type: " + this.contentType);
        }
        switch (this.drmType) {
            case 0:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), null, null);
            case 1:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), new s.g(HttpUrl.FRAGMENT_ENCODE_SET, HttpUrl.FRAGMENT_ENCODE_SET), null);
            case 2:
                Context context = this.context;
                String str = this.userAgent;
                String string = this.contentUri.toString();
                s.e eVar = new s.e();
                String str2 = this.drmHeader;
                return new C0717a(context, str, string, eVar, str2 == null ? null : x(str2));
            case 3:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), new C0711d(), this.drmHeader.getBytes());
            case 4:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), new C0711d(), this.contentUri.toString().getBytes());
            case 5:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), new C0710c(), this.drmHeader.getBytes());
            case 6:
                return new C0717a(this.context, this.userAgent, this.contentUri.toString(), new C0710c(), this.contentUri.toString().getBytes());
            default:
                Log.d(this.TAG, "If crash, need APP add try catch");
                throw new IllegalStateException("Unsupported drm type: " + this.drmType);
        }
    }

    private x[] H() {
        Log.d(this.TAG, "getTrackInfoExo called");
        ArrayList arrayList = new ArrayList();
        try {
            t.c cVar = this.player;
            if (cVar == null || cVar.y() == null || !this.prepared) {
                return null;
            }
            List listO = this.player.y().o();
            int iW = this.player.y().w(0);
            if (iW > 0) {
                int[][] iArr = this.trackIndexMap;
                if (iArr[0] == null) {
                    int[] iArr2 = new int[iW];
                    iArr[0] = iArr2;
                    Arrays.fill(iArr2, -1);
                }
            }
            int i2 = 0;
            for (int i3 = 0; i3 < iW; i3++) {
                x xVarX = this.player.y().x(0, i3);
                if (listO == null || listO.size() == 0 || ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue() == xVarX.f5850n0) {
                    this.trackIndexMap[0][i2] = i3;
                    arrayList.add(xVarX);
                    i2++;
                }
            }
            int iW2 = this.player.y().w(1);
            if (iW2 > 0) {
                int[][] iArr3 = this.trackIndexMap;
                if (iArr3[1] == null) {
                    int[] iArr4 = new int[iW2];
                    iArr3[1] = iArr4;
                    Arrays.fill(iArr4, -1);
                }
            }
            int i4 = 0;
            for (int i5 = 0; i5 < iW2; i5++) {
                x xVarX2 = this.player.y().x(1, i5);
                if (listO == null || listO.size() == 0 || ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue() == xVarX2.f5850n0) {
                    this.trackIndexMap[1][i4] = i5;
                    arrayList.add(xVarX2);
                    i4++;
                }
            }
            int iW3 = this.player.y().w(2);
            if (iW3 > 0) {
                int[][] iArr5 = this.trackIndexMap;
                if (iArr5[2] == null) {
                    int[] iArr6 = new int[iW3];
                    iArr5[2] = iArr6;
                    Arrays.fill(iArr6, -1);
                }
            }
            int i6 = 0;
            for (int i7 = 0; i7 < iW3; i7++) {
                x xVarX3 = this.player.y().x(2, i7);
                if (xVarX3 != null && (AbstractC0708a.b(xVarX3.f5842g) || listO == null || listO.size() == 0 || ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue() == xVarX3.f5850n0)) {
                    this.trackIndexMap[2][i6] = i7;
                    arrayList.add(xVarX3);
                    i6++;
                }
            }
            x[] xVarArr = new x[arrayList.size()];
            arrayList.toArray(xVarArr);
            return xVarArr;
        } catch (Exception e2) {
            Log.d(this.TAG, e2.toString());
            return null;
        }
    }

    private boolean I(float f2) {
        return Math.abs(f2 - this.playbackParams.getSpeed()) < 1.0E-4f;
    }

    private boolean J() {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return false;
        }
        int iF = this.player.y().f();
        return iF == 2 || (iF >= 4 && iF <= 24);
    }

    private boolean K(Uri uri, String str) {
        return DASH_HEADER.equals(str) || DASH_MARLIN_HEADER.equals(str) || uri.toString().contains(".mpd");
    }

    private boolean L(Uri uri, String str) {
        String queryParameter = uri.getQueryParameter("type");
        if (HLS_HEADER.equals(str) || HLS_HEADER_V2.equals(str)) {
            return true;
        }
        return (queryParameter != null && (queryParameter.contains("M3U8") || queryParameter.contains("m3u8"))) || uri.toString().contains(".m3u8");
    }

    private boolean M(Uri uri, String str) {
        if (MSS_HEADER.equals(str) || uri.toString().contains(".ism")) {
            return true;
        }
        return uri.toString().contains(".ssm") && uri.toString().contains("Manifest");
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x005b  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x005e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private void N(boolean r10) {
        /*
            Method dump skipped, instruction units count: 210
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: z0.AbstractC0754e.N(boolean):void");
    }

    private void O() {
        t.c cVar;
        t.c cVar2;
        t.c cVar3;
        t.c cVar4;
        if (b0.n.d()) {
            if (this.vendCmdParams != null && (cVar4 = this.player) != null) {
                cVar4.y().N(this.vendCmdParams);
            }
            if (this.mSeamlessMode != -1 && (cVar3 = this.player) != null) {
                cVar3.y().J(this.mSeamlessMode);
            }
            if (this.mSetVideoDegree != -1 && (cVar2 = this.player) != null) {
                cVar2.y().S(this.mSetVideoDegree);
            }
            if (I(0.0f) || I(1.0f) || (cVar = this.player) == null) {
                return;
            }
            cVar.y().H(this.playbackParams);
        }
    }

    private void P(C0643i c0643i, Message message) {
        int i2 = c0643i.f5541g;
        Log.i(this.TAG, "ExoPlaybackException, codecErrorType:" + i2);
        if (i2 == 1) {
            if (this.prepared && this.player.E(0) == 0) {
                message.arg1 = -5002;
                return;
            } else {
                message.arg1 = -5001;
                return;
            }
        }
        if (i2 == 0) {
            if (this.prepared && this.player.E(1) == 0) {
                message.arg1 = -5002;
                return;
            } else {
                message.arg1 = -5000;
                return;
            }
        }
        if (i2 == 2) {
            message.arg1 = -5002;
            return;
        }
        if (c0643i.getCause() instanceof a0.q) {
            message.arg1 = MTK_MEDIA_HTTP_REPONSE_ERROR;
            message.arg2 = ((a0.q) c0643i.getCause()).f2005r;
            Log.i(this.TAG, "2 HTTP response error:" + message.arg2);
            return;
        }
        if (c0643i.getCause() instanceof IOException) {
            message.arg1 = -5002;
            return;
        }
        if (c0643i.getCause() instanceof IllegalStateException) {
            message.arg1 = 4000;
            return;
        }
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null || this.player.y().w(0) != 0 || this.player.y().w(1) != 0) {
            return;
        }
        message.arg1 = -5002;
    }

    private void Q(boolean z2) {
        int i2;
        if (this.audioStartRender && z2 && (((i2 = this.videoTrackCount) == 0 && this.audioTrackCount != 0) || ((this.surface == null && i2 != 0 && this.audioTrackCount != 0) || (this.player.C()[0] && this.audioTrackCount != 0)))) {
            Log.d(this.TAG, "onInfo send MEDIA_INFO_VIDEO_RENDERING_START");
            Message messageObtain = Message.obtain();
            messageObtain.what = 6002;
            messageObtain.arg1 = 3;
            messageObtain.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain);
            this.audioStartRender = false;
        }
        if (this.eventHandler == null || !this.prepared) {
            return;
        }
        if (this.buffering) {
            this.buffering = false;
            Message messageObtain2 = Message.obtain();
            messageObtain2.what = 6002;
            messageObtain2.arg1 = 702;
            messageObtain2.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain2);
        }
        if (this.isSeeking) {
            this.eventHandler.sendEmptyMessage(MTK_MEDIA_EXO_ON_SEEK_COMPLETE);
            this.isSeeking = false;
        }
    }

    private boolean R(boolean z2, int i2) {
        Log.i(this.TAG, "onSubtitleTrack(int value) called. value=" + i2);
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return false;
        }
        if (true == z2) {
            if (this.player.y().w(2) <= 0) {
                return false;
            }
            this.player.y().K(2, 0);
        } else {
            if (z2) {
                return false;
            }
            this.player.y().K(2, -1);
        }
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void S() {
        Uri uri;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.P();
            this.player = null;
        }
        this.trackIndexMap = new int[3][];
        c.InterfaceC0095c interfaceC0095cG = G();
        if (interfaceC0095cG instanceof t.b) {
            n.b bVar = this.dataSource;
            if (bVar != null) {
                ((t.b) interfaceC0095cG).f(new C0752c(bVar, null));
            }
            if (this.hasExternalSubtitle && (uri = this.contentUri) != null) {
                String[] strArrC = AbstractC0708a.c(uri);
                o.d(this.TAG, "externalSubtitlePaths: " + Arrays.toString(strArrC), 16);
                ((t.b) interfaceC0095cG).e(strArrC);
            }
        }
        String tag = getTag();
        this.player = new t.c(interfaceC0095cG, tag.substring(tag.lastIndexOf(64)));
        O();
        this.player.t(this);
        this.player.X(this);
        this.player.y().F(this);
        this.player.y().a(this);
        this.player.Z(this.output);
        this.player.Y(this.tunnelingMode, (AudioManager) this.context.getSystemService("audio"));
        this.player.W(this.focusMode);
        int i2 = this.sessionId;
        if (-1 != i2) {
            this.player.U(i2);
        }
        Log.d(this.TAG, "[Performance]+player.prepare()");
        this.player.N();
        Log.d(this.TAG, "[Performance]-player.prepare()");
        if (this.player != null) {
            if (this.pqParams != null) {
                Log.i(this.TAG, "pre-setting pqParams");
                this.player.f0(this.pqParams);
            }
            this.player.e0(this.videoGameMode);
            this.player.T(this.aiVisionDPTZEnabled);
            this.player.R(this.aiVisionAISREnabled);
            this.player.S(this.aiVisionBokehEnabled);
            this.player.d0(this.surface);
            this.player.a0(false);
        }
    }

    private void T() {
        SurfaceHolder.Callback callback;
        SurfaceHolder surfaceHolder = this.mSurfaceHolder;
        if (surfaceHolder != null && (callback = this.surfaceHolderCallback) != null) {
            surfaceHolder.removeCallback(callback);
            this.surfaceHolderCallback = null;
            this.mSurfaceHolder = null;
        }
        Handler handler = this.eventHandler;
        if (handler != null) {
            handler.removeMessages(6003);
        }
        Context context = this.context;
        if (context != null) {
            context.sendBroadcast(new Intent(INTENT_DOLBY_LOGO_HIDE), EXOPLAYER_BROADCAST_PERMISSION);
        }
        this.prepared = false;
        this.needReplay = false;
        this.pqParams = null;
        this.videoWidth = 1;
        this.videoHeight = 1;
        this.mIsAtmos = false;
        this.mAudioMime = null;
        this.audioMapInfo = null;
        this.isSetLooping = false;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.P();
            this.player = null;
        }
        PlaybackParams playbackParams = this.playbackParams;
        if (playbackParams != null && playbackParams.getSpeed() != 1.0f) {
            this.playbackParams.setSpeed(1.0f);
        }
        C0648b.a();
        this.currentAudioIndicator = -1;
    }

    private void U() {
        this.httpDataSourceCallBack = null;
        this.onPreparedlistener = null;
        this.onVideoSizeChangedListener = null;
        this.onBufferingUpdateListener = null;
        this.onSeekCompleteListener = null;
        this.onCompletionListener = null;
        this.onInfoListener = null;
        this.onErrorListener = null;
    }

    private void V(j jVar) {
        if (jVar != null) {
            this.httpDataSourceCallBack = new d();
        }
    }

    private void W() {
        Context context = this.context;
        if (context == null || this.player == null) {
            return;
        }
        String parameters = ((AudioManager) context.getSystemService("audio")).getParameters("audioindicator=");
        if (TextUtils.isEmpty(parameters) || !parameters.contains("DTS")) {
            return;
        }
        String strSubstring = parameters.substring(parameters.indexOf("DTS"));
        strSubstring.hashCode();
        switch (strSubstring) {
            case "DTS Express":
                this.currentAudioIndicator = 13;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS_EXPRESS), EXOPLAYER_BROADCAST_PERMISSION);
                break;
            case "DTS":
                this.currentAudioIndicator = 11;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS), EXOPLAYER_BROADCAST_PERMISSION);
                break;
            case "DTS:X":
                this.currentAudioIndicator = 15;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS_X), EXOPLAYER_BROADCAST_PERMISSION);
                break;
            case "DTS-HD Master Audio":
                this.currentAudioIndicator = 14;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS_HD_MASTER_AUDIO), EXOPLAYER_BROADCAST_PERMISSION);
                break;
            case "DTS-HD":
                this.currentAudioIndicator = 12;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS_HD), EXOPLAYER_BROADCAST_PERMISSION);
                break;
            default:
                this.currentAudioIndicator = 11;
                this.context.sendBroadcast(new Intent(INTENT_LOGO_DTS), EXOPLAYER_BROADCAST_PERMISSION);
                break;
        }
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    private void X(boolean z2) {
        t.c cVar;
        String str;
        int i2;
        boolean z3;
        int i3 = 2;
        boolean z4 = false;
        if (this.context == null || (cVar = this.player) == null) {
            return;
        }
        x xVarF = this.player.F(0, cVar.D(0));
        if (xVarF == null || !"video/dolby-vision".equals(xVarF.f5842g)) {
            str = null;
            i2 = -1;
            z3 = false;
        } else {
            str = INTENT_DOLBY_LOGO_VISION;
            i2 = 3;
            z3 = true;
        }
        String parameters = ((AudioManager) this.context.getSystemService("audio")).getParameters("audioindicator=");
        if (TextUtils.isEmpty(parameters)) {
            i3 = i2;
        } else {
            boolean zContains = parameters.toLowerCase().contains("ac4");
            if (parameters.toLowerCase().contains("dolby")) {
                if (parameters.toLowerCase().contains("atmos")) {
                    str = z3 ? INTENT_DOLBY_LOGO_VISION_ATMOS : INTENT_DOLBY_LOGO_ATMOS;
                } else {
                    str = z3 ? INTENT_DOLBY_LOGO_VISION_AUDIO : INTENT_DOLBY_LOGO_AUDIO;
                    i3 = 1;
                }
            } else if (parameters.contains("DTS")) {
                String strSubstring = parameters.substring(parameters.indexOf("DTS"));
                strSubstring.hashCode();
                i2 = 11;
                switch (strSubstring.hashCode()) {
                    case -664708621:
                        i3 = !strSubstring.equals("DTS Express") ? -1 : 0;
                        break;
                    case 68035:
                        i3 = !strSubstring.equals("DTS") ? -1 : 1;
                        break;
                    case 65383521:
                        if (!strSubstring.equals(DTS_VERSION_X)) {
                            i3 = -1;
                        }
                        break;
                    case 1873858866:
                        i3 = !strSubstring.equals("DTS-HD Master Audio") ? -1 : 3;
                        break;
                    case 2026876230:
                        i3 = !strSubstring.equals("DTS-HD") ? -1 : 4;
                        break;
                    default:
                        i3 = -1;
                        break;
                }
                switch (i3) {
                    case 0:
                        i3 = 13;
                        str = INTENT_LOGO_DTS_EXPRESS;
                        break;
                    case 1:
                    default:
                        str = INTENT_LOGO_DTS;
                        i3 = i2;
                        break;
                    case 2:
                        i3 = 15;
                        str = INTENT_LOGO_DTS_X;
                        break;
                    case 3:
                        i3 = 14;
                        str = INTENT_LOGO_DTS_HD_MASTER_AUDIO;
                        break;
                    case 4:
                        i3 = 12;
                        str = INTENT_LOGO_DTS_HD;
                        break;
                }
            } else {
                i3 = i2;
            }
            z4 = zContains;
        }
        Log.d(this.TAG, "showLogo: force=" + z2 + ", intent=" + str + ", indicator=" + i3 + ", currentAudioIndicator=" + this.currentAudioIndicator + ", audioIndicatorString=" + parameters);
        if (z2) {
            if (z4) {
                this.context.sendBroadcast(new Intent(INTENT_DOLBY_AUDIO_AC4), EXOPLAYER_BROADCAST_PERMISSION);
            } else {
                this.context.sendBroadcast(new Intent(INTENT_DOLBY_AUDIO_OTHERS), EXOPLAYER_BROADCAST_PERMISSION);
            }
            if (str != null) {
                this.context.sendBroadcast(new Intent(str), EXOPLAYER_BROADCAST_PERMISSION);
            }
        } else if (i3 != this.currentAudioIndicator) {
            if (z4) {
                this.context.sendBroadcast(new Intent(INTENT_DOLBY_AUDIO_AC4), EXOPLAYER_BROADCAST_PERMISSION);
            } else {
                this.context.sendBroadcast(new Intent(INTENT_DOLBY_AUDIO_OTHERS), EXOPLAYER_BROADCAST_PERMISSION);
            }
            if (str != null) {
                this.context.sendBroadcast(new Intent(str), EXOPLAYER_BROADCAST_PERMISSION);
            }
        }
        this.currentAudioIndicator = i3;
    }

    private void Y(boolean z2) {
        PowerManager.WakeLock wakeLock = this.mWakeLock;
        if (wakeLock != null) {
            if (z2 && !wakeLock.isHeld()) {
                this.mWakeLock.acquire();
            } else if (!z2 && this.mWakeLock.isHeld()) {
                this.mWakeLock.release();
            }
        }
        this.mStayAwake = z2;
        Z();
    }

    private void Z() {
        SurfaceHolder surfaceHolder = this.mSurfaceHolder;
        if (surfaceHolder != null) {
            surfaceHolder.setKeepScreenOn(this.mScreenOnWhilePlaying && this.mStayAwake);
        }
    }

    static /* bridge */ /* synthetic */ j e(AbstractC0754e abstractC0754e) {
        abstractC0754e.getClass();
        return null;
    }

    private static byte[] x(String str) {
        byte[] bytes = str.getBytes();
        byte[] bArr = new byte[str.length() * 2];
        for (int i2 = 0; i2 < str.length(); i2++) {
            int i3 = i2 * 2;
            bArr[i3] = bytes[i2];
            bArr[i3 + 1] = 0;
        }
        return bArr;
    }

    private boolean y(int i2) {
        t.c cVar = this.player;
        return cVar != null && cVar.y() != null && this.player.y().getDuration() > 0 && i2 >= 4 && i2 <= 14;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void z() {
        f fVar = this.mLastMemoryInfo;
        if (fVar != null) {
            long j2 = fVar.f7161a;
            int i2 = fVar.f7162b;
            int i3 = fVar.f7163c;
            int i4 = fVar.f7164d;
            long j3 = fVar.f7165e;
            int iE = this.player.E(1);
            int iE2 = this.player.E(2);
            int iE3 = this.player.E(0);
            int iD = this.player.D(1);
            int iD2 = this.player.D(2);
            int iD3 = this.player.D(0);
            Log.d(this.TAG, "checkLastMemory() ui8_clip_id = " + j2 + " -ui8_frame_position = " + j3 + " - ui2_aud_idx = " + i3 + " - ui2_sub_idx = " + i4 + " - ui2_vid_idx = " + i2);
            if (i3 < iE && i3 != iD && i3 != -1) {
                this.player.c0(1, i3);
            }
            if (i4 < iE2 && i4 != iD2 && i4 != -1) {
                this.player.c0(2, i4);
            }
            if (i2 < iE3 && i2 != iD3 && i2 != -1) {
                this.player.c0(0, i2);
            }
            if (j3 > 0) {
                this.player.Q(j3);
            }
        }
        this.mLastMemoryInfo = null;
    }

    public void bluetoothStateChange(int i2) {
        Log.d(this.TAG, "bluetoothStateChange() state=" + i2);
    }

    public boolean canDoSeek() {
        boolean z2;
        Log.i(this.TAG, "canDoSeek()");
        t.c cVar = this.player;
        boolean z3 = false;
        if (cVar != null && cVar.y() != null) {
            if (this.player.y().getDuration() > 0 && !J()) {
                int i2 = 0;
                while (true) {
                    if (i2 > 1) {
                        break;
                    }
                    x xVarF = this.player.F(i2, this.player.D(i2));
                    if (xVarF == null || !xVarF.r().containsKey("canseek")) {
                        i2++;
                    } else {
                        z2 = xVarF.r().getInteger("canseek") == 1;
                        if (!z2 && this.eventHandler != null) {
                            Message messageObtain = Message.obtain();
                            messageObtain.what = 6002;
                            messageObtain.arg1 = MEDIA_INFO_VIDEO_CANNOTSEEK;
                            messageObtain.arg2 = 0;
                            this.eventHandler.sendMessage(messageObtain);
                            Log.i(this.TAG, "is not support seek !!!!!!!");
                        }
                    }
                }
                z3 = z2;
            }
            Log.i(this.TAG, "canDoSeek() " + z3);
        }
        return z3;
    }

    public boolean canDoTrick(int i2) {
        Log.i(this.TAG, "canDoTrick():, speed = " + i2);
        t.c cVar = this.player;
        return cVar != null && cVar.y() != null && this.player.y().getDuration() > 0 && i2 >= 4 && i2 <= 14 && canDoSeek();
    }

    public int getAllAudioTrackCount() throws IllegalStateException {
        Log.d(this.TAG, "getAllAudioTrackCount");
        int i2 = 0;
        try {
            t.c cVar = this.player;
            if (cVar != null && cVar.y() != null) {
                List listO = this.player.y().o();
                int iW = this.player.y().w(1);
                if (iW > 0) {
                    int[][] iArr = this.trackIndexMap;
                    if (iArr[1] == null) {
                        int[] iArr2 = new int[iW];
                        iArr[1] = iArr2;
                        Arrays.fill(iArr2, -1);
                    }
                }
                int i3 = 0;
                int i4 = 0;
                while (i2 < iW) {
                    try {
                        x xVarX = this.player.y().x(1, i2);
                        if (xVarX != null && (listO == null || listO.size() == 0 || xVarX.f5850n0 == ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue())) {
                            int[] iArr3 = this.trackIndexMap[1];
                            if (iArr3[i4] == -1) {
                                iArr3[i4] = i2;
                            }
                            i4++;
                            i3++;
                        }
                        i2++;
                    } catch (Exception e2) {
                        e = e2;
                        i2 = i3;
                        Log.d(this.TAG, e.toString());
                        Log.d(this.TAG, "getAllAudioTrackCount:" + i2);
                        return i2;
                    }
                }
                i2 = i3;
            }
        } catch (Exception e3) {
            e = e3;
        }
        Log.d(this.TAG, "getAllAudioTrackCount:" + i2);
        return i2;
    }

    public int getAllSubtitleTrackCount() throws IllegalStateException {
        Log.d(this.TAG, "getAllSubtitleTrackCount");
        int i2 = 0;
        try {
            t.c cVar = this.player;
            if (cVar != null && cVar.y() != null) {
                List listO = this.player.y().o();
                int iW = this.player.y().w(2);
                if (iW > 0) {
                    int[][] iArr = this.trackIndexMap;
                    if (iArr[2] == null) {
                        int[] iArr2 = new int[iW];
                        iArr[2] = iArr2;
                        Arrays.fill(iArr2, -1);
                    }
                }
                int i3 = 0;
                int i4 = 0;
                while (i2 < iW) {
                    try {
                        x xVarX = this.player.y().x(2, i2);
                        if (xVarX != null && (AbstractC0708a.b(xVarX.f5842g) || listO == null || listO.size() == 0 || xVarX.f5850n0 == ((Integer) listO.get(this.currentSelectedProgramIndex)).intValue())) {
                            int[] iArr3 = this.trackIndexMap[2];
                            if (iArr3[i4] == -1) {
                                iArr3[i4] = i2;
                            }
                            i4++;
                            i3++;
                        }
                        i2++;
                    } catch (Exception e2) {
                        e = e2;
                        i2 = i3;
                        Log.d(this.TAG, e.toString());
                        Log.d(this.TAG, "getAllSubtitleTrackCount:" + i2);
                        return i2;
                    }
                }
                i2 = i3;
            }
        } catch (Exception e3) {
            e = e3;
        }
        Log.d(this.TAG, "getAllSubtitleTrackCount:" + i2);
        return i2;
    }

    public int getBufferPercent() {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return -1;
        }
        return this.player.y().getBufferPercentage();
    }

    public List<I.c> getCues() {
        return this.cues;
    }

    public int getCurrentAudioIndex() {
        int iV;
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null && (iV = this.player.y().v(1)) >= 0 && this.trackIndexMap[1] != null) {
            int i2 = 0;
            while (true) {
                int[] iArr = this.trackIndexMap[1];
                if (i2 >= iArr.length) {
                    break;
                }
                if (iArr[i2] == iV) {
                    return i2;
                }
                i2++;
            }
        }
        return -1;
    }

    @Override // android.media.MediaPlayer
    public int getCurrentPosition() {
        int currentPosition;
        Log.d(this.TAG, "getCurrentPositionExo called");
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            currentPosition = -1;
        } else {
            currentPosition = this.player.y().getCurrentPosition();
            if (currentPosition > 0 && !this.isSeeking) {
                if (b0.n.d()) {
                    X(false);
                }
                if (b0.n.c()) {
                    N(false);
                }
            }
        }
        Log.d(this.TAG, "getCurrentPosition():" + currentPosition);
        return currentPosition;
    }

    public int getCurrentSubtitleIndex() {
        int iV;
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null && (iV = this.player.y().v(2)) >= 0 && this.trackIndexMap[2] != null) {
            int i2 = 0;
            while (true) {
                int[] iArr = this.trackIndexMap[2];
                if (i2 >= iArr.length) {
                    break;
                }
                if (iArr[i2] == iV) {
                    return i2;
                }
                i2++;
            }
        }
        return -1;
    }

    public double getDownloadRate() {
        return this.bitRate / 1048576.0d;
    }

    @Override // android.media.MediaPlayer
    public int getDuration() {
        Log.d(this.TAG, "getDuration called");
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return 0;
        }
        return this.player.y().getDuration();
    }

    public int getIsFilmmaker() {
        t.c cVar = this.player;
        int iH = (cVar == null || cVar.y() == null) ? -1 : this.player.y().h();
        Log.i(this.TAG, "isFilmmaker:" + iH);
        return iH;
    }

    public long getLastMemoryFileID() {
        return D();
    }

    public f getLastMemoryFilePosition() {
        if (this.player == null) {
            Log.d(this.TAG, "getLastMemoryFilePosition() player is null");
            return null;
        }
        long jD = this.contentUri != null ? D() : -1L;
        int iD = this.player.D(0);
        int iD2 = this.player.D(1);
        int iD3 = this.player.D(2);
        long jW = this.player.w();
        Log.d(this.TAG, "getLastMemoryFilePosition() ui8_clip_id = " + jD + " -ui8_frame_position = " + jW + " - ui2_aud_idx = " + iD2 + " - ui2_sub_idx = " + iD3 + " - ui2_vid_idx = " + iD);
        return new f(jD, iD, iD2, iD3, jW);
    }

    public int getPlayMode() {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return -1;
        }
        return this.player.y().f();
    }

    @Override // android.media.MediaPlayer
    public PlaybackParams getPlaybackParams() {
        return this.playbackParams;
    }

    @Override // android.media.MediaPlayer
    public int getSelectedTrack(int i2) throws IllegalStateException {
        int i3;
        int iB;
        Log.d(this.TAG, "getSelectedTrackExo called. trackType=" + i2);
        int i4 = 0;
        int i5 = -1;
        if (i2 == 1) {
            i3 = 0;
        } else if (i2 == 2) {
            i3 = 1;
        } else {
            if (i2 != 3 && i2 != 4) {
                Log.e(this.TAG, "Illegal track type!");
                return -1;
            }
            i3 = 2;
        }
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null || this.trackIndexMap[i3] == null) {
            return -1;
        }
        int iV = this.player.y().v(i3);
        while (true) {
            int[] iArr = this.trackIndexMap[i3];
            if (i4 >= iArr.length) {
                break;
            }
            if (iArr[i4] == iV) {
                i5 = i4;
            }
            i4++;
        }
        if (i3 == 1) {
            iB = B();
        } else {
            if (i3 != 2) {
                return i5;
            }
            iB = B() + getAllAudioTrackCount();
        }
        return i5 + iB;
    }

    public String getTag() {
        String string = toString();
        int iLastIndexOf = string.lastIndexOf("@");
        string.substring(iLastIndexOf);
        if (iLastIndexOf < 0) {
            return "ExoMediaPlayer";
        }
        return "ExoMediaPlayer" + string.substring(iLastIndexOf);
    }

    public int getTunnelAudioSessionId() {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return 0;
        }
        int iY = this.player.y().y();
        Log.d(this.TAG, "getTunnelAudioSessionId: " + iY);
        return iY;
    }

    public int getUniqueStreamId() {
        return this.uniqueStreamId;
    }

    public int getVideoHdrType() {
        return this.videoVendorParam.f3067a;
    }

    @Override // android.media.MediaPlayer
    public int getVideoHeight() {
        return this.videoHeight;
    }

    public q getVideoVendorParam() {
        return this.videoVendorParam;
    }

    @Override // android.media.MediaPlayer
    public int getVideoWidth() {
        return this.videoWidth;
    }

    @Override // android.media.MediaPlayer
    public boolean isLooping() {
        return this.isSetLooping;
    }

    @Override // android.media.MediaPlayer
    public boolean isPlaying() {
        t.c cVar = this.player;
        if (cVar != null) {
            return cVar.y().isPlaying() || (J() && this.player.y().f() != 2);
        }
        return false;
    }

    public z0.g[] mtkGetTrackInfo() throws IllegalStateException {
        Log.d(this.TAG, "exo mtkGetTrackInfo called");
        x[] xVarArrH = H();
        if (xVarArrH == null || xVarArrH.length <= 0) {
            return null;
        }
        z0.g[] gVarArr = new z0.g[xVarArrH.length];
        for (int i2 = 0; i2 < xVarArrH.length; i2++) {
            x xVar = xVarArrH[i2];
            gVarArr[i2] = new z0.g(xVar.f5842g, xVar.r());
        }
        return gVarArr;
    }

    @Deprecated
    public boolean offSubtitleTrack() {
        Log.i(this.TAG, "offSubtitleTrack");
        return R(false, 0);
    }

    public void onAudioCodecFormatChanged(AudioMetadataReadMap audioMetadataReadMap, int i2) {
        AudioMetadataReadMap audioMetadataReadMap2;
        if (audioMetadataReadMap == null || !this.prepared) {
            Log.i(this.TAG, "onAudioCodecFormatChanged: info is null or prepared is false");
            return;
        }
        this.tunnelingAudioSessionId = i2;
        if (audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_MIME)) {
            this.mAudioMime = (String) audioMetadataReadMap.get(AudioMetadata.Format.KEY_MIME);
        }
        if (audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_ATMOS_PRESENT)) {
            boolean zBooleanValue = ((Boolean) audioMetadataReadMap.get(AudioMetadata.Format.KEY_ATMOS_PRESENT)).booleanValue();
            AudioMetadata.Key key = x.f5828r0;
            if (audioMetadataReadMap.containsKey(key) && (audioMetadataReadMap2 = this.audioMapInfo) != null && audioMetadataReadMap2.containsKey(key) && ((Long) audioMetadataReadMap.get(key)).longValue() < ((Long) this.audioMapInfo.get(key)).longValue()) {
                Log.w(this.TAG, "new seq-number[" + audioMetadataReadMap.get(key) + "] < old seq-number[" + this.audioMapInfo.get(key) + "]");
                return;
            }
            this.mIsAtmos = zBooleanValue;
        }
        this.audioMapInfo = audioMetadataReadMap;
        Log.i(this.TAG, "onAudioCodecFormatChanged sessionId:" + i2 + ", mIsAtmos:" + this.mIsAtmos);
    }

    public void onAudioFormatEnabled(p.j jVar, int i2, long j2) {
    }

    @Override // t.c.a
    public void onAudioOnlyPlayDone() {
    }

    @Override // t.c.a
    public void onAvailableRangeChanged(int i2, F f2) {
    }

    @Override // t.c.a
    public void onBandwidthSample(int i2, long j2, long j3) {
        this.bitRate = j3;
    }

    @Override // b0.p.a
    public void onCues(List<I.c> list) {
        Log.d(this.TAG, "onCues called");
        if (J()) {
            Log.v(this.TAG, "Tricking...don't show subtitles");
            return;
        }
        this.cues = list;
        if (list != null && list.size() > 0) {
            Log.d(this.TAG, "cues != null; cues.size = " + list.size());
            for (I.c cVar : list) {
                Log.d(this.TAG, "cue.text=" + ((Object) cVar.f938a));
            }
        }
        if (this.eventHandler != null) {
            Message messageObtain = Message.obtain();
            messageObtain.what = MTK_MEDIA_EXO_ON_CUES;
            messageObtain.obj = list;
            this.eventHandler.sendMessage(messageObtain);
        }
    }

    public void onDecoderInitialized(String str, long j2, long j3) {
    }

    @Override // t.c.a
    public void onDroppedFrames(int i2, long j2) {
    }

    public void onError(Exception exc) {
        Message messageObtain = Message.obtain();
        messageObtain.what = 1;
        messageObtain.arg1 = 0;
        messageObtain.arg2 = 0;
        try {
            if (exc instanceof u.k) {
                messageObtain.arg1 = 263;
            } else if (exc.getCause() instanceof a0.q) {
                messageObtain.arg1 = MTK_MEDIA_HTTP_REPONSE_ERROR;
                messageObtain.arg2 = ((a0.q) exc.getCause()).f2005r;
                Log.i(this.TAG, "HTTP response error:" + messageObtain.arg2);
            } else if ((exc instanceof C0643i) && (exc.getCause() instanceof IllegalArgumentException)) {
                messageObtain.arg1 = -5003;
            } else if (exc instanceof C0643i) {
                P((C0643i) exc, messageObtain);
            } else if (exc instanceof IOException) {
                messageObtain.arg1 = -5002;
            }
            Log.i(this.TAG, "onError arg1:" + messageObtain.arg1 + ", arg2:" + messageObtain.arg2);
            int i2 = messageObtain.arg1;
            if (i2 != -5001 && i2 != -5000) {
                messageObtain.what = MTK_MEDIA_EXO_ON_ERROR;
                Message messageObtain2 = Message.obtain(messageObtain);
                this.errMsg = messageObtain2;
                if (this.onErrorListener != null) {
                    this.eventHandler.sendMessage(messageObtain2);
                    return;
                } else {
                    this.delaySendErr = true;
                    return;
                }
            }
            messageObtain.what = 6002;
            this.eventHandler.sendMessage(messageObtain);
            boolean[] zArrC = this.player.C();
            if (zArrC[1] && zArrC[0]) {
                return;
            }
            Log.i(this.TAG, "Catch MediaCodec error, try to replay it!");
            this.needReplay = true;
        } catch (Exception e2) {
            Log.i(this.TAG, "Player has been released.", e2);
        }
    }

    public void onInfo(int i2) {
        x xVarX;
        String str;
        if (i2 == 2) {
            if (J() || this.isSeeking || !this.player.z()) {
                return;
            }
            Log.d(this.TAG, "onInfo send MEDIA_INFO_VIDEO_RENDERING_START");
            Message messageObtain = Message.obtain();
            messageObtain.what = 6002;
            messageObtain.arg1 = 3;
            messageObtain.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain);
            if (!b0.n.c() || getAllAudioTrackCount() <= 0 || (xVarX = this.player.y().x(1, this.player.y().v(1))) == null || (str = xVarX.f5842g) == null || !str.contains("dts")) {
                return;
            }
            W();
            return;
        }
        if (i2 != 3) {
            return;
        }
        Log.d(this.TAG, "[Performance]onInfo recive MTK_INFO_TYPE_PREPARED");
        this.prepared = true;
        this.audioStartRender = true;
        this.eventHandler.sendEmptyMessage(6001);
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return;
        }
        this.videoTrackCount = this.player.y().w(0);
        this.audioTrackCount = this.player.y().w(1);
        this.textTrackCount = this.player.y().w(2);
        Log.d(this.TAG, "videoTrackCount=" + this.videoTrackCount + ", audioTrackCount=" + this.audioTrackCount + ", textTrackCount=" + this.textTrackCount);
        int i3 = this.videoTrackCount;
        if (i3 == 0 && this.audioTrackCount != 0) {
            if (i3 == 0) {
                Log.d(this.TAG, "send audio only message");
                Message messageObtain2 = Message.obtain();
                messageObtain2.what = 6002;
                messageObtain2.arg1 = -5008;
                messageObtain2.arg2 = 0;
                this.eventHandler.sendMessage(messageObtain2);
            }
            Log.d(this.TAG, "onInfo send MEDIA_INFO_VIDEO_RENDERING_START");
            Message messageObtain3 = Message.obtain();
            messageObtain3.what = 6002;
            messageObtain3.arg1 = 3;
            messageObtain3.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain3);
        } else if (this.audioTrackCount == 0 && i3 != 0) {
            Log.d(this.TAG, "send video only message");
            Message messageObtain4 = Message.obtain();
            messageObtain4.what = 6002;
            messageObtain4.arg1 = -5009;
            messageObtain4.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain4);
        }
        if (this.player.y().canSeekForward() || this.player.y().canSeekBackward()) {
            return;
        }
        Message messageObtain5 = Message.obtain();
        messageObtain5.what = 6002;
        messageObtain5.arg1 = MEDIA_INFO_VIDEO_CANNOTSEEK;
        messageObtain5.arg2 = 0;
        this.eventHandler.sendMessage(messageObtain5);
    }

    @Override // t.c.a
    public void onLoadCompleted(int i2, long j2, int i3, int i4, p.j jVar, long j3, long j4, long j5, long j6) {
    }

    public void onLoadStarted(int i2, long j2, int i3, int i4, p.j jVar, long j3, long j4) {
    }

    @Override // b0.p.b
    public void onPrepared() {
    }

    @Override // t.c.a
    public void onRenderFrameJiffies(long j2, long j3) {
    }

    @Override // b0.p.b
    public void onSeekReadyInTrick() {
    }

    @Override // t.c.b
    public void onStateChanged(boolean z2, int i2) {
        Log.d(this.TAG, "play state change: playWhenReady=" + z2 + ", plabackState=" + i2);
        if (i2 == 1) {
            if (this.player == null || !this.needReplay) {
                return;
            }
            this.needReplay = false;
            try {
                Handler handler = this.eventHandler;
                if (handler != null) {
                    handler.removeMessages(6001);
                }
                this.player.Z(this.output);
                this.player.N();
                this.player.d0(this.surface);
                this.player.a0(false);
                return;
            } catch (Exception unused) {
                Log.d(this.TAG, "player has been released while replaying.");
                return;
            }
        }
        if (i2 == 3) {
            if (this.eventHandler == null || J()) {
                return;
            }
            this.buffering = true;
            Message messageObtain = Message.obtain();
            messageObtain.what = 6002;
            messageObtain.arg1 = 701;
            messageObtain.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain);
            return;
        }
        if (i2 == 4) {
            Q(z2);
            return;
        }
        if (i2 != 5 || this.player == null || this.eventHandler == null) {
            return;
        }
        Message messageObtain2 = Message.obtain();
        if (this.player.y().w(0) == 0 && this.player.y().w(1) == 0) {
            messageObtain2.what = MTK_MEDIA_EXO_ON_ERROR;
            messageObtain2.arg1 = -5002;
            messageObtain2.arg2 = 0;
            this.eventHandler.sendMessage(messageObtain2);
            return;
        }
        if (!this.isSetLooping) {
            messageObtain2.what = 6003;
            this.eventHandler.sendMessage(messageObtain2);
        } else {
            Log.i(this.TAG, "player will Looping playback");
            this.player.Q(0L);
            this.isSeeking = true;
        }
    }

    @Deprecated
    public boolean onSubtitleTrack() {
        Log.i(this.TAG, "onSubtitleTrack");
        return R(true, 0);
    }

    public void onTrackStateChanged(int i2, int i3, boolean z2) {
    }

    @Override // b0.p.b
    public void onTrickEnded(int i2, int i3) {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return;
        }
        Message messageObtain = Message.obtain();
        if (i3 == 0) {
            messageObtain.what = 6002;
            if (this.player.y().w(0) > 0) {
                messageObtain.arg1 = MEDIA_INFO_VIDEO_REPLAY_DONE;
            } else {
                messageObtain.arg1 = -5006;
            }
            messageObtain.arg2 = 0;
        } else {
            messageObtain.what = 6003;
        }
        this.eventHandler.sendMessage(messageObtain);
    }

    public void onVideoFormatEnabled(p.j jVar, int i2, long j2) {
    }

    @Override // t.c.b
    public void onVideoSizeChanged(int i2, int i3, int i4, float f2, q qVar) {
        this.videoWidth = i2;
        this.videoHeight = i3;
        this.videoVendorParam = qVar;
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null) {
            this.uniqueStreamId = this.player.y().z();
        }
        Log.i(this.TAG, "onVideoSizeChanged: width[" + this.videoWidth + "], height[" + i3 + "], videoHdrType[" + this.videoVendorParam.f3067a + "], uniqueStreamId[" + this.uniqueStreamId + "]");
        Handler handler = this.eventHandler;
        if (handler != null) {
            handler.sendEmptyMessage(6004);
        }
    }

    @Override // android.media.MediaPlayer
    public void pause() throws IllegalStateException {
        Log.d(this.TAG, "pause");
        if (1 == this.mDataSourceType) {
            Log.i(this.TAG, "mStallingSupport " + this.mStallingSupport);
            if (!this.mStallingSupport && this.mSeekType == 0) {
                Log.i(this.TAG, "pauseExo Exception");
                throw new IllegalStateException("pauseExo Exception");
            }
        }
        Y(false);
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return;
        }
        this.player.y().pause();
    }

    @Override // android.media.MediaPlayer
    public void prepare() throws IllegalStateException, IOException {
        Log.d(this.TAG, "prepare");
        S();
    }

    @Override // android.media.MediaPlayer
    public void prepareAsync() throws IllegalStateException {
        Log.d(this.TAG, "[Performance]prepareAsync");
        this.asyncPreparing = true;
        new c().start();
    }

    @Override // android.media.MediaPlayer
    public void release() {
        Log.d(this.TAG, "release() called");
        U();
        reset();
        super.release();
    }

    @Override // android.media.MediaPlayer
    public void reset() {
        int i2;
        Log.d(this.TAG, "reset() called");
        synchronized (this) {
            while (this.asyncPreparing) {
                try {
                    wait();
                } catch (InterruptedException unused) {
                    Thread.currentThread().interrupt();
                }
            }
        }
        T();
        Looper looper = this.myLooper;
        if (looper != null) {
            looper.quitSafely();
            this.myLooper = null;
        }
        this.audioStartRender = false;
        this.contentUri = null;
        this.delaySendErr = false;
        try {
            i2 = Integer.parseInt(D.y(MEDIA_TUNNELING_MODE_KEY, "1"));
        } catch (NumberFormatException e2) {
            e = e2;
            i2 = 1;
        }
        try {
            Log.i(this.TAG, "isTunnelingMode:" + i2);
        } catch (NumberFormatException e3) {
            e = e3;
            Log.e(this.TAG, "Invalid tunneling mode string. " + e.toString());
        }
        if (i2 == 0) {
            this.tunnelingMode = 0;
        } else {
            this.tunnelingMode = 1;
        }
        super.reset();
    }

    @Override // android.media.MediaPlayer
    public void seekTo(int i2) throws IllegalStateException {
        t.c cVar;
        Log.d(this.TAG, "seekTo called : msec=" + i2);
        if (canDoSeek() && (cVar = this.player) != null) {
            this.isSeeking = true;
            cVar.y().seekTo(i2);
        }
    }

    @Override // android.media.MediaPlayer
    public void selectTrack(int i2) throws IllegalStateException {
        Log.d(this.TAG, "selectTrack called. index=" + i2);
        if (i2 < 0) {
            Log.e(this.TAG, "Illegal track index!");
            return;
        }
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null) {
            for (int i3 = 0; i3 < 3; i3++) {
                int[] iArr = this.trackIndexMap[i3];
                if (iArr != null) {
                    for (int i4 = 0; i4 < iArr.length && iArr[i4] >= 0; i4++) {
                        if (i2 == 0) {
                            this.player.y().K(i3, iArr[i4]);
                            return;
                        }
                        i2--;
                    }
                }
            }
        }
        Log.e(this.TAG, "Illegal track index!");
    }

    public void setAIVisionAISREnabled(boolean z2) {
        Log.i(this.TAG, "setAIVisionAISREnabled: " + z2);
        this.aiVisionAISREnabled = z2;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.R(z2);
        }
    }

    public void setAIVisionBokehEnabled(boolean z2) {
        Log.i(this.TAG, "setAIVisionBokehEnabled: " + z2);
        this.aiVisionBokehEnabled = z2;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.S(z2);
        }
    }

    public void setAIVisionDPTZEnabled(boolean z2) {
        Log.i(this.TAG, "setAIVisionDPTZEnabled: " + z2);
        this.aiVisionDPTZEnabled = z2;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.T(z2);
        }
    }

    @Override // android.media.MediaPlayer
    public void setAudioSessionId(int i2) {
        Log.d(this.TAG, "set AudioSessionId: SessionId = " + i2);
        if (this.sessionId != i2) {
            this.sessionId = i2;
            t.c cVar = this.player;
            if (cVar != null) {
                cVar.U(i2);
            }
        }
    }

    public boolean setAudioTrack(int i2) {
        Log.i(this.TAG, "setAudioTrack, track = " + i2);
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null && this.trackIndexMap[1] != null) {
            if (i2 >= 0 && i2 < getAllAudioTrackCount()) {
                this.player.y().K(1, this.trackIndexMap[1][i2]);
                PlaybackParams playbackParams = this.playbackParams;
                if (playbackParams == null || playbackParams.getSpeed() == 1.0f) {
                    return true;
                }
                this.player.y().H(this.playbackParams);
                return true;
            }
            if (i2 == 255) {
                this.player.y().K(1, -1);
                return true;
            }
        }
        return false;
    }

    @Override // android.media.MediaPlayer
    public void setDataSource(Context context, Uri uri) throws IllegalStateException, IOException, SecurityException, IllegalArgumentException {
        setDataSource(context, uri, (Map<String, String>) null);
    }

    public void setDispPath(int i2) {
        if (b0.n.d()) {
            Log.i(this.TAG, "setDispPath: " + i2);
            this.mDispPath = i2;
            t.c cVar = this.player;
            if (cVar != null) {
                if (i2 == 0 || i2 == 1) {
                    cVar.V(i2);
                }
            }
        }
    }

    @Override // android.media.MediaPlayer
    public void setDisplay(SurfaceHolder surfaceHolder) {
        Log.d(this.TAG, "setDisplay");
        if (surfaceHolder != null) {
            this.mSurfaceHolder = surfaceHolder;
            this.surface = surfaceHolder.getSurface();
            if (this.surfaceHolderCallback == null) {
                this.surfaceHolderCallback = new b();
            }
            surfaceHolder.addCallback(this.surfaceHolderCallback);
            t.c cVar = this.player;
            if (cVar != null) {
                cVar.d0(this.surface);
            }
            if (this.mDataSourceType != 0) {
                Z();
            }
        }
    }

    public void setExternalSubtitleCharsetEncoding(String str) throws IllegalStateException {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null || !this.prepared) {
            throw new IllegalStateException("Player not prepared.");
        }
        if (this.player.y().v(2) == -1) {
            throw new IllegalStateException("No text track enabled.");
        }
        this.player.y().G(str);
    }

    public void setFocus(int i2) {
        Log.d(this.TAG, "setFocus: mode = " + i2);
        if (this.focusMode != i2) {
            this.focusMode = i2;
            t.c cVar = this.player;
            if (cVar != null) {
                cVar.W(i2);
            }
        }
    }

    public int setLastMemoryFilePosition(f fVar) {
        this.mLastMemoryInfo = fVar;
        Log.d(this.TAG, "setLastMemoryFilePosition() info = " + fVar);
        return this.mLastMemoryInfo != null ? 1 : 0;
    }

    @Override // android.media.MediaPlayer
    public void setLooping(boolean z2) {
        Log.i(this.TAG, "setLooping() called " + z2);
        if (this.player == null) {
            throw new IllegalStateException("setLooping fail");
        }
        this.isSetLooping = z2;
    }

    public void setMediaTunnelingMode(int i2) {
        Log.d(this.TAG, "setMediaTunnelingMode:" + i2);
        if (i2 == 0 || i2 == 1) {
            this.tunnelingMode = i2;
        }
    }

    public void setOnAudioCodecFormatChangedListener(g gVar) {
    }

    @Override // android.media.MediaPlayer
    public void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener) {
        this.onBufferingUpdateListener = onBufferingUpdateListener;
    }

    @Override // android.media.MediaPlayer
    public void setOnCompletionListener(MediaPlayer.OnCompletionListener onCompletionListener) {
        this.onCompletionListener = onCompletionListener;
    }

    @Override // android.media.MediaPlayer
    public void setOnErrorListener(MediaPlayer.OnErrorListener onErrorListener) {
        Log.d(this.TAG, "setOnErrorListener");
        this.onErrorListener = onErrorListener;
        Message message = this.errMsg;
        if (message == null || !this.delaySendErr) {
            return;
        }
        this.delaySendErr = false;
        this.eventHandler.sendMessage(message);
    }

    @Override // android.media.MediaPlayer
    public void setOnInfoListener(MediaPlayer.OnInfoListener onInfoListener) {
        Log.d(this.TAG, "setOnInfoListener");
        this.onInfoListener = onInfoListener;
    }

    @Override // android.media.MediaPlayer
    public void setOnPreparedListener(MediaPlayer.OnPreparedListener onPreparedListener) {
        if (this.prepared && this.onPreparedlistener == null && onPreparedListener != null) {
            Log.d(this.TAG, "trigger onPrepared called ");
            onPreparedListener.onPrepared(this);
        }
        this.onPreparedlistener = onPreparedListener;
    }

    @Override // android.media.MediaPlayer
    public void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener onSeekCompleteListener) {
        this.onSeekCompleteListener = onSeekCompleteListener;
    }

    @Override // android.media.MediaPlayer
    public void setOnVideoSizeChangedListener(MediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener) {
        this.onVideoSizeChangedListener = onVideoSizeChangedListener;
    }

    public void setPQAwareEnabled(boolean z2) {
    }

    public int setPlayMode(int i2) {
        h hVarA = A(i2);
        Log.i(this.TAG, "setPlayModeExo(): speed = " + i2 + " PlayerSpeed = " + hVarA);
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return -1;
        }
        if (i2 == 1) {
            this.player.y().pause();
        } else if (i2 == 3) {
            this.player.y().start();
        } else {
            if (!y(i2)) {
                return -1;
            }
            this.player.y().R(i2);
        }
        return 0;
    }

    @Override // android.media.MediaPlayer
    public void setPlaybackParams(PlaybackParams playbackParams) {
        Log.i(this.TAG, "setPlaybackParams(): setPlaybackRate = " + playbackParams.getSpeed());
        this.playbackParams = playbackParams;
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            throw new IllegalStateException("setPlaybackParams fail");
        }
        this.player.y().H(this.playbackParams);
    }

    @Override // android.media.MediaPlayer
    public void setScreenOnWhilePlaying(boolean z2) {
        Log.i(this.TAG, "setScreenOnWhilePlaying(): Enter");
        if (this.mDataSourceType != 0) {
            Log.i(this.TAG, "setScreenOnWhilePlaying(): screenOn=" + z2);
            if (this.mScreenOnWhilePlaying != z2) {
                if (z2 && this.mSurfaceHolder == null) {
                    Log.w(this.TAG, "setScreenOnWhilePlaying(true) is ineffective without a SurfaceHolder");
                }
                this.mScreenOnWhilePlaying = z2;
                Z();
            }
        }
        Log.i(this.TAG, "setScreenOnWhilePlaying(): Leave");
    }

    public boolean setSeamlessMode(boolean z2) {
        Log.i(this.TAG, "setSeamlessMode(): seamlessMode: " + z2);
        this.mSeamlessMode = z2 ? 1 : 0;
        if (this.asyncPreparing) {
            throw new IllegalStateException("setSeamlessMode fail");
        }
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return true;
        }
        this.player.y().J(this.mSeamlessMode);
        return true;
    }

    public boolean setSubtitleDataSource(String str) {
        Log.d(this.TAG, "setSubtitleDataSource called. uri=" + str);
        this.hasExternalSubtitle = true;
        return true;
    }

    @Deprecated
    public boolean setSubtitleTrack(int i2) {
        Log.d(this.TAG, "setSubtitleTrack called. track=" + i2);
        t.c cVar = this.player;
        if (cVar != null && cVar.y() != null && this.trackIndexMap[2] != null) {
            if (i2 >= 0 && i2 < getAllSubtitleTrackCount()) {
                this.player.y().K(2, this.trackIndexMap[2][i2]);
                return true;
            }
            if (i2 == 255) {
                this.player.y().K(2, -1);
                return true;
            }
        }
        return false;
    }

    @Override // android.media.MediaPlayer
    public void setSurface(Surface surface) {
        Log.d(this.TAG, "setSurface");
        this.mSurfaceHolder = null;
        this.surface = surface;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.d0(surface);
        }
        if (this.mDataSourceType != 0) {
            Z();
        }
    }

    public boolean setVendCmd(Bundle bundle) {
        if (!b0.n.d()) {
            return false;
        }
        if (this.asyncPreparing) {
            throw new IllegalStateException("setVendCmd fail");
        }
        this.vendCmdParams = new Bundle(bundle);
        for (String str : bundle.keySet()) {
            Object obj = bundle.get(str);
            Log.i(this.TAG, "setVendCmd  key: " + str + " values:" + obj);
        }
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return true;
        }
        this.player.y().N(bundle);
        return true;
    }

    public void setVideoGameMode(int i2) {
        Log.i(this.TAG, "setVideoGameMode: " + i2);
        if (i2 != 0 && i2 != 1) {
            Log.e(this.TAG, "Invalid Params");
            return;
        }
        this.videoGameMode = i2;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.e0(i2);
        }
    }

    public void setVideoPqParams(String str) {
        Log.i(this.TAG, "setVideoPqParams ");
        if (str == null) {
            Log.e(this.TAG, "Invalid pqParams");
            return;
        }
        this.pqParams = str;
        t.c cVar = this.player;
        if (cVar != null) {
            cVar.f0(str);
        }
    }

    public void setVolume(float f2) {
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return;
        }
        this.player.y().Q(f2);
    }

    @Override // android.media.MediaPlayer
    public void setWakeMode(Context context, int i2) {
        boolean z2;
        Log.i(this.TAG, "setWakeMode(): Enter");
        if (this.mDataSourceType != 0) {
            Log.i(this.TAG, "setWakeMode(): mode=" + i2);
            PowerManager.WakeLock wakeLock = this.mWakeLock;
            if (wakeLock != null) {
                if (wakeLock.isHeld()) {
                    this.mWakeLock.release();
                    z2 = true;
                } else {
                    z2 = false;
                }
                this.mWakeLock = null;
            } else {
                z2 = false;
            }
            PowerManager.WakeLock wakeLockNewWakeLock = ((PowerManager) context.getSystemService("power")).newWakeLock(i2 | 536870912, AbstractC0754e.class.getName());
            this.mWakeLock = wakeLockNewWakeLock;
            wakeLockNewWakeLock.setReferenceCounted(false);
            if (z2) {
                this.mWakeLock.acquire();
            }
        }
        Log.i(this.TAG, "setWakeMode(): Leave");
    }

    public void setWebInterface(j jVar) {
        V(jVar);
    }

    @Override // android.media.MediaPlayer
    public void start() throws IllegalStateException {
        Log.d(this.TAG, "start() called");
        t.c cVar = this.player;
        if (cVar == null || cVar.y() == null) {
            return;
        }
        this.player.y().start();
    }

    public boolean step(int i2) throws IllegalStateException {
        Log.i(this.TAG, "step() called, amount=" + i2);
        return false;
    }

    @Override // android.media.MediaPlayer
    public void stop() throws IllegalStateException {
        Log.d(this.TAG, "stop");
        T();
        Looper looper = this.myLooper;
        if (looper != null) {
            looper.quitSafely();
            this.myLooper = null;
        }
        this.audioStartRender = false;
        this.delaySendErr = false;
    }

    public int updateRotation(int i2) {
        Log.i(this.TAG, "updateRotation(): rotation_degree: " + i2);
        this.mSetVideoDegree = i2;
        if (this.asyncPreparing) {
            Log.i(this.TAG, "IllegalStateException updateRotation fail");
            throw new IllegalStateException("updateRotation fail");
        }
        if (i2 == 0 || i2 == 90 || i2 == 180 || i2 == 270) {
            t.c cVar = this.player;
            if (cVar != null && cVar.y() != null) {
                this.player.y().S(this.mSetVideoDegree);
            }
            return this.mSetVideoDegree;
        }
        Log.i(this.TAG, "IllegalArgumentException Invalid rotation_degree parameter" + this.mSetVideoDegree);
        throw new IllegalArgumentException("updateRotation fail");
    }

    @Override // android.media.MediaPlayer
    public void setDataSource(Context context, Uri uri, Map<String, String> map) throws IllegalStateException, IOException, SecurityException, IllegalArgumentException {
        if (uri == null) {
            Log.e(this.TAG, "If crash, need APP add try catch");
            throw new IllegalArgumentException("uri is null");
        }
        Log.i(this.TAG, "setDataSource: uri=" + uri.toString());
        if (this.eventHandler != null) {
            Log.d(this.TAG, "setDataSource: remove all messages");
            this.eventHandler.removeCallbacksAndMessages(null);
        }
        this.contentUri = uri;
        this.context = context;
        this.mHeaders = map;
        String scheme = uri.getScheme();
        if (!"http".equals(scheme) && !"https".equals(scheme)) {
            this.contentType = 1001;
            return;
        }
        this.contentUri.toString();
        a aVar = new a(map);
        aVar.start();
        try {
            aVar.join();
        } catch (InterruptedException e2) {
            e2.printStackTrace();
        }
    }

    @Deprecated
    public boolean onSubtitleTrack(int i2) {
        Log.i(this.TAG, "onSubtitleTrack");
        return R(true, i2);
    }

    @Override // android.media.MediaPlayer
    @Deprecated
    public void setDataSource(String str) throws IllegalStateException, IOException, SecurityException, IllegalArgumentException {
        Log.e(this.TAG, "setDataSource(String path) API:3");
        throw new IllegalArgumentException();
    }

    @Deprecated
    public void setDataSource(String str, Map<String, String> map) throws IllegalStateException, IOException, SecurityException, IllegalArgumentException {
        Log.e(this.TAG, "setDataSource(String path, Map<String, String> headers) API:4");
        throw new IllegalArgumentException();
    }

    public void setDataSource(A0.b bVar, Context context) throws IllegalStateException, IOException, IllegalArgumentException {
        Log.i(this.TAG, "setDataSource(final DataSource, Context): Enter DLNA VIP");
        throw null;
    }
}
