mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 12:29:04 +08:00
feat: add audio switch ui
This commit is contained in:
parent
95d06e160b
commit
cb228bef2b
@ -106,6 +106,12 @@ const kRemoteImageQualityLow = 'low';
|
||||
/// [kRemoteImageQualityCustom] Custom image quality.
|
||||
const kRemoteImageQualityCustom = 'custom';
|
||||
|
||||
/// [kRemoteAudioGuestToHost] Guest to host audio mode(default).
|
||||
const kRemoteAudioGuestToHost = 'guest-to-host';
|
||||
|
||||
/// [kRemoteAudioTwoWay] two-way audio mode(default).
|
||||
const kRemoteAudioTwoWay = 'two-way';
|
||||
|
||||
const kIgnoreDpi = true;
|
||||
|
||||
/// flutter/packages/flutter/lib/src/services/keyboard_key.dart -> _keyLabels
|
||||
|
@ -1106,6 +1106,30 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
padding: padding,
|
||||
),
|
||||
MenuEntryDivider<String>(),
|
||||
MenuEntryRadios<String>(
|
||||
text: translate('Audio Transmission Mode'),
|
||||
optionsGetter: () => [
|
||||
MenuEntryRadioOption(
|
||||
text: translate('Guest to Host'),
|
||||
value: kRemoteAudioGuestToHost,
|
||||
dismissOnClicked: true,
|
||||
),
|
||||
MenuEntryRadioOption(
|
||||
text: translate('Two way'),
|
||||
value: kRemoteAudioTwoWay,
|
||||
dismissOnClicked: true,
|
||||
),
|
||||
],
|
||||
curOptionGetter: () async =>
|
||||
// null means peer id is not found, which there's no need to care about
|
||||
await bind.sessionGetAudioMode(id: widget.id) ?? '',
|
||||
optionSetter: (String oldValue, String newValue) async {
|
||||
if (oldValue != newValue) {
|
||||
await bind.sessionSetAudioMode(id: widget.id, value: newValue);
|
||||
}
|
||||
},
|
||||
padding: padding,
|
||||
),
|
||||
];
|
||||
|
||||
if (widget.state.viewStyle.value == kRemoteViewStyleOriginal) {
|
||||
@ -1337,6 +1361,8 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
if (perms['audio'] != false) {
|
||||
displayMenu
|
||||
.add(_createSwitchMenuEntry('Mute', 'disable-audio', padding, true));
|
||||
displayMenu
|
||||
.add(_createSwitchMenuEntry('Mute', 'disable-audio', padding, true));
|
||||
}
|
||||
|
||||
if (Platform.isWindows &&
|
||||
|
@ -444,6 +444,11 @@ enum ImageQuality {
|
||||
Best = 4;
|
||||
}
|
||||
|
||||
enum AudioMode {
|
||||
GuestToHost = 0;
|
||||
TwoWay = 1;
|
||||
}
|
||||
|
||||
message VideoCodecState {
|
||||
enum PreferCodec {
|
||||
Auto = 0;
|
||||
@ -475,6 +480,7 @@ message OptionMessage {
|
||||
BoolOption enable_file_transfer = 9;
|
||||
VideoCodecState video_codec_state = 10;
|
||||
int32 custom_fps = 11;
|
||||
AudioMode audio_mode = 12;
|
||||
}
|
||||
|
||||
message TestDelay {
|
||||
|
@ -212,6 +212,11 @@ pub struct PeerConfig {
|
||||
deserialize_with = "PeerConfig::deserialize_image_quality"
|
||||
)]
|
||||
pub image_quality: String,
|
||||
#[serde(
|
||||
default = "PeerConfig::default_audio_mode",
|
||||
deserialize_with = "PeerConfig::deserialize_audio_mode"
|
||||
)]
|
||||
pub audio_mode: String,
|
||||
#[serde(
|
||||
default = "PeerConfig::default_custom_image_quality",
|
||||
deserialize_with = "PeerConfig::deserialize_custom_image_quality"
|
||||
@ -996,6 +1001,11 @@ impl PeerConfig {
|
||||
deserialize_image_quality,
|
||||
UserDefaultConfig::load().get("image_quality")
|
||||
);
|
||||
serde_field_string!(
|
||||
default_audio_mode,
|
||||
deserialize_audio_mode,
|
||||
"guest-to-host".to_owned()
|
||||
);
|
||||
|
||||
fn default_custom_image_quality() -> Vec<i32> {
|
||||
let f: f64 = UserDefaultConfig::load()
|
||||
|
@ -1252,6 +1252,27 @@ impl LoginConfigHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the audio mode option.
|
||||
/// Return [`AudioMode`] if the option is valid, otherwise return `None`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `q` - The audio mode option.
|
||||
/// * `ignore_default` - Ignore the default value.
|
||||
fn get_audio_mode_enum(&self, q: &str, ignore_default: bool) -> Option<AudioMode> {
|
||||
if q == "guest-to-host" {
|
||||
Some(AudioMode::GuestToHost)
|
||||
} else if q == "two-way" {
|
||||
Some(AudioMode::TwoWay)
|
||||
} else {
|
||||
if ignore_default {
|
||||
None
|
||||
} else {
|
||||
Some(AudioMode::GuestToHost)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the status of a toggle option.
|
||||
///
|
||||
/// # Arguments
|
||||
@ -1338,6 +1359,24 @@ impl LoginConfigHandler {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn save_audio_mode(&mut self, value: String) -> Option<Message> {
|
||||
let mut res = None;
|
||||
if let Some(q) = self.get_audio_mode_enum(&value, false) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_option(OptionMessage {
|
||||
audio_mode: q.into(),
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_misc(misc);
|
||||
res = Some(msg_out);
|
||||
}
|
||||
let mut config = self.load_config();
|
||||
config.audio_mode = value;
|
||||
self.save_config(config);
|
||||
res
|
||||
}
|
||||
|
||||
/// Create a [`Message`] for saving custom fps.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -233,6 +233,20 @@ pub fn session_set_image_quality(id: String, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_audio_mode(id: String) -> Option<String> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_audio_mode())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_audio_mode(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
|
||||
session.save_audio_mode(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_mode(id: String) -> Option<String> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_keyboard_mode())
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "帧率"),
|
||||
("Auto", "自动"),
|
||||
("Other Default Options", "其它默认选项"),
|
||||
("Guest to Host", "被控到主机"),
|
||||
("Two way", "双向"),
|
||||
("Audio Transmission Mode", "音频传输模式"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -436,6 +436,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Switch Sides", ""),
|
||||
("Please confirm if you want to share your desktop?", ""),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
("Display", ""),
|
||||
("Default View Style", ""),
|
||||
("Default Scroll Style", ""),
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "fps"),
|
||||
("Auto", "Automatisch"),
|
||||
("Other Default Options", "Weitere Standardoptionen"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", "Otras opciones predeterminadas"),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "خودکار"),
|
||||
("Other Default Options", "سایر گزینه های پیش فرض"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Autres options par défaut"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Altre Opzioni Predefinite"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Inne opcje domyślne"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Авто"),
|
||||
("Other Default Options", "Другие параметры по умолчанию"),
|
||||
("Please confirm if you want to share your desktop?", "Подтвердите, что хотите поделиться своим рабочим столом?"),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "幀率"),
|
||||
("Auto", "自動"),
|
||||
("Other Default Options", "其它默認選項"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
@ -89,6 +89,18 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
self.lc.write().unwrap().save_keyboard_mode(value);
|
||||
}
|
||||
|
||||
pub fn get_audio_mode(&self) -> String {
|
||||
self.lc.read().unwrap().audio_mode.clone()
|
||||
}
|
||||
|
||||
pub fn save_audio_mode(&self, value: String) {
|
||||
let msg = self.lc.write().unwrap().save_audio_mode(value);
|
||||
// Notify remote guest that the audio mode has been changed.
|
||||
if let Some(msg) = msg {
|
||||
self.send(Data::Message(msg));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save_view_style(&mut self, value: String) {
|
||||
self.lc.write().unwrap().save_view_style(value);
|
||||
}
|
||||
@ -653,6 +665,13 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_audio_transmission_mode(&self, id: &str) {
|
||||
|
||||
}
|
||||
fn set_audio_transmission_mode(&self, id: &str, mode: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
|
Loading…
Reference in New Issue
Block a user