来自服务器的Flutter WebRTC流视频

时间:2018-09-21 11:35:27

标签: dart flutter webrtc

我正在使用WebRTC从服务器流式传输视频。 WebRTC for flutter刚刚发布了一段时间,那里没有太多的文档。我想知道的是如何检测iceCandidate是否打开并且不是null。如何检查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");
    }
  }

此flutter插件上没有onconnectedstatechange。而且没有onTrack可以从服务器流式传输视频。任何帮助将不胜感激!

0 个答案:

没有答案