package androidx.media3.exoplayer.hls.playlist;

import android.net.Uri;
import androidx.annotation.Nullable;
import androidx.media3.common.DrmInitData;
import androidx.media3.common.StreamKey;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import com.google.android.gms.measurement.internal.u1;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.z0;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
@UnstableApi
public final class HlsMediaPlaylist extends HlsPlaylist {
    public static final int PLAYLIST_TYPE_EVENT = 2;
    public static final int PLAYLIST_TYPE_UNKNOWN = 0;
    public static final int PLAYLIST_TYPE_VOD = 1;
    public final int discontinuitySequence;
    public final long durationUs;
    public final boolean hasDiscontinuitySequence;
    public final boolean hasEndTag;
    public final boolean hasPositiveStartOffset;
    public final boolean hasProgramDateTime;
    public final ImmutableList<Interstitial> interstitials;
    public final long mediaSequence;
    public final long partTargetDurationUs;
    public final int playlistType;
    public final boolean preciseStart;

    @Nullable
    public final DrmInitData protectionSchemes;
    public final Map<Uri, RenditionReport> renditionReports;
    public final List<Segment> segments;
    public final ServerControl serverControl;
    public final long startOffsetUs;
    public final long startTimeUs;
    public final long targetDurationUs;
    public final List<Part> trailingParts;
    public final int version;

    public static class ClientDefinedAttribute {
        public static final int TYPE_DOUBLE = 2;
        public static final int TYPE_HEX_TEXT = 1;
        public static final int TYPE_TEXT = 0;
        private final double doubleValue;
        public final String name;

        @Nullable
        private final String textValue;
        public final int type;

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface Type {
        }

        public ClientDefinedAttribute(String str, double d10) {
            this.name = str;
            this.type = 2;
            this.doubleValue = d10;
            this.textValue = null;
        }

