Webrtc Native C++如何自定义断网重联

在 m76 版本的 WebRTC 中,可以使用 PeerConnection 的 OnIceConnectionChange 方法来监听 ICE 连接状态的变化。当 ICE 连接状态变为 kIceConnectionDisconnected 时,可以在一定时间后进行重连。可以通过设置一个计时器,在一定时间后尝试重新连接。

具体实现方式如下:

首先,在 PeerConnection 对象的创建和配置过程中,需要设置一个 rtc::scoped_refptr 对象,用于监听 ICE 连接状态变化。例如:

auto connection = peerConnectionFactory->CreatePeerConnection(rtcConfiguration, nullptr, nullptr, nullptr, &connectionObserver

猜你喜欢

转载自blog.csdn.net/weixin_43466192/article/details/130067920