# Device

<a id="device"></a>

# Device

```cpp
#include <icy/av/devicemanager.h>

struct Device
```

[Defined in src/av/include/icy/av/devicemanager.h:44](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L44)

Represents a system audio, video or render device.

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| [`Type`](#type-8) | [`type`](#type-7)  |  |
| `std::string` | [`id`](#id-6)  |  |
| `std::string` | [`name`](#name-6)  |  |
| `bool` | [`isDefault`](#isdefault)  |  |
| `bool` | [`isConnected`](#isconnected)  |  |
| `bool` | [`isInUse`](#isinuse)  |  |
| std::vector< [`VideoCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-VideoCapability.md#videocapability) > | [`videoCapabilities`](#videocapabilities)  |  |
| std::vector< [`AudioCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-AudioCapability.md#audiocapability) > | [`audioCapabilities`](#audiocapabilities)  |  |

---

<a id="type-7"></a>

### type

```cpp
Type type {Unknown}
```

Type: [`Type`](#type-8)

[Defined in src/av/include/icy/av/devicemanager.h:73](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L73)

---

<a id="id-6"></a>

### id

```cpp
std::string id
```

[Defined in src/av/include/icy/av/devicemanager.h:74](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L74)

---

<a id="name-6"></a>

### name

```cpp
std::string name
```

[Defined in src/av/include/icy/av/devicemanager.h:75](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L75)

---

<a id="isdefault"></a>

### isDefault

```cpp
bool isDefault {false}
```

[Defined in src/av/include/icy/av/devicemanager.h:76](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L76)

---

<a id="isconnected"></a>

### isConnected

```cpp
bool isConnected {true}
```

[Defined in src/av/include/icy/av/devicemanager.h:77](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L77)

---

<a id="isinuse"></a>

### isInUse

```cpp
bool isInUse {false}
```

[Defined in src/av/include/icy/av/devicemanager.h:78](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L78)

---

<a id="videocapabilities"></a>

### videoCapabilities

```cpp
std::vector< VideoCapability > videoCapabilities
```

Type: std::vector< [`VideoCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-VideoCapability.md#videocapability) >

[Defined in src/av/include/icy/av/devicemanager.h:80](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L80)

---

<a id="audiocapabilities"></a>

### audioCapabilities

```cpp
std::vector< AudioCapability > audioCapabilities
```

Type: std::vector< [`AudioCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-AudioCapability.md#audiocapability) >

[Defined in src/av/include/icy/av/devicemanager.h:81](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L81)

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`Device`](#device-1)  | Construct a device with Unknown type and empty fields. |
|  | [`Device`](#device-2)  | Construct a device with explicit fields. |
| `void` | [`print`](#print-6) `const` | Print device details (type, id, name, capabilities) to the given stream. |
| `bool` | [`operator==`](#operator-155) `const` `inline` | Equality based on type, id, and name. |
| [`VideoCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-VideoCapability.md#videocapability) | [`bestVideoCapability`](#bestvideocapability) `const` `inline` | Find the video capability closest to the requested parameters. |
| [`AudioCapability`](https://auscaster.com/icey/docs/api-reference/icy-av-Device-AudioCapability.md#audiocapability) | [`bestAudioCapability`](#bestaudiocapability) `const` `inline` | Find the audio capability closest to the requested parameters. |

---

<a id="device-1"></a>

### Device

```cpp
Device()
```

[Defined in src/av/include/icy/av/devicemanager.h:84](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L84)

Construct a device with Unknown type and empty fields.

---

<a id="device-2"></a>

### Device

```cpp
Device(Type type, const std::string & id, const std::string & name, bool isDefault = false)
```

[Defined in src/av/include/icy/av/devicemanager.h:91](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L91)

Construct a device with explicit fields.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `type` | [`Type`](#type-8) | The device type (VideoInput, AudioInput, etc.). |
| `id` | `const std::string &` | The platform-specific device identifier. |
| `name` | `const std::string &` | The human-readable device name. |
| `isDefault` | `bool` | True if this is the system default device of its type. |

---

<a id="print-6"></a>

### print

`const`

```cpp
void print(std::ostream & os) const
```

[Defined in src/av/include/icy/av/devicemanager.h:95](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L95)

Print device details (type, id, name, capabilities) to the given stream.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `os` | `std::ostream &` | The output stream to write to. |

---

<a id="operator-155"></a>

### operator==

`const` `inline`

```cpp
inline bool operator==(const Device & that) const
```

[Defined in src/av/include/icy/av/devicemanager.h:98](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L98)

Equality based on type, id, and name.

---

<a id="bestvideocapability"></a>

### bestVideoCapability

`const` `inline`

```cpp
inline VideoCapability bestVideoCapability(int width, int height, double fps) const
```

[Defined in src/av/include/icy/av/devicemanager.h:112](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L112)

Find the video capability closest to the requested parameters.

Scoring: resolution match weighted 70%, fps match weighted 30%. Both dimensions are normalised to [0,1] so the weights are meaningful. Prefers capabilities that are >= the requested resolution (upscaling is worse than slight downscaling).

Returns a default capability with the requested values if none are available (allows callers to skip the empty check).

---

<a id="bestaudiocapability"></a>

### bestAudioCapability

`const` `inline`

```cpp
inline AudioCapability bestAudioCapability(int sampleRate, int channels) const
```

[Defined in src/av/include/icy/av/devicemanager.h:151](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L151)

Find the audio capability closest to the requested parameters.

Scoring: sample rate match weighted 70%, channel count weighted 30%. Both dimensions are normalised to [0,1].

Returns a default capability with the requested values if none are available.

## Public Types

| Name | Description |
|------|-------------|
| [`Type`](#type-8)  |  |

---

<a id="type-8"></a>

### Type

```cpp
enum Type
```

[Defined in src/av/include/icy/av/devicemanager.h:46](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/devicemanager.h#L46)

| Value | Description |
|-------|-------------|
| `Unknown` |  |
| `VideoInput` |  |
| `VideoOutput` |  |
| `AudioInput` |  |
| `AudioOutput` |  |
