avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::hw::DeviceProbeRange Class Reference

Lazy range that probes every compiled device type. More...

#include <hwcontext.h>

Classes

class  iterator
 Forward iterator that creates and destroys one device per step. More...

Public Member Functions

 DeviceProbeRange ()=default
 Empty range, used as the past-the-end value.
 DeviceProbeRange (const char *device) noexcept
 Range over all types with a borrowed device selector.
 DeviceProbeRange (const std::string &device)
 Range over all types with a device selector stored by the range.
 DeviceProbeRange (const DeviceProbeRange &other)
 Copy the range, keeping the stored selector valid.
 DeviceProbeRange (DeviceProbeRange &&other) noexcept
 Move the range.
DeviceProbeRange & operator= (DeviceProbeRange other)
 Assign through copy-and-swap.
void swap (DeviceProbeRange &other) noexcept
 Exchange the state of two ranges, fixing up the stored selectors.
iterator begin () const
 Start probing.
iterator end () const
 End of the range.

Detailed Description

A probe creates a temporary device context and destroys it immediately. Availability is reported per type. Creation is the only reliable check: av_hwdevice_iterate_types() lists compiled backends, not present hardware.

Parameters
deviceBackend-specific device selector passed to av_hwdevice_ctx_create(). It is a string and not std::filesystem::path on purpose: the value identifies a device, and it is not necessarily a node in the filesystem. Depending on the backend it can be:
  • a filesystem path (VAAPI, DRM: "/dev/dri/renderD128");
  • a numeric index (CUDA: "1");
  • a display or adapter name (D3D11VA, VideoToolbox);
  • an empty string or nullptr for the default device. A path type would wrongly imply a filesystem node and cannot represent the other forms.
Note
The const char* overload borrows the pointer. The caller must keep the string alive for the whole iteration. The std::string overload stores a copy inside the range.
See also
isDeviceAvailable(), allDeviceTypes()

Constructor & Destructor Documentation

◆ DeviceProbeRange() [1/4]

av::hw::DeviceProbeRange::DeviceProbeRange ( const char * device)
inlineexplicitnoexcept
Parameters
devicebackend-specific selector; must outlive the range

◆ DeviceProbeRange() [2/4]

av::hw::DeviceProbeRange::DeviceProbeRange ( const std::string & device)
inlineexplicit
Parameters
devicebackend-specific selector; a copy is kept

◆ DeviceProbeRange() [3/4]

av::hw::DeviceProbeRange::DeviceProbeRange ( const DeviceProbeRange & other)
inline
Parameters
otherthe range to copy

◆ DeviceProbeRange() [4/4]

av::hw::DeviceProbeRange::DeviceProbeRange ( DeviceProbeRange && other)
inlinenoexcept
Parameters
otherthe range to move from; left empty

Member Function Documentation

◆ begin()

iterator av::hw::DeviceProbeRange::begin ( ) const
inline
Returns
an iterator at the first compiled type, already probed

◆ end()

iterator av::hw::DeviceProbeRange::end ( ) const
inline
Returns
the past-the-end iterator

◆ operator=()

DeviceProbeRange & av::hw::DeviceProbeRange::operator= ( DeviceProbeRange other)
inline
Parameters
otherthe range to assign from
Returns
this range

◆ swap()

void av::hw::DeviceProbeRange::swap ( DeviceProbeRange & other)
inlinenoexcept
Parameters
otherthe range to swap with

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