Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-mice-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/rtc-node': patch
---

Add userdata constructor param to AudioFrame
11 changes: 9 additions & 2 deletions packages/livekit-rtc/src/audio_frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@ export class AudioFrame {
channels: number;
samplesPerChannel: number;

private _userdata: Record<string, unknown> = {};
private _userdata: Record<string, unknown>;

// note: if converting from Uint8Array to Int16Array, *do not* use buffer.slice!
// it is marked unstable by Node and can cause undefined behaviour, such as massive chunks of
// noise being added to the end.
// it is recommended to use buffer.subarray instead.
// XXX(nbsp): add this when writing proper docs
constructor(data: Int16Array, sampleRate: number, channels: number, samplesPerChannel: number) {
constructor(
data: Int16Array,
sampleRate: number,
channels: number,
samplesPerChannel: number,
userdata: Record<string, unknown> = {},
) {
this.data = data;
this.sampleRate = sampleRate;
this.channels = channels;
this.samplesPerChannel = samplesPerChannel;
this._userdata = userdata;
}

static create(sampleRate: number, channels: number, samplesPerChannel: number): AudioFrame {
Expand Down
Loading