libcamera
v0.3.1+12-19bbca3c
Supporting cameras in Linux since 2019
|
Enumerate, store and search media devices. More...
Public Member Functions | |
virtual int | init ()=0 |
Initialize the enumerator. More... | |
virtual int | enumerate ()=0 |
Enumerate all media devices in the system. More... | |
std::shared_ptr< MediaDevice > | search (const DeviceMatch &dm) |
Search available media devices for a pattern match. More... | |
Static Public Member Functions | |
static std::unique_ptr< DeviceEnumerator > | create () |
Create a new device enumerator matching the systems capabilities. More... | |
Public Attributes | |
Signal | devicesAdded |
Notify of new media devices being found. More... | |
Protected Member Functions | |
std::unique_ptr< MediaDevice > | createDevice (const std::string &deviceNode) |
Create a media device instance. More... | |
void | addDevice (std::unique_ptr< MediaDevice > media) |
Add a media device to the enumerator. More... | |
void | removeDevice (const std::string &deviceNode) |
Remove a media device from the enumerator. More... | |
Enumerate, store and search media devices.
The DeviceEnumerator class is responsible for all interactions with the operating system related to media devices. It enumerates all media devices in the system, and for each device found creates an instance of the MediaDevice class and stores it internally. The list of media devices can then be searched using DeviceMatch search patterns.
The enumerator also associates media device entities with device node paths.
|
protected |
Add a media device to the enumerator.
[in] | media | media device instance to add |
Store the media device in the internal list for later matching with pipeline handlers. media shall be created with createDevice() first. This function shall be called after all members of the entities of the media graph have been confirmed to be initialized.
|
static |
Create a new device enumerator matching the systems capabilities.
Depending on how the operating system handles device detection, hot-plug notification and device node lookup, different device enumerator implementations may be needed. This function creates the best enumerator for the operating system based on the available resources. Not all different enumerator types are guaranteed to support all features.
|
protected |
Create a media device instance.
[in] | deviceNode | path to the media device to create |
Create a media device for the deviceNode, open it, and populate its media graph. The device enumerator shall then populate the media device by associating device nodes with entities using MediaEntity::setDeviceNode(). This process is specific to each device enumerator, and the device enumerator shall ensure that device nodes are ready to be used (for instance, if applicable, by waiting for device nodes to be created and access permissions to be set by the system). Once done, it shall add the media device to the system with addDevice().
|
pure virtual |
Enumerate all media devices in the system.
This function finds and add all media devices in the system to the enumerator. It shall be implemented by all subclasses of DeviceEnumerator using system-specific methods.
Individual media devices that can't be properly enumerated shall be skipped with a warning message logged, without returning an error. Only errors that prevent enumeration altogether shall be fatal.
|
pure virtual |
Initialize the enumerator.
-EBUSY | the enumerator has already been initialized |
-ENODEV | the enumerator can't enumerate devices |
|
protected |
Remove a media device from the enumerator.
[in] | deviceNode | Path to the media device to remove |
Remove the media device identified by deviceNode previously added to the enumerator with addDevice(). The media device's MediaDevice::disconnected signal is emitted.
std::shared_ptr< MediaDevice > libcamera::DeviceEnumerator::search | ( | const DeviceMatch & | dm | ) |
Search available media devices for a pattern match.
[in] | dm | Search pattern |
Search in the enumerated media devices that are not already in use for a match described in dm. If a match is found and the caller intends to use it the caller is responsible for acquiring the MediaDevice object and releasing it when done with it.
libcamera::DeviceEnumerator::devicesAdded |
Notify of new media devices being found.
This signal is emitted when the device enumerator finds new media devices in the system. It may be emitted for every newly detected device, or once for multiple devices, at the discretion of the device enumerator. Not all device enumerator types may support dynamic detection of new devices.