# FrameHold

URL: https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/framehold/

Defined in: [frame-hold.ts:20](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L20)

Keeps frames in order until `release`, then passes them, and every later one, straight on.

## Type Parameters

| Type Parameter |
| ------ |
| <a id="type-parameter-frame"></a> `Frame` |

## Properties

### isReleased

```ts
readonly isReleased: boolean;
```

Defined in: [frame-hold.ts:34](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L34)

Whether `release` was called.

***

### stats

```ts
readonly stats: Readonly<FrameHoldStats>;
```

Defined in: [frame-hold.ts:36](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L36)

Counters.

## Methods

### clear()

```ts
clear(): void;
```

Defined in: [frame-hold.ts:32](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L32)

Drop every kept frame; later frames are kept again until `release`. Does nothing once released.

#### Returns

`void`

***

### push()

```ts
push(frame): void;
```

Defined in: [frame-hold.ts:22](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L22)

Keep a frame, or pass it on once released. A frame reader's `onFrame` can be this method.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `frame` | `Frame` |

#### Returns

`void`

***

### release()

```ts
release(consumer): void;
```

Defined in: [frame-hold.ts:30](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/frame-hold.ts#L30)

Pass every kept frame to `consumer`, oldest first, then every later frame as it comes. Once only. A frame pushed
from inside `consumer` while the kept ones are passed on waits its turn behind them. A kept frame the consumer
throws on does not stop the rest: each is passed on, and the first error is thrown after the last (as a frame
reader's `onFrame` failing for one frame does not lose the next). After `release`, `push` throws what the consumer
throws.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `consumer` | (`frame`) => `void` |

#### Returns

`void`
