package com.bytedance.android.livesdkapi.depend.model.live;

import android.text.TextUtils;
import com.bytedance.android.livesdkapi.depend.model.live.LiveCoreSDKData;
import com.bytedance.covode.number.Covode;
import com.google.gson.a.c;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;

public class StreamUrl {
    @c(LIZ = "id")
    public long LIZ;
    @c(LIZ = "id_str")
    public String LIZIZ;
    @c(LIZ = "provider")
    public int LIZJ;
    @c(LIZ = "rtmp_push_url")
    public String LIZLLL;
    @c(LIZ = "push_urls")
    public List<String> LJ;
    @c(LIZ = "rtmp_pull_url")
    public String LJFF;
    @c(LIZ = "flv_pull_url")
    public Map<String, String> LJI;
    @c(LIZ = "resolution_name")
    public Map<String, String> LJII;
    @c(LIZ = "flv_pull_url_params")
    public Map<String, String> LJIIIIZZ;
    @c(LIZ = "candidate_resolution")
    public List<String> LJIIIZ;
    @c(LIZ = "default_resolution")
    public String LJIIJ;
    @c(LIZ = "extra")
    public StreamUrlExtra LJIIJJI;
    @c(LIZ = "rtmp_pull_url_params")
    public String LJIIL;
    @c(LIZ = "rtmp_push_url_params")
    public String LJIILIIL;
    @c(LIZ = "live_core_sdk_data")
    public LiveCoreSDKData LJIILJJIL;
    public String LJIILL;
    public String LJIILLIIL;
    public String LJIIZILJ = null;
    public String LJIJ = null;
    public LiveCoreSDKData.Quality LJIJI = null;
    @c(LIZ = "hls_pull_url")
    public String LJIJJ;
    @c(LIZ = "hls_pull_url_params")
    public String LJIJJLI;
    @c(LIZ = "hls_pull_url_map")
    public Map<String, String> LJIL;
    @c(LIZ = "complete_push_urls")
    public List<String> LJJ;
    @c(LIZ = "stream_control_type")
    public Integer LJJI;
    public LiveCoreSDKData.Quality LJJIFFI = null;
    public final LinkedList<LiveCoreSDKData.Quality> qualityList = new LinkedList<>();
    public final LinkedHashMap<String, String> qualityMap = new LinkedHashMap<>();
    public final LinkedHashMap<String, String> sdkParamsMap = new LinkedHashMap<>();

    static {
        Covode.recordClassIndex(22258);
    }

    public final String LIZ() {
        if (TextUtils.isEmpty(this.LJIILL)) {
            return this.LIZLLL;
        }
        return this.LJIILL;
    }

    public final void LIZJ() {
        this.LJIJI = null;
        this.LJJIFFI = null;
        this.qualityList.clear();
        LiveCoreSDKData liveCoreSDKData = this.LJIILJJIL;
        if (liveCoreSDKData != null) {
            if (liveCoreSDKData.getQualityList() != null && this.LJIILJJIL.getQualityList().size() > 0) {
                for (LiveCoreSDKData.Quality next : this.LJIILJJIL.getQualityList()) {
                    this.qualityList.add(next);
                    if (this.LJJIFFI == null) {
                        this.LJJIFFI = next;
                    }
                }
            }
            this.LJIJI = this.LJIILJJIL.getDefaultQuality();
            if (this.qualityList.isEmpty()) {
                LiveCoreSDKData.Quality quality = this.LJIJI;
                this.LJJIFFI = quality;
                this.qualityList.add(quality);
            }
        }
    }

    public final void LIZIZ() {
        String str;
        String str2;
        this.qualityMap.clear();
        this.sdkParamsMap.clear();
        this.LJIIZILJ = null;
        this.LJIJ = null;
        List<String> list = this.LJIIIZ;
        if (!(list == null || this.LJII == null || this.LJI == null)) {
            for (String next : list) {
                String str3 = this.LJII.get(next);
                if (!(str3 == null || (str = this.LJI.get(next)) == null)) {
                    Map<String, String> map = this.LJIIIIZZ;
                    if (map == null) {
                        str2 = null;
                    } else {
                        str2 = map.get(next);
                    }
                    this.qualityMap.put(str3, str);
                    this.sdkParamsMap.put(str3, str2);
                    if (next.equals(this.LJIIJ)) {
                        this.LJIIZILJ = str3;
                    } else if (this.LJIIZILJ == null) {
                        this.LJIIZILJ = str3;
                    }
                    if (this.LJIJ == null) {
                        this.LJIJ = str3;
                    }
                }
            }
        }
        if (this.qualityMap.isEmpty() && !TextUtils.isEmpty(this.LJFF)) {
            this.LJIIZILJ = "default";
            this.LJIJ = "default";
            this.qualityMap.put("default", this.LJFF);
            this.sdkParamsMap.put(this.LJIIZILJ, this.LJIIL);
        }
    }

    public final Object LIZ(String str) {
        try {
            return new JSONObject(this.LJIILIIL).getJSONObject("PushBase").opt(str);
        } catch (Exception unused) {
            return null;
        }
    }

    public final void LIZ(List<LiveCoreSDKData.Quality> list) {
        this.qualityList.clear();
        this.qualityList.addAll(list);
    }
}
