package com.bytedance.android.livesdk.definition;

import X.0AA;
import X.0cm;
import X.1ey;
import X.C3026Glf;
import X.C3028Glh;
import X.C3491GtA;
import X.C4100H7d;
import X.Cwu;
import X.GAX;
import X.GBD;
import X.GBI;
import X.GBJ;
import X.LeS;
import X.Lea;
import X.M12;
import com.bytedance.android.live.definition.IDefinitionService;
import com.bytedance.android.live.livepullstream.api.IPullStreamService;
import com.bytedance.android.livesdkapi.session.EnterRoomLinkSession;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.Iterator;
import java.util.List;
import kotlin.h.b.n;

public class DefinitionService implements IDefinitionService {
    static {
        Covode.recordClassIndex(15626);
    }

    public void onInit() {
    }

    public boolean isAudienceLowestDefinition() {
        GBJ gbj = (GBJ) Lea.LJIIJ(GBI.LIZ((DataChannel) null));
        if (gbj != null) {
            return gbj.LIZLLL;
        }
        return false;
    }

    public Cwu<String, String> getAutoLevelDefinition() {
        T t;
        Iterator<T> it = GBI.LIZ((DataChannel) null).iterator();
        while (true) {
            if (!it.hasNext()) {
                t = null;
                break;
            }
            t = it.next();
            if (n.LIZ(((GBJ) t).LIZIZ(), "auto")) {
                break;
            }
        }
        GBJ gbj = (GBJ) t;
        if (gbj != null) {
            return new Cwu<>(gbj.LIZIZ(), gbj.LIZ());
        }
        return null;
    }

    public Cwu<String, String> getNextLowerLevelDefinition() {
        List<GBJ> LIZ = GBI.LIZ((DataChannel) null);
        Iterator<T> it = LIZ.iterator();
        int i = 0;
        while (it.hasNext()) {
            it.next();
            int i2 = i + 1;
            if (i < 0) {
                LeS.LIZIZ();
            }
            if (LIZ.get(i).LIZLLL && i2 < LIZ.size()) {
                return new Cwu<>(LIZ.get(i2).LIZIZ(), LIZ.get(i2).LIZ());
            }
            i = i2;
        }
        return null;
    }

    public void reportAudienceRotateBtnShow(String str) {
        M12.LIZ(str);
        M12.LIZ(str);
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_user_screen_rotate_btn_show");
        LIZ.LIZ("anchor_id", GBD.LIZ());
        LIZ.LIZ("room_id", str);
        LIZ.LIZLLL();
    }

    public void reportAnchorDefinitionBtnShow(String str) {
        M12.LIZ(str);
        M12.LIZ(str);
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_live_anchor_definition_selection_btn_show");
        C3028Glh LIZIZ = C4100H7d.LIZ().LIZIZ();
        n.LIZIZ(LIZIZ, "");
        LIZ.LIZ("anchor_id", LIZIZ.LIZJ());
        LIZ.LIZ("current_definition", str);
        LIZ.LIZIZ("screen_share");
        LIZ.LIZLLL();
    }

    public void showDefinitionSelectionDialog(0AA r2, boolean z) {
        M12.LIZ(r2);
        LiveDefinitionSelectionDialog.LIZJ.LIZ(r2, z);
    }

    public void reportAudienceDefinitionBtnShow(String str, String str2, String str3) {
        M12.LIZ(str, str2, str3);
        GBD.LIZ(str, str2, str3);
    }

    public void reportAudienceDefinitionTipsShow(String str, String str2, String str3) {
        String LJI;
        M12.LIZ(str, str2, str3);
        M12.LIZ(str, str2, str3);
        C3026Glf glf = GAX.LIZ;
        String str4 = "";
        n.LIZIZ(glf, str4);
        EnterRoomLinkSession LIZ = glf.LIZ();
        n.LIZIZ(LIZ, str4);
        String str5 = LIZ.LIZIZ.LIZLLL.LJJIJLIJ;
        if (str5 == null) {
            str5 = str4;
        }
        IPullStreamService LIZ2 = 0cm.LIZ(IPullStreamService.class);
        n.LIZIZ(LIZ2, str4);
        1ey LIZIZ = LIZ2.getLivePlayControllerManager().LIZIZ(str5);
        if (!(LIZIZ == null || (LJI = LIZIZ.LJI()) == null)) {
            str4 = LJI;
        }
        C3491GtA LIZ3 = C3491GtA.LJFF.LIZ("livesdk_live_definition_switch_show");
        LIZ3.LIZ("anchor_id", GBD.LIZ());
        LIZ3.LIZ("room_id", str);
        LIZ3.LIZ("user_id", GBD.LIZJ());
        LIZ3.LIZ("live_type", GBD.LIZIZ());
        LIZ3.LIZ("room_orientation", str3);
        LIZ3.LIZ("current_definition", str4);
        LIZ3.LIZIZ(str2);
        LIZ3.LIZLLL();
    }

    public void reportAudienceRotateBtnClick(String str, long j, String str2, String str3) {
        String str4;
        M12.LIZ(str, str2, str3);
        M12.LIZ(str, str2, str3);
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_user_screen_rotate_btn_click");
        LIZ.LIZ("anchor_id", GBD.LIZ());
        LIZ.LIZ("room_id", str);
        LIZ.LIZ("action", str3);
        LIZ.LIZ("room_orientation_after", str2);
        if (str2.hashCode() == 49 && str2.equals("1")) {
            str4 = "portrait_to_landscape";
        } else {
            str4 = "landscape_to_portrait";
        }
        LIZ.LIZ("rotate_type", str4);
        LIZ.LIZ("duration", String.valueOf((System.currentTimeMillis() - j) / 1000));
        LIZ.LIZLLL();
    }

    public void reportAudienceDefinitionDialogSelectSuccess(String str, String str2, String str3, String str4, String str5, String str6, String str7) {
        String str8 = str6;
        String str9 = str2;
        String str10 = str7;
        String str11 = str;
        String str12 = str3;
        String str13 = str4;
        String str14 = str5;
        M12.LIZ(str11, str9, str12, str13, str14, str8, str10);
        GBD.LIZ(str11, str9, str12, str13, str14, str8, str10);
    }
}
