Expand description
Implementation of SRT in pure safe rust.
Generally used for live video streaming across lossy but high bandwidth connections.
Quick start
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();
}
Modules
Structs
SRT provides a powerful set of statistical data on a socket. This data can be used to keep an eye on a socket’s health and track faulty behavior.
Connected SRT connection, generally created with SrtSocketBuilder
.