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>
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 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<()>
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.
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 acquire(&self) -> Result<ActiveCamera<'_>>
pub fn acquire(&self) -> Result<ActiveCamera<'_>>
Acquires exclusive rights to the camera, which allows changing configuration and capturing.