feat(fax): add fax routing, job tracking, inbox management, and T.38/UDPTL media support

This commit is contained in:
2026-04-20 20:43:42 +00:00
parent 3c010a3b1b
commit d2c18a4ebb
27 changed files with 4247 additions and 280 deletions
+54 -1
View File
@@ -10,7 +10,7 @@ use crate::mixer::RtpPacket;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::net::UdpSocket;
use tokio::sync::mpsc;
use tokio::sync::{mpsc, watch};
/// Channel pair for connecting a leg to the mixer.
pub struct LegChannels {
@@ -109,3 +109,56 @@ pub fn spawn_sip_outbound(
}
})
}
/// Spawn a raw UDP inbound task for non-RTP passthrough media such as T.38 UDPTL.
pub fn spawn_raw_udp_inbound(
media_socket: Arc<UdpSocket>,
inbound_tx: mpsc::Sender<Vec<u8>>,
mut cancel_rx: watch::Receiver<bool>,
) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
let mut buf = vec![0u8; 2048];
loop {
tokio::select! {
_ = cancel_rx.changed() => break,
recv = media_socket.recv_from(&mut buf) => {
match recv {
Ok((n, _from)) => {
if n == 0 {
continue;
}
if inbound_tx.send(buf[..n].to_vec()).await.is_err() {
break;
}
}
Err(_) => break,
}
}
}
}
})
}
/// Spawn a raw UDP outbound task for non-RTP passthrough media such as T.38 UDPTL.
pub fn spawn_raw_udp_outbound(
media_socket: Arc<UdpSocket>,
remote_media: SocketAddr,
mut outbound_rx: mpsc::Receiver<Vec<u8>>,
mut cancel_rx: watch::Receiver<bool>,
) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
loop {
tokio::select! {
_ = cancel_rx.changed() => break,
pkt = outbound_rx.recv() => {
match pkt {
Some(packet) => {
let _ = media_socket.send_to(&packet, remote_media).await;
}
None => break,
}
}
}
}
})
}