Skip to content

Cannot Publish Custom Audio Frames in Node.js SDK: protoInfo/data_ptr Errors #504

@ashuitbhu2004

Description

@ashuitbhu2004

Describe the bug

I am trying to publish custom audio frames using the Node.js SDK (@livekit/rtc-node), but it is not possible due to internal SDK requirements that cannot be satisfied from userland JavaScript.

Request:
Please provide a supported way to publish custom audio frames from Node.js, or update the documentation to clarify the current limitations.

Reproduction

Steps to Reproduce:

  1. Create an AudioSource and attempt to call captureFrame with a plain object or Buffer, as suggested by the documentation.
  2. Observe the following error:
  • TypeError: frame.protoInfo is not a function
  1. Attempt to work around by providing a custom class with a protoInfo() method that returns an object with the expected properties.
  2. Observe the following error:
  • Error: cannot encode field livekit.proto.AudioFrameBufferInfo.data_ptr to binary: required field not set

Minimal Repro Script:

import { AudioSource } from '@livekit/rtc-node';

// Minimal AudioFrameBufferInfo mimic (plain object)
class AudioFrame {
  constructor({ data, sampleRate, numChannels, samplesPerChannel }) {
    this.data = data;
    this.sampleRate = sampleRate;
    this.numChannels = numChannels;
    this.samplesPerChannel = samplesPerChannel;
  }
  protoInfo() {
    return {
      data: this.data,
      sampleRate: this.sampleRate,
      numChannels: this.numChannels,
      samplesPerChannel: this.samplesPerChannel
    };
  }
}

const audioSource = new AudioSource(48000, 1, 1000);

const frame = new AudioFrame({
  data: Buffer.alloc(480 * 2),
  sampleRate: 48000,
  numChannels: 1,
  samplesPerChannel: 480
});

audioSource.captureFrame(frame);

Logs

Error: cannot encode field livekit.proto.AudioFrameBufferInfo.data_ptr to binary: required field not set

Error stack: TypeError: frame.protoInfo is not a function
    at AudioSource.captureFrame (file:////Voice/node
_modules/@livekit/rtc-node/dist/audio_source.js:89:21)

System Info

Environment:
@livekit/rtc-node version: 0.13.16
Node.js version: 18.20.8
Platform: macOS

Severity

blocking all usage of LiveKit

Additional Information

Analysis:

  • The SDK expects a protoInfo() method on the frame object, which is not documented.
  • The protobuf encoder expects a data_ptr field, which cannot be set from JavaScript.
  • There is no way to create a valid AudioFrameBufferInfo from userland JS, as data_ptr is likely set by native code.

Expected Behavior:

  • The SDK should accept a Buffer or plain object for audio frames, as documented, or provide a public API to construct the required protobuf message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions