Skip to main content

Producer

Struct Producer 

Source
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

Source

pub fn timescale(&self) -> Option<Timescale>

The parent track’s timescale, or None when it declared no timeline.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn consume(&self) -> Consumer

Create a new consumer for the group.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Deref for Producer

Source§

type Target = Info

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for Producer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
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