flutter webrtc remote stream

670 views Asked by At

I am having a problem with onaddremotestream in flutter webrtc

I am following this guide https://github.com/cyb3rcod3/flutter-openvidu-demo trying to integrate flutter with openvidu https://docs.openvidu.io/en/2.24.0/tutorials/openvidu-hello-world/

openvidu web https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-hello-world

openvidu server working normally and when connecting web browser and iOS device the web browser sees both local and remote stream...but iOS device or emulator only sees local stream and no remote stream!

code used old android embeddings v1 so I had to update packages and add null safety for latest flutter webrtc

  1. in signalling.dart

I replaced

 _localPeerConnection.addStream(_localStream);

with

_localStream?.getTracks().forEach((track) {print('adding our localtracks');_localPeerConnection?.addTrack(track,_localStream!);});

this made local stream show in screen

  1. in signalling.dart
in functionFuture<RTCPeerConnection> _createRemotePeerConnection(RemoteParticipant remoteParticipant)

the below code for remote participant stream triggers

remotePeerConnection.onAddStream = (MediaStream stream) {
  print("should add remote  stream for remote participant");
  remoteParticipant.mediaStream = stream;
  if (this.onParticipantsStreamUpdate != null){
    this.onParticipantsStreamUpdate?.call(remoteParticipant);
  }
  if (this.onAddRemoteStream != null){
    print(' call onaddremotestream from remote participant');
    onAddRemoteStream?.call(stream);
  }
};

and in UI page call_sample.dart

_signaling?.onAddRemoteStream = ((stream) {
  print('onAddRemoteStream: ${stream.id}');
  // stream.getVideoTracks()[0].addRenderer(new VideoRenderer(remoteRender));
  _remoteRenderer.srcObject = stream;


  // _remoteRenderer.srcObject = _signaling?.getRemoteStream();
  setState(() {});
});

gets triggered but the output of print is flutter: onAddRemoteStream: default and the screen is black/grey

I am not sure where the problem is since the browser sees the device means the openvidu is working and the problem is in flutter app!

0

There are 0 answers