srt_tokio/lib.rs
1#![forbid(unsafe_code)]
2#![recursion_limit = "256"]
3
4//! Implementation of [SRT](https://www.haivision.com/products/srt-secure-reliable-transport/) in pure safe rust.
5//!
6//! Generally used for live video streaming across lossy but high bandwidth connections.
7//!
8//! # Quick start
9//! ```rust
10//! use srt_tokio::SrtSocket;
11//! use futures::prelude::*;
12//! use bytes::Bytes;
13//! use std::time::Instant;
14//! use std::io;
15//!
16//! #[tokio::main]
17//! async fn main()
18//!# // keep this to quell `needless_doctest_main` warning
19//!# -> ()
20//! {
21//! let sender_fut = async {
22//! let mut tx = SrtSocket::builder().listen_on(2223).await?;
23//!
24//! let iter = ["1", "2", "3"];
25//!
26//! tx.send_all(&mut stream::iter(&iter)
27//! .map(|b| Ok((Instant::now(), Bytes::from(*b))))).await?;
28//! tx.close().await?;
29//!
30//! Ok::<_, io::Error>(())
31//! };
32//!
33//! let receiver_fut = async {
34//! let mut rx = SrtSocket::builder().call("127.0.0.1:2223", None).await?;
35//!
36//! assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"1"[..].into()));
37//! assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"2"[..].into()));
38//! assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"3"[..].into()));
39//! assert_eq!(rx.try_next().await?, None);
40//!
41//! Ok::<_, io::Error>(())
42//! };
43//!
44//! futures::try_join!(sender_fut, receiver_fut).unwrap();
45//! }
46//!
47//! ```
48//!
49
50mod listener;
51mod net;
52mod socket;
53mod watch;
54
55pub use net::bind_socket;
56pub use srt_protocol::access;
57pub use srt_protocol::options;
58
59pub use crate::{
60 listener::{ConnectionRequest, ListenerStatistics, SrtIncoming, SrtListener},
61 socket::{SocketStatistics, SrtSocket, SrtSocketBuilder},
62};