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
impl MediaSource
Sourcepub fn configure_video(&self, codec: &str) -> Result<(), MediaSourceError>
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.*.
Sourcepub fn push_video(
&self,
data: impl Into<Bytes>,
timestamp_micros: u64,
) -> Result<(), MediaSourceError>
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.
Sourcepub fn configure_audio(
&self,
codec: &str,
sample_rate: u32,
channels: u8,
description: Option<&[u8]>,
) -> Result<(), MediaSourceError>
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.
Sourcepub fn push_audio(
&self,
data: impl Into<Bytes>,
timestamp_micros: u64,
level: Option<AudioLevel>,
) -> Result<(), MediaSourceError>
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.
Sourcepub fn add_rendition(
&self,
name: &str,
label: impl Into<String>,
bitrate: Option<u64>,
framerate: Option<u32>,
) -> Result<Rendition, MediaSourceError>
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.
Sourcepub async fn remove_track(&self, kind: TrackKind) -> Result<()>
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.
Sourcepub async fn keyframe_request(&self) -> Result<()>
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.
Sourcepub async fn demand_change(&self) -> Result<TrackDemand>
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.