# SourceTimeline

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

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

Maps timestamps from a clock with its own origin and rate onto the broadcast timeline: an `AudioContext`'s time
(works in every browser), or Chromium's `MediaStreamTrackProcessor` timestamps, which count from the system's
monotonic zero, not from `performance.now()`'s.

## Properties

### anchorSourceUs

```ts
readonly anchorSourceUs: number | undefined;
```

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

The source time of the current anchor; `undefined` until the first calibration or timestamp.

***

### captureLatencyUs

```ts
captureLatencyUs: number;
```

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

How long the capture device holds a sample before the source sees it, in integer microseconds, subtracted from
every timestamp so it stays the capture time. No browser API reports it: set it from a known device latency, and
again when the device changes. It does not affect calibration.

## Methods

### calibrate()

```ts
calibrate(sourceUs, atUs?): boolean;
```

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

Record that source time `sourceUs` happened at `atUs` on the broadcast clock's own source (default: now), for
example an `AudioContext` time and the `performance.now()` time it was rendered at, both in microseconds. The pair
becomes the anchor when there is none, or when the current anchor predicts it more than `toleranceUs` off: the
source drifted, or jumped, as an `AudioContext` does when it is replaced. Returns whether the anchor changed.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `sourceUs` | `number` |
| `atUs?` | `number` |

#### Returns

`boolean`

***

### timestampUs()

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

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

The broadcast time of this source timestamp: the anchor's broadcast time plus the source's own elapsed time,
rounded to whole microseconds, less the capture latency. Without an anchor, the first call anchors this timestamp
at the clock's `now()`.

#### Parameters

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

#### Returns

`number`
