add media and start working on RTP tools for testing capture
This commit is contained in:
parent
ffd7fedf70
commit
f774eb52cb
13
aes67.c
13
aes67.c
|
@ -252,12 +252,10 @@ static void aes67_rx_net(struct work_struct *work)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.msg_flags = MSG_WAITFORONE;
|
msg.msg_flags = MSG_DONTWAIT;
|
||||||
|
|
||||||
snd_printk(KERN_INFO "Starting network receive loop\n");
|
snd_printk(KERN_INFO "Starting network receive loop\n");
|
||||||
for (;;) {
|
while (stream->running) {
|
||||||
if (!stream->running)
|
|
||||||
break;
|
|
||||||
|
|
||||||
struct kvec iv;
|
struct kvec iv;
|
||||||
iv.iov_base = recv_buf;
|
iv.iov_base = recv_buf;
|
||||||
|
@ -267,10 +265,7 @@ static void aes67_rx_net(struct work_struct *work)
|
||||||
iv.iov_len, msg.msg_flags);
|
iv.iov_len, msg.msg_flags);
|
||||||
|
|
||||||
if (msglen == -EAGAIN) {
|
if (msglen == -EAGAIN) {
|
||||||
snd_printk(
|
msleep(10);
|
||||||
KERN_WARNING
|
|
||||||
"Failed to receive message. With EAGAIN, Sleeping and trying again\n");
|
|
||||||
msleep(1000);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +501,7 @@ static int aes67_stream_create(struct aes67_stream **stream, int direction)
|
||||||
|
|
||||||
struct sockaddr_in addr = { .sin_family = AF_INET,
|
struct sockaddr_in addr = { .sin_family = AF_INET,
|
||||||
.sin_port = htons(9375),
|
.sin_port = htons(9375),
|
||||||
.sin_addr = { htonl(INADDR_LOOPBACK) } };
|
.sin_addr = { htonl(INADDR_ANY) } };
|
||||||
|
|
||||||
strm->socket->ops->bind(strm->socket, (struct sockaddr *)&addr,
|
strm->socket->ops->bind(strm->socket, (struct sockaddr *)&addr,
|
||||||
sizeof(addr));
|
sizeof(addr));
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
target/
|
||||||
|
Cargo.lock
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "rtp-tools"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.87"
|
||||||
|
clap = { version = "4.5.17", features = ["derive"] }
|
|
@ -0,0 +1 @@
|
||||||
|
target/debug/rtp-tools
|
|
@ -0,0 +1,87 @@
|
||||||
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::Read,
|
||||||
|
vec::Vec,
|
||||||
|
cmp::min
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
#[arg(short, long, value_name = "x.x.x.x:port")]
|
||||||
|
bind: Option<String>,
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Option<Commands>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand, Debug)]
|
||||||
|
enum Commands {
|
||||||
|
Play {
|
||||||
|
file: std::path::PathBuf,
|
||||||
|
addr: String,
|
||||||
|
},
|
||||||
|
Listen,
|
||||||
|
}
|
||||||
|
|
||||||
|
const MTU: usize = 1500;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
let cli = Args::parse();
|
||||||
|
|
||||||
|
match &cli.command {
|
||||||
|
Some(Commands::Play { file, addr }) => {
|
||||||
|
println!("Playing {file:?} -> {addr}");
|
||||||
|
//open file
|
||||||
|
let mut fd = File::open(file)?;
|
||||||
|
|
||||||
|
//buffer
|
||||||
|
let mut file_buffer = Vec::with_capacity(1500 * 512);
|
||||||
|
let read_bytes = fd.read_to_end(&mut file_buffer)?;
|
||||||
|
|
||||||
|
let buffer_len = file_buffer.len();
|
||||||
|
println!("ReadBytes {read_bytes} Len {buffer_len}");
|
||||||
|
|
||||||
|
let header_len = MTU - 8 - 176;
|
||||||
|
let mut packet_len = buffer_len / header_len;
|
||||||
|
if buffer_len % header_len > 0 {
|
||||||
|
packet_len += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut packets: Vec<Vec<u8>> = vec![Vec::with_capacity(header_len); packet_len];
|
||||||
|
let loop_len = min(buffer_len, header_len);
|
||||||
|
|
||||||
|
'outer: for i in 0..loop_len {
|
||||||
|
for j in 0..packet_len {
|
||||||
|
let index = i + (header_len * j);
|
||||||
|
if index == buffer_len {
|
||||||
|
break 'outer;
|
||||||
|
}
|
||||||
|
packets[j].push(file_buffer[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for packet in packets {
|
||||||
|
let s = String::from_utf8(packet)?;
|
||||||
|
println!("Packet: {s}");
|
||||||
|
}
|
||||||
|
|
||||||
|
//open socket
|
||||||
|
|
||||||
|
//stream file to socket
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Some(Commands::Listen) => {
|
||||||
|
println!("Listen!");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
println!("Use --help for commands");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue