【发布时间】:2019-02-25 19:31:46
【问题描述】:
我正在使用 WebRTC 从服务器流式传输视频。用于 Flutter 的 WebRTC 刚刚发布,没有太多文档。我想知道的是如何检测 iceCandidate 是否开启且不为空。如何检查 iceConnectionState == 是否已连接?
stream() async{
Map<String,dynamic> configuration = {
"iceServers" : []
};
final Map<String, dynamic> constraints = {
"mandatory": {},
"optional": [ {"DtlsSrtpKeyAgreement": false}, ],
};
peerConnection = await createPeerConnection(configuration, constraints);
print('ok');
peerConnection.onIceCandidate = gotIceCandidate;
peerConnection.onIceConnectionState = onIceState;
}
void gotIceCandidate(RTCIceCandidate iceCandidate){
if (iceCandidate.candidate != null){
print("onIceCandidate");
}
}
void onIceState(RTCIceConnectionState iceConnectionState){
if (iceConnectionState.index == 3){//CONNECTED
print("connected");
}else if(iceConnectionState.index == 5){//FAILED
print("failed");
}
}
这个颤振插件上没有onconnectedstatechange。并且没有 onTrack 从服务器流式传输视频。任何帮助将不胜感激!
【问题讨论】:
-
您提到您正在使用 Flutter 插件,您能否提供您正在使用的插件和a minimal, complete and verifiable example。另外,我注意到有一个可用的插件。你指的是这个plugin吗?