Blancduman / mediasoup-client-flutter

Flutter version of the mediasoup-client library.
MIT License
106 stars 53 forks source link

Bug Report: producer.replaceTrack() doesn't work. #62

Open un-hongly opened 2 years ago

un-hongly commented 2 years ago

I'm working on a feature where user can switch their camera. To do that I replace a new track for the producer using producer.replaceTrack(newTrack) but it always returns a log that says "replaceTrack() | same track, ignored." even when I pass a completely new track.

I looked into your code inside producer.dart file at line 357 you compare a track parameter to the track parameter itself (see below) which is why the condition is always matched.

  Future<void> replaceTrack(MediaStreamTrack track) async {
   ...
       if (track == track) {
      _logger.debug('replaceTrack() | same track, ignored.');

      return;
    }
  ...
  }
Blancduman commented 2 years ago

LOL. Sorry for that. Im working on major update. For now, implement it by closing producer and creating new.

Blancduman commented 1 year ago

LOL. Sorry for that. Im working on major update. For now, implement it with closing producer and creating new.

вт, 30 авг. 2022 г., 19:22 un-hongly @.***>:

I'm working on a feature where user can switch their camera. To do that I replace a new track for the producer using producer.replaceTrack(newTrack) but it always returns a log that says "replaceTrack() | same track, ignored." even when I pass a completely new track.

I looked into your code inside producer.dart file at line 357 you compare a track parameter to the track parameter itself (see below) which is why the condition is always matched.

Future replaceTrack(MediaStreamTrack track) async { ... if (track == track) { _logger.debug('replaceTrack() | same track, ignored.');

  return;
}

... }

— Reply to this email directly, view it on GitHub https://github.com/Blancduman/mediasoup-client-flutter/issues/62, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIVXEO7OULNBCAAXEFTFS2LV3YYKZANCNFSM6AAAAAAQASFCLU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

thanhle7 commented 1 month ago

Two years since then function "replaceTrack" is yet unable to work.

thanhle7 commented 1 month ago

By looking at producer.dart, I foud something weird :)

// Set the new track.
track = track;

why not using:

this.track = track;

or, rename the class property with '_' prefix, then

_track = track;