libcamera: libcamera::CameraManager Class Reference

libcamera v0.7.0 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::CameraManager Class Reference

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

Inheritance diagram for libcamera::CameraManager:
[legend]
Collaboration diagram for libcamera::CameraManager:
[legend]

## Classes
class | Private

## 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.
Public Member Functions inherited from libcamera::Object
| Object (Object *parent=nullptr)
| Construct an Object instance.
virtual | ~Object ()
| Destroy an Object instance.
void | deleteLater ()
| Schedule deletion of the instance in the thread it belongs to.
void | postMessage (std::unique_ptr< Message > msg)
| Post a message to the object's thread.
template<typename T, typename R, typename... FuncArgs, typename... Args, std::enable_if_t< std::is_base_of< Object, T >::value > * = nullptr>
R | invokeMethod (R(T::*func)(FuncArgs...), ConnectionType type, Args &&... args)
| Invoke a method asynchronously on an Object instance.
Thread * | thread () const
| Retrieve the thread the object is bound to.
void | moveToThread (Thread *thread)
| Move the object and all its children to a different thread.
Object * | parent () const
| Retrieve the object's parent.
Public Member Functions inherited from libcamera::Extensible
| Extensible (std::unique_ptr< Private > d)
| Construct an instance of an Extensible class.

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

## Additional Inherited Members
Protected Member Functions inherited from libcamera::Object
virtual void | message (Message *msg)
| Message handler for the object.
bool | assertThreadBound (const char *message)
| Check if the caller complies with thread-bound constraints.
Protected Member Functions inherited from libcamera::Extensible
template<typename T>
const T * | _d () const
| Retrieve the private data instance.
template<typename T>
T * | _d ()
| Retrieve the private data instance.

## 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()

const std::string & libcamera::CameraManager::version | ( |  | ) |
| inlinestatic

Retrieve the libcamera version string.

Thread Safety
  This function is thread-safe.

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