【问题标题】:Flutter WebRTC streaming video from serverFlutter WebRTC 从服务器流式传输视频
【发布时间】: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 从服务器流式传输视频。任何帮助将不胜感激!

【问题讨论】:

标签: dart flutter webrtc


【解决方案1】:

flutter_webrtc 具有RTCPeerConnection().iceConnectionState 属性,您可以按照docs 中的说明使用该属性。同样,onTrack 也是available on the same class

【讨论】:

    猜你喜欢
    • 2013-07-29
    • 2011-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    • 2013-12-26
    相关资源
    最近更新 更多