Struct libcamera::camera::ActiveCamera

source ·
pub struct ActiveCamera<'d> { /* private fields */ }
Expand description

An active instance of a camera.

This gives exclusive access to the camera and allows capturing and modifying configuration.

Obtained by Camera::acquire().

Implementations§

source§

impl<'d> ActiveCamera<'d>

source

pub fn on_request_completed(&mut self, cb: impl FnMut(Request) + Send + 'd)

Sets a callback for completed camera requests.

Callback is executed in the libcamera thread context so it is best to setup a channel to send all requests for processing elsewhere.

Only one callback can be set at a time. If there was a previously set callback, it will be discarded when setting a new one.

source

pub fn configure(&mut self, config: &mut CameraConfiguration) -> Result<()>

Applies camera configuration.

Default configuration can be obtained from Camera::generate_configuration() and then adjusted as needed.

source

pub fn create_request(&mut self, cookie: Option<u64>) -> Option<Request>

Creates a capture Request.

To perform a capture, it must firstly be initialized by attaching a framebuffer with Request::add_buffer() and then queued for execution by ActiveCamera::queue_request().

§Arguments
  • cookie - An optional user-provided u64 identifier that can be used to uniquely identify request in request completed callback.
source

pub fn queue_request(&self, req: Request) -> Result<()>

Queues Request for execution. Completed requests are returned in request completed callback, set by the ActiveCamera::on_request_completed().

Requests that do not have attached framebuffers are invalid and are rejected without being queued.

source

pub fn start(&mut self, controls: Option<&ControlList>) -> Result<()>

Starts camera capture session.

Once started, ActiveCamera::queue_request() is permitted and camera configuration can no longer be changed.

source

pub fn stop(&mut self) -> Result<()>

Stops camera capture session.

Once stopped, ActiveCamera::queue_request() is no longer permitted and camera configuration can be adjusted.

Methods from Deref<Target = Camera<'d>>§

source

pub fn id(&self) -> &str

ID of the camera.

This usually contains hardware path within the system and is not human-friendly. Use properties::Model from Camera::properties() to obtain a human readable identification instead.

source

pub fn controls(&self) -> &ControlInfoMap

Returns a list of available camera controls and their limit.

source

pub fn properties(&self) -> &PropertyList

Returns a list of camera properties.

See properties for available items.

source

pub fn generate_configuration( &self, roles: &[StreamRole], ) -> Option<CameraConfiguration>

Generates default camera configuration for the given StreamRoles.

The resulting CameraConfiguration contains stream configurations for each of the requested roles.

Generated configuration can be adjusted as needed and then passed onto ActiveCamera::configure() to apply.

source

pub fn acquire(&self) -> Result<ActiveCamera<'_>>

Acquires exclusive rights to the camera, which allows changing configuration and capturing.

Trait Implementations§

source§

impl<'d> Deref for ActiveCamera<'d>

source§

type Target = Camera<'d>

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<'d> DerefMut for ActiveCamera<'d>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'d> Drop for ActiveCamera<'d>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d> Freeze for ActiveCamera<'d>

§

impl<'d> RefUnwindSafe for ActiveCamera<'d>

§

impl<'d> !Send for ActiveCamera<'d>

§

impl<'d> !Sync for ActiveCamera<'d>

§

impl<'d> Unpin for ActiveCamera<'d>

§

impl<'d> UnwindSafe for ActiveCamera<'d>

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