New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@livekit/rtc-node

Package Overview
Dependencies
Maintainers
20
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livekit/rtc-node - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

3

dist/audio_frame.d.ts

@@ -1,2 +0,3 @@

import { AudioFrameBufferInfo, OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
import type { OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
import { AudioFrameBufferInfo } from './proto/audio_frame_pb.js';
export declare class AudioFrame {

@@ -3,0 +4,0 @@ data: Uint16Array;

@@ -19,5 +19,5 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

static fromOwnedInfo(owned) {
let info = owned.info;
let len = info.numChannels * info.samplesPerChannel * 2; // c_int16
let data = FfiClient.instance.copyBuffer(info.dataPtr, len);
const info = owned.info;
const len = info.numChannels * info.samplesPerChannel * 2; // c_int16
const data = FfiClient.instance.copyBuffer(info.dataPtr, len);
new FfiHandle(owned.handle.id).dispose();

@@ -24,0 +24,0 @@ return new AudioFrame(new Uint16Array(data.buffer), info.sampleRate, info.numChannels, info.samplesPerChannel);

@@ -0,4 +1,4 @@

import type { AudioFrame } from './audio_frame.js';
import { FfiHandle } from './napi/native.js';
import { AudioFrame } from './audio_frame.js';
import { AudioSourceInfo } from './proto/audio_frame_pb.js';
import type { AudioSourceInfo } from './proto/audio_frame_pb.js';
export declare class AudioSource {

@@ -5,0 +5,0 @@ /** @internal */

@@ -1,7 +0,4 @@

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient } from './ffi_client.js';
import { FfiHandle } from './napi/native.js';
import { AudioSourceType, CaptureAudioFrameRequest, NewAudioSourceRequest, } from './proto/audio_frame_pb.js';
import { FfiClient } from './ffi_client.js';
export class AudioSource {

@@ -11,3 +8,3 @@ constructor(sampleRate, numChannels) {

this.numChannels = numChannels;
let req = new NewAudioSourceRequest({
const req = new NewAudioSourceRequest({
type: AudioSourceType.AUDIO_SOURCE_NATIVE,

@@ -17,3 +14,3 @@ sampleRate: sampleRate,

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -28,10 +25,10 @@ case: 'newAudioSource',

async captureFrame(frame) {
let req = new CaptureAudioFrameRequest({
const req = new CaptureAudioFrameRequest({
sourceHandle: this.ffiHandle.handle,
buffer: frame.protoInfo(),
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'captureAudioFrame', value: req },
});
let cb = await FfiClient.instance.waitFor((ev) => {
const cb = await FfiClient.instance.waitFor((ev) => {
return ev.message.case == 'captureAudioFrame' && ev.message.value.asyncId == res.asyncId;

@@ -38,0 +35,0 @@ });

@@ -0,6 +1,6 @@

import type TypedEmitter from 'typed-emitter';
import { AudioFrame } from './audio_frame.js';
import { FfiHandle } from './ffi_client.js';
import { AudioStreamInfo } from './proto/audio_frame_pb.js';
import { Track } from './track.js';
import TypedEmitter from 'typed-emitter';
import type { AudioStreamInfo } from './proto/audio_frame_pb.js';
import type { Track } from './track.js';
export type AudioFrameEvent = {

@@ -7,0 +7,0 @@ frame: AudioFrame;

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import { AudioFrame } from './audio_frame.js';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import { AudioStreamType, NewAudioStreamRequest, } from './proto/audio_frame_pb.js';
import EventEmitter from 'events';
import { AudioStreamType, NewAudioStreamRequest } from './proto/audio_frame_pb.js';
export var AudioStreamEvent;

@@ -20,6 +20,6 @@ (function (AudioStreamEvent) {

}
let streamEvent = ev.message.value.message;
const streamEvent = ev.message.value.message;
switch (streamEvent.case) {
case 'frameReceived':
let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
const frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
this.emit(AudioStreamEvent.FrameReceived, { frame });

@@ -33,7 +33,7 @@ break;

this.track = track;
let req = new NewAudioStreamRequest({
const req = new NewAudioStreamRequest({
type: AudioStreamType.AUDIO_STREAM_NATIVE,
trackHandle: track.ffi_handle.handle,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -40,0 +40,0 @@ case: 'newAudioStream',

@@ -25,3 +25,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

setSharedKey(sharedKey, keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -44,3 +44,3 @@ message: {

exportSharedKey(keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -54,3 +54,3 @@ message: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -64,3 +64,3 @@ case: 'e2ee',

ratchetSharedKey(keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -74,3 +74,3 @@ message: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -84,3 +84,3 @@ case: 'e2ee',

setKey(participantIdentity, keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -103,3 +103,3 @@ message: {

exportKey(participantIdentity, keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -114,3 +114,3 @@ message: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -124,3 +124,3 @@ case: 'e2ee',

ratchetKey(participantIdentity, keyIndex) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -135,3 +135,3 @@ message: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -155,3 +155,3 @@ case: 'e2ee',

this.enabled = enabled;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -175,3 +175,3 @@ message: {

this.keyIndex = keyIndex;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -207,3 +207,3 @@ message: {

this.enabled = enabled;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -225,3 +225,3 @@ message: {

frameCryptors() {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -233,3 +233,3 @@ message: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -240,3 +240,3 @@ case: 'e2ee',

});
let frameCryptors = res.message.value.frameCryptors.map((cryptor) => new FrameCryptor(this.roomHandle, cryptor.participantIdentity, cryptor.keyIndex, cryptor.enabled));
const frameCryptors = res.message.value.frameCryptors.map((cryptor) => new FrameCryptor(this.roomHandle, cryptor.participantIdentity, cryptor.keyIndex, cryptor.enabled));
return frameCryptors;

@@ -243,0 +243,0 @@ }

@@ -1,5 +0,5 @@

import { FfiRequest, FfiResponse, FfiEvent } from './proto/ffi_pb.js';
import TypedEmitter from 'typed-emitter';
import type { PartialMessage } from '@bufbuild/protobuf';
import type TypedEmitter from 'typed-emitter';
import { FfiHandle } from './napi/native.js';
import { PartialMessage } from '@bufbuild/protobuf';
import { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';
export { FfiHandle, FfiEvent, FfiResponse, FfiRequest };

@@ -21,4 +21,5 @@ export type FfiClientCallbacks = {

retrievePtr(data: Uint8Array): bigint;
dispose(): Promise<void>;
waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T>;
}
//# sourceMappingURL=ffi_client.d.ts.map

@@ -1,7 +0,4 @@

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiRequest, FfiResponse, FfiEvent } from './proto/ffi_pb.js';
import EventEmitter from 'events';
import { FfiHandle, livekitFfiRequest, livekitInitialize, livekitCopyBuffer, livekitRetrievePtr, } from './napi/native.js';
import { FfiHandle, livekitCopyBuffer, livekitDispose, livekitFfiRequest, livekitInitialize, livekitRetrievePtr, } from './napi/native.js';
import { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';
export { FfiHandle, FfiEvent, FfiResponse, FfiRequest };

@@ -22,3 +19,3 @@ export var FfiClientEvent;

livekitInitialize((event_data) => {
let event = FfiEvent.fromBinary(event_data);
const event = FfiEvent.fromBinary(event_data);
this.emit(FfiClientEvent.FfiEvent, event);

@@ -28,5 +25,5 @@ }, true);

request(req) {
let request = new FfiRequest(req);
let req_data = request.toBinary();
let res_data = livekitFfiRequest(req_data);
const request = new FfiRequest(req);
const req_data = request.toBinary();
const res_data = livekitFfiRequest(req_data);
return FfiResponse.fromBinary(res_data).message.value;

@@ -40,5 +37,8 @@ }

}
async dispose() {
return await livekitDispose();
}
async waitFor(predicate) {
return new Promise((resolve, _) => {
let listener = (ev) => {
return new Promise((resolve) => {
const listener = (ev) => {
if (predicate(ev)) {

@@ -45,0 +45,0 @@ this.off(FfiClientEvent.FfiEvent, listener);

export { Room, RoomEvent, ConnectError, RoomOptions, RtcConfiguration } from './room.js';
export { Participant, RemoteParticipant, LocalParticipant } from './participant.js';
export { Track, LocalTrack, RemoteTrack, VideoTrack, LocalAudioTrack, LocalVideoTrack, RemoteAudioTrack, RemoteVideoTrack, AudioTrack, } from './track.js';
export { VideoFrame, } from './video_frame.js';
export { VideoFrame } from './video_frame.js';
export { AudioFrame } from './audio_frame.js';

@@ -6,0 +6,0 @@ export { AudioStream, AudioFrameEvent } from './audio_stream.js';

@@ -7,3 +7,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

export { Track, LocalAudioTrack, LocalVideoTrack, RemoteAudioTrack, RemoteVideoTrack, } from './track.js';
export { VideoFrame, } from './video_frame.js';
export { VideoFrame } from './video_frame.js';
export { AudioFrame } from './audio_frame.js';

@@ -10,0 +10,0 @@ export { AudioStream } from './audio_stream.js';

@@ -7,2 +7,3 @@ /* tslint:disable */

export function livekitInitialize(callback: (data: Uint8Array) => void, captureLogs: boolean): void;
export function livekitDispose(): Promise<void>;
export function livekitFfiRequest(data: Uint8Array): Uint8Array;

@@ -9,0 +10,0 @@ export function livekitRetrievePtr(handle: Uint8Array): bigint;

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
// this file exists to smoothly translate the autogenerated CommonJS code
// to an ES module that plays better with TypeScript.
import native from './native.cjs';
import native from './native.cjs';
export const {
livekitInitialize,
livekitDispose,
livekitCopyBuffer,

@@ -12,0 +12,0 @@ livekitRetrievePtr,

import { FfiHandle } from './ffi_client.js';
import { ParticipantInfo, OwnedParticipant } from './proto/participant_pb.js';
import { TrackPublishOptions } from './proto/room_pb.js';
import { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.js';
import { LocalTrack } from './track.js';
import type { OwnedParticipant, ParticipantInfo } from './proto/participant_pb.js';
import type { TrackPublishOptions } from './proto/room_pb.js';
import type { LocalTrack } from './track.js';
import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
import { LocalTrackPublication } from './track_publication.js';
export declare abstract class Participant {

@@ -7,0 +8,0 @@ /** @internal */

@@ -6,3 +6,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

import { DataPacketKind, PublishDataRequest, PublishTrackRequest, UnpublishTrackRequest, UpdateLocalMetadataRequest, UpdateLocalNameRequest, } from './proto/room_pb.js';
import { LocalTrackPublication, } from './track_publication.js';
import { LocalTrackPublication } from './track_publication.js';
export class Participant {

@@ -33,3 +33,3 @@ constructor(owned_info) {

async publishData(data, options) {
let req = new PublishDataRequest({
const req = new PublishDataRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -49,6 +49,6 @@ dataPtr: FfiClient.instance.retrievePtr(data),

}
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'publishData', value: req },
});
let cb = await FfiClient.instance.waitFor((ev) => {
const cb = await FfiClient.instance.waitFor((ev) => {
return ev.message.case == 'publishData' && ev.message.value.asyncId == res.asyncId;

@@ -61,7 +61,7 @@ });

async updateMetadata(metadata) {
let req = new UpdateLocalMetadataRequest({
const req = new UpdateLocalMetadataRequest({
localParticipantHandle: this.ffi_handle.handle,
metadata: metadata,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'updateLocalMetadata', value: req },

@@ -74,7 +74,7 @@ });

async updateName(name) {
let req = new UpdateLocalNameRequest({
const req = new UpdateLocalNameRequest({
localParticipantHandle: this.ffi_handle.handle,
name: name,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'updateLocalName', value: req },

@@ -87,3 +87,3 @@ });

async publishTrack(track, options) {
let req = new PublishTrackRequest({
const req = new PublishTrackRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -93,9 +93,9 @@ trackHandle: track.ffi_handle.handle,

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'publishTrack', value: req },
});
let cb = await FfiClient.instance.waitFor((ev) => {
const cb = await FfiClient.instance.waitFor((ev) => {
return ev.message.case == 'publishTrack' && ev.message.value.asyncId == res.asyncId;
});
let track_publication = new LocalTrackPublication(cb.publication);
const track_publication = new LocalTrackPublication(cb.publication);
track_publication.track = track;

@@ -106,7 +106,7 @@ this.trackPublications.set(track_publication.sid, track_publication);

async unpublishTrack(trackSid) {
let req = new UnpublishTrackRequest({
const req = new UnpublishTrackRequest({
localParticipantHandle: this.ffi_handle.handle,
trackSid: trackSid,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'unpublishTrack', value: req },

@@ -117,3 +117,3 @@ });

});
let pub = this.trackPublications.get(trackSid);
const pub = this.trackPublications.get(trackSid);
pub.track = undefined;

@@ -120,0 +120,0 @@ this.trackPublications.delete(trackSid);

@@ -1,8 +0,11 @@

import TypedEmitter from 'typed-emitter';
import { LocalParticipant, Participant, RemoteParticipant } from './participant.js';
import { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType } from './proto/room_pb.js';
import { E2EEManager, E2EEOptions } from './e2ee.js';
import { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.js';
import { LocalTrack, RemoteTrack } from './track.js';
import { EncryptionState } from './proto/e2ee_pb.js';
import type TypedEmitter from 'typed-emitter';
import type { E2EEOptions } from './e2ee.js';
import { E2EEManager } from './e2ee.js';
import type { Participant } from './participant.js';
import { LocalParticipant, RemoteParticipant } from './participant.js';
import type { ConnectionQuality, DataPacketKind, IceServer } from './proto/room_pb.js';
import { ConnectionState, ContinualGatheringPolicy, IceTransportType } from './proto/room_pb.js';
import type { RemoteTrack } from './track.js';
import type { LocalTrackPublication, TrackPublication } from './track_publication.js';
import { RemoteTrackPublication } from './track_publication.js';
export interface RtcConfiguration {

@@ -47,4 +50,4 @@ iceTransportType: IceTransportType;

participantDisconnected: (participant: RemoteParticipant) => void;
localTrackPublished: (publication: LocalTrackPublication, track: LocalTrack) => void;
localTrackUnpublished: (publication: LocalTrackPublication) => void;
localTrackPublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
localTrackUnpublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
trackPublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;

@@ -54,15 +57,15 @@ trackUnpublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;

trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
trackSubscriptionFailed: (participant: RemoteParticipant, publicationSid: string, error: string) => void;
trackMuted: (participant: Participant, publication: TrackPublication) => void;
trackUnmuted: (participant: Participant, publication: TrackPublication) => void;
activeSpeakersChanged: (speakers: RemoteParticipant[]) => void;
roomMetadataChanged: (oldMetadata: string, metadata: string) => void;
participantMetadataChanged: (participant: Participant, oldMetadata: string, metadata: string) => void;
participantNameChanged: (participant: Participant, oldName: string, name: string) => void;
connectionQualityChanged: (participant: Participant, quality: ConnectionQuality) => void;
dataReceived: (data: Uint8Array, kind: DataPacketKind, participant?: RemoteParticipant) => void;
e2eeStateChanged: (participant: Participant, state: EncryptionState) => void;
trackSubscriptionFailed: (trackSid: string, participant: RemoteParticipant, reason?: string) => void;
trackMuted: (publication: TrackPublication, participant: Participant) => void;
trackUnmuted: (publication: TrackPublication, participant: Participant) => void;
activeSpeakersChanged: (speakers: Participant[]) => void;
roomMetadataChanged: (metadata: string) => void;
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
participantNameChanged: (name: string, participant: Participant) => void;
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacketKind, topic?: string) => void;
encryptionError: (error: Error) => void;
connectionStateChanged: (state: ConnectionState) => void;
connected: () => void;
disconnected: () => void;
disconnected: (reason?: string) => void;
reconnecting: () => void;

@@ -89,4 +92,4 @@ reconnected: () => void;

DataReceived = "dataReceived",
E2EEStateChanged = "e2eeStateChanged",
ConenctionStateChanged = "connectionStateChanged",
EncryptionError = "encryptionError",
ConnectionStateChanged = "connectionStateChanged",
Connected = "connected",

@@ -93,0 +96,0 @@ Disconnected = "disconnected",

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import { E2EEManager } from './e2ee.js';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import EventEmitter from 'events';
import { LocalParticipant, RemoteParticipant } from './participant.js';
import { EncryptionState } from './proto/e2ee_pb.js';
import { ConnectRequest, ConnectionState, ContinualGatheringPolicy, IceTransportType, } from './proto/room_pb.js';
import { E2EEManager } from './e2ee.js';
import { RemoteTrackPublication, } from './track_publication.js';
import { TrackKind } from './proto/track_pb.js';
import { RemoteAudioTrack, RemoteVideoTrack } from './track.js';
import { TrackKind } from './proto/track_pb.js';
import { RemoteTrackPublication } from './track_publication.js';
export const defaultRtcConfiguration = {

@@ -33,5 +34,5 @@ iceTransportType: IceTransportType.TRANSPORT_ALL,

}
let ev = ffiEvent.message.value.message;
const ev = ffiEvent.message.value.message;
if (ev.case == 'participantConnected') {
let participant = this.createRemoteParticipant(ev.value.info);
const participant = this.createRemoteParticipant(ev.value.info);
this.remoteParticipants.set(participant.identity, participant);

@@ -41,3 +42,3 @@ this.emit(RoomEvent.ParticipantConnected, participant);

else if (ev.case == 'participantDisconnected') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.remoteParticipants.delete(participant.identity);

@@ -47,13 +48,13 @@ this.emit(RoomEvent.ParticipantDisconnected, participant);

else if (ev.case == 'localTrackPublished') {
let publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
this.emit(RoomEvent.LocalTrackPublished, publication, publication.track);
const publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
this.emit(RoomEvent.LocalTrackPublished, publication, this.localParticipant);
}
else if (ev.case == 'localTrackUnpublished') {
let publication = this.localParticipant.trackPublications.get(ev.value.publicationSid);
const publication = this.localParticipant.trackPublications.get(ev.value.publicationSid);
this.localParticipant.trackPublications.delete(ev.value.publicationSid);
this.emit(RoomEvent.LocalTrackUnpublished, publication);
this.emit(RoomEvent.LocalTrackUnpublished, publication, this.localParticipant);
}
else if (ev.case == 'trackPublished') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = new RemoteTrackPublication(ev.value.publication);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = new RemoteTrackPublication(ev.value.publication);
participant.trackPublications.set(publication.sid, publication);

@@ -63,4 +64,4 @@ this.emit(RoomEvent.TrackPublished, publication, participant);

else if (ev.case == 'trackUnpublished') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.publicationSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.publicationSid);
participant.trackPublications.delete(ev.value.publicationSid);

@@ -70,5 +71,5 @@ this.emit(RoomEvent.TrackUnpublished, publication, participant);

else if (ev.case == 'trackSubscribed') {
let ownedTrack = ev.value.track;
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ownedTrack.info.sid);
const ownedTrack = ev.value.track;
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ownedTrack.info.sid);
publication.subscribed = true;

@@ -84,4 +85,4 @@ if (ownedTrack.info.kind == TrackKind.KIND_VIDEO) {

else if (ev.case == 'trackUnsubscribed') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.track = undefined;

@@ -92,8 +93,8 @@ publication.subscribed = false;

else if (ev.case == 'trackSubscriptionFailed') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.emit(RoomEvent.TrackSubscriptionFailed, participant, ev.value.trackSid, ev.value.error);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.emit(RoomEvent.TrackSubscriptionFailed, ev.value.trackSid, participant, ev.value.error);
}
else if (ev.case == 'trackMuted') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.retrieveParticipant(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.info.muted = true;

@@ -103,7 +104,7 @@ if (publication.track) {

}
this.emit(RoomEvent.TrackMuted, participant, publication);
this.emit(RoomEvent.TrackMuted, publication, participant);
}
else if (ev.case == 'trackUnmuted') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.retrieveParticipant(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.info.muted = false;

@@ -113,44 +114,43 @@ if (publication.track) {

}
this.emit(RoomEvent.TrackUnmuted, participant, publication);
this.emit(RoomEvent.TrackUnmuted, publication, participant);
}
else if (ev.case == 'activeSpeakersChanged') {
let activeSpeakers = ev.value.participantSids.map((sid) => this.getRemoteParticipantBySid(sid));
const activeSpeakers = ev.value.participantSids.map((sid) => this.getRemoteParticipantBySid(sid));
this.emit(RoomEvent.ActiveSpeakersChanged, activeSpeakers);
}
else if (ev.case == 'roomMetadataChanged') {
let oldMetadata = this.info.metadata;
this.info.metadata = ev.value.metadata;
this.emit(RoomEvent.RoomMetadataChanged, oldMetadata, this.info.metadata);
this.emit(RoomEvent.RoomMetadataChanged, this.info.metadata);
}
else if (ev.case == 'participantMetadataChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let oldMetadata = participant.metadata;
const participant = this.retrieveParticipant(ev.value.participantSid);
participant.info.metadata = ev.value.metadata;
this.emit(RoomEvent.ParticipantMetadataChanged, participant, oldMetadata, participant.metadata);
this.emit(RoomEvent.ParticipantMetadataChanged, participant.metadata, participant);
}
else if (ev.case == 'participantNameChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let oldName = participant.name;
const participant = this.retrieveParticipant(ev.value.participantSid);
participant.info.name = ev.value.name;
this.emit(RoomEvent.ParticipantNameChanged, participant, oldName, participant.name);
this.emit(RoomEvent.ParticipantNameChanged, participant.name, participant);
}
else if (ev.case == 'connectionQualityChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.ConnectionQualityChanged, participant, ev.value.quality);
const participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.ConnectionQualityChanged, ev.value.quality, participant);
}
else if (ev.case == 'dataReceived') {
// Can be undefined if the data is sent from a Server SDK
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let info = ev.value.data;
let buffer = FfiClient.instance.copyBuffer(info.data.dataPtr, Number(info.data.dataLen));
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const info = ev.value.data;
const buffer = FfiClient.instance.copyBuffer(info.data.dataPtr, Number(info.data.dataLen));
new FfiHandle(info.handle.id).dispose();
this.emit(RoomEvent.DataReceived, buffer, ev.value.kind, participant);
this.emit(RoomEvent.DataReceived, buffer, participant, ev.value.kind, ev.value.topic);
}
else if (ev.case == 'e2eeStateChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.E2EEStateChanged, participant, ev.value.state);
if (ev.value.state == EncryptionState.INTERNAL_ERROR) {
// throw generic error until Rust SDK is updated to supply the error alongside INTERNAL_ERROR
this.emit(RoomEvent.EncryptionError, new Error('internal server error'));
}
}
else if (ev.case == 'connectionStateChanged') {
this.connectionState = ev.value.state;
this.emit(RoomEvent.ConenctionStateChanged, this.connectionState);
this.emit(RoomEvent.ConnectionStateChanged, this.connectionState);
/*} else if (ev.case == 'connected') {

@@ -184,3 +184,3 @@ this.emit(RoomEvent.Connected);*/

const options = { ...defaultRoomOptions, ...opts };
let req = new ConnectRequest({
const req = new ConnectRequest({
url: url,

@@ -202,3 +202,3 @@ token: token,

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -209,3 +209,3 @@ case: 'connect',

});
let cb = await FfiClient.instance.waitFor((ev) => {
const cb = await FfiClient.instance.waitFor((ev) => {
return ev.message.case == 'connect' && ev.message.value.asyncId == res.asyncId;

@@ -221,6 +221,6 @@ });

this.localParticipant = new LocalParticipant(cb.localParticipant);
for (let pt of cb.participants) {
let rp = this.createRemoteParticipant(pt.participant);
for (let pub of pt.publications) {
let publication = new RemoteTrackPublication(pub);
for (const pt of cb.participants) {
const rp = this.createRemoteParticipant(pt.participant);
for (const pub of pt.publications) {
const publication = new RemoteTrackPublication(pub);
rp.trackPublications.set(publication.sid, publication);

@@ -243,2 +243,5 @@ }

});
FfiClient.instance.removeAllListeners();
await FfiClient.instance.dispose();
this.removeAllListeners();
}

@@ -289,4 +292,4 @@ getRemoteParticipantBySid(sid) {

RoomEvent["DataReceived"] = "dataReceived";
RoomEvent["E2EEStateChanged"] = "e2eeStateChanged";
RoomEvent["ConenctionStateChanged"] = "connectionStateChanged";
RoomEvent["EncryptionError"] = "encryptionError";
RoomEvent["ConnectionStateChanged"] = "connectionStateChanged";
RoomEvent["Connected"] = "connected";

@@ -293,0 +296,0 @@ RoomEvent["Disconnected"] = "disconnected";

import { FfiHandle } from './napi/native.js';
import { EncryptionType } from './proto/e2ee_pb.js';
import { OwnedTrackPublication, TrackKind, TrackPublicationInfo, TrackSource } from './proto/track_pb.js';
import { Track } from './track.js';
import type { EncryptionType } from './proto/e2ee_pb.js';
import type { OwnedTrackPublication, TrackKind, TrackPublicationInfo, TrackSource } from './proto/track_pb.js';
import type { Track } from './track.js';
export declare abstract class TrackPublication {

@@ -6,0 +6,0 @@ /** @internal */

@@ -54,3 +54,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

setSubscribed(subscribed) {
let req = new SetSubscribedRequest({
const req = new SetSubscribedRequest({
subscribe: subscribed,

@@ -57,0 +57,0 @@ publicationHandle: this.ffiHandle.handle,

@@ -1,5 +0,5 @@

import { AudioSource } from './audio_source.js';
import type { AudioSource } from './audio_source.js';
import { FfiHandle } from './ffi_client.js';
import { OwnedTrack, StreamState, TrackInfo, TrackKind } from './proto/track_pb.js';
import { VideoSource } from './video_source.js';
import type { OwnedTrack, StreamState, TrackInfo, TrackKind } from './proto/track_pb.js';
import type { VideoSource } from './video_source.js';
export declare abstract class Track {

@@ -6,0 +6,0 @@ /** @internal */

@@ -1,6 +0,3 @@

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiHandle } from './ffi_client.js';
import { CreateAudioTrackRequest, CreateVideoTrackRequest, } from './proto/track_pb.js';
import { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';
export class Track {

@@ -32,7 +29,7 @@ constructor(owned) {

static createAudioTrack(name, source) {
let req = new CreateAudioTrackRequest({
const req = new CreateAudioTrackRequest({
name: name,
sourceHandle: source.ffiHandle.handle,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'createAudioTrack', value: req },

@@ -48,7 +45,7 @@ });

static createVideoTrack(name, source) {
let req = new CreateVideoTrackRequest({
const req = new CreateVideoTrackRequest({
name: name,
sourceHandle: source.ffiHandle.handle,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: { case: 'createVideoTrack', value: req },

@@ -55,0 +52,0 @@ });

@@ -1,2 +0,3 @@

import { OwnedVideoBuffer, VideoBufferInfo, VideoBufferType } from './proto/video_frame_pb.js';
import type { OwnedVideoBuffer } from './proto/video_frame_pb.js';
import { VideoBufferInfo, VideoBufferType } from './proto/video_frame_pb.js';
export declare class VideoFrame {

@@ -3,0 +4,0 @@ data: Uint8Array;

@@ -39,3 +39,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

static fromOwnedInfo(owned) {
let info = owned.info;
const info = owned.info;
return new VideoFrame(FfiClient.instance.copyBuffer(info.dataPtr, getPlaneLength(info.type, info.width, info.height)), info.width, info.height, info.type);

@@ -42,0 +42,0 @@ }

import { FfiHandle } from './ffi_client.js';
import { VideoRotation, VideoSourceInfo } from './proto/video_frame_pb.js';
import { VideoFrame } from './video_frame.js';
import type { VideoSourceInfo } from './proto/video_frame_pb.js';
import { VideoRotation } from './proto/video_frame_pb.js';
import type { VideoFrame } from './video_frame.js';
export declare class VideoSource {

@@ -5,0 +6,0 @@ /** @internal */

@@ -10,3 +10,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

this.height = height;
let req = new NewVideoSourceRequest({
const req = new NewVideoSourceRequest({
type: VideoSourceType.VIDEO_SOURCE_NATIVE,

@@ -18,3 +18,3 @@ resolution: {

});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -29,3 +29,3 @@ case: 'newVideoSource',

captureFrame(frame, timestampUs = 0n, rotation = VideoRotation.VIDEO_ROTATION_0) {
let req = new CaptureVideoFrameRequest({
const req = new CaptureVideoFrameRequest({
sourceHandle: this.ffiHandle.handle,

@@ -32,0 +32,0 @@ buffer: frame.protoInfo(),

@@ -0,6 +1,6 @@

import type TypedEmitter from 'typed-emitter';
import { FfiHandle } from './ffi_client.js';
import { Track } from './track.js';
import TypedEmitter from 'typed-emitter';
import type { VideoRotation, VideoStreamInfo } from './proto/video_frame_pb.js';
import type { Track } from './track.js';
import { VideoFrame } from './video_frame.js';
import { VideoRotation, VideoStreamInfo } from './proto/video_frame_pb.js';
export type VideoFrameEvent = {

@@ -7,0 +7,0 @@ frame: VideoFrame;

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import EventEmitter from 'events';
import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
import { VideoFrame } from './video_frame.js';
import { NewVideoStreamRequest, VideoStreamType, } from './proto/video_frame_pb.js';
export var VideoStreamEvent;

@@ -20,8 +20,8 @@ (function (VideoStreamEvent) {

}
let streamEvent = ev.message.value.message;
const streamEvent = ev.message.value.message;
switch (streamEvent.case) {
case 'frameReceived':
let rotation = streamEvent.value.rotation;
let timestampUs = streamEvent.value.timestampUs;
let frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
const rotation = streamEvent.value.rotation;
const timestampUs = streamEvent.value.timestampUs;
const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
this.emit(VideoStreamEvent.FrameReceived, { frame, timestampUs, rotation });

@@ -35,7 +35,7 @@ break;

this.track = track;
let req = new NewVideoStreamRequest({
const req = new NewVideoStreamRequest({
type: VideoStreamType.VIDEO_STREAM_NATIVE,
trackHandle: track.ffi_handle.handle,
});
let res = FfiClient.instance.request({
const res = FfiClient.instance.request({
message: {

@@ -42,0 +42,0 @@ case: 'newVideoStream',

@@ -5,6 +5,12 @@ {

"license": "Apache-2.0",
"version": "0.3.0",
"author": "LiveKit",
"version": "0.4.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/livekit/node-sdks-temp.git",
"directory": "rtc-node"
},
"files": [

@@ -43,9 +49,2 @@ "dist",

},
"optionalDependencies": {
"@livekit/rtc-node-darwin-arm64": "0.3.0",
"@livekit/rtc-node-darwin-x64": "0.3.0",
"@livekit/rtc-node-linux-arm64-gnu": "0.3.0",
"@livekit/rtc-node-linux-x64-gnu": "0.3.0",
"@livekit/rtc-node-win32-x64-msvc": "0.3.0"
},
"scripts": {

@@ -56,2 +55,3 @@ "build:tsc": "tsc && cp -r src/napi dist/napi",

"build:debug": "napi build --platform",
"lint": "eslint -f unix \"src/**/*.ts\" --ignore-pattern \"src/proto/*\"",
"universal": "napi universal",

@@ -58,0 +58,0 @@ "version": "napi version"

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiHandle } from './ffi_client.js';
import { AudioFrameBufferInfo, OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
import type { OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
import { AudioFrameBufferInfo } from './proto/audio_frame_pb.js';

@@ -28,5 +28,5 @@ export class AudioFrame {

static fromOwnedInfo(owned: OwnedAudioFrameBuffer): AudioFrame {
let info = owned.info;
let len = info.numChannels * info.samplesPerChannel * 2; // c_int16
let data = FfiClient.instance.copyBuffer(info.dataPtr, len);
const info = owned.info;
const len = info.numChannels * info.samplesPerChannel * 2; // c_int16
const data = FfiClient.instance.copyBuffer(info.dataPtr, len);
new FfiHandle(owned.handle.id).dispose();

@@ -33,0 +33,0 @@ return new AudioFrame(

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import TypedEmitter from 'typed-emitter';
import type { AudioFrame } from './audio_frame.js';
import { FfiClient } from './ffi_client.js';
import { FfiHandle } from './napi/native.js';
import { AudioFrame } from './audio_frame.js';
import {
import type {
AudioSourceInfo,
AudioSourceType,
CaptureAudioFrameCallback,
CaptureAudioFrameRequest,
CaptureAudioFrameResponse,
NewAudioSourceRequest,
NewAudioSourceResponse,
} from './proto/audio_frame_pb.js';
import { FfiClient, FfiRequest } from './ffi_client.js';
import {
AudioSourceType,
CaptureAudioFrameRequest,
NewAudioSourceRequest,
} from './proto/audio_frame_pb.js';

@@ -33,3 +32,3 @@ export class AudioSource {

let req = new NewAudioSourceRequest({
const req = new NewAudioSourceRequest({
type: AudioSourceType.AUDIO_SOURCE_NATIVE,

@@ -40,3 +39,3 @@ sampleRate: sampleRate,

let res = FfiClient.instance.request<NewAudioSourceResponse>({
const res = FfiClient.instance.request<NewAudioSourceResponse>({
message: {

@@ -53,3 +52,3 @@ case: 'newAudioSource',

async captureFrame(frame: AudioFrame) {
let req = new CaptureAudioFrameRequest({
const req = new CaptureAudioFrameRequest({
sourceHandle: this.ffiHandle.handle,

@@ -59,7 +58,7 @@ buffer: frame.protoInfo(),

let res = FfiClient.instance.request<CaptureAudioFrameResponse>({
const res = FfiClient.instance.request<CaptureAudioFrameResponse>({
message: { case: 'captureAudioFrame', value: req },
});
let cb = await FfiClient.instance.waitFor<CaptureAudioFrameCallback>((ev) => {
const cb = await FfiClient.instance.waitFor<CaptureAudioFrameCallback>((ev) => {
return ev.message.case == 'captureAudioFrame' && ev.message.value.asyncId == res.asyncId;

@@ -66,0 +65,0 @@ });

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import type TypedEmitter from 'typed-emitter';
import { AudioFrame } from './audio_frame.js';
import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client.js';
import {
AudioStreamInfo,
AudioStreamType,
NewAudioStreamRequest,
NewAudioStreamResponse,
} from './proto/audio_frame_pb.js';
import { Track } from './track.js';
import EventEmitter from 'events';
import TypedEmitter from 'typed-emitter';
import type { FfiEvent } from './ffi_client.js';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import type { AudioStreamInfo, NewAudioStreamResponse } from './proto/audio_frame_pb.js';
import { AudioStreamType, NewAudioStreamRequest } from './proto/audio_frame_pb.js';
import type { Track } from './track.js';
export type AudioFrameEvent = {
frame: AudioFrame
}
frame: AudioFrame;
};

@@ -41,3 +37,3 @@ export type AudioStreamCallbacks = {

let req = new NewAudioStreamRequest({
const req = new NewAudioStreamRequest({
type: AudioStreamType.AUDIO_STREAM_NATIVE,

@@ -47,3 +43,3 @@ trackHandle: track.ffi_handle.handle,

let res = FfiClient.instance.request<NewAudioStreamResponse>({
const res = FfiClient.instance.request<NewAudioStreamResponse>({
message: {

@@ -69,6 +65,6 @@ case: 'newAudioStream',

let streamEvent = ev.message.value.message;
const streamEvent = ev.message.value.message;
switch (streamEvent.case) {
case 'frameReceived':
let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
const frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
this.emit(AudioStreamEvent.FrameReceived, { frame });

@@ -75,0 +71,0 @@ break;

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiRequest } from './ffi_client.js';
import { FfiClient } from './ffi_client.js';
import type {
E2eeManagerGetFrameCryptorsResponse,
E2eeResponse,
GetKeyResponse,
GetSharedKeyResponse,
RatchetKeyResponse,
RatchetSharedKeyResponse,
} from './proto/e2ee_pb.js';
import {
E2eeManagerGetFrameCryptorsResponse,
E2eeManagerSetEnabledRequest,
E2eeRequest,
E2eeResponse,
EncryptionType,

@@ -15,9 +20,5 @@ FrameCryptorSetEnabledRequest,

GetKeyRequest,
GetKeyResponse,
GetSharedKeyRequest,
GetSharedKeyResponse,
RatchetKeyRequest,
RatchetKeyResponse,
RatchetSharedKeyRequest,
RatchetSharedKeyResponse,
SetKeyRequest,

@@ -65,3 +66,3 @@ SetSharedKeyRequest,

setSharedKey(sharedKey: Uint8Array, keyIndex: number) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -86,3 +87,3 @@ message: {

exportSharedKey(keyIndex: number): Uint8Array {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -97,3 +98,3 @@ message: {

let res = FfiClient.instance.request<E2eeResponse>({
const res = FfiClient.instance.request<E2eeResponse>({
message: {

@@ -109,3 +110,3 @@ case: 'e2ee',

ratchetSharedKey(keyIndex: number): Uint8Array {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -120,3 +121,3 @@ message: {

let res = FfiClient.instance.request<E2eeResponse>({
const res = FfiClient.instance.request<E2eeResponse>({
message: {

@@ -132,3 +133,3 @@ case: 'e2ee',

setKey(participantIdentity: string, keyIndex: number) {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -153,3 +154,3 @@ message: {

exportKey(participantIdentity: string, keyIndex: number): Uint8Array {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -165,3 +166,3 @@ message: {

let res = FfiClient.instance.request<E2eeResponse>({
const res = FfiClient.instance.request<E2eeResponse>({
message: {

@@ -177,3 +178,3 @@ case: 'e2ee',

ratchetKey(participantIdentity: string, keyIndex: number): Uint8Array {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -189,3 +190,3 @@ message: {

let res = FfiClient.instance.request<E2eeResponse>({
const res = FfiClient.instance.request<E2eeResponse>({
message: {

@@ -216,3 +217,3 @@ case: 'e2ee',

this.enabled = enabled;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -238,3 +239,3 @@ message: {

this.keyIndex = keyIndex;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -280,3 +281,3 @@ message: {

this.enabled = enabled;
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -300,3 +301,3 @@ message: {

frameCryptors(): FrameCryptor[] {
let req = new E2eeRequest({
const req = new E2eeRequest({
roomHandle: this.roomHandle,

@@ -309,3 +310,3 @@ message: {

let res = FfiClient.instance.request<E2eeResponse>({
const res = FfiClient.instance.request<E2eeResponse>({
message: {

@@ -317,3 +318,3 @@ case: 'e2ee',

let frameCryptors = (
const frameCryptors = (
res.message.value as E2eeManagerGetFrameCryptorsResponse

@@ -320,0 +321,0 @@ ).frameCryptors.map(

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiRequest, FfiResponse, FfiEvent } from './proto/ffi_pb.js';
import type { PartialMessage } from '@bufbuild/protobuf';
import EventEmitter from 'events';
import TypedEmitter from 'typed-emitter';
import type TypedEmitter from 'typed-emitter';
import {
FfiHandle,
livekitCopyBuffer,
livekitDispose,
livekitFfiRequest,
livekitInitialize,
livekitCopyBuffer,
livekitRetrievePtr,
} from './napi/native.js';
import { PartialMessage } from '@bufbuild/protobuf';
import { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';

@@ -41,3 +41,3 @@ export { FfiHandle, FfiEvent, FfiResponse, FfiRequest };

livekitInitialize((event_data: Uint8Array) => {
let event = FfiEvent.fromBinary(event_data);
const event = FfiEvent.fromBinary(event_data);
this.emit(FfiClientEvent.FfiEvent, event);

@@ -48,5 +48,5 @@ }, true);

request<T>(req: PartialMessage<FfiRequest>): T {
let request = new FfiRequest(req);
let req_data = request.toBinary();
let res_data = livekitFfiRequest(req_data);
const request = new FfiRequest(req);
const req_data = request.toBinary();
const res_data = livekitFfiRequest(req_data);
return FfiResponse.fromBinary(res_data).message.value as T;

@@ -63,5 +63,9 @@ }

async dispose() {
return await livekitDispose();
}
async waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T> {
return new Promise<T>((resolve, _) => {
let listener = (ev: FfiEvent) => {
return new Promise<T>((resolve) => {
const listener = (ev: FfiEvent) => {
if (predicate(ev)) {

@@ -68,0 +72,0 @@ this.off(FfiClientEvent.FfiEvent, listener);

@@ -18,5 +18,3 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.

} from './track.js';
export {
VideoFrame,
} from './video_frame.js';
export { VideoFrame } from './video_frame.js';
export { AudioFrame } from './audio_frame.js';

@@ -23,0 +21,0 @@ export { AudioStream, AudioFrameEvent } from './audio_stream.js';

@@ -7,2 +7,3 @@ /* tslint:disable */

export function livekitInitialize(callback: (data: Uint8Array) => void, captureLogs: boolean): void;
export function livekitDispose(): Promise<void>;
export function livekitFfiRequest(data: Uint8Array): Uint8Array;

@@ -9,0 +10,0 @@ export function livekitRetrievePtr(handle: Uint8Array): bigint;

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
// this file exists to smoothly translate the autogenerated CommonJS code
// to an ES module that plays better with TypeScript.
import native from './native.cjs';
import native from './native.cjs';
export const {
livekitInitialize,
livekitDispose,
livekitCopyBuffer,

@@ -12,0 +12,0 @@ livekitRetrievePtr,

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiClientEvent, FfiHandle, FfiRequest } from './ffi_client.js';
import { ParticipantInfo, OwnedParticipant } from './proto/participant_pb.js';
import {
DataPacketKind,
import { FfiClient, FfiHandle } from './ffi_client.js';
import type { OwnedParticipant, ParticipantInfo } from './proto/participant_pb.js';
import type {
PublishDataCallback,
PublishDataRequest,
PublishDataResponse,
PublishTrackCallback,
PublishTrackRequest,
PublishTrackResponse,
TrackPublishOptions,
UnpublishTrackCallback,
UnpublishTrackRequest,
UnpublishTrackResponse,
UpdateLocalMetadataCallback,
UpdateLocalMetadataRequest,
UpdateLocalMetadataResponse,
UpdateLocalNameCallback,
UpdateLocalNameRequest,
UpdateLocalNameResponse,
} from './proto/room_pb.js';
import {
LocalTrackPublication,
RemoteTrackPublication,
TrackPublication,
} from './track_publication.js';
import { LocalTrack } from './track.js';
DataPacketKind,
PublishDataRequest,
PublishTrackRequest,
UnpublishTrackRequest,
UpdateLocalMetadataRequest,
UpdateLocalNameRequest,
} from './proto/room_pb.js';
import type { LocalTrack } from './track.js';
import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
import { LocalTrackPublication } from './track_publication.js';

@@ -84,3 +82,3 @@ export abstract class Participant {

async publishData(data: Uint8Array, options: DataPublishOptions) {
let req = new PublishDataRequest({
const req = new PublishDataRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -101,7 +99,7 @@ dataPtr: FfiClient.instance.retrievePtr(data),

let res = FfiClient.instance.request<PublishDataResponse>({
const res = FfiClient.instance.request<PublishDataResponse>({
message: { case: 'publishData', value: req },
});
let cb = await FfiClient.instance.waitFor<PublishDataCallback>((ev) => {
const cb = await FfiClient.instance.waitFor<PublishDataCallback>((ev) => {
return ev.message.case == 'publishData' && ev.message.value.asyncId == res.asyncId;

@@ -116,3 +114,3 @@ });

async updateMetadata(metadata: string) {
let req = new UpdateLocalMetadataRequest({
const req = new UpdateLocalMetadataRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -122,3 +120,3 @@ metadata: metadata,

let res = FfiClient.instance.request<UpdateLocalMetadataResponse>({
const res = FfiClient.instance.request<UpdateLocalMetadataResponse>({
message: { case: 'updateLocalMetadata', value: req },

@@ -133,3 +131,3 @@ });

async updateName(name: string) {
let req = new UpdateLocalNameRequest({
const req = new UpdateLocalNameRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -139,3 +137,3 @@ name: name,

let res = FfiClient.instance.request<UpdateLocalNameResponse>({
const res = FfiClient.instance.request<UpdateLocalNameResponse>({
message: { case: 'updateLocalName', value: req },

@@ -153,3 +151,3 @@ });

): Promise<LocalTrackPublication> {
let req = new PublishTrackRequest({
const req = new PublishTrackRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -160,11 +158,11 @@ trackHandle: track.ffi_handle.handle,

let res = FfiClient.instance.request<PublishTrackResponse>({
const res = FfiClient.instance.request<PublishTrackResponse>({
message: { case: 'publishTrack', value: req },
});
let cb = await FfiClient.instance.waitFor<PublishTrackCallback>((ev) => {
const cb = await FfiClient.instance.waitFor<PublishTrackCallback>((ev) => {
return ev.message.case == 'publishTrack' && ev.message.value.asyncId == res.asyncId;
});
let track_publication = new LocalTrackPublication(cb.publication);
const track_publication = new LocalTrackPublication(cb.publication);
track_publication.track = track;

@@ -177,3 +175,3 @@ this.trackPublications.set(track_publication.sid, track_publication);

async unpublishTrack(trackSid: string) {
let req = new UnpublishTrackRequest({
const req = new UnpublishTrackRequest({
localParticipantHandle: this.ffi_handle.handle,

@@ -183,3 +181,3 @@ trackSid: trackSid,

let res = FfiClient.instance.request<UnpublishTrackResponse>({
const res = FfiClient.instance.request<UnpublishTrackResponse>({
message: { case: 'unpublishTrack', value: req },

@@ -192,3 +190,3 @@ });

let pub = this.trackPublications.get(trackSid);
const pub = this.trackPublications.get(trackSid);
pub.track = undefined;

@@ -195,0 +193,0 @@ this.trackPublications.delete(trackSid);

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import EventEmitter from 'events';
import type TypedEmitter from 'typed-emitter';
import type { E2EEOptions } from './e2ee.js';
import { E2EEManager } from './e2ee.js';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import EventEmitter from 'events';
import TypedEmitter from 'typed-emitter';
import { FfiEvent } from './proto/ffi_pb.js';
import { LocalParticipant, Participant, RemoteParticipant } from './participant.js';
import {
import type { Participant } from './participant.js';
import { LocalParticipant, RemoteParticipant } from './participant.js';
import { EncryptionState } from './proto/e2ee_pb.js';
import type { FfiEvent } from './proto/ffi_pb.js';
import type { OwnedParticipant } from './proto/participant_pb.js';
import type {
ConnectCallback,
ConnectRequest,
ConnectResponse,
ConnectionQuality,
ConnectionState,
ContinualGatheringPolicy,
DataPacketKind,
DisconnectResponse,
IceServer,
IceTransportType,
RoomInfo,
} from './proto/room_pb.js';
import { E2EEManager, E2EEOptions, defaultE2EEOptions } from './e2ee.js';
import { OwnedParticipant } from './proto/participant_pb.js';
import {
LocalTrackPublication,
RemoteTrackPublication,
TrackPublication,
} from './track_publication.js';
import { LocalTrack, RemoteAudioTrack, RemoteTrack, RemoteVideoTrack } from './track.js';
ConnectRequest,
ConnectionState,
ContinualGatheringPolicy,
IceTransportType,
} from './proto/room_pb.js';
import { TrackKind } from './proto/track_pb.js';
import { EncryptionState } from './proto/e2ee_pb.js';
import type { RemoteTrack } from './track.js';
import { RemoteAudioTrack, RemoteVideoTrack } from './track.js';
import type { LocalTrackPublication, TrackPublication } from './track_publication.js';
import { RemoteTrackPublication } from './track_publication.js';

@@ -93,3 +94,3 @@ export interface RtcConfiguration {

let req = new ConnectRequest({
const req = new ConnectRequest({
url: url,

@@ -112,3 +113,3 @@ token: token,

let res = FfiClient.instance.request<ConnectResponse>({
const res = FfiClient.instance.request<ConnectResponse>({
message: {

@@ -120,3 +121,3 @@ case: 'connect',

let cb = await FfiClient.instance.waitFor<ConnectCallback>((ev: FfiEvent) => {
const cb = await FfiClient.instance.waitFor<ConnectCallback>((ev: FfiEvent) => {
return ev.message.case == 'connect' && ev.message.value.asyncId == res.asyncId;

@@ -136,7 +137,7 @@ });

for (let pt of cb.participants) {
let rp = this.createRemoteParticipant(pt.participant);
for (const pt of cb.participants) {
const rp = this.createRemoteParticipant(pt.participant);
for (let pub of pt.publications) {
let publication = new RemoteTrackPublication(pub);
for (const pub of pt.publications) {
const publication = new RemoteTrackPublication(pub);
rp.trackPublications.set(publication.sid, publication);

@@ -162,2 +163,6 @@ }

});
FfiClient.instance.removeAllListeners();
await FfiClient.instance.dispose();
this.removeAllListeners();
}

@@ -173,32 +178,32 @@

let ev = ffiEvent.message.value.message;
const ev = ffiEvent.message.value.message;
if (ev.case == 'participantConnected') {
let participant = this.createRemoteParticipant(ev.value.info);
const participant = this.createRemoteParticipant(ev.value.info);
this.remoteParticipants.set(participant.identity, participant);
this.emit(RoomEvent.ParticipantConnected, participant);
} else if (ev.case == 'participantDisconnected') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.remoteParticipants.delete(participant.identity);
this.emit(RoomEvent.ParticipantDisconnected, participant);
} else if (ev.case == 'localTrackPublished') {
let publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
this.emit(RoomEvent.LocalTrackPublished, publication, publication.track);
const publication = this.localParticipant.trackPublications.get(ev.value.trackSid);
this.emit(RoomEvent.LocalTrackPublished, publication, this.localParticipant);
} else if (ev.case == 'localTrackUnpublished') {
let publication = this.localParticipant.trackPublications.get(ev.value.publicationSid);
const publication = this.localParticipant.trackPublications.get(ev.value.publicationSid);
this.localParticipant.trackPublications.delete(ev.value.publicationSid);
this.emit(RoomEvent.LocalTrackUnpublished, publication);
this.emit(RoomEvent.LocalTrackUnpublished, publication, this.localParticipant);
} else if (ev.case == 'trackPublished') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = new RemoteTrackPublication(ev.value.publication);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = new RemoteTrackPublication(ev.value.publication);
participant.trackPublications.set(publication.sid, publication);
this.emit(RoomEvent.TrackPublished, publication, participant);
} else if (ev.case == 'trackUnpublished') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.publicationSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.publicationSid);
participant.trackPublications.delete(ev.value.publicationSid);
this.emit(RoomEvent.TrackUnpublished, publication, participant);
} else if (ev.case == 'trackSubscribed') {
let ownedTrack = ev.value.track;
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ownedTrack.info.sid);
const ownedTrack = ev.value.track;
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ownedTrack.info.sid);
publication.subscribed = true;

@@ -213,4 +218,4 @@ if (ownedTrack.info.kind == TrackKind.KIND_VIDEO) {

} else if (ev.case == 'trackUnsubscribed') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.track = undefined;

@@ -220,7 +225,7 @@ publication.subscribed = false;

} else if (ev.case == 'trackSubscriptionFailed') {
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.emit(RoomEvent.TrackSubscriptionFailed, participant, ev.value.trackSid, ev.value.error);
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
this.emit(RoomEvent.TrackSubscriptionFailed, ev.value.trackSid, participant, ev.value.error);
} else if (ev.case == 'trackMuted') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.retrieveParticipant(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.info.muted = true;

@@ -230,6 +235,6 @@ if (publication.track) {

}
this.emit(RoomEvent.TrackMuted, participant, publication);
this.emit(RoomEvent.TrackMuted, publication, participant);
} else if (ev.case == 'trackUnmuted') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let publication = participant.trackPublications.get(ev.value.trackSid);
const participant = this.retrieveParticipant(ev.value.participantSid);
const publication = participant.trackPublications.get(ev.value.trackSid);
publication.info.muted = false;

@@ -239,5 +244,5 @@ if (publication.track) {

}
this.emit(RoomEvent.TrackUnmuted, participant, publication);
this.emit(RoomEvent.TrackUnmuted, publication, participant);
} else if (ev.case == 'activeSpeakersChanged') {
let activeSpeakers = ev.value.participantSids.map((sid) =>
const activeSpeakers = ev.value.participantSids.map((sid) =>
this.getRemoteParticipantBySid(sid),

@@ -247,36 +252,30 @@ );

} else if (ev.case == 'roomMetadataChanged') {
let oldMetadata = this.info.metadata;
this.info.metadata = ev.value.metadata;
this.emit(RoomEvent.RoomMetadataChanged, oldMetadata, this.info.metadata);
this.emit(RoomEvent.RoomMetadataChanged, this.info.metadata);
} else if (ev.case == 'participantMetadataChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let oldMetadata = participant.metadata;
const participant = this.retrieveParticipant(ev.value.participantSid);
participant.info.metadata = ev.value.metadata;
this.emit(
RoomEvent.ParticipantMetadataChanged,
participant,
oldMetadata,
participant.metadata,
);
this.emit(RoomEvent.ParticipantMetadataChanged, participant.metadata, participant);
} else if (ev.case == 'participantNameChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
let oldName = participant.name;
const participant = this.retrieveParticipant(ev.value.participantSid);
participant.info.name = ev.value.name;
this.emit(RoomEvent.ParticipantNameChanged, participant, oldName, participant.name);
this.emit(RoomEvent.ParticipantNameChanged, participant.name, participant);
} else if (ev.case == 'connectionQualityChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.ConnectionQualityChanged, participant, ev.value.quality);
const participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.ConnectionQualityChanged, ev.value.quality, participant);
} else if (ev.case == 'dataReceived') {
// Can be undefined if the data is sent from a Server SDK
let participant = this.getRemoteParticipantBySid(ev.value.participantSid);
let info = ev.value.data;
let buffer = FfiClient.instance.copyBuffer(info.data.dataPtr, Number(info.data.dataLen));
const participant = this.getRemoteParticipantBySid(ev.value.participantSid);
const info = ev.value.data;
const buffer = FfiClient.instance.copyBuffer(info.data.dataPtr, Number(info.data.dataLen));
new FfiHandle(info.handle.id).dispose();
this.emit(RoomEvent.DataReceived, buffer, ev.value.kind, participant);
this.emit(RoomEvent.DataReceived, buffer, participant, ev.value.kind, ev.value.topic);
} else if (ev.case == 'e2eeStateChanged') {
let participant = this.retrieveParticipant(ev.value.participantSid);
this.emit(RoomEvent.E2EEStateChanged, participant, ev.value.state);
if (ev.value.state == EncryptionState.INTERNAL_ERROR) {
// throw generic error until Rust SDK is updated to supply the error alongside INTERNAL_ERROR
this.emit(RoomEvent.EncryptionError, new Error('internal server error'));
}
} else if (ev.case == 'connectionStateChanged') {
this.connectionState = ev.value.state;
this.emit(RoomEvent.ConenctionStateChanged, this.connectionState);
this.emit(RoomEvent.ConnectionStateChanged, this.connectionState);
/*} else if (ev.case == 'connected') {

@@ -325,4 +324,7 @@ this.emit(RoomEvent.Connected);*/

participantDisconnected: (participant: RemoteParticipant) => void;
localTrackPublished: (publication: LocalTrackPublication, track: LocalTrack) => void;
localTrackUnpublished: (publication: LocalTrackPublication) => void;
localTrackPublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
localTrackUnpublished: (
publication: LocalTrackPublication,
participant: LocalParticipant,
) => void;
trackPublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;

@@ -341,22 +343,23 @@ trackUnpublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;

trackSubscriptionFailed: (
trackSid: string,
participant: RemoteParticipant,
publicationSid: string,
error: string,
reason?: string,
) => void;
trackMuted: (participant: Participant, publication: TrackPublication) => void;
trackUnmuted: (participant: Participant, publication: TrackPublication) => void;
activeSpeakersChanged: (speakers: RemoteParticipant[]) => void;
roomMetadataChanged: (oldMetadata: string, metadata: string) => void;
participantMetadataChanged: (
participant: Participant,
oldMetadata: string,
metadata: string,
trackMuted: (publication: TrackPublication, participant: Participant) => void;
trackUnmuted: (publication: TrackPublication, participant: Participant) => void;
activeSpeakersChanged: (speakers: Participant[]) => void;
roomMetadataChanged: (metadata: string) => void;
participantMetadataChanged: (metadata: string | undefined, participant: Participant) => void;
participantNameChanged: (name: string, participant: Participant) => void;
connectionQualityChanged: (quality: ConnectionQuality, participant: Participant) => void;
dataReceived: (
payload: Uint8Array,
participant?: RemoteParticipant,
kind?: DataPacketKind,
topic?: string,
) => void;
participantNameChanged: (participant: Participant, oldName: string, name: string) => void;
connectionQualityChanged: (participant: Participant, quality: ConnectionQuality) => void;
dataReceived: (data: Uint8Array, kind: DataPacketKind, participant?: RemoteParticipant) => void;
e2eeStateChanged: (participant: Participant, state: EncryptionState) => void;
encryptionError: (error: Error) => void;
connectionStateChanged: (state: ConnectionState) => void;
connected: () => void;
disconnected: () => void;
disconnected: (reason?: string) => void;
reconnecting: () => void;

@@ -384,4 +387,4 @@ reconnected: () => void;

DataReceived = 'dataReceived',
E2EEStateChanged = 'e2eeStateChanged',
ConenctionStateChanged = 'connectionStateChanged',
EncryptionError = 'encryptionError',
ConnectionStateChanged = 'connectionStateChanged',
Connected = 'connected',

@@ -388,0 +391,0 @@ Disconnected = 'disconnected',

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiRequest } from './ffi_client.js';
import { FfiClient } from './ffi_client.js';
import { FfiHandle } from './napi/native.js';
import { EncryptionType } from './proto/e2ee_pb.js';
import { SetSubscribedRequest, SetSubscribedResponse } from './proto/room_pb.js';
import {
import type { EncryptionType } from './proto/e2ee_pb.js';
import type { SetSubscribedResponse } from './proto/room_pb.js';
import { SetSubscribedRequest } from './proto/room_pb.js';
import type {
OwnedTrackPublication,

@@ -15,3 +15,3 @@ TrackKind,

} from './proto/track_pb.js';
import { Track } from './track.js';
import type { Track } from './track.js';

@@ -86,3 +86,3 @@ export abstract class TrackPublication {

setSubscribed(subscribed: boolean) {
let req = new SetSubscribedRequest({
const req = new SetSubscribedRequest({
subscribe: subscribed,

@@ -89,0 +89,0 @@ publicationHandle: this.ffiHandle.handle,

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { AudioSource } from './audio_source.js';
import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
import {
CreateAudioTrackRequest,
import type { AudioSource } from './audio_source.js';
import { FfiClient, FfiHandle } from './ffi_client.js';
import type {
CreateAudioTrackResponse,
CreateVideoTrackRequest,
CreateVideoTrackResponse,

@@ -17,3 +14,4 @@ OwnedTrack,

} from './proto/track_pb.js';
import { VideoSource } from './video_source.js';
import { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';
import type { VideoSource } from './video_source.js';

@@ -59,3 +57,3 @@ export abstract class Track {

static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack {
let req = new CreateAudioTrackRequest({
const req = new CreateAudioTrackRequest({
name: name,

@@ -65,3 +63,3 @@ sourceHandle: source.ffiHandle.handle,

let res = FfiClient.instance.request<CreateAudioTrackResponse>({
const res = FfiClient.instance.request<CreateAudioTrackResponse>({
message: { case: 'createAudioTrack', value: req },

@@ -80,3 +78,3 @@ });

static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack {
let req = new CreateVideoTrackRequest({
const req = new CreateVideoTrackRequest({
name: name,

@@ -86,3 +84,3 @@ sourceHandle: source.ffiHandle.handle,

let res = FfiClient.instance.request<CreateVideoTrackResponse>({
const res = FfiClient.instance.request<CreateVideoTrackResponse>({
message: { case: 'createVideoTrack', value: req },

@@ -89,0 +87,0 @@ });

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
import { FfiClient, FfiRequest } from './ffi_client.js';
import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
import {
OwnedVideoBuffer,
VideoBufferInfo,
VideoBufferInfo_ComponentInfo,
VideoBufferType,
VideoConvertResponse,
} from './proto/video_frame_pb.js';

@@ -20,8 +18,3 @@

constructor(
data: Uint8Array,
width: number,
height: number,
type: VideoBufferType,
) {
constructor(data: Uint8Array, width: number, height: number, type: VideoBufferType) {
this.data = data;

@@ -35,3 +28,3 @@ this.width = width;

get dataPtr(): bigint {
return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer))
return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
}

@@ -65,3 +58,3 @@

static fromOwnedInfo(owned: OwnedVideoBuffer): VideoFrame {
let info = owned.info;
const info = owned.info;
return new VideoFrame(

@@ -79,3 +72,3 @@ FfiClient.instance.copyBuffer(

getPlane(planeNth: number): Uint8Array | void {
const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height)
const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
if (planeNth >= planeInfos.length) return;

@@ -98,8 +91,8 @@

});
const resp = FfiClient.instance.request<VideoConvertResponse>(req)
const resp = FfiClient.instance.request<VideoConvertResponse>(req);
if (resp.error) {
throw resp.error
throw resp.error;
}
return VideoFrame.fromOwnedInfo(resp.buffer)
return VideoFrame.fromOwnedInfo(resp.buffer);
}

@@ -106,0 +99,0 @@ }

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
import { FfiClient, FfiHandle } from './ffi_client.js';
import type {
CaptureVideoFrameResponse,
NewVideoSourceResponse,
VideoSourceInfo,
} from './proto/video_frame_pb.js';
import {
CaptureVideoFrameRequest,
CaptureVideoFrameResponse,
NewVideoSourceRequest,
NewVideoSourceResponse,
VideoRotation,
VideoSourceInfo,
VideoSourceType,
} from './proto/video_frame_pb.js';
import { VideoFrame } from './video_frame.js';
import type { VideoFrame } from './video_frame.js';

@@ -30,3 +31,3 @@ export class VideoSource {

let req = new NewVideoSourceRequest({
const req = new NewVideoSourceRequest({
type: VideoSourceType.VIDEO_SOURCE_NATIVE,

@@ -39,3 +40,3 @@ resolution: {

let res = FfiClient.instance.request<NewVideoSourceResponse>({
const res = FfiClient.instance.request<NewVideoSourceResponse>({
message: {

@@ -52,3 +53,3 @@ case: 'newVideoSource',

captureFrame(frame: VideoFrame, timestampUs = 0n, rotation = VideoRotation.VIDEO_ROTATION_0) {
let req = new CaptureVideoFrameRequest({
const req = new CaptureVideoFrameRequest({
sourceHandle: this.ffiHandle.handle,

@@ -55,0 +56,0 @@ buffer: frame.protoInfo(),

// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client.js';
import { Track } from './track.js';
import EventEmitter from 'events';
import TypedEmitter from 'typed-emitter';
import { VideoFrame } from './video_frame.js';
import {
NewVideoStreamRequest,
import type TypedEmitter from 'typed-emitter';
import type { FfiEvent } from './ffi_client.js';
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
import type {
NewVideoStreamResponse,
VideoRotation,
VideoStreamInfo,
VideoStreamType,
} from './proto/video_frame_pb.js';
import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
import type { Track } from './track.js';
import { VideoFrame } from './video_frame.js';
export type VideoFrameEvent = {
frame: VideoFrame,
timestampUs: bigint,
rotation: VideoRotation,
}
frame: VideoFrame;
timestampUs: bigint;
rotation: VideoRotation;
};

@@ -44,3 +43,3 @@ export type VideoStreamCallbacks = {

let req = new NewVideoStreamRequest({
const req = new NewVideoStreamRequest({
type: VideoStreamType.VIDEO_STREAM_NATIVE,

@@ -50,3 +49,3 @@ trackHandle: track.ffi_handle.handle,

let res = FfiClient.instance.request<NewVideoStreamResponse>({
const res = FfiClient.instance.request<NewVideoStreamResponse>({
message: {

@@ -72,8 +71,8 @@ case: 'newVideoStream',

let streamEvent = ev.message.value.message;
const streamEvent = ev.message.value.message;
switch (streamEvent.case) {
case 'frameReceived':
let rotation = streamEvent.value.rotation;
let timestampUs = streamEvent.value.timestampUs;
let frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
const rotation = streamEvent.value.rotation;
const timestampUs = streamEvent.value.timestampUs;
const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
this.emit(VideoStreamEvent.FrameReceived, { frame, timestampUs, rotation });

@@ -80,0 +79,0 @@ break;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc