Initial gui working

This commit is contained in:
joeyahines committed 2026-10-16 18:19:26 -06:00
1 parent 43b1aaa9f7
commit 1ab9260a39
9 files changed
+3615 -103

No files matched your search

+1 -3
View File
@@ -1,11 +1,9 @@
mod udp_connection;
use crate::udp_connection::OpusUdpConnection;
use clap::{Parser, Subcommand};
use log::{LevelFilter, error};
use std::net::SocketAddr;
use std::sync::mpsc::channel;
use tap_core::audio_source_thread::AudioSourceThread;
use tap_core::udp_connection::OpusUdpConnection;
#[derive(Parser, Debug)]
#[command(version, about = "Tap sounds from a audio device and send them over a UDP socket", long_about = None)]
-39
View File
@@ -1,39 +0,0 @@
use std::io::{Read, Write};
use std::net::{SocketAddr, UdpSocket};
use std::time::Duration;
#[derive(Debug)]
pub struct OpusUdpConnection {
udp_socket: UdpSocket,
dest: SocketAddr,
}
impl OpusUdpConnection {
pub fn new(src: SocketAddr, dest: SocketAddr) -> Result<Self, std::io::Error> {
Ok(Self {
udp_socket: UdpSocket::bind(src)?,
dest,
})
}
#[allow(dead_code)]
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> std::io::Result<()> {
self.udp_socket.set_read_timeout(timeout)
}
}
impl Write for OpusUdpConnection {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.udp_socket.send_to(buf, self.dest)
}
fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}
impl Read for OpusUdpConnection {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
self.udp_socket.recv(buf)
}
}