From 61ecb07a99caa11a93602c8d3ee859a33f0b0ba9 Mon Sep 17 00:00:00 2001 From: Del Wang Date: Mon, 29 Dec 2025 10:14:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=8B=86=E5=88=86=20bin=20=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/hello/.gitignore | 1 + apps/hello/Cargo.toml | 7 +++++++ apps/hello/src/bin/client.rs | 12 ++++++++++++ apps/hello/src/bin/server.rs | 11 +++++++++++ apps/hello/src/{main.rs => bin/test.rs} | 7 ++----- apps/hello/src/lib.rs | 4 ++++ apps/hello/src/net/mod.rs | 6 ++++++ apps/runtime/build.sh | 5 ++++- 8 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 apps/hello/.gitignore create mode 100644 apps/hello/src/bin/client.rs create mode 100644 apps/hello/src/bin/server.rs rename apps/hello/src/{main.rs => bin/test.rs} (94%) create mode 100644 apps/hello/src/lib.rs create mode 100644 apps/hello/src/net/mod.rs diff --git a/apps/hello/.gitignore b/apps/hello/.gitignore new file mode 100644 index 0000000..bf9e782 --- /dev/null +++ b/apps/hello/.gitignore @@ -0,0 +1 @@ +*.mp3 \ No newline at end of file diff --git a/apps/hello/Cargo.toml b/apps/hello/Cargo.toml index 46476f5..de74159 100644 --- a/apps/hello/Cargo.toml +++ b/apps/hello/Cargo.toml @@ -15,3 +15,10 @@ debug = false alsa = "0.11" opus = "0.3" anyhow = "1.0" +tokio = { version = "1.47", features = ["full"] } +symphonia = { version = "0.5", features = ["mp3", "isomp4"] } +serde = { version = "1.0", features = ["derive"] } +bincode = "1.3" +log = "0.4" +env_logger = "0.11" +byteorder = "1.5" diff --git a/apps/hello/src/bin/client.rs b/apps/hello/src/bin/client.rs new file mode 100644 index 0000000..da84003 --- /dev/null +++ b/apps/hello/src/bin/client.rs @@ -0,0 +1,12 @@ +use hello::audio::{AudioPlayer, OpusCodec}; +use hello::config::AudioConfig; +use anyhow::Result; + +// todo 左右声道分发,播放音频 +fn main() -> Result<()> { + let config = AudioConfig::default(); + let player = AudioPlayer::new(&config)?; + let mut codec = OpusCodec::new(&config)?; + + +} diff --git a/apps/hello/src/bin/server.rs b/apps/hello/src/bin/server.rs new file mode 100644 index 0000000..be6ee1f --- /dev/null +++ b/apps/hello/src/bin/server.rs @@ -0,0 +1,11 @@ +use hello::audio::{OpusCodec}; +use hello::config::AudioConfig; +use anyhow::Result; + +// todo 向 client 分发左右声道音频数据 +fn main() -> Result<()> { + let config = AudioConfig::default(); + let mut codec = OpusCodec::new(&config)?; + + +} diff --git a/apps/hello/src/main.rs b/apps/hello/src/bin/test.rs similarity index 94% rename from apps/hello/src/main.rs rename to apps/hello/src/bin/test.rs index 5e12891..6559f36 100644 --- a/apps/hello/src/main.rs +++ b/apps/hello/src/bin/test.rs @@ -1,8 +1,5 @@ -mod audio; -mod config; - -use crate::audio::{AudioPlayer, AudioRecorder, OpusCodec}; -use crate::config::AudioConfig; +use hello::audio::{AudioPlayer, AudioRecorder, OpusCodec}; +use hello::config::AudioConfig; use anyhow::Result; use std::collections::VecDeque; use std::time::{Duration, Instant}; diff --git a/apps/hello/src/lib.rs b/apps/hello/src/lib.rs new file mode 100644 index 0000000..8ffc885 --- /dev/null +++ b/apps/hello/src/lib.rs @@ -0,0 +1,4 @@ +pub mod audio; +pub mod config; +pub mod net; +pub mod sync; diff --git a/apps/hello/src/net/mod.rs b/apps/hello/src/net/mod.rs new file mode 100644 index 0000000..05297c9 --- /dev/null +++ b/apps/hello/src/net/mod.rs @@ -0,0 +1,6 @@ +pub mod protocol; +pub mod discovery; + +pub use protocol::*; +pub use discovery::*; + diff --git a/apps/runtime/build.sh b/apps/runtime/build.sh index ef2a04d..0cdfd78 100755 --- a/apps/runtime/build.sh +++ b/apps/runtime/build.sh @@ -27,4 +27,7 @@ docker run --rm -v $(pwd)/../hello:/app/hello open-xiaoai-runtime \ # 5. 上传二进制文件到小爱音箱 # dd if=apps/hello/target/armv7-unknown-linux-gnueabihf/release/hello \ -# | ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.235 "dd of=/data/hello" \ No newline at end of file +# | ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.235 "dd of=/data/hello" + +# dd if=apps/hello/target/armv7-unknown-linux-gnueabihf/release/hello \ +# | ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.153 "dd of=/data/hello" \ No newline at end of file