---
url: https://docs.moqtail.dev/ts/api/player/classes/SstsSource.md
---
# Class: SstsSource

The switching set source of the `ssts()` plugin.

## Extends

* [`SourceElement`](SourceElement.md)

## Implements

* [`MediaSourceElement`](../interfaces/MediaSourceElement.md)

## Constructors

### Constructor

> **new SstsSource**(`context`, `options`, `preferred`): `SstsSource`

`preferred` is the plugin's list, most preferred first; the source starts on the first negotiated one.

#### Parameters

##### context

[`ElementContext`](../interfaces/ElementContext.md)

##### options

[`SwitchingSetOptions`](../interfaces/SwitchingSetOptions.md)

##### preferred

readonly `bigint`\[]

#### Returns

`SstsSource`

#### Overrides

[`SourceElement`](SourceElement.md).[`constructor`](SourceElement.md#constructor)

## Properties

### algorithms

> `readonly` **algorithms**: readonly `bigint`\[]

The negotiated algorithms (`sstsAlgorithms`), most preferred first, read at init.

***

### context

> `protected` `readonly` **context**: [`ElementContext`](../interfaces/ElementContext.md)

#### Inherited from

[`SourceElement`](SourceElement.md).[`context`](SourceElement.md#context)

***

### definition

> `readonly` **definition**: [`ElementDefinition`](../interfaces/ElementDefinition.md)

Set by `defineElement` once `init` resolves, so it can't be used from a constructor.

#### Inherited from

[`SourceElement`](SourceElement.md).[`definition`](SourceElement.md#definition)

***

### options

> `readonly` **options**: [`SwitchingSetOptions`](../interfaces/SwitchingSetOptions.md)

***

### pad

> `readonly` **pad**: [`Pad`](Pad.md)

***

### pads

> `readonly` **pads**: [`Pad`](Pad.md)\[] = `[]`

#### Inherited from

[`SourceElement`](SourceElement.md).[`pads`](SourceElement.md#pads)

## Accessors

### algorithm

#### Get Signature

> **get** **algorithm**(): `bigint`

##### Returns

`bigint`

## Methods

### createPad()

> `protected` **createPad**(`direction`, `capabilities`): [`Pad`](Pad.md)

Creates a pad and emits `padadded`.

#### Parameters

##### direction

`"sink"` | `"src"`

##### capabilities

[`Capabilities`](../type-aliases/Capabilities.md)

#### Returns

[`Pad`](Pad.md)

#### Inherited from

[`SourceElement`](SourceElement.md).[`createPad`](SourceElement.md#createpad)

***

### destroy()

> **destroy**(): `Promise`<`void`>

Removes the element's pads. The runtime aborts `context.signal` before and releases the
elements this one loaded after. Override for your own cleanup and call `super.destroy()`.

#### Returns

`Promise`<`void`>

#### Inherited from

[`SourceElement`](SourceElement.md).[`destroy`](SourceElement.md#destroy)

***

### emit()

> **emit**<`K`>(`event`, ...`args`): `void`

Calls every listener of `event` with `args`. Allocates nothing when there are none.

#### Type Parameters

##### K

`K` *extends* `"ready"` | `"padadded"` | `"padremoved"` | `"nomorepads"`

#### Parameters

##### event

`K`

##### args

...`Parameters`<[`ElementEvents`](../interfaces/ElementEvents.md)\[`K`]>

#### Returns

`void`

#### Inherited from

[`SourceElement`](SourceElement.md).[`emit`](SourceElement.md#emit)

***

### getRenditions()

> **getRenditions**(): [`Rendition`](../interfaces/Rendition.md)\[]

#### Returns

[`Rendition`](../interfaces/Rendition.md)\[]

#### Implementation of

[`MediaSourceElement`](../interfaces/MediaSourceElement.md).[`getRenditions`](../interfaces/MediaSourceElement.md#getrenditions)

***

### matchesCapabilities()

> `protected` **matchesCapabilities**(`pad`): `boolean`

True if the pad matches one of the definition's `in` capability bundles.

#### Parameters

##### pad

[`Pad`](Pad.md)

#### Returns

`boolean`

#### Inherited from

[`SourceElement`](SourceElement.md).[`matchesCapabilities`](SourceElement.md#matchescapabilities)

***

### negotiate()

> **negotiate**(): `boolean`

The chain only offers pads of elements this one loaded: take them all.

#### Returns

`boolean`

#### Overrides

[`SourceElement`](SourceElement.md).[`negotiate`](SourceElement.md#negotiate)

***

### off()

> **off**<`K`>(`event`, `listener`): `void`

Removes `listener`, the same function given to `on()`, from `event`.

#### Type Parameters

##### K

`K` *extends* `"ready"` | `"padadded"` | `"padremoved"` | `"nomorepads"`

#### Parameters

##### event

`K`

##### listener

[`ElementEvents`](../interfaces/ElementEvents.md)\[`K`]

#### Returns

`void`

#### Inherited from

[`SourceElement`](SourceElement.md).[`off`](SourceElement.md#off)

***

### on()

> **on**<`K`>(`event`, `listener`): `void`

Adds `listener` for `event`. Adding the same function twice has no effect.

#### Type Parameters

##### K

`K` *extends* `"ready"` | `"padadded"` | `"padremoved"` | `"nomorepads"`

#### Parameters

##### event

`K`

##### listener

[`ElementEvents`](../interfaces/ElementEvents.md)\[`K`]

#### Returns

`void`

#### Inherited from

[`SourceElement`](SourceElement.md).[`on`](SourceElement.md#on)

***

### pauseSwitching()

> **pauseSwitching**(): `Promise`<`void`>

Pauses automatic switching: `activate` 0 on the set (SSTS 6.2).

#### Returns

`Promise`<`void`>

***

### receive()

> **receive**(`pad`, `item`): `Promise`<`void`>

Called once per item on a taken pad; the pad's next item waits for the returned promise.

#### Parameters

##### pad

[`Pad`](Pad.md)

##### item

[`PadItem`](../type-aliases/PadItem.md)

#### Returns

`Promise`<`void`>

#### Overrides

[`SourceElement`](SourceElement.md).[`receive`](SourceElement.md#receive)

***

### removePad()

> `protected` **removePad**(`pad`, `failed?`): `void`

Removes a pad and emits `padremoved`. Pass `failed` when a failure, not a catalog update, lost it.

#### Parameters

##### pad

[`Pad`](Pad.md)

##### failed?

`boolean` = `false`

#### Returns

`void`

#### Inherited from

[`SourceElement`](SourceElement.md).[`removePad`](SourceElement.md#removepad)

***

### resumeSwitching()

> **resumeSwitching**(): `Promise`<`void`>

Resumes automatic switching: `activate` back to the set size.

#### Returns

`Promise`<`void`>

***

### selectRenditions()

> **selectRenditions**(`renditionIds`): `Promise`<`void`>

Changes the switching set (SSTS 6.2): a deselected track is unsubscribed, a selected one
subscribed again. A single selection keeps every track in the set and pins it by threshold.

#### Parameters

##### renditionIds

`string`\[]

#### Returns

`Promise`<`void`>

#### Implementation of

[`MediaSourceElement`](../interfaces/MediaSourceElement.md).[`selectRenditions`](../interfaces/MediaSourceElement.md#selectrenditions)

***

### setAlgorithm()

> **setAlgorithm**(`id`): `Promise`<`void`>

Moves the whole set to another negotiated algorithm with a REQUEST_UPDATE per subscription;
a rejected update rolls the others back, so the set never carries two algorithms.
With concurrent calls the latest wins and earlier ones reject with `ABORTED`.

#### Parameters

##### id

`bigint`

#### Returns

`Promise`<`void`>

***

### setTracks()

> **setTracks**(`tracks`): `void`

New tracks get a child, selected unless a track is pinned; removed ones are released.

#### Parameters

##### tracks

readonly (`object` & `object` & `object`)\[]

#### Returns

`void`

#### Implementation of

[`MediaSourceElement`](../interfaces/MediaSourceElement.md).[`setTracks`](../interfaces/MediaSourceElement.md#settracks)

***

### start()

> **start**(): `Promise`<`void`>

**`Internal`**

Loads a child per track, in parallel: the publisher activates once all are assigned
(SSTS 6.3). The set plays on the children that loaded; it fails only when none did.

#### Returns

`Promise`<`void`>

***

### switch()

> **switch**(`renditionId`): `Promise`<`void`>

Pins the relay to one track: the same as selecting only it.

#### Parameters

##### renditionId

`string`

#### Returns

`Promise`<`void`>

#### Implementation of

[`MediaSourceElement`](../interfaces/MediaSourceElement.md).[`switch`](../interfaces/MediaSourceElement.md#switch)
