package androidx.media3.exoplayer.rtsp;

import androidx.media3.common.util.Util;
import defpackage.bj4;
import defpackage.cj4;
import defpackage.fw4;
import defpackage.gv;
import defpackage.hs0;
import defpackage.rq6;
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 cj4<String, String> namesAndValues;

    public static final class Builder {
        private final cj4.a<String, String> namesAndValuesBuilder;

        @hs0
        public Builder add(String str, String str2) {
            this.namesAndValuesBuilder.e(RtspHeaders.convertToStandardHeaderName(str.trim()), str2.trim());
            return this;
        }

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

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

        public Builder() {
            this.namesAndValuesBuilder = new cj4.a<>();
        }

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

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

        private Builder(cj4.a<String, String> aVar) {
            this.namesAndValuesBuilder = aVar;
        }
    }

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

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

    public Builder buildUpon() {
        cj4.a aVar = new cj4.a();
        for (Map.Entry entry : this.namesAndValues.ad().entrySet()) {
            aVar.c((Iterable) entry.getValue(), entry.getKey());
        }
        return new Builder(aVar);
    }

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

    @rq6
    public String get(String str) {
        bj4<String> bj4VarValues = values(str);
        if (bj4VarValues.isEmpty()) {
            return null;
        }
        return (String) fw4.c(bj4VarValues);
    }

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

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

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