removeScreenshareStream method

Future<void> removeScreenshareStream(
  1. WrappedMediaStream stream
)

Implementation

Future<void> removeScreenshareStream(WrappedMediaStream stream) async {
  final streamIndex = screenshareStreams
      .indexWhere((stream) => stream.userId == stream.userId);

  if (streamIndex == -1) {
    throw Exception('Couldn\'t find screenshare stream to remove');
  }

  screenshareStreams
      .removeWhere((element) => element.userId == stream.userId);

  onStreamRemoved.add(stream);

  if (stream.isLocal()) {
    await stream.disposeRenderer();
    await stopMediaStream(stream.stream);
  }

  onGroupCallEvent.add(GroupCallEvent.ScreenshareStreamsChanged);
}