7个不稳定版本
0.4.4 | 2024年5月31日 |
---|---|
0.4.3 | 2023年9月25日 |
0.4.1 | 2023年3月11日 |
0.3.0 | 2022年1月14日 |
0.1.0 | 2020年9月23日 |
#59 在 视频
每月200 次下载
用于 5 个Crate(4个直接)
650KB
15K SLoC
纯Rust安全实现的SRT。
通常用于在具有高带宽但存在丢包的连接上进行实时视频流。
快速开始
use srt_tokio::SrtSocket;
use futures::prelude::*;
use bytes::Bytes;
use std::time::Instant;
use std::io;
#[tokio::main]
async fn main()
{
let sender_fut = async {
let mut tx = SrtSocket::builder().listen_on(2223).await?;
let iter = ["1", "2", "3"];
tx.send_all(&mut stream::iter(&iter)
.map(|b| Ok((Instant::now(), Bytes::from(*b))))).await?;
tx.close().await?;
Ok::<_, io::Error>(())
};
let receiver_fut = async {
let mut rx = SrtSocket::builder().call("127.0.0.1:2223", None).await?;
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"1"[..].into()));
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"2"[..].into()));
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"3"[..].into()));
assert_eq!(rx.try_next().await?, None);
Ok::<_, io::Error>(())
};
futures::try_join!(sender_fut, receiver_fut).unwrap();
}
依赖项
~9–20MB
~290K SLoC