@livekit/rtc-node 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/Cargo.toml +2 -1
  2. package/dist/audio_frame.d.ts +2 -1
  3. package/dist/audio_frame.d.ts.map +1 -1
  4. package/dist/audio_frame.js +3 -3
  5. package/dist/audio_frame.js.map +1 -1
  6. package/dist/audio_source.d.ts +2 -2
  7. package/dist/audio_source.d.ts.map +1 -1
  8. package/dist/audio_source.js +6 -9
  9. package/dist/audio_source.js.map +1 -1
  10. package/dist/audio_stream.d.ts +3 -3
  11. package/dist/audio_stream.d.ts.map +1 -1
  12. package/dist/audio_stream.js +6 -6
  13. package/dist/audio_stream.js.map +1 -1
  14. package/dist/e2ee.d.ts.map +1 -1
  15. package/dist/e2ee.js +16 -16
  16. package/dist/e2ee.js.map +1 -1
  17. package/dist/ffi_client.d.ts +4 -3
  18. package/dist/ffi_client.d.ts.map +1 -1
  19. package/dist/ffi_client.js +11 -11
  20. package/dist/ffi_client.js.map +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/napi/native.cjs +9 -2
  26. package/dist/napi/native.d.ts +1 -0
  27. package/dist/napi/native.js +2 -2
  28. package/dist/participant.d.ts +5 -4
  29. package/dist/participant.d.ts.map +1 -1
  30. package/dist/participant.js +15 -15
  31. package/dist/participant.js.map +1 -1
  32. package/dist/room.d.ts +25 -22
  33. package/dist/room.d.ts.map +1 -1
  34. package/dist/room.js +58 -55
  35. package/dist/room.js.map +1 -1
  36. package/dist/track.d.ts +3 -3
  37. package/dist/track.d.ts.map +1 -1
  38. package/dist/track.js +5 -8
  39. package/dist/track.js.map +1 -1
  40. package/dist/track_publication.d.ts +3 -3
  41. package/dist/track_publication.d.ts.map +1 -1
  42. package/dist/track_publication.js +1 -1
  43. package/dist/track_publication.js.map +1 -1
  44. package/dist/video_frame.d.ts +2 -1
  45. package/dist/video_frame.d.ts.map +1 -1
  46. package/dist/video_frame.js +1 -1
  47. package/dist/video_frame.js.map +1 -1
  48. package/dist/video_source.d.ts +3 -2
  49. package/dist/video_source.d.ts.map +1 -1
  50. package/dist/video_source.js +3 -3
  51. package/dist/video_source.js.map +1 -1
  52. package/dist/video_stream.d.ts +3 -3
  53. package/dist/video_stream.d.ts.map +1 -1
  54. package/dist/video_stream.js +8 -8
  55. package/dist/video_stream.js.map +1 -1
  56. package/package.json +8 -8
  57. package/src/audio_frame.ts +5 -5
  58. package/src/audio_source.ts +13 -14
  59. package/src/audio_stream.ts +13 -17
  60. package/src/e2ee.ts +25 -24
  61. package/src/ffi_client.ts +15 -11
  62. package/src/index.ts +1 -3
  63. package/src/napi/native.cjs +9 -2
  64. package/src/napi/native.d.ts +1 -0
  65. package/src/napi/native.js +2 -2
  66. package/src/nodejs.rs +5 -0
  67. package/src/participant.ts +27 -29
  68. package/src/room.ts +94 -91
  69. package/src/track.ts +9 -11
  70. package/src/track_publication.ts +7 -7
  71. package/src/video_frame.ts +9 -16
  72. package/src/video_source.ts +10 -9
  73. package/src/video_stream.ts +17 -18
@@ -1,14 +1,12 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
-
5
- import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
4
+ import { FfiClient, FfiRequest } from './ffi_client.js';
5
+ import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
6
6
  import {
7
- OwnedVideoBuffer,
8
7
  VideoBufferInfo,
9
8
  VideoBufferInfo_ComponentInfo,
10
9
  VideoBufferType,
11
- VideoConvertResponse,
12
10
  } from './proto/video_frame_pb.js';
13
11
 
