increased mic logging
This commit is contained in:
parent
8ebb4a8b92
commit
b9a5f51565
@ -210,11 +210,11 @@ impl LesavkaClientApp {
|
|||||||
let req = MonitorRequest { id: monitor_id, max_bitrate: 6_000 };
|
let req = MonitorRequest { id: monitor_id, max_bitrate: 6_000 };
|
||||||
match cli.capture_video(Request::new(req)).await {
|
match cli.capture_video(Request::new(req)).await {
|
||||||
Ok(mut stream) => {
|
Ok(mut stream) => {
|
||||||
debug!("🎥 cli video{monitor_id}: stream opened");
|
debug!("🎥🏁 cli video{monitor_id}: stream opened");
|
||||||
while let Some(res) = stream.get_mut().message().await.transpose() {
|
while let Some(res) = stream.get_mut().message().await.transpose() {
|
||||||
match res {
|
match res {
|
||||||
Ok(pkt) => {
|
Ok(pkt) => {
|
||||||
trace!("🎥 cli video{monitor_id}: got {} bytes", pkt.data.len());
|
trace!("🎥📥 cli video{monitor_id}: got {} bytes", pkt.data.len());
|
||||||
if tx.send(pkt).is_err() {
|
if tx.send(pkt).is_err() {
|
||||||
warn!("⚠️🎥 cli video{monitor_id}: GUI thread gone");
|
warn!("⚠️🎥 cli video{monitor_id}: GUI thread gone");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# scripts/manual/audio-clip-fetch.sh
|
# scripts/manual/audio-mic-fetch.sh
|
||||||
|
|
||||||
# Pull & play the most recent 1 s AAC clip from lesavka‑server
|
PI_HOST="nikto@192.168.42.253" # adjust if needed
|
||||||
PI_HOST="nikto@192.168.42.253" # adjust
|
|
||||||
REMOTE_DIR="/tmp"
|
REMOTE_DIR="/tmp"
|
||||||
DEST="$(mktemp -u).aac"
|
TMPDIR=$(mktemp -d)
|
||||||
|
scp -q "${PI_HOST}:${REMOTE_DIR}/mic-*.aac" "$TMPDIR/" 2>/dev/null \
|
||||||
|
|| { echo "❌ no mic clip files found yet"; exit 1; }
|
||||||
|
|
||||||
scp "${PI_HOST}:${REMOTE_DIR}/ear-*.aac" "$DEST" 2>/dev/null \
|
LATEST=$(ls -1t "$TMPDIR"/mic-*.aac | head -n1)
|
||||||
|| { echo "❌ no clip files yet"; exit 1; }
|
echo "🎤 playing $(basename "$LATEST") ..."
|
||||||
|
gst-play-1.0 --quiet "$LATEST"
|
||||||
LATEST=$(ls -1t ear-*.aac | head -n1)
|
|
||||||
echo "🎧 playing ${LATEST} ..."
|
|
||||||
gst-play-1.0 --quiet "${LATEST}"
|
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
// server/src/main.rs
|
// server/src/main.rs
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
use std::{panic, backtrace::Backtrace, pin::Pin, sync::Arc, time::Duration};
|
use std::{panic, backtrace::Backtrace, pin::Pin, sync::Arc};
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use futures_util::{Stream, StreamExt};
|
use futures_util::{Stream, StreamExt};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@ -84,6 +85,14 @@ async fn open_with_retry(path: &str) -> anyhow::Result<tokio::fs::File> {
|
|||||||
Err(anyhow::anyhow!("timeout waiting for {path}"))
|
Err(anyhow::anyhow!("timeout waiting for {path}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn next_minute() -> SystemTime {
|
||||||
|
let now = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH).unwrap();
|
||||||
|
let secs = now.as_secs();
|
||||||
|
let next = (secs / 60 + 1) * 60;
|
||||||
|
UNIX_EPOCH + Duration::from_secs(next)
|
||||||
|
}
|
||||||
|
|
||||||
/*──────────────── Handler ───────────────────*/
|
/*──────────────── Handler ───────────────────*/
|
||||||
struct Handler {
|
struct Handler {
|
||||||
kb: Arc<Mutex<tokio::fs::File>>,
|
kb: Arc<Mutex<tokio::fs::File>>,
|
||||||
@ -180,10 +189,32 @@ impl Relay for Handler {
|
|||||||
// channel just to satisfy the “stream Empty” return type
|
// channel just to satisfy the “stream Empty” return type
|
||||||
let (tx, rx) = tokio::sync::mpsc::channel(1);
|
let (tx, rx) = tokio::sync::mpsc::channel(1);
|
||||||
|
|
||||||
// forward packets from gRPC to AppSrc
|
// -------- 1 clip‑tap variables ----------------------------
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH, Duration};
|
||||||
|
let mut capturing = Vec::with_capacity(200_000); // ~1 s @128 kbit
|
||||||
|
let mut next_min_boundary = next_minute();
|
||||||
|
|
||||||
|
// -------- 2 forward packets + collect for clip‑tap --------
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut inbound = req.into_inner();
|
let mut inbound = req.into_inner();
|
||||||
while let Some(pkt) = inbound.next().await.transpose()? {
|
while let Some(pkt) = inbound.next().await.transpose()? {
|
||||||
|
/* ---- clip‑tap: accumulate raw AAC ----- */
|
||||||
|
capturing.extend_from_slice(&pkt.data);
|
||||||
|
if capturing.len() > 192_000 { // keep at most ~1 s
|
||||||
|
capturing.truncate(192_000);
|
||||||
|
}
|
||||||
|
if tracing::enabled!(tracing::Level::TRACE)
|
||||||
|
&& SystemTime::now() >= next_min_boundary {
|
||||||
|
if !capturing.is_empty() {
|
||||||
|
let ts = chrono::Local::now()
|
||||||
|
.format("%Y%m%d-%H%M%S").to_string();
|
||||||
|
let path = format!("/tmp/mic-{ts}.aac");
|
||||||
|
std::fs::write(&path, &capturing).ok();
|
||||||
|
tracing::debug!("📼 wrote mic clip → {}", path);
|
||||||
|
}
|
||||||
|
capturing.clear();
|
||||||
|
next_min_boundary = next_minute();
|
||||||
|
}
|
||||||
static CNT: std::sync::atomic::AtomicU64 =
|
static CNT: std::sync::atomic::AtomicU64 =
|
||||||
std::sync::atomic::AtomicU64::new(0);
|
std::sync::atomic::AtomicU64::new(0);
|
||||||
let n = CNT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
let n = CNT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||||
@ -240,7 +271,7 @@ impl Relay for Handler {
|
|||||||
Ok(Response::new(Box::pin(s)))
|
Ok(Response::new(Box::pin(s)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*────────────── USB-reset RPC ───────────*/
|
/*────────────── USB-reset RPC ────────────*/
|
||||||
async fn reset_usb(
|
async fn reset_usb(
|
||||||
&self,
|
&self,
|
||||||
_req: Request<Empty>,
|
_req: Request<Empty>,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user