package t;

import D.h;
import D.i;
import I.m;
import a0.k;
import a0.l;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import b0.j;
import java.io.IOException;
import java.util.Map;
import n.C0641g;
import n.G;
import n.InterfaceC0634B;
import n.q;
import n.s;
import n.w;
import o.C0648b;
import t.c;

/* JADX INFO: loaded from: classes.dex */
public class e implements c.InterfaceC0095c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final Context f6450a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final String f6451b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final String f6452c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private Map f6453d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private a f6454e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private k.a f6455f;

    private static final class a implements j.b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final Context f6456a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private String f6457b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private final c f6458c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private final j f6459d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private Map f6460e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private boolean f6461f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private k.a f6462g;

        public a(Context context, String str, String str2, c cVar, Map map) {
            this.f6456a = context;
            this.f6457b = str;
            this.f6458c = cVar;
            this.f6459d = new j(str2, new l(context, str), new i());
            this.f6460e = map;
        }

        public void a() {
            this.f6461f = true;
        }

        public void b() {
            this.f6459d.o(this.f6458c.x().getLooper(), this);
        }

        @Override // b0.j.b
        public void c(IOException iOException) {
            if (this.f6461f) {
                return;
            }
            this.f6458c.M(iOException);
        }

        @Override // b0.j.b
        /* JADX INFO: renamed from: e, reason: merged with bridge method [inline-methods] */
        public void d(h hVar) {
            boolean z2;
            boolean z3;
            D.j jVar;
            E.b bVar;
            a0.j jVar2;
            q qVar;
            a0.j jVar3;
            G fVar;
            if (this.f6461f) {
                return;
            }
            Handler handlerX = this.f6458c.x();
            C0641g c0641g = new C0641g(new a0.i(65536));
            a0.j jVar4 = new a0.j();
            D.l lVar = new D.l();
            if (hVar instanceof D.e) {
                D.e eVar = (D.e) hVar;
                boolean z4 = !eVar.f349e.isEmpty();
                z2 = !eVar.f348d.isEmpty();
                z3 = z4;
            } else {
                z2 = false;
                z3 = false;
            }
            Log.i("HlsRendererBuilder", "Default user Agent:" + this.f6457b);
            Map map = this.f6460e;
            if (map != null && map.containsKey("User-Agent")) {
                this.f6457b = (String) this.f6460e.get("User-Agent");
                Log.i("HlsRendererBuilder", "Customized user Agent:" + this.f6457b);
                this.f6460e.remove("User-Agent");
            }
            k kVar = new k(this.f6457b, null, jVar4, 8000, 8000, false, this.f6462g);
            Map map2 = this.f6460e;
            if (map2 != null) {
                for (Map.Entry entry : map2.entrySet()) {
                    Log.i("HlsRendererBuilder", "setRequestProperty key[" + ((String) entry.getKey()) + "] value[" + ((String) entry.getValue()) + "]");
                    kVar.i((String) entry.getKey(), (String) entry.getValue());
                }
            }
            D.j jVar5 = new D.j(new D.c(true, kVar, hVar, D.b.c(this.f6456a), jVar4, lVar), c0641g, 16646144, handlerX, this.f6458c, 0);
            Context context = this.f6456a;
            s sVar = s.f5653a;
            w wVar = new w(context, jVar5, sVar, 1, 5000L, handlerX, this.f6458c, 50, new String[0]);
            E.b bVar2 = new E.b(jVar5, new F.e(), this.f6458c, handlerX.getLooper());
            if (z2) {
                jVar = jVar5;
                jVar2 = jVar4;
                bVar = bVar2;
                qVar = new q(new InterfaceC0634B[]{jVar, new D.j(new D.c(false, new l(this.f6456a, jVar4, this.f6457b), hVar, D.b.b(), jVar4, lVar), c0641g, 3538944, handlerX, this.f6458c, 1)}, sVar, (u.b) null, true, this.f6458c.x(), (q.f) this.f6458c, C0648b.b(this.f6456a), 3, new String[0]);
            } else {
                jVar = jVar5;
                bVar = bVar2;
                jVar2 = jVar4;
                qVar = new q((InterfaceC0634B) jVar, sVar, (u.b) null, true, this.f6458c.x(), (q.f) this.f6458c, C0648b.b(this.f6456a), 3, new String[0]);
            }
            q qVar2 = qVar;
            if (z3) {
                jVar3 = jVar2;
                fVar = new m(new D.j(new D.c(false, new l(this.f6456a, jVar2, this.f6457b), hVar, D.b.d(), jVar2, lVar), c0641g, 131072, handlerX, this.f6458c, 2), this.f6458c.y(), handlerX.getLooper(), new I.i[0]);
            } else {
                jVar3 = jVar2;
                fVar = new K.f(jVar, this.f6458c.y(), handlerX.getLooper(), new String[0]);
            }
            G[] gArr = new G[6];
            gArr[0] = wVar;
            gArr[1] = qVar2;
            gArr[3] = bVar;
            gArr[2] = fVar;
            this.f6458c.K(gArr, jVar3);
        }

        public void f(k.a aVar) {
            this.f6462g = aVar;
        }
    }

    public e(Context context, String str, String str2, Map map) {
        this.f6450a = context;
        this.f6451b = str;
        this.f6452c = str2;
        this.f6453d = map;
        Log.i("HlsRendererBuilder", "new HlsRendererBuilder");
        Map map2 = this.f6453d;
        if (map2 == null || !map2.containsKey("User-Agent")) {
            return;
        }
        Log.i("HlsRendererBuilder", "HlsRendererBuilder user Agent:" + ((String) this.f6453d.get("User-Agent")));
    }

    @Override // t.c.InterfaceC0095c
    public void a(c cVar) {
        a aVar = new a(this.f6450a, this.f6451b, this.f6452c, cVar, this.f6453d);
        this.f6454e = aVar;
        aVar.f(this.f6455f);
        this.f6454e.b();
    }

    @Override // t.c.InterfaceC0095c
    public void b(k.a aVar) {
        this.f6455f = aVar;
    }

    @Override // t.c.InterfaceC0095c
    public boolean c() {
        return false;
    }

    @Override // t.c.InterfaceC0095c
    public void cancel() {
        a aVar = this.f6454e;
        if (aVar != null) {
            aVar.a();
            this.f6454e = null;
        }
    }
}
