replaceUserMediaStream method

Future<void> replaceUserMediaStream(
  1. WrappedMediaStream existingStream,
  2. WrappedMediaStream replacementStream
)

Implementation

Future<void> replaceUserMediaStream(WrappedMediaStream existingStream,
    WrappedMediaStream replacementStream) async {
  final streamIndex = userMediaStreams
      .indexWhere((stream) => stream.userId == existingStream.userId);

  if (streamIndex == -1) {
    throw Exception('Couldn\'t find user media stream to replace');
  }

  userMediaStreams.replaceRange(streamIndex, 1, [replacementStream]);

  await existingStream.dispose();
  //replacementStream.measureVolumeActivity(true);
  onGroupCallEvent.add(GroupCallEvent.UserMediaStreamsChanged);
}