# BroadcastClock

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

Defined in: [clock.ts:99](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L99)

A publisher's single clock: every track in the broadcast is stamped from it, in microseconds since the Unix epoch.
One moment on a monotonic source is pinned to the system clock, and the timeline advances at the source's rate.

## Properties

### originEpochUs

```ts
readonly originEpochUs: number;
```

Defined in: [clock.ts:103](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L103)

The pinned moment as microseconds since the Unix epoch.

***

### originUs

```ts
readonly originUs: number;
```

Defined in: [clock.ts:101](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L101)

The pinned moment, on the source clock.

## Methods

### fromSourceUs()

```ts
fromSourceUs(sourceUs): number;
```

Defined in: [clock.ts:111](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L111)

Map a timestamp on this clock's own source, such as `performance.now()` microseconds taken at capture, to the
timeline: `originEpochUs + sourceUs − originUs`. For a capture clock with another origin, use
[BroadcastClock.sourceTimeline](https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/broadcastclock/#sourcetimeline).

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `sourceUs` | `number` |

#### Returns

`number`

***

### now()

```ts
now(): number;
```

Defined in: [clock.ts:105](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L105)

The timeline now: Unix-epoch microseconds.

#### Returns

`number`

***

### sampleTimeline()

```ts
sampleTimeline(sampleRate, options?): SampleTimeline;
```

Defined in: [clock.ts:118](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L118)

Anchor a sample counter that starts at zero. The device clock that drives it drifts against the source, so
re-anchor with a fresh timeline when the two disagree by more than a frame.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `sampleRate` | `number` |
| `options?` | [`SampleTimelineOptions`](https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/sampletimelineoptions/) |

#### Returns

[`SampleTimeline`](https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/sampletimeline/)

***

### sourceTimeline()

```ts
sourceTimeline(options?): SourceTimeline;
```

Defined in: [clock.ts:113](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/src/clock.ts#L113)

Map a clock with its own origin and rate, kept on the broadcast timeline by calibration.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options?` | [`SourceTimelineOptions`](https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/sourcetimelineoptions/) |

#### Returns

[`SourceTimeline`](https://www.caprid.com/docs/reference/typescript/caprid/moq-media/interfaces/sourcetimeline/)
