StreamState

Struct StreamState 

Source
pub struct StreamState {
Show 15 fields pub id: u32, pub mode: StreamMode, pub stream_key: Option<String>, pub publish_type: Option<String>, pub started_at: Option<Instant>, pub has_video_header: bool, pub has_audio_header: bool, pub has_metadata: bool, pub last_video_ts: u32, pub last_audio_ts: u32, pub video_frames: u64, pub audio_frames: u64, pub keyframes: u64, pub bytes_received: u64, pub gop_buffer: GopBuffer,
}
Expand description

Per-stream state

Fields§

§id: u32

Message stream ID

§mode: StreamMode

Current mode

§stream_key: Option<String>

Stream key/name (for publish/play)

§publish_type: Option<String>

Publish type (“live”, “record”, “append”)

§started_at: Option<Instant>

Time when stream became active

§has_video_header: bool

Whether we’ve received video sequence header

§has_audio_header: bool

Whether we’ve received audio sequence header

§has_metadata: bool

Whether we’ve received metadata

§last_video_ts: u32

Last video timestamp

§last_audio_ts: u32

Last audio timestamp

§video_frames: u64

Video frames received

§audio_frames: u64

Audio frames received

§keyframes: u64

Keyframes received

§bytes_received: u64

Total bytes received on this stream

§gop_buffer: GopBuffer

GOP buffer for late-joiner support

Implementations§

Source§

impl StreamState

Source

pub fn new(id: u32) -> Self

Create a new stream state

Source

pub fn start_publish(&mut self, stream_key: String, publish_type: String)

Start publishing on this stream

Source

pub fn start_play(&mut self, stream_name: String)

Start playing on this stream

Source

pub fn stop(&mut self)

Stop the stream

Source

pub fn is_publishing(&self) -> bool

Check if stream is publishing

Source

pub fn is_playing(&self) -> bool

Check if stream is playing

Source

pub fn is_ready(&self) -> bool

Check if stream is ready (has required headers)

Source

pub fn duration(&self) -> Option<Duration>

Get stream duration

Source

pub fn on_video( &mut self, timestamp: u32, is_keyframe: bool, is_header: bool, size: usize, )

Update video state

Source

pub fn on_audio(&mut self, timestamp: u32, is_header: bool, size: usize)

Update audio state

Source

pub fn on_metadata(&mut self)

Mark metadata received

Source

pub fn bitrate(&self) -> Option<u64>

Get bitrate estimate (bits per second)

Trait Implementations§

Source§

impl Debug for StreamState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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