flutter-webrtc / flutter-webrtc-demo

Demo for flutter-webrtc
MIT License
1.15k stars 417 forks source link

PeerConnection. onTrack is never fired or received callback #116

Closed Vakil-Parth closed 3 years ago

Vakil-Parth commented 3 years ago

` createPeerConnection(_iceServers).then((connection) async { peerConnection = connection;

  await peerConnection.setRemoteDescription(
      RTCSessionDescription(data['offer']['sdp'], data['offer']['type']));

  peerConnection.onTrack = (event) {
    print('------------------------------ onTrack'); // never got this callback, works well with Web
    if (event.track.kind == 'video') {
      _localRenderer.srcObject = event.streams[0];
    }
  };

  RTCSessionDescription rtcSessionDescription =
      await peerConnection.createAnswer();

  await peerConnection.setLocalDescription(rtcSessionDescription);

  RTCSessionDescription localSessionDescription =
      await peerConnection.getLocalDescription();
  socket.emit(
      "answer", {'id': data['id'], 'description': localSessionDescription.sdp});

  peerConnection.onIceCandidate = (candidate) {
    print('onIceCandidate');
    socket.emit("candidate", {
      'id': data['id'],
      'candidate': {
        'sdpMid': candidate.sdpMid,
        'sdpMLineIndex': candidate.sdpMlineIndex,
        'candidate': candidate.candidate
      }
    });
  };

`

Vakil-Parth commented 3 years ago

Found issue with chrome browser