        public boolean equals(@Nullable Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof ClientDefinedAttribute)) {
                return false;
            }
            ClientDefinedAttribute clientDefinedAttribute = (ClientDefinedAttribute) obj;
            return this.type == clientDefinedAttribute.type && Double.compare(this.doubleValue, clientDefinedAttribute.doubleValue) == 0 && Objects.equals(this.name, clientDefinedAttribute.name) && Objects.equals(this.textValue, clientDefinedAttribute.textValue);
        }

        public double getDoubleValue() {
            Assertions.checkState(this.type == 2);
            return this.doubleValue;
        }

        public String getTextValue() {
            Assertions.checkState(this.type != 2);
            return (String) Assertions.checkNotNull(this.textValue);
        }

        public int hashCode() {
            return Objects.hash(this.name, Integer.valueOf(this.type), Double.valueOf(this.doubleValue), this.textValue);
        }

        public ClientDefinedAttribute(String str, String str2, int i10) {
            boolean z10 = true;
            if (i10 == 1 && !str2.startsWith("0x") && !str2.startsWith("0X")) {
                z10 = false;
            }
            Assertions.checkState(z10);
            this.name = str;
            this.type = i10;
            this.textValue = str2;
            this.doubleValue = 0.0d;
        }
    }

    public static final class Interstitial {
        public static final String CUE_TRIGGER_ONCE = "ONCE";
        public static final String CUE_TRIGGER_POST = "POST";
        public static final String CUE_TRIGGER_PRE = "PRE";
        public static final String NAVIGATION_RESTRICTION_JUMP = "JUMP";
        public static final String NAVIGATION_RESTRICTION_SKIP = "SKIP";
        public static final String SNAP_TYPE_IN = "IN";
        public static final String SNAP_TYPE_OUT = "OUT";
        public static final String TIMELINE_OCCUPIES_POINT = "POINT";
        public static final String TIMELINE_OCCUPIES_RANGE = "RANGE";
        public static final String TIMELINE_STYLE_HIGHLIGHT = "HIGHLIGHT";
        public static final String TIMELINE_STYLE_PRIMARY = "PRIMARY";

        @Nullable
        public final Uri assetListUri;

        @Nullable
        public final Uri assetUri;
        public final ImmutableList<ClientDefinedAttribute> clientDefinedAttributes;
        public final boolean contentMayVary;
        public final List<String> cue;
        public final long durationUs;
        public final long endDateUnixUs;
        public final boolean endOnNext;

        /* JADX INFO: renamed from: id, reason: collision with root package name */
        public final String f3049id;
        public final long plannedDurationUs;
        public final long playoutLimitUs;
        public final ImmutableList<String> restrictions;
        public final long resumeOffsetUs;
        public final ImmutableList<String> snapTypes;
        public final long startDateUnixUs;
        public final String timelineOccupies;
        public final String timelineStyle;

        public static final class Builder {
            private Uri assetListUri;
            private Uri assetUri;
            private Boolean contentMayVary;
            private boolean endOnNext;

            /* JADX INFO: renamed from: id, reason: collision with root package name */
            private final String f3050id;
            private String timelineOccupies;
            private String timelineStyle;
            private final Map<String, ClientDefinedAttribute> clientDefinedAttributes = new HashMap();
            private long startDateUnixUs = -9223372036854775807L;
            private long endDateUnixUs = -9223372036854775807L;
            private long durationUs = -9223372036854775807L;
            private long plannedDurationUs = -9223372036854775807L;
            private List<String> cue = new ArrayList();
            private long resumeOffsetUs = -9223372036854775807L;
            private long playoutLimitUs = -9223372036854775807L;
            private List<String> snapTypes = new ArrayList();
            private List<String> restrictions = new ArrayList();

            public Builder(String str) {
                this.f3050id = str;
            }

            @Nullable
            public Interstitial build() {
                Uri uri = this.assetListUri;
                if ((uri != null || this.assetUri == null) && (uri == null || this.assetUri != null)) {
                    return null;
                }
                long j10 = this.startDateUnixUs;
                if (j10 == -9223372036854775807L) {
                    return null;
                }
                String str = this.f3050id;
                Uri uri2 = this.assetUri;
                long j11 = this.endDateUnixUs;
                long j12 = this.durationUs;
                long j13 = this.plannedDurationUs;
                List<String> list = this.cue;
                boolean z10 = this.endOnNext;
                long j14 = this.resumeOffsetUs;
                long j15 = this.playoutLimitUs;
                List<String> list2 = this.snapTypes;
                List<String> list3 = this.restrictions;
                ArrayList arrayList = new ArrayList(this.clientDefinedAttributes.values());
                Boolean bool = this.contentMayVary;
                boolean z11 = bool == null || bool.booleanValue();
                String str2 = this.timelineOccupies;
                if (str2 == null) {
                    str2 = Interstitial.TIMELINE_OCCUPIES_POINT;
                }
                String str3 = str2;
                String str4 = this.timelineStyle;
                if (str4 == null) {
                    str4 = Interstitial.TIMELINE_STYLE_HIGHLIGHT;
                }
                return new Interstitial(str, uri2, uri, j10, j11, j12, j13, list, z10, j14, j15, list2, list3, arrayList, z11, str3, str4);
            }

            @CanIgnoreReturnValue
            public Builder setAssetListUri(@Nullable Uri uri) {
                if (uri == null) {
                    return this;
                }
                Uri uri2 = this.assetListUri;
                if (uri2 != null) {
                    Assertions.checkArgument(uri2.equals(uri), "Can't change assetListUri from " + this.assetListUri + " to " + uri);
                }
                this.assetListUri = uri;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setAssetUri(@Nullable Uri uri) {
                if (uri == null) {
                    return this;
                }
                Uri uri2 = this.assetUri;
                if (uri2 != null) {
                    Assertions.checkArgument(uri2.equals(uri), "Can't change assetUri from " + this.assetUri + " to " + uri);
                }
                this.assetUri = uri;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setClientDefinedAttributes(List<ClientDefinedAttribute> list) {
                if (list.isEmpty()) {
                    return this;
                }
                for (int i10 = 0; i10 < list.size(); i10++) {
                    ClientDefinedAttribute clientDefinedAttribute = list.get(i10);
                    String str = clientDefinedAttribute.name;
                    ClientDefinedAttribute clientDefinedAttribute2 = this.clientDefinedAttributes.get(str);
                    if (clientDefinedAttribute2 != null) {
                        boolean zEquals = clientDefinedAttribute2.equals(clientDefinedAttribute);
                        StringBuilder sbN = u1.n("Can't change ", str, " from ");
                        sbN.append(clientDefinedAttribute2.textValue);
                        sbN.append(" ");
                        sbN.append(clientDefinedAttribute2.doubleValue);
                        sbN.append(" to ");
                        sbN.append(clientDefinedAttribute.textValue);
                        sbN.append(" ");
                        sbN.append(clientDefinedAttribute.doubleValue);
                        Assertions.checkArgument(zEquals, sbN.toString());
                    }
                    this.clientDefinedAttributes.put(str, clientDefinedAttribute);
                }
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setContentMayVary(@Nullable Boolean bool) {
                if (bool == null) {
                    return this;
                }
                Boolean bool2 = this.contentMayVary;
                if (bool2 != null) {
                    Assertions.checkArgument(bool2.equals(bool), "Can't change contentMayVary from " + this.contentMayVary + " to " + bool);
                }
                this.contentMayVary = bool;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setCue(List<String> list) {
                if (list.isEmpty()) {
                    return this;
                }
                if (!this.cue.isEmpty()) {
                    boolean zEquals = this.cue.equals(list);
                    StringBuilder sb = new StringBuilder("Can't change cue from ");
                    List<String> list2 = this.cue;
                    StringBuilder sb2 = new StringBuilder();
                    Iterator<T> it = list2.iterator();
                    if (it.hasNext()) {
                        while (true) {
                            sb2.append((CharSequence) it.next());
                            if (!it.hasNext()) {
                                break;
                            }
                            sb2.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb2.toString());
                    sb.append(" to ");
                    StringBuilder sb3 = new StringBuilder();
                    Iterator<T> it2 = list.iterator();
                    if (it2.hasNext()) {
                        while (true) {
                            sb3.append((CharSequence) it2.next());
                            if (!it2.hasNext()) {
                                break;
                            }
                            sb3.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb3.toString());
                    Assertions.checkArgument(zEquals, sb.toString());
                }
                this.cue = list;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setDurationUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.durationUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change durationUs from " + this.durationUs + " to " + j10);
                }
                this.durationUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setEndDateUnixUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.endDateUnixUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change endDateUnixUs from " + this.endDateUnixUs + " to " + j10);
                }
                this.endDateUnixUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setEndOnNext(boolean z10) {
                if (!z10) {
                    return this;
                }
                this.endOnNext = true;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setPlannedDurationUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.plannedDurationUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change plannedDurationUs from " + this.plannedDurationUs + " to " + j10);
                }
                this.plannedDurationUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setPlayoutLimitUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.playoutLimitUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change playoutLimitUs from " + this.playoutLimitUs + " to " + j10);
                }
                this.playoutLimitUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setRestrictions(List<String> list) {
                if (list.isEmpty()) {
                    return this;
                }
                if (!this.restrictions.isEmpty()) {
                    boolean zEquals = this.restrictions.equals(list);
                    StringBuilder sb = new StringBuilder("Can't change restrictions from ");
                    List<String> list2 = this.restrictions;
                    StringBuilder sb2 = new StringBuilder();
                    Iterator<T> it = list2.iterator();
                    if (it.hasNext()) {
                        while (true) {
                            sb2.append((CharSequence) it.next());
                            if (!it.hasNext()) {
                                break;
                            }
                            sb2.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb2.toString());
                    sb.append(" to ");
                    StringBuilder sb3 = new StringBuilder();
                    Iterator<T> it2 = list.iterator();
                    if (it2.hasNext()) {
                        while (true) {
                            sb3.append((CharSequence) it2.next());
                            if (!it2.hasNext()) {
                                break;
                            }
                            sb3.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb3.toString());
                    Assertions.checkArgument(zEquals, sb.toString());
                }
                this.restrictions = list;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setResumeOffsetUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.resumeOffsetUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change resumeOffsetUs from " + this.resumeOffsetUs + " to " + j10);
                }
                this.resumeOffsetUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setSnapTypes(List<String> list) {
                if (list.isEmpty()) {
                    return this;
                }
                if (!this.snapTypes.isEmpty()) {
                    boolean zEquals = this.snapTypes.equals(list);
                    StringBuilder sb = new StringBuilder("Can't change snapTypes from ");
                    List<String> list2 = this.snapTypes;
                    StringBuilder sb2 = new StringBuilder();
                    Iterator<T> it = list2.iterator();
                    if (it.hasNext()) {
                        while (true) {
                            sb2.append((CharSequence) it.next());
                            if (!it.hasNext()) {
                                break;
                            }
                            sb2.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb2.toString());
                    sb.append(" to ");
                    StringBuilder sb3 = new StringBuilder();
                    Iterator<T> it2 = list.iterator();
                    if (it2.hasNext()) {
                        while (true) {
                            sb3.append((CharSequence) it2.next());
                            if (!it2.hasNext()) {
                                break;
                            }
                            sb3.append((CharSequence) ", ");
                        }
                    }
                    sb.append(sb3.toString());
                    Assertions.checkArgument(zEquals, sb.toString());
                }
                this.snapTypes = list;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setStartDateUnixUs(long j10) {
                if (j10 == -9223372036854775807L) {
                    return this;
                }
                long j11 = this.startDateUnixUs;
                if (j11 != -9223372036854775807L) {
                    Assertions.checkArgument(j11 == j10, "Can't change startDateUnixUs from " + this.startDateUnixUs + " to " + j10);
                }
                this.startDateUnixUs = j10;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setTimelineOccupies(@Nullable String str) {
                if (str == null) {
                    return this;
                }
                String str2 = this.timelineOccupies;
                if (str2 != null) {
                    Assertions.checkArgument(str2.equals(str), "Can't change timelineOccupies from " + this.timelineOccupies + " to " + str);
                }
                this.timelineOccupies = str;
                return this;
            }

            @CanIgnoreReturnValue
            public Builder setTimelineStyle(@Nullable String str) {
                if (str == null) {
                    return this;
                }
                String str2 = this.timelineStyle;
                if (str2 != null) {
                    Assertions.checkArgument(str2.equals(str), "Can't change timelineStyle from " + this.timelineStyle + " to " + str);
                }
                this.timelineStyle = str;
                return this;
            }
        }

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface CueTriggerType {
        }

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface NavigationRestriction {
        }

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface SnapType {
        }

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface TimelineOccupiesType {
        }

        @Target({ElementType.TYPE_USE})
        @Documented
        @Retention(RetentionPolicy.SOURCE)
        public @interface TimelineStyleType {
        }

        public Interstitial(String str, @Nullable Uri uri, @Nullable Uri uri2, long j10, long j11, long j12, long j13, List<String> list, boolean z10, long j14, long j15, List<String> list2, List<String> list3, List<ClientDefinedAttribute> list4, boolean z11, String str2, String str3) {
            Assertions.checkArgument((uri == null || uri2 == null) && !(uri == null && uri2 == null));
            this.f3049id = str;
            this.assetUri = uri;
            this.assetListUri = uri2;
            this.startDateUnixUs = j10;
            this.endDateUnixUs = j11;
            this.durationUs = j12;
            this.plannedDurationUs = j13;
            this.cue = list;
            this.endOnNext = z10;
            this.resumeOffsetUs = j14;
            this.playoutLimitUs = j15;
            this.snapTypes = ImmutableList.p(list2);
            this.restrictions = ImmutableList.p(list3);
            this.clientDefinedAttributes = ImmutableList.y(new androidx.browser.trusted.b(3), list4);
            this.contentMayVary = z11;
            this.timelineOccupies = str2;
            this.timelineStyle = str3;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static /* synthetic */ int lambda$new$0(ClientDefinedAttribute clientDefinedAttribute, ClientDefinedAttribute clientDefinedAttribute2) {
            return clientDefinedAttribute.name.compareTo(clientDefinedAttribute2.name);
        }

        public boolean equals(@Nullable Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof Interstitial)) {
                return false;
            }
            Interstitial interstitial = (Interstitial) obj;
            return this.startDateUnixUs == interstitial.startDateUnixUs && this.endDateUnixUs == interstitial.endDateUnixUs && this.durationUs == interstitial.durationUs && this.plannedDurationUs == interstitial.plannedDurationUs && this.endOnNext == interstitial.endOnNext && this.resumeOffsetUs == interstitial.resumeOffsetUs && this.playoutLimitUs == interstitial.playoutLimitUs && this.contentMayVary == interstitial.contentMayVary && Objects.equals(this.f3049id, interstitial.f3049id) && Objects.equals(this.assetUri, interstitial.assetUri) && Objects.equals(this.assetListUri, interstitial.assetListUri) && Objects.equals(this.cue, interstitial.cue) && Objects.equals(this.snapTypes, interstitial.snapTypes) && Objects.equals(this.restrictions, interstitial.restrictions) && Objects.equals(this.clientDefinedAttributes, interstitial.clientDefinedAttributes) && Objects.equals(this.timelineOccupies, interstitial.timelineOccupies) && Objects.equals(this.timelineStyle, interstitial.timelineStyle);
        }

        public int hashCode() {
            return Objects.hash(this.f3049id, this.assetUri, this.assetListUri, Long.valueOf(this.startDateUnixUs), Long.valueOf(this.endDateUnixUs), Long.valueOf(this.durationUs), Long.valueOf(this.plannedDurationUs), this.cue, Boolean.valueOf(this.endOnNext), Long.valueOf(this.resumeOffsetUs), Long.valueOf(this.playoutLimitUs), this.snapTypes, this.restrictions, this.clientDefinedAttributes, Boolean.valueOf(this.contentMayVary), this.timelineOccupies, this.timelineStyle);
        }
    }

    public static final class Part extends SegmentBase {
        public final boolean isIndependent;
        public final boolean isPreload;

        public Part(String str, @Nullable Segment segment, long j10, int i10, long j11, @Nullable DrmInitData drmInitData, @Nullable String str2, @Nullable String str3, long j12, long j13, boolean z10, boolean z11, boolean z12) {
            super(str, segment, j10, i10, j11, drmInitData, str2, str3, j12, j13, z10);
            this.isIndependent = z11;
            this.isPreload = z12;
        }

        public Part copyWith(long j10, int i10) {
            return new Part(this.url, this.initializationSegment, this.durationUs, i10, j10, this.drmInitData, this.fullSegmentEncryptionKeyUri, this.encryptionIV, this.byteRangeOffset, this.byteRangeLength, this.hasGapTag, this.isIndependent, this.isPreload);
        }
    }

    @Target({ElementType.TYPE_USE})
    @Documented
    @Retention(RetentionPolicy.SOURCE)
    public @interface PlaylistType {
    }

    public static final class RenditionReport {
        public final long lastMediaSequence;
        public final int lastPartIndex;
        public final Uri playlistUri;

        public RenditionReport(Uri uri, long j10, int i10) {
            this.playlistUri = uri;
            this.lastMediaSequence = j10;
            this.lastPartIndex = i10;
        }
    }

    public static class SegmentBase implements Comparable<Long> {
        public final long byteRangeLength;
        public final long byteRangeOffset;

        @Nullable
        public final DrmInitData drmInitData;
        public final long durationUs;

        @Nullable
        public final String encryptionIV;

        @Nullable
        public final String fullSegmentEncryptionKeyUri;
        public final boolean hasGapTag;

        @Nullable
        public final Segment initializationSegment;
        public final int relativeDiscontinuitySequence;
        public final long relativeStartTimeUs;
        public final String url;

        private SegmentBase(String str, @Nullable Segment segment, long j10, int i10, long j11, @Nullable DrmInitData drmInitData, @Nullable String str2, @Nullable String str3, long j12, long j13, boolean z10) {
            this.url = str;
            this.initializationSegment = segment;
            this.durationUs = j10;
            this.relativeDiscontinuitySequence = i10;
            this.relativeStartTimeUs = j11;
            this.drmInitData = drmInitData;
            this.fullSegmentEncryptionKeyUri = str2;
            this.encryptionIV = str3;
            this.byteRangeOffset = j12;
            this.byteRangeLength = j13;
            this.hasGapTag = z10;
        }

        @Override // java.lang.Comparable
        public int compareTo(Long l10) {
            if (this.relativeStartTimeUs > l10.longValue()) {
                return 1;
            }
            return this.relativeStartTimeUs < l10.longValue() ? -1 : 0;
        }
    }

    public static final class ServerControl {
        public final boolean canBlockReload;
        public final boolean canSkipDateRanges;
        public final long holdBackUs;
        public final long partHoldBackUs;
        public final long skipUntilUs;

        public ServerControl(long j10, boolean z10, long j11, long j12, boolean z11) {
            this.skipUntilUs = j10;
            this.canSkipDateRanges = z10;
            this.holdBackUs = j11;
            this.partHoldBackUs = j12;
            this.canBlockReload = z11;
        }
    }

    public HlsMediaPlaylist(int i10, String str, List<String> list, long j10, boolean z10, long j11, boolean z11, int i11, long j12, int i12, long j13, long j14, boolean z12, boolean z13, boolean z14, @Nullable DrmInitData drmInitData, List<Segment> list2, List<Part> list3, ServerControl serverControl, Map<Uri, RenditionReport> map, List<Interstitial> list4) {
        super(str, list, z12);
        this.playlistType = i10;
        this.startTimeUs = j11;
        this.preciseStart = z10;
        this.hasDiscontinuitySequence = z11;
        this.discontinuitySequence = i11;
        this.mediaSequence = j12;
        this.version = i12;
        this.targetDurationUs = j13;
        this.partTargetDurationUs = j14;
        this.hasEndTag = z13;
        this.hasProgramDateTime = z14;
        this.protectionSchemes = drmInitData;
        this.segments = ImmutableList.p(list2);
        this.trailingParts = ImmutableList.p(list3);
        this.renditionReports = ImmutableMap.b(map);
        this.interstitials = ImmutableList.p(list4);
        if (!list3.isEmpty()) {
            Part part = (Part) z0.n(list3);
            this.durationUs = part.relativeStartTimeUs + part.durationUs;
        } else if (list2.isEmpty()) {
            this.durationUs = 0L;
        } else {
            Segment segment = (Segment) z0.n(list2);
            this.durationUs = segment.relativeStartTimeUs + segment.durationUs;
        }
        this.startOffsetUs = j10 != -9223372036854775807L ? j10 >= 0 ? Math.min(this.durationUs, j10) : Math.max(0L, this.durationUs + j10) : -9223372036854775807L;
        this.hasPositiveStartOffset = j10 >= 0;
        this.serverControl = serverControl;
    }

    @Override // androidx.media3.exoplayer.offline.FilterableManifest
    public HlsPlaylist copy(List<StreamKey> list) {
        return this;
    }

    public HlsMediaPlaylist copyWith(long j10, int i10) {
        return new HlsMediaPlaylist(this.playlistType, this.baseUri, this.tags, this.startOffsetUs, this.preciseStart, j10, true, i10, this.mediaSequence, this.version, this.targetDurationUs, this.partTargetDurationUs, this.hasIndependentSegments, this.hasEndTag, this.hasProgramDateTime, this.protectionSchemes, this.segments, this.trailingParts, this.serverControl, this.renditionReports, this.interstitials);
    }

    public HlsMediaPlaylist copyWithEndTag() {
        return this.hasEndTag ? this : new HlsMediaPlaylist(this.playlistType, this.baseUri, this.tags, this.startOffsetUs, this.preciseStart, this.startTimeUs, this.hasDiscontinuitySequence, this.discontinuitySequence, this.mediaSequence, this.version, this.targetDurationUs, this.partTargetDurationUs, this.hasIndependentSegments, true, this.hasProgramDateTime, this.protectionSchemes, this.segments, this.trailingParts, this.serverControl, this.renditionReports, this.interstitials);
    }

    public long getEndTimeUs() {
        return this.startTimeUs + this.durationUs;
    }

    public boolean isNewerThan(@Nullable HlsMediaPlaylist hlsMediaPlaylist) {
        if (hlsMediaPlaylist == null) {
            return true;
        }
        long j10 = this.mediaSequence;
        long j11 = hlsMediaPlaylist.mediaSequence;
        if (j10 > j11) {
            return true;
        }
        if (j10 < j11) {
            return false;
        }
        int size = this.segments.size() - hlsMediaPlaylist.segments.size();
        if (size != 0) {
            return size > 0;
        }
        int size2 = this.trailingParts.size();
        int size3 = hlsMediaPlaylist.trailingParts.size();
        if (size2 <= size3) {
            return size2 == size3 && this.hasEndTag && !hlsMediaPlaylist.hasEndTag;
        }
        return true;
    }

    public static final class Segment extends SegmentBase {
        public final List<Part> parts;
        public final String title;

        public Segment(String str, long j10, long j11, @Nullable String str2, @Nullable String str3) {
            this(str, null, "", 0L, -1, -9223372036854775807L, null, str2, str3, j10, j11, false, ImmutableList.t());
        }

        public Segment copyWith(long j10, int i10) {
            ArrayList arrayList = new ArrayList();
            long j11 = j10;
            for (int i11 = 0; i11 < this.parts.size(); i11++) {
                Part part = this.parts.get(i11);
                arrayList.add(part.copyWith(j11, i10));
                j11 += part.durationUs;
            }
            return new Segment(this.url, this.initializationSegment, this.title, this.durationUs, i10, j10, this.drmInitData, this.fullSegmentEncryptionKeyUri, this.encryptionIV, this.byteRangeOffset, this.byteRangeLength, this.hasGapTag, arrayList);
        }

        public Segment(String str, @Nullable Segment segment, String str2, long j10, int i10, long j11, @Nullable DrmInitData drmInitData, @Nullable String str3, @Nullable String str4, long j12, long j13, boolean z10, List<Part> list) {
            super(str, segment, j10, i10, j11, drmInitData, str3, str4, j12, j13, z10);
            this.title = str2;
            this.parts = ImmutableList.p(list);
        }
    }

    @Override // androidx.media3.exoplayer.offline.FilterableManifest
    /* JADX INFO: renamed from: copy, reason: avoid collision after fix types in other method */
    public /* bridge */ /* synthetic */ HlsPlaylist copy2(List list) {
        return copy((List<StreamKey>) list);
    }
}
