1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#![deny(clippy::all)] #![forbid(unsafe_code)] #![recursion_limit = "256"] //! Implementation of [SRT](https://www.haivision.com/products/srt-secure-reliable-transport/) in pure safe rust. //! //! Generally used for live video streaming across lossy but high bandwidth connections. //! //! # Quick start //! ```rust //! use srt_tokio::SrtSocketBuilder; //! use futures::prelude::*; //! use bytes::Bytes; //! use std::time::Instant; //! use std::io; //! //! #[tokio::main] //! async fn main() //!# // keep this to quell `needless_doctest_main` warning //!# -> () //! { //! let sender_fut = async { //! let mut tx = SrtSocketBuilder::new_listen().local_port(2223).connect().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 = SrtSocketBuilder::new_connect("127.0.0.1:2223").connect().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(); //! } //! //! ``` //! mod builder; mod channel; mod codec; mod multiplex; mod pending_connection; pub mod tokio; mod util; use codec::PacketCodec; pub use crate::builder::{ConnInitMethod, SrtSocketBuilder}; pub use crate::multiplex::{multiplex, PackChan, StreamerServer}; pub use crate::tokio::SrtSocket; use srt_protocol::connection::{self, Connection, ConnectionSettings}; use srt_protocol::crypto; use srt_protocol::packet::{self, ControlPacket, Packet, PacketParseError}; use srt_protocol::protocol; use srt_protocol::SocketID;