Skip to main content

MediaSource

Struct MediaSource 

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

A video track with its renditions and an audio track, fed with encoded frames and published as LOC with the MSF catalog and media timeline. Once its broadcast is closed or dropped, its pushes fail and its waits end with an error.

Implementations§

Source§

impl MediaSource

Source

pub fn configure_video(&self, codec: &str) -> Result<(), MediaSourceError>

codec is a WebCodecs codec string: avc1.* or avc3.* and hvc1.* or hev1.* in Annex B, vp8, vp09.* or av01.*.

Source

pub fn push_video( &self, data: impl Into<Bytes>, timestamp_micros: u64, ) -> Result<(), MediaSourceError>

One encoded frame, after configure_video. A keyframe opens a group and sets the track’s configuration (for H.264 and H.265, its parameter sets). timestamp_micros must not run backwards.

Source

pub fn configure_audio( &self, codec: &str, sample_rate: u32, channels: u8, description: Option<&[u8]>, ) -> Result<(), MediaSourceError>

codec is opus, or an AAC mp4a.40.* whose description is the AudioSpecificConfig.

Source

pub fn push_audio( &self, data: impl Into<Bytes>, timestamp_micros: u64, level: Option<AudioLevel>, ) -> Result<(), MediaSourceError>

One encoded audio frame, after configure_audio; level is written as its LOC Audio Level property.

Source

pub fn add_rendition( &self, name: &str, label: impl Into<String>, bitrate: Option<u64>, framerate: Option<u32>, ) -> Result<Rendition, MediaSourceError>

Another encoding of the video in the track <video>_<name>: feed it frames of the same pictures, with keyframes on the same pictures as the video’s. It joins the video’s switching set (draft-ietf-moq-cmsf-01 §3.2). bitrate (bits per second) and framerate go into the catalog.

Source

pub async fn remove_track(&self, kind: TrackKind) -> Result<()>

Ends the video (with its renditions) or the audio with PUBLISH_DONE and sends the catalog without it. Stop pushing its media first; configuring it again and pushing publishes it again. Fails when the relay session has ended.

Source

pub async fn keyframe_request(&self) -> Result<()>

Resolves the next time a subscriber asks for a new group (NEW_GROUP_REQUEST) or the broadcast needs one: encode the next frame of the video and of every rendition as a keyframe then. It does not end with the session: wait for Session::closed beside it.

Source

pub async fn demand_change(&self) -> Result<TrackDemand>

The next change of whether a subscriber takes one of the source’s tracks. A change replaces its track’s unread one, so a late reader gets each track’s latest. Fails for a source added without on_demand.

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.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> MaybeSync for T
where T: Sync,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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