Blancduman / mediasoup-client-flutter

Flutter version of the mediasoup-client library.
MIT License
105 stars 58 forks source link

transport.produce(): Null check operator used on a null value #81

Open dkliss opened 1 year ago

dkliss commented 1 year ago

Hi,

I received an error when connect connectSendTranport() in function transport.produce(). When I traced it down, I noticed that below function was doing a null check on null value of _pc i.e. _pc value was null when this function was called. I called connectSendTranport() function after "connect" & "produce" events.

RTCRtpTransceiver transceiver = await _pc!.addTransceiver(
      track: options.track,
      kind: RTCRtpMediaTypeExtension.fromString(options.track.kind!),
      init: RTCRtpTransceiverInit(
        direction: TransceiverDirection.SendOnly,
        streams: [options.stream],
        sendEncodings: options.encodings,
      ),
    );

The error does not occur if I add a delay of (example 1 second) before calling connectSendTranport() (after events "connect" & "produce").

A bit similar to issue: https://github.com/Blancduman/mediasoup-client-flutter/issues/50

Future send(HandlerSendOptions options) seems to be dependent upon pc not null.