package androidx.media3.session;

import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import androidx.annotation.CheckResult;
import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.DeviceInfo;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.PlaybackParameters;
import androidx.media3.common.Player;
import androidx.media3.common.Timeline;
import androidx.media3.common.TrackSelectionParameters;
import androidx.media3.common.Tracks;
import androidx.media3.common.VideoSize;
import androidx.media3.common.text.CueGroup;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
class PlayerInfo {
    public static final PlayerInfo DEFAULT;
    public static final int DISCONTINUITY_REASON_DEFAULT = 0;
    private static final String FIELD_AUDIO_ATTRIBUTES;
    private static final String FIELD_CUE_GROUP;
    private static final String FIELD_CURRENT_TRACKS;
    private static final String FIELD_DEVICE_INFO;
    private static final String FIELD_DEVICE_MUTED;
    private static final String FIELD_DEVICE_VOLUME;
    private static final String FIELD_DISCONTINUITY_REASON;
    private static final String FIELD_IN_PROCESS_BINDER;
    private static final String FIELD_IS_LOADING;
    private static final String FIELD_IS_PLAYING;

    @VisibleForTesting
    static final String FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS;
    private static final String FIELD_MEDIA_ITEM_TRANSITION_REASON;
    private static final String FIELD_MEDIA_METADATA;

    @VisibleForTesting
    static final String FIELD_NEW_POSITION_INFO;

    @VisibleForTesting
    static final String FIELD_OLD_POSITION_INFO;
    private static final String FIELD_PLAYBACK_ERROR;
    private static final String FIELD_PLAYBACK_PARAMETERS;
    private static final String FIELD_PLAYBACK_STATE;
    private static final String FIELD_PLAYBACK_SUPPRESSION_REASON;
    private static final String FIELD_PLAYLIST_METADATA;
    private static final String FIELD_PLAY_WHEN_READY;
    private static final String FIELD_PLAY_WHEN_READY_CHANGE_REASON;
    private static final String FIELD_REPEAT_MODE;

    @VisibleForTesting
    static final String FIELD_SEEK_BACK_INCREMENT_MS;

    @VisibleForTesting
    static final String FIELD_SEEK_FORWARD_INCREMENT_MS;

    @VisibleForTesting
    static final String FIELD_SESSION_POSITION_INFO;
    private static final String FIELD_SHUFFLE_MODE_ENABLED;
    private static final String FIELD_TIMELINE;
    private static final String FIELD_TIMELINE_CHANGE_REASON;
    private static final String FIELD_TRACK_SELECTION_PARAMETERS;
    private static final String FIELD_VIDEO_SIZE;
    private static final String FIELD_VOLUME;
    public static final int MEDIA_ITEM_TRANSITION_REASON_DEFAULT = 0;
    public static final int PLAY_WHEN_READY_CHANGE_REASON_DEFAULT = 1;
    public static final int TIMELINE_CHANGE_REASON_DEFAULT = 0;
    public final AudioAttributes audioAttributes;
    public final CueGroup cueGroup;
    public final Tracks currentTracks;
    public final DeviceInfo deviceInfo;
    public final boolean deviceMuted;
    public final int deviceVolume;
    public final int discontinuityReason;
    public final boolean isLoading;
    public final boolean isPlaying;
    public final long maxSeekToPreviousPositionMs;
    public final int mediaItemTransitionReason;
    public final MediaMetadata mediaMetadata;
    public final Player.PositionInfo newPositionInfo;
    public final Player.PositionInfo oldPositionInfo;
    public final boolean playWhenReady;
    public final int playWhenReadyChangeReason;
    public final PlaybackParameters playbackParameters;
    public final int playbackState;
    public final int playbackSuppressionReason;

    @Nullable
    public final PlaybackException playerError;
    public final MediaMetadata playlistMetadata;
    public final int repeatMode;
    public final long seekBackIncrementMs;
    public final long seekForwardIncrementMs;
    public final SessionPositionInfo sessionPositionInfo;
    public final boolean shuffleModeEnabled;
    public final Timeline timeline;
    public final int timelineChangeReason;
    public final TrackSelectionParameters trackSelectionParameters;
    public final VideoSize videoSize;
    public final float volume;

    public static class Builder {
        private AudioAttributes audioAttributes;
        private CueGroup cueGroup;
        private Tracks currentTracks;
        private DeviceInfo deviceInfo;
        private boolean deviceMuted;
        private int deviceVolume;
        private int discontinuityReason;
        private boolean isLoading;
        private boolean isPlaying;
        private long maxSeekToPreviousPositionMs;
        private int mediaItemTransitionReason;
        private MediaMetadata mediaMetadata;
        private Player.PositionInfo newPositionInfo;
        private Player.PositionInfo oldPositionInfo;
        private boolean playWhenReady;
        private int playWhenReadyChangeReason;
        private PlaybackParameters playbackParameters;
        private int playbackState;
        private int playbackSuppressionReason;

