Conversation
a-wing
left a comment
There was a problem hiding this comment.
There have a very import problem:
Live777 support mutil-stream:
- each stream include a datachannel
- each datachannel should use independent udp port
a-wing
left a comment
There was a problem hiding this comment.
- Rename add
ptz_udp=>channelordatachannel - Merge datachannel some config and add example
conf/live777.toml - Signed CLA: https://github.com/binbat/live777/blob/main/.github/CLA.md#list-of-contributors
|
BTW: Must resolved this conflicts |
a-wing
left a comment
There was a problem hiding this comment.
- Need check each commit can pass CI
formatandlint - Add some unit test
| # listen_addr:listen_port - liveion listens here for replies from downstream | ||
| # target_host:target_port - liveion sends DataChannel messages to this address |
There was a problem hiding this comment.
listen_addr:listen_port => listen_host:listen_port
Usually listen_addr = listen_host + listen_port
| // Format addresses, wrapping IPv6 in brackets | ||
| let target = if target_host.contains(':') { | ||
| format!("[{}]:{}", target_host, target_port) | ||
| } else { | ||
| format!("{}:{}", target_host, target_port) | ||
| }; | ||
| let bind_addr = if listen_addr.contains(':') { | ||
| format!("[{}]:{}", listen_addr, listen_port) | ||
| } else { | ||
| format!("{}:{}", listen_addr, listen_port) | ||
| }; |
There was a problem hiding this comment.
| // DataChannel ↔ UDP bidirectional forwarding. | ||
| // Messages from the WHIP publisher arrive on the subscribe channel. | ||
| let dc_rx = self.data_channel_forward.subscribe.subscribe(); | ||
| let dc_tx = self.data_channel_forward.publish.clone(); | ||
| let stream_cfg = self.ptz_udp.streams.get(&self.stream).cloned(); | ||
| super::channel::spawn_channel( | ||
| self.stream.clone(), | ||
| dc_rx, | ||
| dc_tx, | ||
| stream_cfg, | ||
| ) | ||
| .await; |
There was a problem hiding this comment.
If has stream no set about data_channel config. We shouldn't start any data_channel function
| let socket = match UdpSocket::bind(&bind_addr).await { | ||
| Ok(s) => { | ||
| info!("channel [{}]: listen={} target={}", stream, bind_addr, target); | ||
| Arc::new(s) | ||
| } | ||
| Err(e) => { | ||
| warn!("channel [{}]: bind socket failed: {}", stream, e); | ||
| return; | ||
| } | ||
| }; |
There was a problem hiding this comment.
There function should add a return Error
When UdpSocket::bind has error, should stop and return Error
| tokio::spawn(async move { | ||
| loop { | ||
| match dc_rx.recv().await { | ||
| Ok(data) => { | ||
| if let Err(e) = socket_dc.send_to(&data, &target).await { | ||
| warn!("channel [{}]: send to {} failed: {}", stream_dc, target, e); | ||
| } else { | ||
| debug!("channel [{}]: DC->UDP {} bytes -> {}", stream_dc, data.len(), target); | ||
| } | ||
| } | ||
| Err(broadcast::error::RecvError::Lagged(n)) => { | ||
| warn!("channel [{}]: lagged, dropped {} messages", stream_dc, n); | ||
| } | ||
| Err(broadcast::error::RecvError::Closed) => { | ||
| info!("channel [{}]: channel closed", stream_dc); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| // --- UDP -> DataChannel (passthrough, no wrapping) --- | ||
| tokio::spawn(async move { | ||
| let mut buf = vec![0u8; 1024]; | ||
| loop { | ||
| match socket.recv_from(&mut buf).await { | ||
| Ok((n, addr)) => { | ||
| let data = buf[..n].to_vec(); | ||
| debug!("channel [{}]: UDP->DC {} bytes from {}", stream, n, addr); | ||
| if let Err(e) = dc_tx.send(data) { | ||
| warn!("channel [{}]: forward to DC failed: {}", stream, e); | ||
| } | ||
| } | ||
| Err(e) => { | ||
| warn!("channel [{}]: recv_from failed: {}", stream, e); | ||
| } | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
There has two tokio::spawn. I think merge only one tokio::spawn is more good
|
|
||
| glob = "0.3" | ||
| url = { version = "2.5", optional = true } | ||
| url = { workspace = true, optional = true } |
There was a problem hiding this comment.
If you want to remove url use std parse url, there no change here.
If you want to use url, change here is ok
Codecov Report❌ Patch coverage is
... and 57 files with indirect coverage changes 🚀 New features to boost your workflow:
|
No description provided.