# Format

<a id="format-5"></a>

# Format

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

struct Format
```

[Defined in src/av/include/icy/av/format.h:30](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L30)

Defines a media container format which is available through the [FormatRegistry](https://auscaster.com/icey/docs/api-reference/icy-av-FormatRegistry.md#formatregistry) for encoding or decoding.

A format bundles the preferred default audio and video codec settings for a named container such as MP4, MKV, or WAV.

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| `std::string` | [`name`](#name-5)  | Base [Format](#format-5) Variables. |
| `std::string` | [`id`](#id-5)  | The short name of this format. |
| [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) | [`video`](#video)  | The video codec. |
| [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) | [`audio`](#audio)  | The audio codec. |
| `int` | [`priority`](#priority-2)  | The priority this format will be displayed on the list. |

---

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

### name

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

[Defined in src/av/include/icy/av/format.h:43](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L43)

Base [Format](#format-5) Variables.

The display name of this format.

---

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

### id

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

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

The short name of this format.

---

<a id="video"></a>

### video

```cpp
VideoCodec video
```

Type: [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec)

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

The video codec.

---

<a id="audio"></a>

### audio

```cpp
AudioCodec audio
```

Type: [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec)

[Defined in src/av/include/icy/av/format.h:47](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L47)

The audio codec.

---

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

### priority

```cpp
int priority
```

[Defined in src/av/include/icy/av/format.h:49](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L49)

The priority this format will be displayed on the list.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`Format`](#format-6)  | Ctors/Dtors. |
|  | [`Format`](#format-7)  | Construct a multiplex (audio + video) format. |
|  | [`Format`](#format-8)  | Construct a video-only format. |
|  | [`Format`](#format-9)  | Construct an audio-only format. |
|  | [`Format`](#format-10)  |  |
| [`Format`](#format-5) & | [`operator=`](#operator-146)  | Defaulted assignment operator. |
|  | [`~Format`](#format-11) `virtual` | Defaulted destructor. |
| [`Type`](#type-4) | [`type`](#type-3) `const` | Return the media type (None, Video, Audio, or Multiplex) derived from which codecs are enabled. |
| `std::string` | [`toString`](#tostring-6) `virtual` `const` |  |
| `void` | [`print`](#print-5) `virtual` | Print a multi-line human-readable description to the given stream. |

---

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

### Format

```cpp
Format()
```

[Defined in src/av/include/icy/av/format.h:56](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L56)

Ctors/Dtors.

Construct an empty format with no codecs enabled.

---

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

### Format

```cpp
Format(const std::string & name, const std::string & id, const VideoCodec & video, const AudioCodec & audio, int priority = 0)
```

[Defined in src/av/include/icy/av/format.h:64](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L64)

Construct a multiplex (audio + video) format.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | `const std::string &` | The display name of the format. |
| `id` | `const std::string &` | The short FFmpeg muxer ID (e.g. "mp4"). |
| `video` | const [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) & | The video codec parameters. |
| `audio` | const [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) & | The audio codec parameters. |
| `priority` | `int` | Sort priority; higher values appear first. |

---

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

### Format

```cpp
Format(const std::string & name, const std::string & id, const VideoCodec & video, int priority = 0)
```

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

Construct a video-only format.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | `const std::string &` | The display name of the format. |
| `id` | `const std::string &` | The short FFmpeg muxer ID. |
| `video` | const [`VideoCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-VideoCodec.md#videocodec) & | The video codec parameters. |
| `priority` | `int` | Sort priority; higher values appear first. |

---

<a id="format-9"></a>

### Format

```cpp
Format(const std::string & name, const std::string & id, const AudioCodec & audio, int priority = 0)
```

[Defined in src/av/include/icy/av/format.h:82](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L82)

Construct an audio-only format.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | `const std::string &` | The display name of the format. |
| `id` | `const std::string &` | The short FFmpeg muxer ID. |
| `audio` | const [`AudioCodec`](https://auscaster.com/icey/docs/api-reference/icy-av-AudioCodec.md#audiocodec) & | The audio codec parameters. |
| `priority` | `int` | Sort priority; higher values appear first. |

---

<a id="format-10"></a>

### Format

```cpp
Format(const Format & r)
```

[Defined in src/av/include/icy/av/format.h:87](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L87)

---

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

### operator=

```cpp
Format & operator=(const Format &) = default
```

[Defined in src/av/include/icy/av/format.h:88](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L88)

Defaulted assignment operator.

---

<a id="format-11"></a>

### ~Format

`virtual`

```cpp
virtual ~Format() = default
```

[Defined in src/av/include/icy/av/format.h:90](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L90)

Defaulted destructor.

---

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

### type

`const`

```cpp
Type type() const
```

[Defined in src/av/include/icy/av/format.h:93](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L93)

Return the media type (None, Video, Audio, or Multiplex) derived from which codecs are enabled.

---

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

### toString

`virtual` `const`

```cpp
virtual std::string toString() const
```

[Defined in src/av/include/icy/av/format.h:96](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L96)

#### Returns
A compact string representation of the format and its enabled codecs.

---

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

### print

`virtual`

```cpp
virtual void print(std::ostream & ost)
```

[Defined in src/av/include/icy/av/format.h:100](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L100)

Print a multi-line human-readable description to the given stream.

#### Parameters

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

## Public Static Methods

| Return | Name | Description |
|--------|------|-------------|
| `bool` | [`preferable`](#preferable) `static` `inline` | Comparator returning true if `first` has higher priority than `second`. |

---

<a id="preferable"></a>

### preferable

`static` `inline`

```cpp
static inline bool preferable(const Format & first, const Format & second)
```

[Defined in src/av/include/icy/av/format.h:106](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L106)

Comparator returning true if `first` has higher priority than `second`. 
#### Returns
True if first.priority > second.priority.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `first` | const [`Format`](#format-5) & | The format to compare. |
| `second` | const [`Format`](#format-5) & | The format to compare against. |

## Public Types

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

---

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

### Type

```cpp
enum Type
```

[Defined in src/av/include/icy/av/format.h:32](https://github.com/auscaster/icey/blob/main/src/av/include/icy/av/format.h#L32)

| Value | Description |
|-------|-------------|
| `None` |  |
| `Video` | video only |
| `Audio` | audio only |
| `Multiplex` | both video & audio |
