remove video/audio decoder in client for cli

This commit is contained in:
rustdesk 2022-12-29 12:47:02 +08:00
parent 7d65094664
commit 8c7bc08776

View File

@ -4,6 +4,7 @@ use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait}, traits::{DeviceTrait, HostTrait, StreamTrait},
Device, Host, StreamConfig, Device, Host, StreamConfig,
}; };
#[cfg(not(features = "cli"))]
use magnum_opus::{Channels::*, Decoder as AudioDecoder}; use magnum_opus::{Channels::*, Decoder as AudioDecoder};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::{ use std::{
@ -36,6 +37,7 @@ use hbb_common::{
}; };
pub use helper::LatencyController; pub use helper::LatencyController;
pub use helper::*; pub use helper::*;
#[cfg(not(features = "cli"))]
use scrap::{ use scrap::{
codec::{Decoder, DecoderCfg}, codec::{Decoder, DecoderCfg},
record::{Recorder, RecorderContext}, record::{Recorder, RecorderContext},
@ -585,6 +587,7 @@ impl Client {
} }
/// Audio handler for the [`Client`]. /// Audio handler for the [`Client`].
#[cfg(not(features = "cli"))]
#[derive(Default)] #[derive(Default)]
pub struct AudioHandler { pub struct AudioHandler {
audio_decoder: Option<(AudioDecoder, Vec<f32>)>, audio_decoder: Option<(AudioDecoder, Vec<f32>)>,
@ -601,6 +604,7 @@ pub struct AudioHandler {
latency_controller: Arc<Mutex<LatencyController>>, latency_controller: Arc<Mutex<LatencyController>>,
} }
#[cfg(not(features = "cli"))]
impl AudioHandler { impl AudioHandler {
/// Create a new audio handler. /// Create a new audio handler.
pub fn new(latency_controller: Arc<Mutex<LatencyController>>) -> Self { pub fn new(latency_controller: Arc<Mutex<LatencyController>>) -> Self {
@ -796,6 +800,7 @@ impl AudioHandler {
} }
/// Video handler for the [`Client`]. /// Video handler for the [`Client`].
#[cfg(not(features = "cli"))]
pub struct VideoHandler { pub struct VideoHandler {
decoder: Decoder, decoder: Decoder,
latency_controller: Arc<Mutex<LatencyController>>, latency_controller: Arc<Mutex<LatencyController>>,
@ -804,6 +809,7 @@ pub struct VideoHandler {
record: bool, record: bool,
} }
#[cfg(not(features = "cli"))]
impl VideoHandler { impl VideoHandler {
/// Create a new video handler. /// Create a new video handler.
pub fn new(latency_controller: Arc<Mutex<LatencyController>>) -> Self { pub fn new(latency_controller: Arc<Mutex<LatencyController>>) -> Self {
@ -1524,6 +1530,7 @@ where
let latency_controller = LatencyController::new(); let latency_controller = LatencyController::new();
let latency_controller_cl = latency_controller.clone(); let latency_controller_cl = latency_controller.clone();
#[cfg(not(features = "cli"))]
std::thread::spawn(move || { std::thread::spawn(move || {
let mut video_handler = VideoHandler::new(latency_controller); let mut video_handler = VideoHandler::new(latency_controller);
loop { loop {
@ -1548,6 +1555,7 @@ where
} }
log::info!("Video decoder loop exits"); log::info!("Video decoder loop exits");
}); });
#[cfg(not(features = "cli"))]
std::thread::spawn(move || { std::thread::spawn(move || {
let mut audio_handler = AudioHandler::new(latency_controller_cl); let mut audio_handler = AudioHandler::new(latency_controller_cl);
loop { loop {