Android11+无法在webview或chrome中收集icecandidates。
创始人
2024-08-20 09:01:02
0

Android 11+ 限制了 webview 或 chrome 中收集 ice candidates 的能力。为了解决这个问题,可以使用 Google 开发的 WebRTC 应用程序库,在应用程序中手动获取和添加 ice candidates。

下面是一些示例代码,用于手动获取和添加 ice candidates:

// 获取 PeerConnection 对象 PeerConnection peerConnection = ...;

// 创建一个 RTCConfiguration 对象,并设置 STUN/TURN 服务器的地址和凭证 RTCConfiguration rtcConfig = new RTCConfiguration.Builder() .setIceServers(Arrays.asList( new IceServer("stun:stun.l.google.com:19302"), new IceServer("turn:example.com:3478", "username", "password") )) .build();

// 创建 PeerConnectionObserver 对象 PeerConnection.Observer observer = new PeerConnection.Observer() { @Override public void onIceCandidate(IceCandidate iceCandidate) { // 当收到一个新的 ice candidate 时,手动添加到 PeerConnection 中 peerConnection.addIceCandidate(iceCandidate); }

// 其他方法省略...

};

// 创建一个 PeerConnection 实例 peerConnection = factory.createPeerConnection(rtcConfig, observer);

// 获取本地的 SDP 信息 SessionDescription localSdp = peerConnection.getLocalDescription();

// 将本地 SDP 信息设置到远程的 PeerConnection 中 remotePeerConnection.setRemoteDescription(new SimpleSdpObserver(), localSdp);

// 获取远程的 SDP 信息 SessionDescription remoteSdp = remotePeerConnection.getRemoteDescription();

// 将远程的 SDP 信息设置到本地 PeerConnection 中 peerConnection.setRemoteDescription(new SimpleSdpObserver(), remoteSdp);

// 收集 ice candidates peerConnection.createOffer(new SimpleSdpObserver() { @Override public void onCreateSuccess(SessionDescription sdp) { // 将本地的 SDP 信息设置到 PeerConnection 中 peerConnection.setLocalDescription(new SimpleSdpObserver(), sdp);

    // 遍历收集到的 ice candidates
    for (IceCandidate candidate : ice

相关内容

热门资讯

透视app!德州透视插件(透视... 透视app!德州透视插件(透视)hhpoker辅助器(真是有透视)-哔哩哔哩1、在德州透视插件插件功...
透视攻略!拱趴大菠萝有挂吗(透... 透视攻略!拱趴大菠萝有挂吗(透视)pokemmo手机版透视脚本(总是是有辅助器)-哔哩哔哩1、不需要...
透视脚本!欢聚水鱼脚本(辅助)... 您好,jj斗地主捕鱼辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多...
透视软件!hhpoker作必弊... 透视软件!hhpoker作必弊实战视频(透视)hhpoker透视脚本下载(其实存在有脚本)-哔哩哔哩...
透视方法!wepoker透视脚... 透视方法!wepoker透视脚本免费使用视频(透视)wepoker怎么提高运气(确实一直总是有挂)-...
透视app!HH平台挂(透视)... 透视app!HH平台挂(透视)hhpoker脚本下载(一贯一直总是有挂)-哔哩哔哩亲,关键说明,hh...
透视技巧!德扑圈透视(透视)德... 透视技巧!德扑圈透视(透视)德扑圈透视挂(其实是真的有脚本)-哔哩哔哩1、德扑圈透视挂公共底牌简单,...
透视神器!聚星ai辅助工具激活... 透视神器!聚星ai辅助工具激活码(透视)sohoopoker辅助(原来存在有脚本)-哔哩哔哩1、上手...
透视插件!德普软件(透视)德普... 透视插件!德普软件(透视)德普之星有透视辅助吗(其实存在有脚本)-哔哩哔哩运德普之星有透视辅助吗辅助...
透视插件!aapoker插件下... 透视插件!aapoker插件下载(透视)aapoker怎么控制牌(切实存在有脚本)-哔哩哔哩1、下载...