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>
impl<'d> ActiveCamera<'d>
Sourcepub fn on_request_completed(&mut self, cb: impl FnMut(Request) + Send + 'd)
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.
Sourcepub fn on_buffer_completed(
&mut self,
cb: impl FnMut(&mut Request, Stream) + Send + 'd,
)
pub fn on_buffer_completed( &mut self, cb: impl FnMut(&mut Request, Stream) + Send + 'd, )
Sets a callback for per-buffer completion events.
This fires for every buffer as libcamera emits bufferCompleted; the corresponding Request remains queued
until the requestCompleted signal fires.
Sourcepub fn subscribe_request_completed(&mut self) -> Receiver<Request>
pub fn subscribe_request_completed(&mut self) -> Receiver<Request>
Subscribe to request completed events via a channel (async-friendly).
The returned receiver yields owned Requests as libcamera completes them.
Sourcepub fn subscribe_buffer_completed(&mut self) -> Receiver<BufferCompletedEvent>
pub fn subscribe_buffer_completed(&mut self) -> Receiver<BufferCompletedEvent>
Subscribe to per-buffer completion events via a channel (async-friendly).
The receiver yields lightweight BufferCompletedEvent snapshots; the underlying Request
remains owned by libcamera until requestCompleted fires.
Sourcepub fn on_disconnected(&mut self, cb: impl FnMut() + Send + 'd)
pub fn on_disconnected(&mut self, cb: impl FnMut() + Send + 'd)
Sets a callback for camera disconnected events.
Sourcepub fn configure(&mut self, config: &mut CameraConfiguration) -> Result<()>
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.
Sourcepub fn create_request(&mut self, cookie: Option<u64>) -> Option<Request>
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.
Sourcepub fn queue_request(&self, req: Request) -> Result<(), (Request, Error)>
pub fn queue_request(&self, req: Request) -> Result<(), (Request, Error)>
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.
Sourcepub fn start(&mut self, controls: Option<&ControlList>) -> Result<()>
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.
Sourcepub fn stop(&mut self) -> Result<()>
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>>§
Sourcepub fn id(&self) -> &str
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.
Sourcepub fn controls(&self) -> &ControlInfoMap
pub fn controls(&self) -> &ControlInfoMap
Returns a list of available camera controls and their limit.
Sourcepub fn properties(&self) -> &PropertyList
pub fn properties(&self) -> &PropertyList
Returns a list of camera properties.
See properties for available items.
Sourcepub fn generate_configuration(
&self,
roles: &[StreamRole],
) -> Option<CameraConfiguration>
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.
Sourcepub fn generate_first_supported_configuration(
&self,
roles: &[StreamRole],
) -> Option<(CameraConfiguration, StreamRole)>
pub fn generate_first_supported_configuration( &self, roles: &[StreamRole], ) -> Option<(CameraConfiguration, StreamRole)>
Try roles in order and return the first generated configuration that succeeds.
Sourcepub fn acquire(&self) -> Result<ActiveCamera<'d>>
pub fn acquire(&self) -> Result<ActiveCamera<'d>>
Acquires exclusive rights to the camera, which allows changing configuration and capturing.