removeLocalStream method

Future<void> removeLocalStream(
  1. WrappedMediaStream callFeed
)

Implementation

Future<void> removeLocalStream(WrappedMediaStream callFeed) async {
  final senderArray = callFeed.purpose == SDPStreamMetadataPurpose.Usermedia
      ? usermediaSenders
      : screensharingSenders;

  for (final element in senderArray) {
    await pc!.removeTrack(element);
  }

  if (callFeed.purpose == SDPStreamMetadataPurpose.Screenshare) {
    await stopMediaStream(callFeed.stream);
  }

  // Empty the array
  senderArray.removeRange(0, senderArray.length);
  onStreamRemoved.add(callFeed);
  await deleteStream(callFeed);
}