use ::std::collections::HashMap;
use ::zbus::{DeserializeDict, Type, proxy};
#[proxy(
interface = "net.b128.VoiceFilter1",
default_service = "net.b128.VoiceFilter.Daemon",
default_path = "/net/b128/VoiceFilter"
)]
pub trait VoiceFilter {
fn set_stage_enabled(&self, name: &str, enabled: bool) -> ::zbus::Result<()>;
#[zbus(property)]
fn parameters(&self) -> ::zbus::Result<Vec<ParameterTuple>>;
fn set_parameter(&self, stage: &str, name: &str, value: f64) -> ::zbus::Result<()>;
#[zbus(property)]
fn listen(&self) -> ::zbus::Result<bool>;
#[zbus(property)]
fn set_listen(&self, on: bool) -> ::zbus::Result<()>;
#[zbus(property)]
fn keep_listen(&self) -> ::zbus::Result<bool>;
#[zbus(property)]
fn set_keep_listen(&self, keep: bool) -> ::zbus::Result<()>;
#[zbus(property)]
fn listen_volume(&self) -> ::zbus::Result<f64>;
#[zbus(property)]
fn set_listen_volume(&self, db: f64) -> ::zbus::Result<()>;
#[zbus(property)]
fn stages(&self) -> ::zbus::Result<Vec<(String, bool)>>;
#[zbus(property)]
fn input(&self) -> ::zbus::Result<String>;
#[zbus(property)]
fn set_input(&self, name: &str) -> ::zbus::Result<()>;
#[zbus(property)]
fn inputs(&self) -> ::zbus::Result<Vec<(String, String, i32)>>;
#[zbus(property)]
fn output(&self) -> ::zbus::Result<String>;
#[zbus(property)]
fn set_output(&self, name: &str) -> ::zbus::Result<()>;
#[zbus(property)]
fn outputs(&self) -> ::zbus::Result<Vec<(String, String, i32)>>;
#[zbus(property)]
fn latency(&self) -> ::zbus::Result<HashMap<String, f64>>;
#[zbus(property)]
fn echo(&self) -> ::zbus::Result<HashMap<String, f64>>;
#[zbus(property)]
fn quantum(&self) -> ::zbus::Result<u64>;
#[zbus(property)]
fn max_frame_time(&self) -> ::zbus::Result<f64>;
#[zbus(property)]
fn counters(&self) -> ::zbus::Result<HashMap<String, u64>>;
#[zbus(property)]
fn levels(&self) -> ::zbus::Result<HashMap<String, f64>>;
}
type ParameterTuple = (String, String, String, String, f64, f64, f64, f64, f64);
#[derive(Clone, Debug, PartialEq)]
pub struct Parameter {
pub stage: String,
pub name: String,
pub title: String,
pub unit: String,
pub min: f64,
pub max: f64,
pub step: f64,
pub default: f64,
pub value: f64,
}
impl From<ParameterTuple> for Parameter {
fn from((stage, name, title, unit, min, max, step, default, value): ParameterTuple) -> Self {
Self {
stage,
name,
title,
unit,
min,
max,
step,
default,
value,
}
}
}
pub struct Status {
pub listen: bool,
pub keep_listen: bool,
pub listen_volume: f64,
pub stages: Vec<(String, bool)>,
pub parameters: Vec<Parameter>,
pub input: String,
pub inputs: Vec<(String, String, i32)>,
pub output: String,
pub outputs: Vec<(String, String, i32)>,
pub latency: HashMap<String, f64>,
pub echo: HashMap<String, f64>,
pub quantum: u64,
pub max_frame_time: f64,
pub counters: HashMap<String, u64>,
pub levels: HashMap<String, f64>,
}
#[derive(DeserializeDict, Type)]
#[zbus(signature = "a{sv}", rename_all = "PascalCase")]
struct Properties {
listen: bool,
keep_listen: bool,
listen_volume: f64,
stages: Vec<(String, bool)>,
parameters: Vec<ParameterTuple>,
input: String,
inputs: Vec<(String, String, i32)>,
output: String,
outputs: Vec<(String, String, i32)>,
latency: HashMap<String, f64>,
echo: HashMap<String, f64>,
quantum: u64,
max_frame_time: f64,
counters: HashMap<String, u64>,
levels: HashMap<String, f64>,
}
impl VoiceFilterProxy<'_> {
pub async fn status(&self) -> ::zbus::Result<Status> {
let proxy = self.inner();
let reply = proxy
.connection()
.call_method(
Some(proxy.destination()),
proxy.path(),
Some("org.freedesktop.DBus.Properties"),
"GetAll",
&(proxy.interface(),),
)
.await?;
let properties: Properties = reply.body().deserialize()?;
Ok(Status {
listen: properties.listen,
keep_listen: properties.keep_listen,
listen_volume: properties.listen_volume,
stages: properties.stages,
parameters: properties
.parameters
.into_iter()
.map(Parameter::from)
.collect(),
input: properties.input,
inputs: properties.inputs,
output: properties.output,
outputs: properties.outputs,
latency: properties.latency,
echo: properties.echo,
quantum: properties.quantum,
max_frame_time: properties.max_frame_time,
counters: properties.counters,
levels: properties.levels,
})
}
}