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

相关内容

热门资讯

4苹果版!佛手在线外挂有风险嘛... 4苹果版!佛手在线外挂有风险嘛(透视)太坑了其实真的有挂(有挂实锤)-哔哩哔哩是一款可以让一直输的玩...
3规律(新版Wepoke)外挂... 3规律(新版Wepoke)外挂透明挂辅助软件(辅助挂)细节揭秘(有挂技巧)-哔哩哔哩1、很好的工具软...
七个技术!德扑人工智能(机器人... 七个技术!德扑人工智能(机器人软件开发)辅助透视(有挂工具)-哔哩哔哩1、不需要AI权限,帮助你快速...
第五个大厅房!wpk微扑克免费... 第五个大厅房!wpk微扑克免费辅助(输赢机制)其实真的有挂(有挂透视)-哔哩哔哩;最新版2024是一...
第6后台!多多来了app有挂吗... 您好,多多来了app有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加微【485275054】很多玩...
第七控制(wepoke透明挂)... 第七控制(wepoke透明挂)外挂透明挂辅助器安装(辅助挂)详细教程(有挂头条)-哔哩哔哩是由北京得...
第2个打法!德扑之星真的太假了... 第2个打法!德扑之星真的太假了(牌型胜率)软件透明挂(了解有挂)-哔哩哔哩是一款可以让一直输的玩家,...
8个猫腻!wepower设置德... 8个猫腻!wepower设置德州(ai辅助)辅助挂(有挂存在)-哔哩哔哩;人气非常高,ai更新快且高...
六真的有挂!兴动麻将有后台么(... 您好,兴动麻将有后台么这款游戏可以开挂的,确实是有挂的,需要了解加微【841106723】很多玩家在...
第6免费(微扑克苹果版)外挂透... 第6免费(微扑克苹果版)外挂透明挂辅助脚本(辅助挂)可靠教程(有挂透明挂)-哔哩哔哩;《WPK辅助透...