Audio mute unmute fixes (#234)

* progress

* refresh

* Create Podfile.lock

* Update Podfile.lock

* pub

* update deps.

* fix tests

* dart format .

* fix duplicate imports

---------

Co-authored-by: cloudwebrtc <[email protected]>
This commit is contained in:
Hiroshi Horie
2023-02-06 12:43:27 +09:00
committed by GitHub
co-authored by cloudwebrtc
parent 75412779a2
commit a23eb6332c
16 changed files with 429 additions and 324 deletions
-14
View File
@@ -25,7 +25,6 @@ import 'participant.dart';
/// Represents the current participant in the room. Instance of [LocalParticipant] is automatically
/// created after successfully connecting to a [Room] and will be accessible from [Room.localParticipant].
class LocalParticipant extends Participant<LocalTrackPublication> {
bool stopMicTrackOnMute = false;
@internal
LocalParticipant({
required Room room,
@@ -54,8 +53,6 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
publishOptions =
publishOptions ?? room.roomOptions.defaultAudioPublishOptions;
stopMicTrackOnMute = publishOptions.stopMicTrackOnMute;
final trackInfo = await room.engine.addTrack(
cid: track.getCid(),
name: track.name,
@@ -313,24 +310,13 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
logger.fine('setSourceEnabled(source: $source, enabled: $enabled)');
final publication = getTrackPublicationBySource(source);
if (publication != null) {
var track = publication.track;
var stopOnMute = stopMicTrackOnMute && track is LocalAudioTrack;
if (enabled) {
await publication.unmute();
if (stopOnMute) {
await track.restartTrack();
await track.onTrackStarted();
}
} else {
if (source == TrackSource.screenShareVideo) {
await unpublishTrack(publication.sid);
} else {
await publication.mute();
if (stopOnMute) {
await track.sender?.setTrack(null);
await track.stop();
await track.onTrackStopped();
}
}
}
return publication;