14
12
  export class VideoFrame {
@@ -17,12 +15,7 @@ export class VideoFrame {
17
15
  height: number;
18
16
  type: VideoBufferType;
19
17
 
20
- constructor(
21
- data: Uint8Array,
22
- width: number,
23
- height: number,
24
- type: VideoBufferType,
25
- ) {
18
+ constructor(data: Uint8Array, width: number, height: number, type: VideoBufferType) {
26
19
  this.data = data;
27
20
  this.width = width;
28
21
  this.height = height;
@@ -31,7 +24,7 @@ export class VideoFrame {
31
24
 
32
25
  /** @internal */
33
26
  get dataPtr(): bigint {
34
- return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer))
27
+ return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
35
28
  }
36
29
 
37
30
  /** @internal */
@@ -60,7 +53,7 @@ export class VideoFrame {
60
53
 
61
54
  /** @internal */
62
55
  static fromOwnedInfo(owned: OwnedVideoBuffer): VideoFrame {
63
- let info = owned.info;
56
+ const info = owned.info;
64
57
  return new VideoFrame(
65
58
  FfiClient.instance.copyBuffer(
66
59
  info.dataPtr,
@@ -73,7 +66,7 @@ export class VideoFrame {
73
66
  }
74
67
 
75
68
  getPlane(planeNth: number): Uint8Array | void {
76
- const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height)
69
+ const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
77
70
  if (planeNth >= planeInfos.length) return;
78
71
 
79
72
  const planeInfo = planeInfos[planeNth];
@@ -91,12 +84,12 @@ export class VideoFrame {
91
84
  },
92
85
  },
93
86
  });
94
- const resp = FfiClient.instance.request<VideoConvertResponse>(req)
87
+ const resp = FfiClient.instance.request<VideoConvertResponse>(req);
95
88
  if (resp.error) {
96
- throw resp.error
89
+ throw resp.error;
97
90
  }
98
91
 
99
- return VideoFrame.fromOwnedInfo(resp.buffer)
92
+ return VideoFrame.fromOwnedInfo(resp.buffer);
100
93
  }
101
94
  }
102
95
 
@@ -1,18 +1,19 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
-
5
- import { FfiClient, FfiHandle, FfiRequest } from './ffi_client.js';
4
+ import { FfiClient, FfiHandle } from './ffi_client.js';
5
+ import type {
6
+ CaptureVideoFrameResponse,
7
+ NewVideoSourceResponse,
8
+ VideoSourceInfo,
9
+ } from './proto/video_frame_pb.js';
6
10
  import {
7
11
  CaptureVideoFrameRequest,
8
- CaptureVideoFrameResponse,
9
12
  NewVideoSourceRequest,
10
- NewVideoSourceResponse,
11
13
  VideoRotation,
12
- VideoSourceInfo,
13
14
  VideoSourceType,
14
15
  } from './proto/video_frame_pb.js';
15
- import { VideoFrame } from './video_frame.js';
16
+ import type { VideoFrame } from './video_frame.js';
16
17
 
17
18
  export class VideoSource {
18
19
  /** @internal */
@@ -27,7 +28,7 @@ export class VideoSource {
27
28
  this.width = width;
28
29
  this.height = height;
29
30
 
30
- let req = new NewVideoSourceRequest({
31
+ const req = new NewVideoSourceRequest({
31
32
  type: VideoSourceType.VIDEO_SOURCE_NATIVE,
32
33
  resolution: {
33
34
  width: width,
@@ -35,7 +36,7 @@ export class VideoSource {
35
36
  },
36
37
  });
37
38
 
38
- let res = FfiClient.instance.request<NewVideoSourceResponse>({
39
+ const res = FfiClient.instance.request<NewVideoSourceResponse>({
39
40
  message: {
40
41
  case: 'newVideoSource',
41
42
  value: req,
@@ -47,7 +48,7 @@ export class VideoSource {
47
48
  }
48
49
 
49
50
  captureFrame(frame: VideoFrame, timestampUs = 0n, rotation = VideoRotation.VIDEO_ROTATION_0) {
50
- let req = new CaptureVideoFrameRequest({
51
+ const req = new CaptureVideoFrameRequest({
51
52
  sourceHandle: this.ffiHandle.handle,
52
53
  buffer: frame.protoInfo(),
53
54
  rotation,
@@ -1,25 +1,24 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
-
5
- import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client.js';
6
- import { Track } from './track.js';
7
4
  import EventEmitter from 'events';
8
- import TypedEmitter from 'typed-emitter';
9
- import { VideoFrame } from './video_frame.js';
10
- import {
11
- NewVideoStreamRequest,
5
+ import type TypedEmitter from 'typed-emitter';
6
+ import type { FfiEvent } from './ffi_client.js';
7
+ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
8
+ import type {
12
9
  NewVideoStreamResponse,
13
10
  VideoRotation,
14
11
  VideoStreamInfo,
15
- VideoStreamType,
16
12
  } from './proto/video_frame_pb.js';
13
+ import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
14
+ import type { Track } from './track.js';
15
+ import { VideoFrame } from './video_frame.js';
17
16
 
18
17
  export type VideoFrameEvent = {
19
- frame: VideoFrame,
20
- timestampUs: bigint,
21
- rotation: VideoRotation,
22
- }
18
+ frame: VideoFrame;
19
+ timestampUs: bigint;
20
+ rotation: VideoRotation;
21
+ };
23
22
 
24
23
  export type VideoStreamCallbacks = {
25
24
  frameReceived: (evt: VideoFrameEvent) => void;
@@ -41,12 +40,12 @@ export class VideoStream extends (EventEmitter as new () => TypedEmitter<VideoSt
41
40
  super();
42
41
  this.track = track;
43
42
 
44
- let req = new NewVideoStreamRequest({
43
+ const req = new NewVideoStreamRequest({
45
44
  type: VideoStreamType.VIDEO_STREAM_NATIVE,
46
45
  trackHandle: track.ffi_handle.handle,
47
46
  });
48
47
 
49
- let res = FfiClient.instance.request<NewVideoStreamResponse>({
48
+ const res = FfiClient.instance.request<NewVideoStreamResponse>({
50
49
  message: {
51
50
  case: 'newVideoStream',
52
51
  value: req,
@@ -67,12 +66,12 @@ export class VideoStream extends (EventEmitter as new () => TypedEmitter<VideoSt
67
66
  return;
68
67
  }
69
68
 
70
- let streamEvent = ev.message.value.message;
69
+ const streamEvent = ev.message.value.message;
71
70
  switch (streamEvent.case) {
72
71
  case 'frameReceived':
73
- let rotation = streamEvent.value.rotation;
74
- let timestampUs = streamEvent.value.timestampUs;
75
- let frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
72
+ const rotation = streamEvent.value.rotation;
73
+ const timestampUs = streamEvent.value.timestampUs;
74
+ const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
76
75
  this.emit(VideoStreamEvent.FrameReceived, { frame, timestampUs, rotation });
77
76
  break;
78
77
  case 'eos':