        @Nullable
        private PlaybackException playerError;
        private MediaMetadata playlistMetadata;
        private int repeatMode;
        private long seekBackIncrementMs;
        private long seekForwardIncrementMs;
        private SessionPositionInfo sessionPositionInfo;
        private boolean shuffleModeEnabled;
        private Timeline timeline;
        private int timelineChangeReason;
        private TrackSelectionParameters trackSelectionParameters;
        private VideoSize videoSize;
        private float volume;

        public Builder(PlayerInfo playerInfo) {
            this.playerError = playerInfo.playerError;
            this.mediaItemTransitionReason = playerInfo.mediaItemTransitionReason;
            this.sessionPositionInfo = playerInfo.sessionPositionInfo;
            this.oldPositionInfo = playerInfo.oldPositionInfo;
            this.newPositionInfo = playerInfo.newPositionInfo;
            this.discontinuityReason = playerInfo.discontinuityReason;
            this.playbackParameters = playerInfo.playbackParameters;
            this.repeatMode = playerInfo.repeatMode;
            this.shuffleModeEnabled = playerInfo.shuffleModeEnabled;
            this.timeline = playerInfo.timeline;
            this.timelineChangeReason = playerInfo.timelineChangeReason;
            this.videoSize = playerInfo.videoSize;
            this.playlistMetadata = playerInfo.playlistMetadata;
            this.volume = playerInfo.volume;
            this.audioAttributes = playerInfo.audioAttributes;
            this.cueGroup = playerInfo.cueGroup;
            this.deviceInfo = playerInfo.deviceInfo;
            this.deviceVolume = playerInfo.deviceVolume;
            this.deviceMuted = playerInfo.deviceMuted;
            this.playWhenReady = playerInfo.playWhenReady;
            this.playWhenReadyChangeReason = playerInfo.playWhenReadyChangeReason;
            this.isPlaying = playerInfo.isPlaying;
            this.isLoading = playerInfo.isLoading;
            this.playbackSuppressionReason = playerInfo.playbackSuppressionReason;
            this.playbackState = playerInfo.playbackState;
            this.mediaMetadata = playerInfo.mediaMetadata;
            this.seekBackIncrementMs = playerInfo.seekBackIncrementMs;
            this.seekForwardIncrementMs = playerInfo.seekForwardIncrementMs;
            this.maxSeekToPreviousPositionMs = playerInfo.maxSeekToPreviousPositionMs;
            this.currentTracks = playerInfo.currentTracks;
            this.trackSelectionParameters = playerInfo.trackSelectionParameters;
        }

        public PlayerInfo build() {
            Assertions.checkState(this.timeline.isEmpty() || this.sessionPositionInfo.positionInfo.mediaItemIndex < this.timeline.getWindowCount());
            return new PlayerInfo(this.playerError, this.mediaItemTransitionReason, this.sessionPositionInfo, this.oldPositionInfo, this.newPositionInfo, this.discontinuityReason, this.playbackParameters, this.repeatMode, this.shuffleModeEnabled, this.videoSize, this.timeline, this.timelineChangeReason, this.playlistMetadata, this.volume, this.audioAttributes, this.cueGroup, this.deviceInfo, this.deviceVolume, this.deviceMuted, this.playWhenReady, this.playWhenReadyChangeReason, this.playbackSuppressionReason, this.playbackState, this.isPlaying, this.isLoading, this.mediaMetadata, this.seekBackIncrementMs, this.seekForwardIncrementMs, this.maxSeekToPreviousPositionMs, this.currentTracks, this.trackSelectionParameters);
        }

