package androidx.media3.exoplayer.rtsp;

import androidx.annotation.Nullable;
import androidx.media3.common.util.Util;
import com.google.common.base.h;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.l0;
import com.google.common.collect.o0;
import com.google.common.collect.z0;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
final class RtspHeaders {
    public static final String ACCEPT = "Accept";
    public static final String ALLOW = "Allow";
    public static final String AUTHORIZATION = "Authorization";
    public static final String BANDWIDTH = "Bandwidth";
    public static final String BLOCKSIZE = "Blocksize";
    public static final String CACHE_CONTROL = "Cache-Control";
    public static final String CONNECTION = "Connection";
    public static final String CONTENT_BASE = "Content-Base";
    public static final String CONTENT_ENCODING = "Content-Encoding";
    public static final String CONTENT_LANGUAGE = "Content-Language";
    public static final String CONTENT_LENGTH = "Content-Length";
    public static final String CONTENT_LOCATION = "Content-Location";
    public static final String CONTENT_TYPE = "Content-Type";
    public static final String CSEQ = "CSeq";
    public static final String DATE = "Date";
    public static final RtspHeaders EMPTY = new Builder().build();
    public static final String EXPIRES = "Expires";
    public static final String LOCATION = "Location";
    public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
    public static final String PROXY_REQUIRE = "Proxy-Require";
    public static final String PUBLIC = "Public";
    public static final String RANGE = "Range";
    public static final String RTCP_INTERVAL = "RTCP-Interval";
    public static final String RTP_INFO = "RTP-Info";
    public static final String SCALE = "Scale";
    public static final String SESSION = "Session";
    public static final String SPEED = "Speed";
    public static final String SUPPORTED = "Supported";
    public static final String TIMESTAMP = "Timestamp";
    public static final String TRANSPORT = "Transport";
    public static final String USER_AGENT = "User-Agent";
    public static final String VIA = "Via";
    public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
    private final ImmutableListMultimap<String, String> namesAndValues;

    public static final class Builder {
        private final o0 namesAndValuesBuilder;

        @CanIgnoreReturnValue
        public Builder add(String str, String str2) {
            o0 o0Var = this.namesAndValuesBuilder;
            String strConvertToStandardHeaderName = RtspHeaders.convertToStandardHeaderName(str.trim());
            String strTrim = str2.trim();
            o0Var.getClass();
            z0.c(strConvertToStandardHeaderName, strTrim);
            l0 l0VarC = (l0) o0Var.a().get(strConvertToStandardHeaderName);
            if (l0VarC == null) {
                l0VarC = o0Var.c(4);
                o0Var.a().put(strConvertToStandardHeaderName, l0VarC);
            }
            l0VarC.a(strTrim);
            return this;
        }

        @CanIgnoreReturnValue
        public Builder addAll(List<String> list) {
            for (int i10 = 0; i10 < list.size(); i10++) {
                String[] strArrSplitAtFirst = Util.splitAtFirst(list.get(i10), ":\\s?");
                if (strArrSplitAtFirst.length == 2) {
                    add(strArrSplitAtFirst[0], strArrSplitAtFirst[1]);
                }
            }
            return this;
        }

        public RtspHeaders build() {
            return new RtspHeaders(this);
        }

        public Builder() {
            this.namesAndValuesBuilder = new o0();
        }

        public Builder(String str, @Nullable String str2, int i10) {
            this();
            add(RtspHeaders.USER_AGENT, str);
            add(RtspHeaders.CSEQ, String.valueOf(i10));
            if (str2 != null) {
                add(RtspHeaders.SESSION, str2);
            }
        }

        @CanIgnoreReturnValue
        public Builder addAll(Map<String, String> map) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                add(entry.getKey(), entry.getValue());
            }
            return this;
        }

        private Builder(o0 o0Var) {
            this.namesAndValuesBuilder = o0Var;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static String convertToStandardHeaderName(String str) {
        return h.k(str, ACCEPT) ? ACCEPT : h.k(str, ALLOW) ? ALLOW : h.k(str, AUTHORIZATION) ? AUTHORIZATION : h.k(str, BANDWIDTH) ? BANDWIDTH : h.k(str, BLOCKSIZE) ? BLOCKSIZE : h.k(str, CACHE_CONTROL) ? CACHE_CONTROL : h.k(str, CONNECTION) ? CONNECTION : h.k(str, CONTENT_BASE) ? CONTENT_BASE : h.k(str, CONTENT_ENCODING) ? CONTENT_ENCODING : h.k(str, CONTENT_LANGUAGE) ? CONTENT_LANGUAGE : h.k(str, CONTENT_LENGTH) ? CONTENT_LENGTH : h.k(str, CONTENT_LOCATION) ? CONTENT_LOCATION : h.k(str, CONTENT_TYPE) ? CONTENT_TYPE : h.k(str, CSEQ) ? CSEQ : h.k(str, DATE) ? DATE : h.k(str, EXPIRES) ? EXPIRES : h.k(str, LOCATION) ? LOCATION : h.k(str, PROXY_AUTHENTICATE) ? PROXY_AUTHENTICATE : h.k(str, PROXY_REQUIRE) ? PROXY_REQUIRE : h.k(str, PUBLIC) ? PUBLIC : h.k(str, RANGE) ? RANGE : h.k(str, RTP_INFO) ? RTP_INFO : h.k(str, RTCP_INTERVAL) ? RTCP_INTERVAL : h.k(str, SCALE) ? SCALE : h.k(str, SESSION) ? SESSION : h.k(str, SPEED) ? SPEED : h.k(str, SUPPORTED) ? SUPPORTED : h.k(str, TIMESTAMP) ? TIMESTAMP : h.k(str, TRANSPORT) ? TRANSPORT : h.k(str, USER_AGENT) ? USER_AGENT : h.k(str, VIA) ? VIA : h.k(str, WWW_AUTHENTICATE) ? WWW_AUTHENTICATE : str;
    }

    public ImmutableListMultimap<String, String> asMultiMap() {
        return this.namesAndValues;
    }

    public Builder buildUpon() {
        o0 o0Var = new o0();
        for (Map.Entry entry : this.namesAndValues.b().entrySet()) {
            o0Var.d((Iterable) entry.getValue(), entry.getKey());
        }
        return new Builder(o0Var);
    }

    public boolean equals(@Nullable Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof RtspHeaders) {
            return this.namesAndValues.equals(((RtspHeaders) obj).namesAndValues);
        }
        return false;
    }

    @Nullable
    public String get(String str) {
        ImmutableList<String> immutableListValues = values(str);
        if (immutableListValues.isEmpty()) {
            return null;
        }
        return (String) z0.n(immutableListValues);
    }

    public int hashCode() {
        return this.namesAndValues.hashCode();
    }

    public ImmutableList<String> values(String str) {
        return this.namesAndValues.get(convertToStandardHeaderName(str));
    }

    private RtspHeaders(Builder builder) {
        this.namesAndValues = builder.namesAndValuesBuilder.e();
    }
}
