---
url: https://docs.moqtail.dev/ts/api/player/interfaces/ElementDefinition.md
---
# Interface: ElementDefinition\<E, P>

What the registry stores.

## Extended by

* [`SourceElementDefinition`](SourceElementDefinition.md)
* [`TransformElementDefinition`](TransformElementDefinition.md)
* [`SinkElementDefinition`](SinkElementDefinition.md)

## Type Parameters

### E

`E` *extends* [`BaseElement`](../classes/BaseElement.md) = [`BaseElement`](../classes/BaseElement.md)

### P

`P` *extends* readonly [`InterfaceKey`](../type-aliases/InterfaceKey.md)\[] = readonly [`InterfaceKey`](../type-aliases/InterfaceKey.md)\[]

## Properties

### capabilities

> `readonly` **capabilities**: [`CapabilityBundles`](../type-aliases/CapabilityBundles.md)

***

### name

> `readonly` **name**: `string`

***

### priority?

> `readonly` `optional` **priority?**: `number`

Ranks the probes that accept a track: lower wins, then the earlier definition. Default selection
also keeps only the lowest of the sets sharing an `altGroup` and `lang`. Default 100.

***

### provides?

> `readonly` `optional` **provides?**: `P`

The optional interfaces this element implements.

***

### type

> `readonly` **type**: `"source"` | `"transform"` | `"sink"`

## Methods

### init()

> **init**(`context`, `options?`): `Promise`<`E`>

Rejection might mean a browser API or a peer dependency is missing.

#### Parameters

##### context

[`ElementContext`](ElementContext.md)

##### options?

`Record`<`string`, `any`>

#### Returns

`Promise`<`E`>

***

### supports()?

> `optional` **supports**(`track`): `boolean` | `Promise`<`boolean`>

Whether this element can handle `track`'s media, asked during selection before any instance exists.
Leaving it out means yes. Called with the track as the pad it would take carries it, so behind a decoder
its packaging is `raw`. Yes answers are kept per role, packaging, codec, MIME type, size, sample rate and
channels for the chain's life.
It isn't part of `negotiate`, which is synchronous, since decoders answer asynchronously and per rendition.

#### Parameters

##### track

[`Identifiers`](Identifiers.md)

#### Returns

`boolean` | `Promise`<`boolean`>

***

### threads()?

> `optional` **threads**(`environment`): `"worker"` | `"main"` | `"both"`

Where the element's engines may run, asked before each instance's `init`. `both` or `worker` give
it `context.worker` while the player has one, and `worker` without one rejects. Default `main`.

#### Parameters

##### environment

###### worker?

{ `has`(`name`): `boolean`; }

The player's worker, absent without one. `has` answers from the worker's own report: its
global names, and `element:<name>` for each engine it serves.

###### worker.has

(`name`) => `boolean`

#### Returns

`"worker"` | `"main"` | `"both"`
