libcamera v0.5.1 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
libcamera::CameraManager Class Reference

Provide access and manage all cameras in the system. More...

Collaboration diagram for libcamera::CameraManager:
[legend]

## Public Member Functions
| ~CameraManager ()
| Destroy the camera manager.
int | start ()
| Start the camera manager.
void | stop ()
| Stop the camera manager.
std::vector< std::shared_ptr< Camera > > | cameras () const
| Retrieve all available cameras.
std::shared_ptr< Camera > | get (std::string_view id)
| Get a camera based on ID.

## Static Public Member Functions
static const std::string & | version ()
| Retrieve the libcamera version string.

## Public Attributes
Signal< std::shared_ptr< Camera > > | cameraAdded
| Notify of a new camera added to the system.
Signal< std::shared_ptr< Camera > > | cameraRemoved
| Notify of a new camera removed from the system.

## Detailed Description

Provide access and manage all cameras in the system.

The camera manager is the entry point to libcamera. It enumerates devices, associates them with pipeline managers, and provides access to the cameras in the system to applications. The manager owns all Camera objects and handles hot-plugging and hot-unplugging to manage the lifetime of cameras.

To interact with libcamera, an application starts by creating a camera manager instance. Only a single instance of the camera manager may exist at a time. Attempting to create a second instance without first deleting the existing instance results in undefined behaviour.

The manager is initially stopped, and shall be started with start(). This will enumerate all the cameras present in the system, which can then be listed with list() and retrieved with get().

Cameras are shared through std::shared_ptr<>, ensuring that a camera will stay valid until the last reference is released without requiring any special action from the application. Once the application has released all the references it held to cameras, the camera manager can be stopped with stop().

## Constructor & Destructor Documentation

## ◆ ~CameraManager()

libcamera::CameraManager::~CameraManager | ( |  | ) |

Destroy the camera manager.

Destroying the camera manager stops it if it is currently running.

## Member Function Documentation

## ◆ cameras()

std::vector< std::shared_ptr< Camera > > libcamera::CameraManager::cameras | ( |  | ) | const

Retrieve all available cameras.

Before calling this function the caller is responsible for ensuring that the camera manager is running.

Thread Safety
  This function is thread-safe.

Returns
  List of all available cameras

## ◆ get()

std::shared_ptr< Camera > libcamera::CameraManager::get | ( | std::string_view | id | ) |

Get a camera based on ID.

Parameters

  [in] | id | ID of camera to get

Before calling this function the caller is responsible for ensuring that the camera manager is running.

Thread Safety
  This function is thread-safe.

Returns
  Shared pointer to Camera object or nullptr if camera not found

## ◆ start()

int libcamera::CameraManager::start | ( |  | ) |

Start the camera manager.

Start the camera manager and enumerate all devices in the system. Once the start has been confirmed the user is free to list and otherwise interact with cameras in the system until either the camera manager is stopped or the camera is unplugged from the system.

Returns
  0 on success or a negative error code otherwise

## ◆ stop()

void libcamera::CameraManager::stop | ( |  | ) |

Stop the camera manager.

Before stopping the camera manager the caller is responsible for making sure all cameras provided by the manager are returned to the manager.

After the manager has been stopped no resource provided by the camera manager should be consider valid or functional even if they for one reason or another have yet to be deleted.

## ◆ version()

static const std::string & libcamera::CameraManager::version | ( |  | ) |
| inline static

Retrieve the libcamera version string.

Thread Safety
  This function is threadsafe.

Returns
  The libcamera version string

## Member Data Documentation

## ◆ cameraAdded

Signal<std::shared_ptr<Camera> > libcamera::CameraManager::cameraAdded

Notify of a new camera added to the system.

This signal is emitted when a new camera is detected and successfully handled by the camera manager. The notification occurs alike for cameras detected when the manager is started with start() or when new cameras are later connected to the system. When the signal is emitted the new camera is already available from the list of cameras().

The signal is emitted from the CameraManager thread. Applications shall minimize the time spent in the signal handler and shall in particular not perform any blocking operation.

## ◆ cameraRemoved

Signal<std::shared_ptr<Camera> > libcamera::CameraManager::cameraRemoved

Notify of a new camera removed from the system.

This signal is emitted when a camera is removed from the system. When the signal is emitted the camera is not available from the list of cameras() anymore.

The signal is emitted from the CameraManager thread. Applications shall minimize the time spent in the signal handler and shall in particular not perform any blocking operation.

The documentation for this class was generated from the following files:

- include/libcamera/camera_manager.h
- src/libcamera/camera_manager.cpp
- /build/libcamera/src/build/src/libcamera/version.cpp