        @CanIgnoreReturnValue
        public Builder setAudioAttributes(AudioAttributes audioAttributes) {
            this.audioAttributes = audioAttributes;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setCues(CueGroup cueGroup) {
            this.cueGroup = cueGroup;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setCurrentTracks(Tracks tracks) {
            this.currentTracks = tracks;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setDeviceInfo(DeviceInfo deviceInfo) {
            this.deviceInfo = deviceInfo;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setDeviceMuted(boolean z2) {
            this.deviceMuted = z2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setDeviceVolume(int i2) {
            this.deviceVolume = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setDiscontinuityReason(int i2) {
            this.discontinuityReason = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setIsLoading(boolean z2) {
            this.isLoading = z2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setIsPlaying(boolean z2) {
            this.isPlaying = z2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setMaxSeekToPreviousPositionMs(long j2) {
            this.maxSeekToPreviousPositionMs = j2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setMediaItemTransitionReason(int i2) {
            this.mediaItemTransitionReason = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setMediaMetadata(MediaMetadata mediaMetadata) {
            this.mediaMetadata = mediaMetadata;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setNewPositionInfo(Player.PositionInfo positionInfo) {
            this.newPositionInfo = positionInfo;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setOldPositionInfo(Player.PositionInfo positionInfo) {
            this.oldPositionInfo = positionInfo;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlayWhenReady(boolean z2) {
            this.playWhenReady = z2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlayWhenReadyChangeReason(int i2) {
            this.playWhenReadyChangeReason = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlaybackParameters(PlaybackParameters playbackParameters) {
            this.playbackParameters = playbackParameters;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlaybackState(int i2) {
            this.playbackState = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlaybackSuppressionReason(int i2) {
            this.playbackSuppressionReason = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlayerError(@Nullable PlaybackException playbackException) {
            this.playerError = playbackException;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setPlaylistMetadata(MediaMetadata mediaMetadata) {
            this.playlistMetadata = mediaMetadata;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setRepeatMode(int i2) {
            this.repeatMode = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setSeekBackIncrement(long j2) {
            this.seekBackIncrementMs = j2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setSeekForwardIncrement(long j2) {
            this.seekForwardIncrementMs = j2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setSessionPositionInfo(SessionPositionInfo sessionPositionInfo) {
            this.sessionPositionInfo = sessionPositionInfo;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setShuffleModeEnabled(boolean z2) {
            this.shuffleModeEnabled = z2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setTimeline(Timeline timeline) {
            this.timeline = timeline;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setTimelineChangeReason(int i2) {
            this.timelineChangeReason = i2;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters) {
            this.trackSelectionParameters = trackSelectionParameters;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setVideoSize(VideoSize videoSize) {
            this.videoSize = videoSize;
            return this;
        }

        @CanIgnoreReturnValue
        public Builder setVolume(@FloatRange(from = com.jsyn.unitgen.u.FALSE, to = com.jsyn.unitgen.u.TRUE) float f2) {
            this.volume = f2;
            return this;
        }
    }

    public static class BundlingExclusions {
        public final boolean areCurrentTracksExcluded;
        public final boolean isTimelineExcluded;
        public static final BundlingExclusions NONE = new BundlingExclusions(false, false);
        private static final String FIELD_IS_TIMELINE_EXCLUDED = Util.intToStringMaxRadix(0);
        private static final String FIELD_ARE_CURRENT_TRACKS_EXCLUDED = Util.intToStringMaxRadix(1);

        public BundlingExclusions(boolean z2, boolean z3) {
            this.isTimelineExcluded = z2;
            this.areCurrentTracksExcluded = z3;
        }

        public static BundlingExclusions fromBundle(Bundle bundle) {
            return new BundlingExclusions(bundle.getBoolean(FIELD_IS_TIMELINE_EXCLUDED, false), bundle.getBoolean(FIELD_ARE_CURRENT_TRACKS_EXCLUDED, false));
        }

        public boolean equals(@Nullable Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof BundlingExclusions)) {
                return false;
            }
            BundlingExclusions bundlingExclusions = (BundlingExclusions) obj;
            return this.isTimelineExcluded == bundlingExclusions.isTimelineExcluded && this.areCurrentTracksExcluded == bundlingExclusions.areCurrentTracksExcluded;
        }

        public int hashCode() {
            return Objects.hash(Boolean.valueOf(this.isTimelineExcluded), Boolean.valueOf(this.areCurrentTracksExcluded));
        }

        @UnstableApi
        public Bundle toBundle() {
            Bundle bundle = new Bundle();
            bundle.putBoolean(FIELD_IS_TIMELINE_EXCLUDED, this.isTimelineExcluded);
            bundle.putBoolean(FIELD_ARE_CURRENT_TRACKS_EXCLUDED, this.areCurrentTracksExcluded);
            return bundle;
        }
    }

    private final class InProcessBinder extends Binder {
        private InProcessBinder() {
        }

        public PlayerInfo getPlayerInfo() {
            return PlayerInfo.this;
        }
    }

    static {
        SessionPositionInfo sessionPositionInfo = SessionPositionInfo.DEFAULT;
        Player.PositionInfo positionInfo = SessionPositionInfo.DEFAULT_POSITION_INFO;
        DEFAULT = new PlayerInfo(null, 0, sessionPositionInfo, positionInfo, positionInfo, 0, PlaybackParameters.DEFAULT, 0, false, VideoSize.UNKNOWN, Timeline.EMPTY, 0, MediaMetadata.EMPTY, 1.0f, AudioAttributes.DEFAULT, CueGroup.EMPTY_TIME_ZERO, DeviceInfo.UNKNOWN, 0, false, false, 1, 0, 1, false, false, MediaMetadata.EMPTY, 5000L, 15000L, 3000L, Tracks.EMPTY, TrackSelectionParameters.DEFAULT);
        FIELD_PLAYBACK_PARAMETERS = Util.intToStringMaxRadix(1);
        FIELD_REPEAT_MODE = Util.intToStringMaxRadix(2);
        FIELD_SHUFFLE_MODE_ENABLED = Util.intToStringMaxRadix(3);
        FIELD_TIMELINE = Util.intToStringMaxRadix(4);
        FIELD_VIDEO_SIZE = Util.intToStringMaxRadix(5);
        FIELD_PLAYLIST_METADATA = Util.intToStringMaxRadix(6);
        FIELD_VOLUME = Util.intToStringMaxRadix(7);
        FIELD_AUDIO_ATTRIBUTES = Util.intToStringMaxRadix(8);
        FIELD_DEVICE_INFO = Util.intToStringMaxRadix(9);
        FIELD_DEVICE_VOLUME = Util.intToStringMaxRadix(10);
        FIELD_DEVICE_MUTED = Util.intToStringMaxRadix(11);
        FIELD_PLAY_WHEN_READY = Util.intToStringMaxRadix(12);
        FIELD_PLAY_WHEN_READY_CHANGE_REASON = Util.intToStringMaxRadix(13);
        FIELD_PLAYBACK_SUPPRESSION_REASON = Util.intToStringMaxRadix(14);
        FIELD_PLAYBACK_STATE = Util.intToStringMaxRadix(15);
        FIELD_IS_PLAYING = Util.intToStringMaxRadix(16);
        FIELD_IS_LOADING = Util.intToStringMaxRadix(17);
        FIELD_PLAYBACK_ERROR = Util.intToStringMaxRadix(18);
        FIELD_SESSION_POSITION_INFO = Util.intToStringMaxRadix(19);
        FIELD_MEDIA_ITEM_TRANSITION_REASON = Util.intToStringMaxRadix(20);
        FIELD_OLD_POSITION_INFO = Util.intToStringMaxRadix(21);
        FIELD_NEW_POSITION_INFO = Util.intToStringMaxRadix(22);
        FIELD_DISCONTINUITY_REASON = Util.intToStringMaxRadix(23);
        FIELD_CUE_GROUP = Util.intToStringMaxRadix(24);
        FIELD_MEDIA_METADATA = Util.intToStringMaxRadix(25);
        FIELD_SEEK_BACK_INCREMENT_MS = Util.intToStringMaxRadix(26);
        FIELD_SEEK_FORWARD_INCREMENT_MS = Util.intToStringMaxRadix(27);
        FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS = Util.intToStringMaxRadix(28);
        FIELD_TRACK_SELECTION_PARAMETERS = Util.intToStringMaxRadix(29);
        FIELD_CURRENT_TRACKS = Util.intToStringMaxRadix(30);
        FIELD_TIMELINE_CHANGE_REASON = Util.intToStringMaxRadix(31);
        FIELD_IN_PROCESS_BINDER = Util.intToStringMaxRadix(32);
    }

    public PlayerInfo(@Nullable PlaybackException playbackException, int i2, SessionPositionInfo sessionPositionInfo, Player.PositionInfo positionInfo, Player.PositionInfo positionInfo2, int i3, PlaybackParameters playbackParameters, int i4, boolean z2, VideoSize videoSize, Timeline timeline, int i5, MediaMetadata mediaMetadata, float f2, AudioAttributes audioAttributes, CueGroup cueGroup, DeviceInfo deviceInfo, int i6, boolean z3, boolean z4, int i7, int i8, int i9, boolean z5, boolean z6, MediaMetadata mediaMetadata2, long j2, long j3, long j4, Tracks tracks, TrackSelectionParameters trackSelectionParameters) {
        this.playerError = playbackException;
        this.mediaItemTransitionReason = i2;
        this.sessionPositionInfo = sessionPositionInfo;
        this.oldPositionInfo = positionInfo;
        this.newPositionInfo = positionInfo2;
        this.discontinuityReason = i3;
        this.playbackParameters = playbackParameters;
        this.repeatMode = i4;
        this.shuffleModeEnabled = z2;
        this.videoSize = videoSize;
        this.timeline = timeline;
        this.timelineChangeReason = i5;
        this.playlistMetadata = mediaMetadata;
        this.volume = f2;
        this.audioAttributes = audioAttributes;
        this.cueGroup = cueGroup;
        this.deviceInfo = deviceInfo;
        this.deviceVolume = i6;
        this.deviceMuted = z3;
        this.playWhenReady = z4;
        this.playWhenReadyChangeReason = i7;
        this.playbackSuppressionReason = i8;
        this.playbackState = i9;
        this.isPlaying = z5;
        this.isLoading = z6;
        this.mediaMetadata = mediaMetadata2;
        this.seekBackIncrementMs = j2;
        this.seekForwardIncrementMs = j3;
        this.maxSeekToPreviousPositionMs = j4;
        this.currentTracks = tracks;
        this.trackSelectionParameters = trackSelectionParameters;
    }

    public static PlayerInfo fromBundle(Bundle bundle, int i2) {
        Timeline timeline;
        int i3;
        long j2;
        IBinder binder = bundle.getBinder(FIELD_IN_PROCESS_BINDER);
        if (binder instanceof InProcessBinder) {
            return ((InProcessBinder) binder).getPlayerInfo();
        }
        Bundle bundle2 = bundle.getBundle(FIELD_PLAYBACK_ERROR);
        PlaybackException playbackExceptionFromBundle = bundle2 == null ? null : PlaybackException.fromBundle(bundle2);
        int i4 = bundle.getInt(FIELD_MEDIA_ITEM_TRANSITION_REASON, 0);
        Bundle bundle3 = bundle.getBundle(FIELD_SESSION_POSITION_INFO);
        SessionPositionInfo sessionPositionInfoFromBundle = bundle3 == null ? SessionPositionInfo.DEFAULT : SessionPositionInfo.fromBundle(bundle3);
        Bundle bundle4 = bundle.getBundle(FIELD_OLD_POSITION_INFO);
        Player.PositionInfo positionInfoFromBundle = bundle4 == null ? SessionPositionInfo.DEFAULT_POSITION_INFO : Player.PositionInfo.fromBundle(bundle4);
        Bundle bundle5 = bundle.getBundle(FIELD_NEW_POSITION_INFO);
        Player.PositionInfo positionInfoFromBundle2 = bundle5 == null ? SessionPositionInfo.DEFAULT_POSITION_INFO : Player.PositionInfo.fromBundle(bundle5);
        int i5 = bundle.getInt(FIELD_DISCONTINUITY_REASON, 0);
        Bundle bundle6 = bundle.getBundle(FIELD_PLAYBACK_PARAMETERS);
        PlaybackParameters playbackParametersFromBundle = bundle6 == null ? PlaybackParameters.DEFAULT : PlaybackParameters.fromBundle(bundle6);
        int i6 = bundle.getInt(FIELD_REPEAT_MODE, 0);
        boolean z2 = bundle.getBoolean(FIELD_SHUFFLE_MODE_ENABLED, false);
        Bundle bundle7 = bundle.getBundle(FIELD_TIMELINE);
        Timeline timelineFromBundle = bundle7 == null ? Timeline.EMPTY : Timeline.fromBundle(bundle7);
        int i7 = bundle.getInt(FIELD_TIMELINE_CHANGE_REASON, 0);
        Bundle bundle8 = bundle.getBundle(FIELD_VIDEO_SIZE);
        VideoSize videoSizeFromBundle = bundle8 == null ? VideoSize.UNKNOWN : VideoSize.fromBundle(bundle8);
        Bundle bundle9 = bundle.getBundle(FIELD_PLAYLIST_METADATA);
        MediaMetadata mediaMetadataFromBundle = bundle9 == null ? MediaMetadata.EMPTY : MediaMetadata.fromBundle(bundle9);
        float f2 = bundle.getFloat(FIELD_VOLUME, 1.0f);
        Bundle bundle10 = bundle.getBundle(FIELD_AUDIO_ATTRIBUTES);
        AudioAttributes audioAttributesFromBundle = bundle10 == null ? AudioAttributes.DEFAULT : AudioAttributes.fromBundle(bundle10);
        Bundle bundle11 = bundle.getBundle(FIELD_CUE_GROUP);
        CueGroup cueGroupFromBundle = bundle11 == null ? CueGroup.EMPTY_TIME_ZERO : CueGroup.fromBundle(bundle11);
        Bundle bundle12 = bundle.getBundle(FIELD_DEVICE_INFO);
        DeviceInfo deviceInfoFromBundle = bundle12 == null ? DeviceInfo.UNKNOWN : DeviceInfo.fromBundle(bundle12);
        int i8 = bundle.getInt(FIELD_DEVICE_VOLUME, 0);
        boolean z3 = bundle.getBoolean(FIELD_DEVICE_MUTED, false);
        boolean z4 = bundle.getBoolean(FIELD_PLAY_WHEN_READY, false);
        int i9 = bundle.getInt(FIELD_PLAY_WHEN_READY_CHANGE_REASON, 1);
        int i10 = bundle.getInt(FIELD_PLAYBACK_SUPPRESSION_REASON, 0);
        int i11 = bundle.getInt(FIELD_PLAYBACK_STATE, 1);
        boolean z5 = bundle.getBoolean(FIELD_IS_PLAYING, false);
        boolean z6 = bundle.getBoolean(FIELD_IS_LOADING, false);
        Bundle bundle13 = bundle.getBundle(FIELD_MEDIA_METADATA);
        MediaMetadata mediaMetadataFromBundle2 = bundle13 == null ? MediaMetadata.EMPTY : MediaMetadata.fromBundle(bundle13);
        String str = FIELD_SEEK_BACK_INCREMENT_MS;
        if (i2 < 4) {
            timeline = timelineFromBundle;
            i3 = i7;
            j2 = 0;
        } else {
            timeline = timelineFromBundle;
            i3 = i7;
            j2 = 5000;
        }
        long j3 = bundle.getLong(str, j2);
        long j4 = bundle.getLong(FIELD_SEEK_FORWARD_INCREMENT_MS, i2 < 4 ? 0L : 15000L);
        long j5 = bundle.getLong(FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS, i2 >= 4 ? 3000L : 0L);
        Bundle bundle14 = bundle.getBundle(FIELD_CURRENT_TRACKS);
        Tracks tracksFromBundle = bundle14 == null ? Tracks.EMPTY : Tracks.fromBundle(bundle14);
        Bundle bundle15 = bundle.getBundle(FIELD_TRACK_SELECTION_PARAMETERS);
        return new PlayerInfo(playbackExceptionFromBundle, i4, sessionPositionInfoFromBundle, positionInfoFromBundle, positionInfoFromBundle2, i5, playbackParametersFromBundle, i6, z2, videoSizeFromBundle, timeline, i3, mediaMetadataFromBundle, f2, audioAttributesFromBundle, cueGroupFromBundle, deviceInfoFromBundle, i8, z3, z4, i9, i10, i11, z5, z6, mediaMetadataFromBundle2, j3, j4, j5, tracksFromBundle, bundle15 == null ? TrackSelectionParameters.DEFAULT : TrackSelectionParameters.fromBundle(bundle15));
    }

    private boolean isPlaying(int i2, boolean z2, int i3) {
        return i2 == 3 && z2 && i3 == 0;
    }

    @CheckResult
    public PlayerInfo copyWithAudioAttributes(AudioAttributes audioAttributes) {
        return new Builder(this).setAudioAttributes(audioAttributes).build();
    }

    public PlayerInfo copyWithCurrentTracks(Tracks tracks) {
        return new Builder(this).setCurrentTracks(tracks).build();
    }

    @CheckResult
    public PlayerInfo copyWithDeviceInfo(DeviceInfo deviceInfo) {
        return new Builder(this).setDeviceInfo(deviceInfo).build();
    }

    @CheckResult
    public PlayerInfo copyWithDeviceVolume(int i2, boolean z2) {
        return new Builder(this).setDeviceVolume(i2).setDeviceMuted(z2).build();
    }

    @CheckResult
    public PlayerInfo copyWithIsLoading(boolean z2) {
        return new Builder(this).setIsLoading(z2).build();
    }

    @CheckResult
    public PlayerInfo copyWithIsPlaying(boolean z2) {
        return new Builder(this).setIsPlaying(z2).build();
    }

    @CheckResult
    public PlayerInfo copyWithMaxSeekToPreviousPositionMs(long j2) {
        return new Builder(this).setMaxSeekToPreviousPositionMs(j2).build();
    }

    @CheckResult
    public PlayerInfo copyWithMediaItemTransitionReason(int i2) {
        return new Builder(this).setMediaItemTransitionReason(i2).build();
    }

    @CheckResult
    public PlayerInfo copyWithMediaMetadata(MediaMetadata mediaMetadata) {
        return new Builder(this).setMediaMetadata(mediaMetadata).build();
    }

    @CheckResult
    public PlayerInfo copyWithPlayWhenReady(boolean z2, int i2, int i3) {
        return new Builder(this).setPlayWhenReady(z2).setPlayWhenReadyChangeReason(i2).setPlaybackSuppressionReason(i3).setIsPlaying(isPlaying(this.playbackState, z2, i3)).build();
    }

    @CheckResult
    public PlayerInfo copyWithPlaybackParameters(PlaybackParameters playbackParameters) {
        return new Builder(this).setPlaybackParameters(playbackParameters).build();
    }

    @CheckResult
    public PlayerInfo copyWithPlaybackState(int i2, @Nullable PlaybackException playbackException) {
        return new Builder(this).setPlayerError(playbackException).setPlaybackState(i2).setIsPlaying(isPlaying(i2, this.playWhenReady, this.playbackSuppressionReason)).build();
    }

    @CheckResult
    public PlayerInfo copyWithPlayerError(PlaybackException playbackException) {
        return new Builder(this).setPlayerError(playbackException).build();
    }

    @CheckResult
    public PlayerInfo copyWithPlaylistMetadata(MediaMetadata mediaMetadata) {
        return new Builder(this).setPlaylistMetadata(mediaMetadata).build();
    }

    @CheckResult
    public PlayerInfo copyWithPositionInfos(Player.PositionInfo positionInfo, Player.PositionInfo positionInfo2, int i2) {
        return new Builder(this).setOldPositionInfo(positionInfo).setNewPositionInfo(positionInfo2).setDiscontinuityReason(i2).build();
    }

    @CheckResult
    public PlayerInfo copyWithRepeatMode(int i2) {
        return new Builder(this).setRepeatMode(i2).build();
    }

    @CheckResult
    public PlayerInfo copyWithSeekBackIncrement(long j2) {
        return new Builder(this).setSeekBackIncrement(j2).build();
    }

    @CheckResult
    public PlayerInfo copyWithSeekForwardIncrement(long j2) {
        return new Builder(this).setSeekForwardIncrement(j2).build();
    }

    @CheckResult
    public PlayerInfo copyWithSessionPositionInfo(SessionPositionInfo sessionPositionInfo) {
        return new Builder(this).setSessionPositionInfo(sessionPositionInfo).build();
    }

    @CheckResult
    public PlayerInfo copyWithShuffleModeEnabled(boolean z2) {
        return new Builder(this).setShuffleModeEnabled(z2).build();
    }

    @CheckResult
    public PlayerInfo copyWithTimeline(Timeline timeline) {
        return new Builder(this).setTimeline(timeline).build();
    }

    @CheckResult
    public PlayerInfo copyWithTimelineAndMediaItemIndex(Timeline timeline, int i2, int i3) {
        Builder timelineChangeReason = new Builder(this).setTimeline(timeline).setTimelineChangeReason(i3);
        Player.PositionInfo positionInfo = new Player.PositionInfo(this.sessionPositionInfo.positionInfo.windowUid, i2, this.sessionPositionInfo.positionInfo.mediaItem, this.sessionPositionInfo.positionInfo.periodUid, this.sessionPositionInfo.positionInfo.periodIndex, this.sessionPositionInfo.positionInfo.positionMs, this.sessionPositionInfo.positionInfo.contentPositionMs, this.sessionPositionInfo.positionInfo.adGroupIndex, this.sessionPositionInfo.positionInfo.adIndexInAdGroup);
        SessionPositionInfo sessionPositionInfo = this.sessionPositionInfo;
        return timelineChangeReason.setSessionPositionInfo(new SessionPositionInfo(positionInfo, sessionPositionInfo.isPlayingAd, sessionPositionInfo.eventTimeMs, sessionPositionInfo.durationMs, sessionPositionInfo.bufferedPositionMs, sessionPositionInfo.bufferedPercentage, sessionPositionInfo.totalBufferedDurationMs, sessionPositionInfo.currentLiveOffsetMs, sessionPositionInfo.contentDurationMs, sessionPositionInfo.contentBufferedPositionMs)).build();
    }

    @CheckResult
    public PlayerInfo copyWithTimelineAndSessionPositionInfo(Timeline timeline, SessionPositionInfo sessionPositionInfo, int i2) {
        return new Builder(this).setTimeline(timeline).setSessionPositionInfo(sessionPositionInfo).setTimelineChangeReason(i2).build();
    }

    @CheckResult
    public PlayerInfo copyWithTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters) {
        return new Builder(this).setTrackSelectionParameters(trackSelectionParameters).build();
    }

    @CheckResult
    public PlayerInfo copyWithVideoSize(VideoSize videoSize) {
        return new Builder(this).setVideoSize(videoSize).build();
    }

    @CheckResult
    public PlayerInfo copyWithVolume(@FloatRange(from = com.jsyn.unitgen.u.FALSE, to = com.jsyn.unitgen.u.TRUE) float f2) {
        return new Builder(this).setVolume(f2).build();
    }

    public PlayerInfo filterByAvailableCommands(Player.Commands commands, boolean z2, boolean z3) {
        Builder builder = new Builder(this);
        boolean zContains = commands.contains(16);
        boolean zContains2 = commands.contains(17);
        builder.setSessionPositionInfo(this.sessionPositionInfo.filterByAvailableCommands(zContains, zContains2));
        builder.setOldPositionInfo(this.oldPositionInfo.filterByAvailableCommands(zContains, zContains2));
        builder.setNewPositionInfo(this.newPositionInfo.filterByAvailableCommands(zContains, zContains2));
        if (!zContains2 && zContains && !this.timeline.isEmpty()) {
            builder.setTimeline(this.timeline.copyWithSingleWindow(this.sessionPositionInfo.positionInfo.mediaItemIndex));
        } else if (z2 || !zContains2) {
            builder.setTimeline(Timeline.EMPTY);
        }
        if (!commands.contains(18)) {
            builder.setPlaylistMetadata(MediaMetadata.EMPTY);
        }
        if (!commands.contains(22)) {
            builder.setVolume(1.0f);
        }
        if (!commands.contains(21)) {
            builder.setAudioAttributes(AudioAttributes.DEFAULT);
        }
        if (!commands.contains(28)) {
            builder.setCues(CueGroup.EMPTY_TIME_ZERO);
        }
        if (!commands.contains(23)) {
            builder.setDeviceVolume(0).setDeviceMuted(false);
        }
        if (!commands.contains(18)) {
            builder.setMediaMetadata(MediaMetadata.EMPTY);
        }
        if (z3 || !commands.contains(30)) {
            builder.setCurrentTracks(Tracks.EMPTY);
        }
        return builder.build();
    }

    @Nullable
    public MediaItem getCurrentMediaItem() {
        if (this.timeline.isEmpty()) {
            return null;
        }
        return this.timeline.getWindow(this.sessionPositionInfo.positionInfo.mediaItemIndex, new Timeline.Window()).mediaItem;
    }

    public Bundle toBundleForRemoteProcess(int i2) {
        Bundle bundle = new Bundle();
        PlaybackException playbackException = this.playerError;
        if (playbackException != null) {
            bundle.putBundle(FIELD_PLAYBACK_ERROR, playbackException.toBundle());
        }
        int i3 = this.mediaItemTransitionReason;
        if (i3 != 0) {
            bundle.putInt(FIELD_MEDIA_ITEM_TRANSITION_REASON, i3);
        }
        if (i2 < 3 || !this.sessionPositionInfo.equals(SessionPositionInfo.DEFAULT)) {
            bundle.putBundle(FIELD_SESSION_POSITION_INFO, this.sessionPositionInfo.toBundle(i2));
        }
        if (i2 < 3 || !SessionPositionInfo.DEFAULT_POSITION_INFO.equalsForBundling(this.oldPositionInfo)) {
            bundle.putBundle(FIELD_OLD_POSITION_INFO, this.oldPositionInfo.toBundle(i2));
        }
        if (i2 < 3 || !SessionPositionInfo.DEFAULT_POSITION_INFO.equalsForBundling(this.newPositionInfo)) {
            bundle.putBundle(FIELD_NEW_POSITION_INFO, this.newPositionInfo.toBundle(i2));
        }
        int i4 = this.discontinuityReason;
        if (i4 != 0) {
            bundle.putInt(FIELD_DISCONTINUITY_REASON, i4);
        }
        if (!this.playbackParameters.equals(PlaybackParameters.DEFAULT)) {
            bundle.putBundle(FIELD_PLAYBACK_PARAMETERS, this.playbackParameters.toBundle());
        }
        int i5 = this.repeatMode;
        if (i5 != 0) {
            bundle.putInt(FIELD_REPEAT_MODE, i5);
        }
        boolean z2 = this.shuffleModeEnabled;
        if (z2) {
            bundle.putBoolean(FIELD_SHUFFLE_MODE_ENABLED, z2);
        }
        if (!this.timeline.equals(Timeline.EMPTY)) {
            bundle.putBundle(FIELD_TIMELINE, this.timeline.toBundle());
        }
        int i6 = this.timelineChangeReason;
        if (i6 != 0) {
            bundle.putInt(FIELD_TIMELINE_CHANGE_REASON, i6);
        }
        if (!this.videoSize.equals(VideoSize.UNKNOWN)) {
            bundle.putBundle(FIELD_VIDEO_SIZE, this.videoSize.toBundle());
        }
        if (!this.playlistMetadata.equals(MediaMetadata.EMPTY)) {
            bundle.putBundle(FIELD_PLAYLIST_METADATA, this.playlistMetadata.toBundle());
        }
        float f2 = this.volume;
        if (f2 != 1.0f) {
            bundle.putFloat(FIELD_VOLUME, f2);
        }
        if (!this.audioAttributes.equals(AudioAttributes.DEFAULT)) {
            bundle.putBundle(FIELD_AUDIO_ATTRIBUTES, this.audioAttributes.toBundle());
        }
        if (!this.cueGroup.equals(CueGroup.EMPTY_TIME_ZERO)) {
            bundle.putBundle(FIELD_CUE_GROUP, this.cueGroup.toBundle());
        }
        if (!this.deviceInfo.equals(DeviceInfo.UNKNOWN)) {
            bundle.putBundle(FIELD_DEVICE_INFO, this.deviceInfo.toBundle());
        }
        int i7 = this.deviceVolume;
        if (i7 != 0) {
            bundle.putInt(FIELD_DEVICE_VOLUME, i7);
        }
        boolean z3 = this.deviceMuted;
        if (z3) {
            bundle.putBoolean(FIELD_DEVICE_MUTED, z3);
        }
        boolean z4 = this.playWhenReady;
        if (z4) {
            bundle.putBoolean(FIELD_PLAY_WHEN_READY, z4);
        }
        int i8 = this.playWhenReadyChangeReason;
        if (i8 != 1) {
            bundle.putInt(FIELD_PLAY_WHEN_READY_CHANGE_REASON, i8);
        }
        int i9 = this.playbackSuppressionReason;
        if (i9 != 0) {
            bundle.putInt(FIELD_PLAYBACK_SUPPRESSION_REASON, i9);
        }
        int i10 = this.playbackState;
        if (i10 != 1) {
            bundle.putInt(FIELD_PLAYBACK_STATE, i10);
        }
        boolean z5 = this.isPlaying;
        if (z5) {
            bundle.putBoolean(FIELD_IS_PLAYING, z5);
        }
        boolean z6 = this.isLoading;
        if (z6) {
            bundle.putBoolean(FIELD_IS_LOADING, z6);
        }
        if (!this.mediaMetadata.equals(MediaMetadata.EMPTY)) {
            bundle.putBundle(FIELD_MEDIA_METADATA, this.mediaMetadata.toBundle());
        }
        long j2 = i2 < 6 ? 0L : 5000L;
        long j3 = this.seekBackIncrementMs;
        if (j3 != j2) {
            bundle.putLong(FIELD_SEEK_BACK_INCREMENT_MS, j3);
        }
        long j4 = i2 < 6 ? 0L : 15000L;
        long j5 = this.seekForwardIncrementMs;
        if (j5 != j4) {
            bundle.putLong(FIELD_SEEK_FORWARD_INCREMENT_MS, j5);
        }
        long j6 = i2 >= 6 ? 3000L : 0L;
        long j7 = this.maxSeekToPreviousPositionMs;
        if (j7 != j6) {
            bundle.putLong(FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS, j7);
        }
        if (!this.currentTracks.equals(Tracks.EMPTY)) {
            bundle.putBundle(FIELD_CURRENT_TRACKS, this.currentTracks.toBundle());
        }
        if (!this.trackSelectionParameters.equals(TrackSelectionParameters.DEFAULT)) {
            bundle.putBundle(FIELD_TRACK_SELECTION_PARAMETERS, this.trackSelectionParameters.toBundle());
        }
        return bundle;
    }

    public Bundle toBundleInProcess() {
        Bundle bundle = new Bundle();
        bundle.putBinder(FIELD_IN_PROCESS_BINDER, new InProcessBinder());
        return bundle;
    }
}
