package com.bytedance.android.live.livepullstream;

import X.7lW;
import X.86a;
import X.AnonymousClass0SE;
import X.AnonymousClass0SG;
import X.AnonymousClass0SH;
import X.AnonymousClass0SI;
import X.AnonymousClass144;
import X.AnonymousClass145;
import X.C11100cm;
import X.C24630yb;
import X.C24650yd;
import X.C24660ye;
import X.C265113x;
import X.C265313z;
import X.C35961bm;
import X.C37941ey;
import X.GAX;
import X.GIv;
import X.GQg;
import X.Gpz;
import X.GtH;
import X.GtV;
import X.Gyh;
import X.H28;
import X.H2B;
import X.HIg;
import X.HIr;
import X.HJB;
import X.Juy;
import X.Juz;
import X.M12;
import android.content.Context;
import com.bytedance.android.live.livepullstream.api.IPullStreamService;
import com.bytedance.android.livesdk.chatroom.detail.RoomPlayer2;
import com.bytedance.android.livesdk.livesetting.watchlive.LivePreCreateSurfaceSetting;
import com.bytedance.android.livesdk.utils.LiveAppBundleUtils;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.depend.model.live.StreamUrlExtra;
import com.bytedance.android.livesdkapi.host.IHostApp;
import com.bytedance.android.livesdkapi.session.EnterRoomConfig;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;

public class PullStreamService implements IPullStreamService {
    public static final String TAG = PullStreamService.class.getSimpleName();

    public AnonymousClass144 getLivePlayControllerManager() {
        return HIg.LIZ;
    }

    public AnonymousClass0SG getIRoomPlayerManager() {
        return Gyh.LIZ();
    }

    public void onInit() {
        Juy.LIZ = new Juz() {
            static {
                Covode.recordClassIndex(9556);
            }

            public final void LIZ(String str) {
                LiveAppBundleUtils.loadSOByLoader(str, "liveplayer-loadLibrary", true);
            }

            public final boolean LIZIZ(String str) {
                return LiveAppBundleUtils.loadSOByLoader(str, "liveplayer-loadPluginLibrary", true);
            }
        };
    }

    static {
        Covode.recordClassIndex(9555);
    }

    public C24630yb getCpuInfoFetcher() {
        return C35961bm.LJI().LJFF();
    }

    public C265313z getDnsOptimizer() {
        return C35961bm.LJI().LIZJ();
    }

    public C24650yd getGpuInfoFetcher() {
        return C35961bm.LJI().LJ();
    }

    public C37941ey getLivePlayController() {
        return C35961bm.LJI().LIZ();
    }

    public C24660ye getLivePlayerLog() {
        return C35961bm.LJI().LIZIZ();
    }

    public AnonymousClass145 getLiveStreamStrategy() {
        return C35961bm.LJI().LIZLLL();
    }

    public String getProjectKey() {
        if (C11100cm.LIZ(IHostApp.class).isInMusicallyRegion()) {
            return "musically_live";
        }
        return "tiktok_live";
    }

    public void clearAsyncWarmUpPlayerManager() {
        MethodCollector.i(6287);
        for (GtH gtH : GtV.LIZ.values()) {
            synchronized (gtH) {
                try {
                    gtH.LIZ();
                    gtH.LIZLLL = null;
                } catch (Throwable th) {
                    MethodCollector.o(6287);
                    throw th;
                }
            }
        }
        MethodCollector.o(6287);
    }

    public C265113x getAudioFocusController(H28 h28) {
        return new H2B(h28);
    }

    public HJB getLivePlayerView(Context context) {
        return new HIr(context);
    }

