Crate srt

Source
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::SrtSocketBuilder;
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 = 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();
}

Re-exports§

pub use crate::tokio::SrtSocket;

Modules§

protocol
tokio

Structs§

CCData
Defines all the data that CC algorithms need
Connection
ConnectionSettings
ControlPacket
A UDP packet carrying control information
DataPacket
A UDT packet carrying data
MsgNumber
PacketCodec
SeqNumber
SocketID
SrtCongestCtrl
SrtSocketBuilder
Struct to build sockets.
SrtVersion
Serialied, it looks like: major * 0x10000 + minor * 0x100 + patch
StreamerServer

Enums§

ConnInitMethod
Describes how this SRT entity will connect to the other.
Packet
Represents A UDT/SRT packet
PacketParseError

Traits§

CongestCtrl
Congestion control trait, sender side

Functions§

multiplex

Type Aliases§

PackChan