embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

Camera

Struct Camera 

Source
pub struct Camera<'d, D: Driver<'d>> { /* private fields */ }
Expand description

Implementation of the USB Video Class 1.5, camera side.

Implementations§

Source§

impl<'d, D: Driver<'d>> Camera<'d, D>

Source

pub fn new( builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: Config<'d>, ) -> Self

Creates a new Camera device, and registers its control handler.

§Panics

If config has no format or more than 16, a format without a frame or with more than 255, a frame of zero size or without a frame interval or with more than 56, a zero frame interval, invalid still image configuration, a packet size below 13 or above the speed’s limit, or the control_buf of the builder is smaller than 48 bytes.

Source

pub fn settings(&self) -> StreamSettings<'d>

What the host selected for the stream, or the defaults before it selects anything.

Source

pub fn control_values(&self) -> ControlValues

Returns the current Processing Unit and Camera Terminal control values.

Source

pub fn take_controls_changed(&self) -> Option<ControlValues>

Returns updated control values if the host modified any since the last call.

Source

pub fn take_still_trigger(&self) -> Option<StillSettings<'d>>

Returns and clears the committed StillSettings if the host triggered a Method 2 still image capture via VS_STILL_IMAGE_TRIGGER_CONTROL.

Source

pub async fn wait_streaming(&mut self) -> StreamSettings<'d>

Waits until the host starts the stream (selects alternate setting 1 for isochronous, or commits the stream for bulk), then returns what it selected.

Source

pub fn start_frame(&mut self) -> FrameWriter<'_, 'd, D>

Starts streaming a video frame chunk by chunk without holding the full frame in RAM.

Source

pub fn start_frame_with_timestamp( &mut self, ts: PayloadTimestamp, ) -> FrameWriter<'_, 'd, D>

Starts streaming a video frame with PTS (and optional SCR) timestamps.

Source

pub fn start_still_frame(&mut self) -> FrameWriter<'_, 'd, D>

Starts streaming a Method 2 still image frame chunk by chunk.

Source

pub async fn write_frame(&mut self, frame: &[u8]) -> Result<(), EndpointError>

Sends one complete video frame with the minimal 2-byte payload header.

Source

pub async fn write_frame_with_timestamp( &mut self, frame: &[u8], ts: PayloadTimestamp, ) -> Result<(), EndpointError>

Sends one complete video frame with UVC PTS (and optional SCR) timestamps.

Source

pub async fn write_still_frame( &mut self, frame: &[u8], ) -> Result<(), EndpointError>

Sends one complete Method 2 still image frame (sets the STI still-image bit).

Auto Trait Implementations§

§

impl<'d, D> !RefUnwindSafe for Camera<'d, D>

§

impl<'d, D> !UnwindSafe for Camera<'d, D>

§

impl<'d, D> Forget for Camera<'d, D>

§

impl<'d, D> Freeze for Camera<'d, D>
where <D as Driver<'d>>::EndpointIn: Freeze,

§

impl<'d, D> Move for Camera<'d, D>

§

impl<'d, D> Send for Camera<'d, D>
where <D as Driver<'d>>::EndpointIn: Send,

§

impl<'d, D> Sync for Camera<'d, D>
where <D as Driver<'d>>::EndpointIn: Sync,

§

impl<'d, D> Unpin for Camera<'d, D>
where <D as Driver<'d>>::EndpointIn: Unpin,

§

impl<'d, D> UnsafeUnpin for Camera<'d, D>
where <D as Driver<'d>>::EndpointIn: UnsafeUnpin,

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

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.