Skip to main content

PauseGate

Struct PauseGate 

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

Stops a branch taking frames, and takes the paused span out of the timeline of what it does take.

Video (PauseGate::new) or audio (PauseGate::for_audio) — one type rather than two, because a recording of both needs its two gates to remove the same span, and two implementations would be two chances for them to stop meaning the same thing. Which kind it takes is fixed at construction and declared, so wiring one to the wrong stream is a link error rather than a file whose sound has slid away from its picture.

§What it is for

Pausing a recording. The file has to stay open and then continue, with no trace of the pause in it — a still picture lasting however long it was paused is not what anybody means by the word. So dropping the frames is only half of it: the frames that follow have to move back by as much as was skipped, or the gap simply moves downstream.

§Not ControlMsg::Pause

That control stops queues pulling, which backpressures whatever feeds them. On a Tee branch it would reach back through the fan-out and stall the source for every other branch — pausing a recording would freeze the preview beside it. This drops frames instead, which nothing upstream can tell.

§How long the pause was

Measured in the source’s own timestamps: the first frame dropped marks where the pause began, and the first frame forwarded after it marks where it ended. That is what makes this composable — it needs to know nothing about the rate, and it is correct even for a source whose rate varies.

It does assume frames keep arriving while paused, which is what it counts. A source that stops entirely cannot be measured this way — but neither does its own timeline advance while it is stopped, so the span this would have subtracted is one that was never there. The two agree.

§Where it goes

In front of the encoder, on frames. Behind one, the encoder would spend the whole pause compressing frames that are about to be thrown away.

Directly in front of it, with nothing that buffers in between. What this forwards is a wrapper holding a reference to the picture rather than the pooled reference it was handed, and a frame reference keeps the buffer allocated while leaving the producer’s pool free to hand that slot out again — the distinction ChangeGate and both video compositors keep retire lists for. This needs none, because the wrapper never outlives the call that made it: the push downstream is synchronous, the encoder copies what it is given before returning, and the pooled reference this was handed is alive for the whole of that. A Queue between the two would end that — the wrapper would outlive the pooled reference, and the compositor would be free to draw into the slot it still names.

§Cost

A reference to the frames it forwards and nothing at all for the ones it drops. No pixels are read, copied or converted.

Implementations§

Source§

impl PauseGate

Source

pub fn new(name: impl Into<String>) -> (Self, PauseGateHandle)

A gate on video frames. Starts running; nothing is paused until a handle says so.

Source

pub fn for_audio(name: impl Into<String>) -> (Self, PauseGateHandle)

A gate on audio frames, for the other track of the same recording.

MemoryDomain::System because that is where audio is: there is no GPU-resident audio frame in this crate, and stating it rather than accepting any domain keeps the link check as sharp here as it is on the video side.

Trait Implementations§

Source§

impl Element for PauseGate

Source§

fn name(&self) -> Arc<str>

Returns a cheap clone (refcount bump, not a deep copy) of this element’s name — crate::bus::BusEvent stores names as Arc<str> for exactly this reason: a hot path like crate::queue::Queue posting BusEvent::Dropped once per overflowed buffer shouldn’t pay for a fresh heap allocation every time it wants to report which element it is.
Source§

fn element_type(&self) -> ElementType

Source§

fn pp_log(&self) -> &PpLog

This element’s identity for crate::bus::Bus::post — same id/name as Element::name, just already wrapped as the crate::pp_log::PpLog its pp_info!/pp_warn!/pp_error! macros need. A stored private field, not built fresh per call, for the same reason name() returns a cheap Arc<str> clone instead of a fresh String — see its own docs.
Source§

fn pp_log_mut(&mut self) -> &mut PpLog

Mutable access to the same field Element::pp_log reads — used by crate::pipeline::ChainBuilder to stamp the owning crate::pipeline::Pipeline’s id onto every element that passes through it, via element_pp_log. Not meant to be called from anywhere else.
Source§

fn graph_id(&self) -> Option<ElementId>

A pre-reserved graph identity for elements that expose dynamic attachment handles. Most elements receive an ID from ChainBuilder and keep the default None implementation.
Source§

fn attach_context(&mut self, _context: &Arc<Context>)

Hands this element the pipeline it is being wired into, at the moment and for the reason Element::pp_log_mut hands it the pipeline’s identity: the clock, the playback clock and the bus are the pipeline’s to give, not the caller’s to choose. Read more
Source§

impl Sink for PauseGate

Source§

fn input_contract(&self) -> InputContract

Video frames. It reads a timestamp and forwards a reference, so where the pixels live is not its business.

Source§

fn consume(&mut self, buf: MediaBuffer) -> Result<()>

Processes one buffer synchronously on the caller’s thread. Read more
Source§

fn control(&mut self, msg: ControlMsg) -> Result<()>

Reacts to a ControlMsg (pause/resume/stop) and, for anything with a downstream of its own, forwards it on — same shape as consume, just a separate channel from MediaBuffer so it can reach every element (not just ones that already know how to interpret a data buffer) and, at a crate::queue::Queue, jump ahead of whatever data is backed up instead of waiting behind it. No default: every Sink has to consciously decide what this means for it, rather than silently dropping it.
Source§

fn ready_consume(&mut self) -> bool

Returns whether calling Self::consume can make progress now. Read more
Source§

impl Source for PauseGate

Source§

fn src_pads(&mut self) -> &mut [SrcPad]

Returns every output pad owned by this element. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Filter for T
where T: Source + Sink,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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