Skip to main content

X11Pipeline

Struct X11Pipeline 

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

Everything the X11 host-ARGB path has to remember between frames.

Unlike the Wayland backend, X11 capture has no compositor to report what changed, so this context exists to hold the state that stands in for that missing damage signal: the per-stripe hashes and the persistent encoder session that let process() discover damage by comparing content frame-to-frame. Hardware full-frame H.264 runs through decide_hw_fullframe; the software path (JPEG, striped or full-frame software H.264) runs through encode_cpu with hash_damage=true.

Recording fan-out (socket sink and MP4 recorder) is handled at the delivery layer; a consumer needing a keyframe goes through X11Pipeline::request_idr like everyone else.

Implementations§

Source§

impl X11Pipeline

Source

pub fn new(settings: RustCaptureSettings) -> Self

Build the context, choosing the full-frame encoder for the X11 host-ARGB path.

§Arguments
  • settings - Capture configuration. The output_mode, use_cpu, and encode_node_index fields drive encoder selection.
§Encoder selection
  1. NVENC — on an NVIDIA driver (or no detectable GPU, since the attempt is cheap).
  2. VA-API — on any other GPU driver. A 4:4:4 request is carried into the attempt, so a device that cannot encode 4:4:4 fails here and falls through rather than being ruled out in advance.
  3. SoftwareX11Encoder::None: the striped (or, with video_fullframe, full-frame) software path inside encode_cpu, encoding with the build’s software H.264 encoder (SOFTWARE_H264_ENCODER). This is also where a 4:4:4 request lands when no hardware encoder can carry it; libx264 carries it, OpenH264 encodes it 4:2:0.
Source

pub fn request_idr(&mut self)

Request an on-demand keyframe on the next processed frame.

Source

pub fn encoder_name(&self) -> &str

Return a human-readable encoder type string for logging.

Source

pub fn colorspace_desc(&self) -> &'static str

The Colorspace: field for this pipeline’s stream log, describing what its encoder settled on: VA-API only reaches 4:4:4 when the driver and FFmpeg build carry it, and the software encoder only when the build’s one does (SOFTWARE_H264_FULLCOLOR).

Source

pub fn reshape( &mut self, settings: &RustCaptureSettings, size_changed: bool, ) -> bool

Adapt the live pipeline to recreated capture surfaces without rebuilding it.

§Arguments
  • settings - New geometry plus current live rates.
  • size_changed - Whether the capture dimensions changed.
§Returns

true if the pipeline was successfully adapted in place; false when the active encoder cannot follow (VAAPI on resize) and the caller must rebuild.

Source

pub fn update_rate(&mut self, bitrate_kbps: i32, vbv_multiplier: f64, fps: f64)

Apply a runtime rate-control / framerate change: the CBR target bitrate + VBV (kbps / kb; ignored unless CBR is active) and the target fps. NVENC reconfigures its live session immediately; VAAPI re-opens its codec context to apply the new rate; the software path picks the new values up on the next process() (encode_cpu reads the updated settings and reconfigures each stripe’s encoder).

Source

pub fn update_tunables(&mut self, t: &LiveTunables)

Apply live per-frame tunables (quality, paint-over, streaming mode, keyframe cadence); every encoder re-reads them from the settings on the next process().

Source

pub fn process(&mut self, argb: &[u8], stride: usize) -> Vec<EncodedStripe>

Encode one host-ARGB frame and return the encoded stripes.

§Arguments
  • argb - Packed BGRA pixel buffer (B,G,R,A byte order, stride bytes per row).
  • stride - Bytes per row (must equal width * 4 for the software path).
§Returns

Vec of EncodedStripe — empty when nothing changed.

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
§

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

§

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

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Ungil for T
where T: Send,

§

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

§

fn vzip(self) -> V

§

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