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

相关内容

热门资讯

透视有挂!决战geo辅助&qu... 透视有挂!决战geo辅助"辅助辅助app"真是真的有挂(哔哩哔哩)1、决战geo辅助透视辅助软件激活...
有玩家发现!禅游指尖四川辅助脚... 有玩家发现!禅游指尖四川辅助脚本"解迷辅助插件"确实是有挂(哔哩哔哩)1、打开软件启动之后找到中间准...
今日!新世界脚本辅助器&quo... 今日!新世界脚本辅助器"开挂辅助工具"确实是真的有挂(哔哩哔哩)1、新世界脚本辅助器透视辅助软件激活...
教程辅助挂!免费雀神挂件怎么安... 教程辅助挂!免费雀神挂件怎么安装"详情辅助神器"确实确实有挂(哔哩哔哩)1、免费雀神挂件怎么安装免费...
近期!财神辅助模拟器"... 近期!财神辅助模拟器"解迷辅助挂"都是真的是有挂(哔哩哔哩)近期!财神辅助模拟器"解迷辅助挂"都是真...
于此同时!湖南牵手胡子跑辅助器... 于此同时!湖南牵手胡子跑辅助器"解谜辅助软件"一贯是有挂(哔哩哔哩);1、下载好湖南牵手胡子跑辅助器...
黑科技技巧!新九哥辅助工具&q... 黑科技技巧!新九哥辅助工具"教你辅助工具"原来真的是有挂(哔哩哔哩)1、不需要AI权限,帮助你快速的...
透视安装!小闲川南辅助工具&q... 透视安装!小闲川南辅助工具"揭幕辅助脚本"确实确实有挂(哔哩哔哩)运小闲川南辅助工具辅助工具,进入游...
据悉!中至赣州冲关辅助&quo... 据悉!中至赣州冲关辅助"解迷辅助插件"果然存在有挂(哔哩哔哩)1、实时中至赣州冲关辅助透视辅助更新:...
据目击者称!博雅红河西元红河挂... 据目击者称!博雅红河西元红河挂"透视辅助神器"其实存在有挂(哔哩哔哩)1、金币登录送、破产送、升级送...