feat: web/native device consistency management (#243)
* fix: Force audio settings to be consistent. * chore: applyAudioSettings for onUnpublish. * revert audio output select for web. * add RoomHardwareManagementMethods to Room. * update. * fix analyze. * update. * update. * chore: Reset sinkId for web when remoteTrack replays. * rename setAudioOutput to setSinkId for flutter web. * chore: Make sure AudioElement has `setSinkId` method.
This commit is contained in:
@@ -88,6 +88,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
|
||||
// did publish
|
||||
await track.onPublish();
|
||||
await room.applyAudioSpeakerSettings();
|
||||
|
||||
[events, room.events].emit(LocalTrackPublishedEvent(
|
||||
participant: this,
|
||||
@@ -228,6 +229,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
|
||||
// did unpublish
|
||||
await track.onUnpublish();
|
||||
await room.applyAudioSpeakerSettings();
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
@@ -319,6 +321,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
await publication.mute();
|
||||
}
|
||||
}
|
||||
await room.applyAudioSpeakerSettings();
|
||||
return publication;
|
||||
} else if (enabled) {
|
||||
if (source == TrackSource.camera) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import '../extensions.dart';
|
||||
import '../logger.dart';
|
||||
import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../publication/remote.dart';
|
||||
import '../support/platform.dart';
|
||||
import '../track/options.dart';
|
||||
import '../track/remote/audio.dart';
|
||||
import '../track/remote/remote.dart';
|
||||
import '../track/remote/video.dart';
|
||||
@@ -75,6 +77,7 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
rtc.MediaStream stream,
|
||||
String trackSid, {
|
||||
rtc.RTCRtpReceiver? receiver,
|
||||
AudioOutputOptions audioOutputOptions = const AudioOutputOptions(),
|
||||
}) async {
|
||||
logger.fine('addSubscribedMediaTrack()');
|
||||
|
||||
@@ -123,6 +126,16 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
}
|
||||
|
||||
await track.start();
|
||||
|
||||
/// Apply audio output selection for the web.
|
||||
if (pub.kind == lk_models.TrackType.AUDIO &&
|
||||
lkPlatformIs(PlatformType.web)) {
|
||||
if (audioOutputOptions.deviceId != null) {
|
||||
await (track as RemoteAudioTrack)
|
||||
.setSinkId(audioOutputOptions.deviceId!);
|
||||
}
|
||||
}
|
||||
|
||||
await pub.updateTrack(track);
|
||||
await pub.updateSubscriptionAllowed(true);
|
||||
addTrackPublication(pub);
|
||||
|
||||
Reference in New Issue
Block a user