pub struct Producer { /* private fields */ }Expand description
Writes frames to a group in order.
Each group is delivered independently over a QUIC stream. Use Self::write_frame for simple single-buffer frames, or Self::create_frame for multi-chunk streaming writes.
The writer cannot be cloned; move it to its next owner instead.
let _: moq_net::group::Producer = producer.clone();Implementations§
Source§impl Producer
impl Producer
Sourcepub fn timescale(&self) -> Option<Timescale>
pub fn timescale(&self) -> Option<Timescale>
The parent track’s timescale, or None when it declared no timeline.
Sourcepub fn write_frame(&mut self, frame: Frame) -> Result<()>
pub fn write_frame(&mut self, frame: Frame) -> Result<()>
Write a whole frame, its payload one contiguous buffer.
If you want to write multiple chunks, use Self::create_frame to get a frame producer. But an upfront size is required.
Its timestamp is converted into the parent track’s timescale. On a scale-less track it
is Timestamp::unscaled at this group’s start; a frame that doesn’t match its track
is Error::TimestampMismatch. So is one below the previous frame’s timestamp: a
group’s timestamps never decrease, so a stream with B-frames stamps decode time and
carries presentation time in its payload. The frame’s frame::Frame::created is
replaced with when it enters this group, so a frame copied from another group is restamped.
Sourcepub fn create_frame(self, frame: Info) -> Result<Producer>
pub fn create_frame(self, frame: Info) -> Result<Producer>
Create a frame with an upfront size and presentation timestamp, streamed in
chunks. The returned frame::Producer takes this writer, so only one frame is
open at a time; its finish hands the writer back.
Use Self::write_frame for a frame already in one buffer.
The timestamp is converted into the parent track’s timescale, so the scale you
build it with doesn’t have to match the track. A frame the group cannot take
aborts the group with the error: Error::FrameTooLarge if the declared size
exceeds 32 MiB, what a copy holds (refused before allocating),
Error::TimestampMismatch if the timestamp can’t be converted or falls below the
previous frame’s, or Error::Closed once the group finished.
The declared size is allocated up front while the frames in flight through the origin handle fit its budget, and grows with the bytes written past that, so a peer’s declaration cannot commit memory it never sends.
Sourcepub fn finish_at(self, end: u64) -> Result<Finished>
pub fn finish_at(self, end: u64) -> Result<Finished>
End the group whole at end, the exclusive end of its presentation in its track’s
timescale, returning the Finished group: no more frames can be written, but it can
still be read or aborted.
A finished group’s own end bounds how long it stays fresh, so the last group of a
paused or finished track ages out without a successor (see
track::Info::max_age). Its span, from its start to end, holds no other group’s
start, so no successor may start before end. An end below the group’s start or
below any of its frames’ timestamps is Error::TimestampMismatch, which aborts the
group; one equal to either is a group that presents no further. Fails with the abort
error if the group was already aborted.
Sourcepub fn finish(self) -> Result<Finished>
pub fn finish(self) -> Result<Finished>
End the group without saying where it ends, returning the Finished group: every
frame written still reaches its readers, but they can’t tell the group is whole, since
only Self::finish_at declares the end a media reader checks against.
What a producer that doesn’t know its group’s end calls, and how a relay ends a
group that expired or arrived partial. Fails with the abort error if the group was
already aborted.
Sourcepub fn abort(self, err: Error) -> Result<()>
pub fn abort(self, err: Error) -> Result<()>
Abort the group with the given error.
Consumes the writer. Drops the cached frames so a stale Consumer can’t pin
their buffers in memory forever; consumers that haven’t drained yet surface the
abort error instead of the leftover cache.
Sourcepub fn poll_ready(&self, waiter: &Waiter, frame: &Info) -> Poll<()>
pub fn poll_ready(&self, waiter: &Waiter, frame: &Info) -> Poll<()>
Resolves once a reader holds the group and the next frame, described by frame, fits
within 16 MB past the end of the last frame its fastest reader took, so a local writer
runs no further ahead than the live tail keeps behind that reader.
Ready once the group is closed, so the next write surfaces why. A reader that took every committed frame is waiting on the writer, so it never holds the writer back, even for a frame larger than the window, and one whose next frame was shed has fallen off the group and is not waited on. Writing without waiting never fails: the group sheds its front instead.
Sourcepub async fn ready(&self, frame: &Info)
pub async fn ready(&self, frame: &Info)
Resolves once a reader holds the group and the next frame, described by frame, fits
within 16 MB past the end of the last frame its fastest reader took, so a local writer
runs no further ahead than the live tail keeps behind that reader.
Ready once the group is closed, so the next write surfaces why. A reader that took every committed frame is waiting on the writer, so it never holds the writer back, even for a frame larger than the window, and one whose next frame was shed has fallen off the group and is not waited on. Writing without waiting never fails: the group sheds its front instead.
Awaits poll_ready.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
One past the index of the last frame written (completed or in-flight), which is also the index the next frame will get.
Counts any frames the group started past, so it’s the group’s logical length rather than the number of frames this handle holds.
Sourcepub fn latest(&self) -> Option<Timestamp>
pub fn latest(&self) -> Option<Timestamp>
The highest timestamp written so far, or None before a timed frame.
A group’s timestamps never decrease, so a timed frame below it is refused.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
Resolves once the group’s outcome is final: Ok once finished, or the abort error,
including eviction.
Sourcepub async fn closed(&self) -> Result<()>
pub async fn closed(&self) -> Result<()>
Resolves once the group’s outcome is final: Ok once finished, or the abort error,
including eviction.
Awaits poll_closed.
Sourcepub fn demand(&self) -> Demand
pub fn demand(&self) -> Demand
Watch reader demand without keeping the group alive, such as for a paced flight to see
its riders leave. track::FillGroups::poll_unwanted resolves as soon as readers take the group.