Skip to main content

Server

Struct Server 

Source
pub struct Server { /* private fields */ }
Expand description

High-level RTSP server orchestrator.

Owns the mount registry, session manager, and transport layer. Delegates TCP connection handling to crate::transport::tcp and RTP delivery to UdpTransport.

§Simple usage (single stream)

use rtsp::Server;
let mut server = Server::new("0.0.0.0:8554");
server.start().unwrap();
// server.send_frame(&h264_data, 3000).unwrap();

§Multi-mount usage

use rtsp::Server;
use rtsp::media::h264::H264Packetizer;
let mut server = Server::new("0.0.0.0:8554");
server.add_mount("/cam1", Box::new(H264Packetizer::with_random_ssrc(96)));
server.start().unwrap();
// server.send_frame_to("/cam1", &data, 3000).unwrap();

Implementations§

Source§

impl Server

Source

pub fn new(bind_addr: &str) -> Self

Create a server with a default H.264 mount at /stream.

bind_addr must be host:port with an explicit non-zero port (e.g. 127.0.0.1:8554). Port 0 is not allowed; validation happens in start.

Source

pub fn new_with_mount_path(bind_addr: &str, mount_path: &str) -> Self

Create a server with a single H.264 mount at the given path.

Use this when the stream path is configurable (e.g. GStreamer mount-path property). bind_addr must be host:port with an explicit non-zero port.

Source

pub fn with_config(bind_addr: &str, config: ServerConfig) -> Self

Create a server with custom protocol/SDP configuration. A default H.264 mount at /stream is created automatically.

Source

pub fn with_packetizer(bind_addr: &str, packetizer: Box<dyn Packetizer>) -> Self

Create a server with a custom packetizer on the default mount.

Source

pub fn with_packetizer_and_config( bind_addr: &str, packetizer: Box<dyn Packetizer>, config: ServerConfig, ) -> Self

Create a server with a custom packetizer and protocol/SDP configuration.

Source

pub fn add_mount(&self, path: &str, packetizer: Box<dyn Packetizer>)

Register a named mount with its own packetizer.

Must be called before start.

Source

pub fn start(&mut self) -> Result<()>

Source

pub fn stop(&mut self)

Source

pub fn is_running(&self) -> bool

Source

pub fn send_frame(&self, data: &[u8], timestamp_increment: u32) -> Result<usize>

Send a raw encoded frame to the default mount (/stream).

Packetizes the data into RTP packets and delivers them to all subscribed playing sessions via UDP.

Source

pub fn send_frame_to( &self, mount_path: &str, data: &[u8], timestamp_increment: u32, ) -> Result<usize>

Send a raw encoded frame to a specific mount.

Packetizes the data using the mount’s codec and delivers the resulting RTP packets to all subscribed playing sessions.

Source

pub fn send_rtp_packet(&self, session_id: &str, payload: &[u8]) -> Result<usize>

Send a pre-packetized RTP packet to a specific session.

Source

pub fn broadcast_rtp_packet(&self, payload: &[u8]) -> Result<usize>

Broadcast a pre-packetized RTP packet to all playing sessions on the default mount.

Source

pub fn get_viewers(&self) -> Vec<Viewer>

Source

pub fn session_manager(&self) -> &SessionManager

Source

pub fn mounts(&self) -> &MountRegistry

Returns the mount registry (used by adapters that need mount access).

Source

pub fn config(&self) -> Arc<ServerConfig>

Returns the server’s protocol configuration.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more