mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
feat: add audio mode config
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::client::{
|
||||
Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
|
||||
Client, CodecFormat, LoginConfigHandler, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
|
||||
SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED,
|
||||
};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
@@ -386,6 +386,24 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
Data::ToggleClipboardFile => {
|
||||
self.check_clipboard_file_context();
|
||||
}
|
||||
Data::ChangeAudioMode(audio_mode) => {
|
||||
match audio_mode {
|
||||
AudioMode::GuestToHost => {
|
||||
if let Some(sender) = self.stop_local_audio_sender.take() {
|
||||
allow_err!(sender.send(()));
|
||||
}
|
||||
}
|
||||
AudioMode::TwoWay => {
|
||||
// Start audio thread for playback.
|
||||
// Cancel previous local audio session.
|
||||
if let Some(sender) = self.stop_local_audio_sender.take() {
|
||||
allow_err!(sender.send(()));
|
||||
}
|
||||
// Start client audio when connection is established.
|
||||
self.stop_local_audio_sender = self.start_client_audio();
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::Message(msg) => {
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
@@ -866,19 +884,27 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
});
|
||||
}
|
||||
}
|
||||
// Start audio thread for playback
|
||||
if !self.handler.is_file_transfer() && !self.handler.is_port_forward() {
|
||||
// Cancel previous local audio session.
|
||||
if let Some(sender) = self.stop_local_audio_sender.take() {
|
||||
allow_err!(sender.send(()));
|
||||
}
|
||||
// Start client audio when connection is established.
|
||||
self.stop_local_audio_sender = self.start_client_audio();
|
||||
}
|
||||
|
||||
if self.handler.is_file_transfer() {
|
||||
self.handler.load_last_jobs();
|
||||
}
|
||||
|
||||
// Start audio thread for playback if current audio mode is two-way transmission.
|
||||
if !self.handler.is_file_transfer() && !self.handler.is_port_forward() {
|
||||
let audio_mode = LoginConfigHandler::get_audio_mode_enum(
|
||||
self.handler.load_config().audio_mode.as_str(),
|
||||
false,
|
||||
)
|
||||
.unwrap_or(AudioMode::GuestToHost);
|
||||
if audio_mode == AudioMode::TwoWay {
|
||||
// Cancel previous local audio session.
|
||||
if let Some(sender) = self.stop_local_audio_sender.take() {
|
||||
allow_err!(sender.send(()));
|
||||
}
|
||||
// Start client audio when connection is established.
|
||||
self.stop_local_audio_sender = self.start_client_audio();
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user