导航菜单

页面标题

页面副标题

Rilo v2.0.21 - PeerConnectionTransportKt.java 源代码

正在查看: Rilo v2.0.21 应用的 PeerConnectionTransportKt.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.livekit.android.room;

import android.gov.nist.javax.sdp.fields.AttributeField;
import android.javax.sdp.MediaDescription;
import io.livekit.android.room.TrackBitrateInfoKey;
import io.livekit.android.webrtc.JainSdpUtilsKt;
import io.livekit.android.webrtc.SdpExt;
import io.livekit.android.webrtc.SdpFmtp;
import io.livekit.android.webrtc.SdpMsid;
import io.livekit.android.webrtc.SdpRtp;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.math.MathKt;
import kotlin.text.StringsKt;

@Metadata(d1 = {"\u00002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0006\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\u001a$\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00072\u0012\u0010\b\u001a\u000e\u0012\u0004\u0012\u00020\n\u0012\u0004\u0012\u00020\u000b0\tH\u0007\u001a\u0010\u0010\f\u001a\u00020\u00052\u0006\u0010\r\u001a\u00020\u0007H\u0007\u001a\u0012\u0010\u000e\u001a\u00020\u000f2\b\u0010\u0010\u001a\u0004\u0018\u00010\u0001H\u0000\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0082T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0002\u001a\u00020\u0003X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"DD_EXTENSION_URI", "", "startBitrateForSVC", "", "ensureCodecBitrates", "", "media", "Landroid/javax/sdp/MediaDescription;", "trackBitrates", "", "Lio/livekit/android/room/TrackBitrateInfoKey;", "Lio/livekit/android/room/TrackBitrateInfo;", "ensureVideoDDExtensionForSVC", "mediaDesc", "isSVCCodec", "", "codec", "livekit-android-sdk_release"}, k = 2, mv = {1, 8, 0}, xi = 48)
public final class PeerConnectionTransportKt {
    private static final String DD_EXTENSION_URI = "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";
    private static final double startBitrateForSVC = 0.7d;

    public static final void ensureVideoDDExtensionForSVC(MediaDescription mediaDescription) {
        SdpRtp sdpRtp;
        String codec;
        boolean z;
        Intrinsics.checkNotNullParameter(mediaDescription, "mediaDesc");
        Pair pair = (Pair) CollectionsKt.firstOrNull(JainSdpUtilsKt.getRtps(mediaDescription));
        if (pair == null || (sdpRtp = (SdpRtp) pair.getSecond()) == null || (codec = sdpRtp.getCodec()) == null || !isSVCCodec(codec)) {
            return;
        }
        long j2 = 0;
        List<Pair<AttributeField, SdpExt>> exts = JainSdpUtilsKt.getExts(mediaDescription);
        boolean z2 = true;
        if (!(exts instanceof Collection) || !exts.isEmpty()) {
            Iterator<T> it2 = exts.iterator();
            while (it2.hasNext()) {
                SdpExt sdpExt = (SdpExt) ((Pair) it2.next()).component2();
                if (Intrinsics.areEqual(sdpExt.getUri(), DD_EXTENSION_URI)) {
                    z = true;
                } else {
                    if (sdpExt.getValue() > j2) {
                        j2 = sdpExt.getValue();
                    }
                    z = false;
                }
                if (z) {
                    break;
                }
            }
        }
        z2 = false;
        if (z2) {
            return;
        }
        mediaDescription.addAttribute(new SdpExt(j2 + 1, null, null, DD_EXTENSION_URI, null).toAttributeField());
    }

    public static final void ensureCodecBitrates(MediaDescription mediaDescription, Map<TrackBitrateInfoKey, TrackBitrateInfo> map) {
        String value;
        Object obj;
        boolean z;
        Intrinsics.checkNotNullParameter(mediaDescription, "media");
        Intrinsics.checkNotNullParameter(map, "trackBitrates");
        SdpMsid msid = JainSdpUtilsKt.getMsid(mediaDescription);
        if (msid == null || (value = msid.getValue()) == null) {
            return;
        }
        for (Map.Entry<TrackBitrateInfoKey, TrackBitrateInfo> entry : map.entrySet()) {
            TrackBitrateInfoKey key = entry.getKey();
            TrackBitrateInfo value2 = entry.getValue();
            if (key instanceof TrackBitrateInfoKey.Cid) {
                boolean z2 = false;
                int i2 = 2;
                if (StringsKt.contains$default(value, ((TrackBitrateInfoKey.Cid) key).getValue(), false, 2, (Object) null)) {
                    Iterator<T> it2 = JainSdpUtilsKt.getRtps(mediaDescription).iterator();
                    while (true) {
                        if (it2.hasNext()) {
                            obj = it2.next();
                            if (StringsKt.equals(((SdpRtp) ((Pair) obj).component2()).getCodec(), value2.getCodec(), true)) {
                                break;
                            }
                        } else {
                            obj = null;
                            break;
                        }
                    }
                    Pair pair = (Pair) obj;
                    if (pair != null) {
                        long payload = ((SdpRtp) pair.component2()).getPayload();
                        Iterator<Pair<AttributeField, SdpFmtp>> it3 = JainSdpUtilsKt.getFmtps(mediaDescription).iterator();
                        boolean z3 = false;
                        while (true) {
                            if (!it3.hasNext()) {
                                z = z3;
                                break;
                            }
                            Pair<AttributeField, SdpFmtp> next = it3.next();
                            AttributeField component1 = next.component1();
                            SdpFmtp component2 = next.component2();
                            if (component2.getPayload() == payload) {
                                String config = component2.getConfig();
                                if (!StringsKt.contains$default(component2.getConfig(), "x-google-start-bitrate", z2, i2, (Object) null)) {
                                    config = config + ";x-google-start-bitrate=" + MathKt.roundToLong(value2.getMaxBitrate() * startBitrateForSVC);
                                }
                                if (!StringsKt.contains$default(component2.getConfig(), "x-google-max-bitrate", false, 2, (Object) null)) {
                                    config = config + ";x-google-max-bitrate=" + value2.getMaxBitrate();
                                }
                                if (!Intrinsics.areEqual(component2.getConfig(), config)) {
                                    component1.setValue(component2.getPayload() + ' ' + config);
                                    z = true;
                                    break;
                                }
                                z2 = false;
                                i2 = 2;
                                z3 = true;
                            }
                        }
                        if (!z) {
                            mediaDescription.addAttribute(new SdpFmtp(payload, "x-google-start-bitrate=" + (value2.getMaxBitrate() * startBitrateForSVC) + ";x-google-max-bitrate=" + value2.getMaxBitrate()).toAttributeField());
                        }
                    }
                }
            }
        }
    }

    public static final boolean isSVCCodec(String str) {
        return str != null && (StringsKt.equals("av1", str, true) || StringsKt.equals("vp9", str, true));
    }
}