Skip to main content

GstreamerVideoCapture

Struct GstreamerVideoCapture 

Source
pub struct GstreamerVideoCapture {
    child: Child,
    stdout: ChildStdout,
    width: u32,
    height: u32,
    framerate: f64,
    next_index: u64,
    raw_buffer: Vec<u8>,
}
Expand description

Streaming video capture wrapping a gst-launch-1.0 child process.

Fields§

§child: Child§stdout: ChildStdout§width: u32§height: u32§framerate: f64§next_index: u64§raw_buffer: Vec<u8>

Pre-allocated scratch buffer for the raw bytes of one frame.

Implementations§

Source§

impl GstreamerVideoCapture

Source

pub fn from_default_camera( width: u32, height: u32, framerate: u32, ) -> Result<Self, Error>

Build a capture from the default OS camera via gst’s autovideosrc (M-CAM.0 / AUT-254).

On macOS autovideosrc routes to avfvideosrc; on Linux v4l2src; on Windows mfvideosrc. Caller picks the output dimensions + framerate — gst’s videoconvert step resizes / converts whatever the camera natively produces.

**macOS gotcha:** `avfvideosrc` requires
`NSCameraUsageDescription` in the bundled app's Info.plist.
Without it the gst pipeline fails with a misleading "device
busy" error AND the OS permission prompt never shows. See
`crates/app/tauri.conf.json` for the project's declaration.
§Errors

Cross-OS behaviour: on a host without a default camera the pipeline spawns but next_frame returns Error::EndOfStream as soon as the OS denies access / reports no device. Integration tests should call default_camera_available first and skip cleanly.

Source

pub fn from_camera( camera_id: &str, width: u32, height: u32, framerate: u32, ) -> Result<Self, Error>

Build a capture pinned to a specific camera resolved by its stable id (M-CAM.4). Re-probes list_cameras() at call time to turn camera_id into the OS-native source element + props (avfvideosrc device-index=N on macOS, mfvideosrc device-path=... on Windows, v4l2src device=... on Linux).

If the camera is in the enumeration but the parser couldn’t extract a gst_source for it (unusual — would indicate a gst-device-monitor output format the parser didn’t recognise), falls back to autovideosrc with a tracing::warn so the user still sees some camera. The picker just won’t be honored.

§Errors
Source

pub fn test_source( width: u32, height: u32, framerate: u32, ) -> Result<Self, Error>

Build a capture from videotestsrc at the given dimensions + framerate. The default videotestsrc pattern is the SMPTE colorbars — useful for visual smoke checks because every frame is visually distinct (animated subpattern).

Source

pub fn dimensions(&self) -> (u32, u32)

Width × height the captured frames will carry.

Source

pub fn framerate(&self) -> f64

Framerate the pipeline emits.

Source

pub fn frames_emitted(&self) -> u64

Cumulative frames emitted across next_frame calls.

Source

pub fn next_frame(&mut self) -> Result<VideoFrame, Error>

Read one BGRA frame. PTS is computed from the frame index and the captured framerate.

§Errors

Trait Implementations§

Source§

impl Debug for GstreamerVideoCapture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for GstreamerVideoCapture

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.

§

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, 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> 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