Skip to main content

StreamBuilder

Struct StreamBuilder 

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

A builder for creating RTMP streaming sessions with a simplified API.

This builder provides a fluent interface for configuring and starting RTMP streaming without needing to manually manage the server lifecycle.

§Example

use ez_ffmpeg::rtmp::embed_rtmp_server::EmbedRtmpServer;

let handle = EmbedRtmpServer::stream_builder()
    .address("localhost:1935")
    .app_name("live")
    .stream_key("stream1")
    .input_file("video.mp4")
    // readrate defaults to 1.0 (realtime)
    .start()?;

handle.wait()?;

Implementations§

Source§

impl StreamBuilder

Source

pub fn new() -> Self

Creates a new StreamBuilder with default settings.

By default, readrate is set to 1.0 (real-time playback speed), which is equivalent to FFmpeg’s -re flag. This is the recommended setting for live RTMP streaming scenarios.

Source

pub fn address(self, address: impl Into<String>) -> Self

Sets the address for the RTMP server (e.g., “localhost:1935”).

Source

pub fn app_name(self, app_name: impl Into<String>) -> Self

Sets the RTMP application name.

Source

pub fn stream_key(self, stream_key: impl Into<String>) -> Self

Sets the stream key (publishing name).

Source

pub fn input_file(self, path: impl AsRef<Path>) -> Self

Sets the input file path to stream.

Source

pub fn readrate(self, rate: f32) -> Self

Sets the read rate for the input file.

A value of 1.0 means realtime playback speed. This is useful for simulating live streaming from a file.

Source

pub fn gop_limit(self, limit: usize) -> Self

Sets the GOP (Group of Pictures) limit for the RTMP server.

This controls how many GOPs are buffered for new subscribers.

Source

pub fn max_connections(self, max: usize) -> Self

Sets the maximum number of connections the server will accept.

Source

pub fn start(self) -> Result<StreamHandle, StreamError>

Starts the RTMP streaming session.

This method validates all required parameters, starts the RTMP server, and begins streaming the input file.

§Required Parameters
  • address: The server address
  • app_name: The RTMP application name
  • stream_key: The stream key (publishing name)
  • input_file: The file to stream
§Returns

A StreamHandle that can be used to wait for completion or manage the stream.

§Errors

Returns StreamError if:

  • Any required parameter is missing
  • The input file does not exist
  • The server fails to start
  • FFmpeg context creation fails

Trait Implementations§

Source§

impl Default for StreamBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V