    public static Context INVOKEVIRTUAL_com_bytedance_android_live_livepullstream_PullStreamService_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            return 7lW.LIZ;
        }
        return applicationContext;
    }

    public String getPlayerTagByWarmUpTaskId(String str) {
        GtV gtV = GtV.LIZIZ;
        M12.LIZ(str);
        GtH gtH = (GtH) GtV.LIZ.get(str);
        if (gtH == null) {
            return "";
        }
        return gtV.LIZ(gtH);
    }

    public void recycleRoomPlayer(String str) {
        AnonymousClass0SE LIZ;
        Gyh LIZ2 = Gyh.LIZ();
        Gpz.LIZ(Gyh.LIZ, "recycle() -> playerTag=".concat(String.valueOf(str)));
        if (str != null && (LIZ = LIZ2.LIZ(str)) != null) {
            LIZ2.LIZ(LIZ);
        }
    }

    public boolean preCreatedSurface(String str, Context context) {
        AnonymousClass0SE LIZ;
        Gyh LIZ2 = Gyh.LIZ();
        if (!LivePreCreateSurfaceSetting.INSTANCE.getValue() || (LIZ = LIZ2.LIZ(str)) == null) {
            return false;
        }
        Gpz.LIZ(Gyh.LIZ, "preCreatedSurface() -> playerTag is ".concat(String.valueOf(str)));
        return LIZ.preCreatedSurface(context);
    }

    public void stopRoomPlayer(String str, boolean z) {
        AnonymousClass0SE LIZ;
        Gyh LIZ2 = Gyh.LIZ();
        String str2 = Gyh.LIZ;
        Gpz.LIZ(str2, "stop() -> playerTag=" + str + "; needRelease: " + z);
        if (str != null && (LIZ = LIZ2.LIZ(str)) != null) {
            LIZ.stop(z);
        }
    }

    public AnonymousClass0SE warmUp(Room room, Context context) {
        String str = TAG;
        Gpz.LIZ(str, "warmUp -> roomId=" + room.getId());
        Gyh LIZ = Gyh.LIZ();
        if (LIZ.LIZIZ()) {
            return null;
        }
        return LIZ.LIZ(room.getId(), context, room.buildPullUrl(), room.getSdkParams(), room.getMultiStreamData(), room.getMultiStreamDefaultQualitySdkKey(), room.getStreamUrlExtraSafely().LJIILIIL, room.getStreamType(), false, (String) null, GAX.LIZ.LIZ().LIZIZ.LIZLLL.LJJLIIIJILLIZJL);
    }

    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x0007: MOVE  (r5v0 com.bytedance.android.livesdkapi.session.EnterRoomConfig) = 
          (r11v0 com.bytedance.android.livesdkapi.session.EnterRoomConfig)
        
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public java.lang.String asyncWarmUpRoomPlayer(long r9, com.bytedance.android.livesdkapi.session.EnterRoomConfig r11, android.content.Context r12) {
        /*
            r8 = this;
            r1 = 0
            r3 = r9
            int r0 = (r3 > r1 ? 1 : (r3 == r1 ? 0 : -1))
            if (r0 == 0) goto L_0x000d
            r5 = r11
            if (r5 == 0) goto L_0x000d
            r6 = r12
            if (r6 != 0) goto L_0x0010
        L_0x000d:
            java.lang.String r0 = ""
            return r0
        L_0x0010:
            java.lang.StringBuilder r2 = new java.lang.StringBuilder
            r2.<init>()
            r2.append(r3)
            r0 = 45
            r2.append(r0)
            long r0 = java.lang.System.currentTimeMillis()
            r2.append(r0)
            java.lang.String r7 = r2.toString()
            X.GtH r2 = new X.GtH
            r2.<init>(r3, r5, r6, r7)
            java.util.Map r0 = X.GtV.LIZ
            r0.put(r7, r2)
            java.util.concurrent.ExecutorService r0 = X.8eL.LIZJ()
            r0.submit(r2)
            return r7
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.live.livepullstream.PullStreamService.asyncWarmUpRoomPlayer(long, com.bytedance.android.livesdkapi.session.EnterRoomConfig, android.content.Context):java.lang.String");
    }

    public AnonymousClass0SE warmUp(long j, EnterRoomConfig enterRoomConfig, Context context) {
        EnterRoomConfig enterRoomConfig2 = enterRoomConfig;
        long j2 = j;
        Gpz.LIZ(TAG, "warmUp -> roomId=".concat(String.valueOf(j2)));
        Gyh LIZ = Gyh.LIZ();
        if (LIZ.LIZIZ() || enterRoomConfig2 == null) {
            return null;
        }
        EnterRoomConfig enterRoomConfig3 = enterRoomConfig2.LIZLLL.LJJIJ;
        if (enterRoomConfig3 != null) {
            enterRoomConfig2.LIZLLL.LJJIJ = null;
            enterRoomConfig2 = enterRoomConfig3;
        }
        String str = enterRoomConfig2.LIZIZ.LIZIZ;
        String str2 = enterRoomConfig2.LIZIZ.LIZLLL;
        String str3 = enterRoomConfig2.LIZIZ.LJ;
        boolean LIZ2 = 86a.LIZ(str3);
        if (LIZ2) {
            str3 = str2;
        }
        return LIZ.LIZ(j2, context, str, enterRoomConfig2.LIZIZ.LIZJ, str3, enterRoomConfig2.LIZIZ.LJFF, new StreamUrlExtra.SrConfig(enterRoomConfig2.LIZIZ.LJII, enterRoomConfig2.LIZIZ.LJIIIIZZ, enterRoomConfig2.LIZIZ.LJIIIZ), GIv.valueOf(enterRoomConfig2.LIZIZ.LJIIJ), !LIZ2, enterRoomConfig2.LIZLLL.LJJIJLIJ, enterRoomConfig2.LIZLLL.LJJLIIIJILLIZJL);
    }

    public AnonymousClass0SE createRoomPlayer(long j, String str, GIv gIv, StreamUrlExtra.SrConfig srConfig, GQg gQg, AnonymousClass0SH r13, Context context, String str2) {
        AnonymousClass0SI LIZ = AnonymousClass0SI.LIZ(INVOKEVIRTUAL_com_bytedance_android_live_livepullstream_PullStreamService_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(context));
        LIZ.LIZIZ(str);
        LIZ.LJ = str2;
        LIZ.LJFF = gIv;
        LIZ.LJI = srConfig;
        return new RoomPlayer2(j, LIZ, gQg, r13);
    }

    public AnonymousClass0SE createRoomPlayer(long j, String str, String str2, GIv gIv, StreamUrlExtra.SrConfig srConfig, GQg gQg, AnonymousClass0SH r14, Context context) {
        AnonymousClass0SI LIZ = AnonymousClass0SI.LIZ(INVOKEVIRTUAL_com_bytedance_android_live_livepullstream_PullStreamService_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(context));
        LIZ.LIZ(str);
        LIZ.LIZJ = str2;
        LIZ.LJFF = gIv;
        LIZ.LJI = srConfig;
        return new RoomPlayer2(j, LIZ, gQg, r14);
    }

    public AnonymousClass0SE ensureRoomPlayer(long j, String str, GIv gIv, StreamUrlExtra.SrConfig srConfig, GQg gQg, AnonymousClass0SH r30, Context context, String str2, String str3) {
        String str4 = TAG;
        StringBuilder sb = new StringBuilder("ensureRoomPlayer -> roomId=");
        long j2 = j;
        sb.append(j2);
        sb.append(", playerTag=");
        String str5 = str3;
        sb.append(str5);
        Gpz.LIZ(str4, sb.toString());
        Gyh LIZ = Gyh.LIZ();
        AnonymousClass0SH r10 = r30;
        GQg gQg2 = gQg;
        StreamUrlExtra.SrConfig srConfig2 = srConfig;
        String str6 = str2;
        String str7 = str;
        Context context2 = context;
        GIv gIv2 = gIv;
        if (LIZ.LIZIZ()) {
            return ((IPullStreamService) C11100cm.LIZ(IPullStreamService.class)).createRoomPlayer(j2, str7, gIv2, srConfig2, gQg2, r10, context2, str6);
        }
        AnonymousClass0SE LIZ2 = LIZ.LIZ(str5);
        if (LIZ2 != null) {
            LIZ2.attach(context2, gQg2, r10);
            return LIZ2;
        }
        AnonymousClass0SE LIZ3 = LIZ.LIZ(j2, context2, str7, str6, (String) null, (String) null, srConfig2, gIv2);
        LIZ.LIZ(LIZ3, context2, gQg2, r10);
        return LIZ3;
    }

    public AnonymousClass0SE ensureRoomPlayer(long j, String str, String str2, GIv gIv, StreamUrlExtra.SrConfig srConfig, GQg gQg, AnonymousClass0SH r31, Context context, String str3) {
        String str4 = TAG;
        StringBuilder sb = new StringBuilder("ensureRoomPlayer -> roomId=");
        long j2 = j;
        sb.append(j2);
        sb.append(", playerTag=");
        String str5 = str3;
        sb.append(str5);
        Gpz.LIZ(str4, sb.toString());
        Gyh LIZ = Gyh.LIZ();
        GQg gQg2 = gQg;
        StreamUrlExtra.SrConfig srConfig2 = srConfig;
        GIv gIv2 = gIv;
        Context context2 = context;
        String str6 = str;
        AnonymousClass0SH r11 = r31;
        if (LIZ.LIZIZ()) {
            return ((IPullStreamService) C11100cm.LIZ(IPullStreamService.class)).createRoomPlayer(j2, str6, (String) null, gIv2, srConfig2, gQg2, r11, context2);
        }
        AnonymousClass0SE LIZ2 = LIZ.LIZ(str5);
        if (LIZ2 != null) {
            LIZ2.attach(context2, gQg2, r11);
            return LIZ2;
        }
        AnonymousClass0SE LIZ3 = LIZ.LIZ(j2, context2, (String) null, (String) null, str6, str2, srConfig2, gIv2);
        LIZ.LIZ(LIZ3, context2, gQg2, r11);
        return LIZ3;
    }
}
