From d48b52aa94e176aee2112cd1b35fbbff1b63835f Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Mon, 20 May 2024 22:47:25 +0800 Subject: [PATCH] fix: audio devcie ids consistency (#513) * fix: audio devcie ids consistency * update. * update. --- lib/src/hardware/hardware.dart | 13 ++++++++----- pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/src/hardware/hardware.dart b/lib/src/hardware/hardware.dart index a9b7fee2..705645c3 100644 --- a/lib/src/hardware/hardware.dart +++ b/lib/src/hardware/hardware.dart @@ -24,11 +24,12 @@ import '../support/platform.dart'; import '../track/audio_management.dart'; class MediaDevice { - const MediaDevice(this.deviceId, this.label, this.kind); + const MediaDevice(this.deviceId, this.label, this.kind, this.groupId); final String deviceId; final String label; final String kind; + final String? groupId; @override bool operator ==(covariant MediaDevice other) { @@ -36,7 +37,8 @@ class MediaDevice { return other.deviceId == deviceId && other.kind == kind && - other.label == label; + other.label == label && + other.groupId == groupId; } @override @@ -46,7 +48,7 @@ class MediaDevice { @override String toString() { - return 'MediaDevice{deviceId: $deviceId, label: $label, kind: $kind}'; + return 'MediaDevice{deviceId: $deviceId, label: $label, kind: $kind, groupId: $groupId}'; } } @@ -81,8 +83,9 @@ class Hardware { Future> enumerateDevices({String? type}) async { var infos = await rtc.navigator.mediaDevices.enumerateDevices(); - var devices = - infos.map((e) => MediaDevice(e.deviceId, e.label, e.kind!)).toList(); + var devices = infos + .map((e) => MediaDevice(e.deviceId, e.label, e.kind!, e.groupId)) + .toList(); if (type != null && type.isNotEmpty) { devices = devices.where((d) => d.kind == type).toList(); } diff --git a/pubspec.yaml b/pubspec.yaml index 07553756..9585a36f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,7 +38,7 @@ dependencies: uuid: '>=3.0.6' synchronized: ^3.0.0+3 protobuf: ^3.0.0 - flutter_webrtc: ^0.10.4 + flutter_webrtc: ^0.10.5 device_info_plus: '>=8.0.0' js: ^0.6.4 platform_detect: ^2.0.7