@livekit/rtc-node 0.0.7 → 0.2.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 (113) hide show
  1. package/build.rs +4 -0
  2. package/dist/audio_frame.d.ts +1 -1
  3. package/dist/audio_frame.d.ts.map +1 -1
  4. package/dist/audio_frame.js +10 -11
  5. package/dist/audio_frame.js.map +1 -1
  6. package/dist/audio_source.d.ts +3 -3
  7. package/dist/audio_source.d.ts.map +1 -1
  8. package/dist/audio_source.js +14 -15
  9. package/dist/audio_source.js.map +1 -1
  10. package/dist/audio_stream.d.ts +8 -5
  11. package/dist/audio_stream.d.ts.map +1 -1
  12. package/dist/audio_stream.js +18 -22
  13. package/dist/audio_stream.js.map +1 -1
  14. package/dist/e2ee.d.ts +1 -1
  15. package/dist/e2ee.d.ts.map +1 -1
  16. package/dist/e2ee.js +42 -45
  17. package/dist/e2ee.js.map +1 -1
  18. package/dist/ffi_client.d.ts +2 -2
  19. package/dist/ffi_client.d.ts.map +1 -1
  20. package/dist/ffi_client.js +17 -24
  21. package/dist/ffi_client.js.map +1 -1
  22. package/dist/index.d.ts +15 -15
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +18 -70
  25. package/dist/index.js.map +1 -1
  26. package/{src/native.js → dist/napi/native.cjs} +12 -0
  27. package/dist/napi/native.js +15 -0
  28. package/dist/participant.d.ts +24 -9
  29. package/dist/participant.d.ts.map +1 -1
  30. package/dist/participant.js +45 -45
  31. package/dist/participant.js.map +1 -1
  32. package/dist/proto/audio_frame_pb.d.ts +0 -46
  33. package/dist/proto/audio_frame_pb.d.ts.map +1 -1
  34. package/dist/proto/audio_frame_pb.js +138 -236
  35. package/dist/proto/audio_frame_pb.js.map +1 -1
  36. package/dist/proto/e2ee_pb.js +134 -162
  37. package/dist/proto/e2ee_pb.js.map +1 -1
  38. package/dist/proto/ffi_pb.d.ts +31 -44
  39. package/dist/proto/ffi_pb.d.ts.map +1 -1
  40. package/dist/proto/ffi_pb.js +140 -126
  41. package/dist/proto/ffi_pb.js.map +1 -1
  42. package/dist/proto/handle_pb.js +7 -11
  43. package/dist/proto/handle_pb.js.map +1 -1
  44. package/dist/proto/participant_pb.js +13 -18
  45. package/dist/proto/participant_pb.js.map +1 -1
  46. package/dist/proto/room_pb.d.ts +5 -1
  47. package/dist/proto/room_pb.d.ts.map +1 -1
  48. package/dist/proto/room_pb.js +393 -454
  49. package/dist/proto/room_pb.js.map +1 -1
  50. package/dist/proto/stats_pb.js +265 -303
  51. package/dist/proto/stats_pb.js.map +1 -1
  52. package/dist/proto/track_pb.js +87 -102
  53. package/dist/proto/track_pb.js.map +1 -1
  54. package/dist/proto/video_frame_pb.d.ts +124 -390
  55. package/dist/proto/video_frame_pb.d.ts.map +1 -1
  56. package/dist/proto/video_frame_pb.js +252 -620
  57. package/dist/proto/video_frame_pb.js.map +1 -1
  58. package/dist/room.d.ts +10 -9
  59. package/dist/room.d.ts.map +1 -1
  60. package/dist/room.js +74 -76
  61. package/dist/room.js.map +1 -1
  62. package/dist/track.d.ts +4 -4
  63. package/dist/track.d.ts.map +1 -1
  64. package/dist/track.js +15 -20
  65. package/dist/track.js.map +1 -1
  66. package/dist/track_publication.d.ts +4 -4
  67. package/dist/track_publication.d.ts.map +1 -1
  68. package/dist/track_publication.js +12 -15
  69. package/dist/track_publication.js.map +1 -1
  70. package/dist/video_frame.d.ts +8 -103
  71. package/dist/video_frame.d.ts.map +1 -1
  72. package/dist/video_frame.js +161 -341
  73. package/dist/video_frame.js.map +1 -1
  74. package/dist/video_source.d.ts +4 -4
  75. package/dist/video_source.d.ts.map +1 -1
  76. package/dist/video_source.js +16 -22
  77. package/dist/video_source.js.map +1 -1
  78. package/dist/video_stream.d.ts +10 -5
  79. package/dist/video_stream.d.ts.map +1 -1
  80. package/dist/video_stream.js +20 -24
  81. package/dist/video_stream.js.map +1 -1
  82. package/package.json +14 -14
  83. package/src/audio_frame.ts +6 -2
  84. package/src/audio_source.ts +8 -4
  85. package/src/audio_stream.ts +15 -7
  86. package/src/e2ee.ts +6 -2
  87. package/src/ffi_client.ts +6 -2
  88. package/src/index.ts +19 -28
  89. package/src/lib.rs +4 -0
  90. package/src/napi/native.cjs +281 -0
  91. package/src/napi/native.js +15 -0
  92. package/src/nodejs.rs +4 -0
  93. package/src/participant.ts +45 -22
  94. package/src/proto/audio_frame_pb.ts +1 -91
  95. package/src/proto/e2ee_pb.ts +1 -1
  96. package/src/proto/ffi_pb.ts +55 -53
  97. package/src/proto/handle_pb.ts +1 -1
  98. package/src/proto/participant_pb.ts +1 -1
  99. package/src/proto/room_pb.ts +7 -1
  100. package/src/proto/stats_pb.ts +1 -1
  101. package/src/proto/track_pb.ts +1 -1
  102. package/src/proto/video_frame_pb.ts +186 -641
  103. package/src/room.ts +56 -48
  104. package/src/track.ts +8 -4
  105. package/src/track_publication.ts +10 -6
  106. package/src/video_frame.ts +186 -579
  107. package/src/video_source.ts +12 -12
  108. package/src/video_stream.ts +21 -10
  109. package/dist/native.d.ts.map +0 -1
  110. package/dist/native.js +0 -297
  111. package/dist/native.js.map +0 -1
  112. /package/dist/{native.d.ts → napi/native.d.ts} +0 -0
  113. /package/src/{native.d.ts → napi/native.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"video_source.js","sourceRoot":"","sources":["../src/video_source.ts"],"names":[],"mappings":";;;AAAA,6CAAgE;AAChE,2DAOgC;AAGhC,MAAa,WAAW;IAStB,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,GAAG,GAAG,IAAI,sCAAqB,CAAC;YAClC,IAAI,EAAE,gCAAe,CAAC,mBAAmB;YACzC,UAAU,EAAE;gBACV,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,MAAM;aACf;SACF,CAAC,CAAC;QAEH,IAAI,GAAG,GAAG,sBAAS,CAAC,QAAQ,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AI,GAAG,GAAG,IAAI,qBAAqB,CAAC;YAClC,IAAI,EAAE,eAAe,CAAC,mBAAmB;YACzC,UAAU,EAAE;gBACV,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,MAAM;aACf;SACF,CAAC,CAAC;QAEH,IAAI,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAyB;YAC3D,OAAO,EAAE;gBACP,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,GAAG;aACX;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,YAAY,CAAC,KAAiB,EAAE,WAAW,GAAG,EAAE,EAAE,QAAQ,GAAG,aAAa,CAAC,gBAAgB;QACzF,IAAI,GAAG,GAAG,IAAI,wBAAwB,CAAC;YACrC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM;YACnC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;YACzB,QAAQ;YACR,WAAW;SACZ,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAA4B;YACpD,OAAO,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE;SACnD,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,10 +1,15 @@
1
- import { FfiHandle } from './ffi_client';
2
- import { Track } from './track';
1
+ import { FfiHandle } from './ffi_client.js';
2
+ import { Track } from './track.js';
3
3
  import TypedEmitter from 'typed-emitter';
4
- import { VideoFrame } from './video_frame';
5
- import { VideoStreamInfo } from './proto/video_frame_pb';
4
+ import { VideoFrame } from './video_frame.js';
5
+ import { VideoRotation, VideoStreamInfo } from './proto/video_frame_pb.js';
6
+ export type VideoFrameEvent = {
7
+ frame: VideoFrame;
8
+ timestampUs: bigint;
9
+ rotation: VideoRotation;
10
+ };
6
11
  export type VideoStreamCallbacks = {
7
- frameReceived: (frame: VideoFrame) => void;
12
+ frameReceived: (evt: VideoFrameEvent) => void;
8
13
  };
9
14
  export declare enum VideoStreamEvent {
10
15
  FrameReceived = "frameReceived"
@@ -1 +1 @@
1
- {"version":3,"file":"video_stream.d.ts","sourceRoot":"","sources":["../src/video_stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAc,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAGL,eAAe,EAEhB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF,oBAAY,gBAAgB;IAC1B,aAAa,kBAAkB;CAChC;0CAE2D,aAAa,oBAAoB,CAAC;AAA9F,qBAAa,WAAY,SAAQ,gBAA8D;IAC7F,gBAAgB;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,SAAS,CAAC;IAErB,KAAK,EAAE,KAAK,CAAC;gBAED,KAAK,EAAE,KAAK;IAsBxB,OAAO,CAAC,OAAO,CAoBd;IAED,KAAK;CAGN"}
1
+ {"version":3,"file":"video_stream.d.ts","sourceRoot":"","sources":["../src/video_stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuC,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAGL,aAAa,EACb,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF,oBAAY,gBAAgB;IAC1B,aAAa,kBAAkB;CAChC;0CAE2D,aAAa,oBAAoB,CAAC;AAA9F,qBAAa,WAAY,SAAQ,gBAA8D;IAC7F,gBAAgB;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,SAAS,CAAC;IAErB,KAAK,EAAE,KAAK,CAAC;gBAED,KAAK,EAAE,KAAK;IAsBxB,OAAO,CAAC,OAAO,CAoBb;IAEF,KAAK;CAGN"}
@@ -1,18 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VideoStream = exports.VideoStreamEvent = void 0;
7
- const ffi_client_1 = require("./ffi_client");
8
- const events_1 = __importDefault(require("events"));
9
- const video_frame_1 = require("./video_frame");
10
- const video_frame_pb_1 = require("./proto/video_frame_pb");
11
- var VideoStreamEvent;
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
5
+ import EventEmitter from 'events';
6
+ import { VideoFrame } from './video_frame.js';
7
+ import { NewVideoStreamRequest, VideoStreamType, } from './proto/video_frame_pb.js';
8
+ export var VideoStreamEvent;
12
9
  (function (VideoStreamEvent) {
13
10
  VideoStreamEvent["FrameReceived"] = "frameReceived";
14
- })(VideoStreamEvent || (exports.VideoStreamEvent = VideoStreamEvent = {}));
15
- class VideoStream extends events_1.default {
11
+ })(VideoStreamEvent || (VideoStreamEvent = {}));
12
+ export class VideoStream extends EventEmitter {
16
13
  constructor(track) {
17
14
  super();
18
15
  this.onEvent = (ev) => {
@@ -23,34 +20,33 @@ class VideoStream extends events_1.default {
23
20
  let streamEvent = ev.message.value.message;
24
21
  switch (streamEvent.case) {
25
22
  case 'frameReceived':
26
- let frameInfo = streamEvent.value.frame;
27
- let buffer = video_frame_1.VideoFrameBuffer.fromOwnedInfo(streamEvent.value.buffer);
28
- let frame = new video_frame_1.VideoFrame(Number(frameInfo.timestampUs), frameInfo.rotation, buffer);
29
- this.emit(VideoStreamEvent.FrameReceived, frame);
23
+ let rotation = streamEvent.value.rotation;
24
+ let timestampUs = streamEvent.value.timestampUs;
25
+ let frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
26
+ this.emit(VideoStreamEvent.FrameReceived, { frame, timestampUs, rotation });
30
27
  break;
31
28
  case 'eos':
32
- ffi_client_1.FfiClient.instance.off(ffi_client_1.FfiClientEvent.FfiEvent, this.onEvent);
29
+ FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);
33
30
  break;
34
31
  }
35
32
  };
36
33
  this.track = track;
37
- let req = new video_frame_pb_1.NewVideoStreamRequest({
38
- type: video_frame_pb_1.VideoStreamType.VIDEO_STREAM_NATIVE,
34
+ let req = new NewVideoStreamRequest({
35
+ type: VideoStreamType.VIDEO_STREAM_NATIVE,
39
36
  trackHandle: track.ffi_handle.handle,
40
37
  });
41
- let res = ffi_client_1.FfiClient.instance.request({
38
+ let res = FfiClient.instance.request({
42
39
  message: {
43
40
  case: 'newVideoStream',
44
41
  value: req,
45
42
  },
46
43
  });
47
44
  this.info = res.stream.info;
48
- this.ffiHandle = new ffi_client_1.FfiHandle(res.stream.handle.id);
49
- ffi_client_1.FfiClient.instance.on(ffi_client_1.FfiClientEvent.FfiEvent, this.onEvent);
45
+ this.ffiHandle = new FfiHandle(res.stream.handle.id);
46
+ FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);
50
47
  }
51
48
  close() {
52
49
  this.ffiHandle.dispose();
53
50
  }
54
51
  }
55
- exports.VideoStream = VideoStream;
56
52
  //# sourceMappingURL=video_stream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"video_stream.js","sourceRoot":"","sources":["../src/video_stream.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA0F;AAE1F,oDAAkC;AAElC,+CAA6D;AAC7D,2DAKgC;AAMhC,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,mDAA+B,CAAA;AACjC,CAAC,EAFW,gBAAgB,gCAAhB,gBAAgB,QAE3B;AAED,MAAa,WAAY,SAAS,gBAA6D;IAQ7F,YAAY,KAAY;QACtB,KAAK,EAAE,CAAC;QAqBF,YAAO,GAAG,CAAC,EAAY,EAAE,EAAE;YACjC,IACE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,kBAAkB;gBACrC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EACtD,CAAC;gBACD,OAAO;YACT,CAAC;YAED,IAAI,WAAW,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;YAC3C,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC;gBACzB,KAAK,eAAe;oBAClB,IAAI,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;oBACxC,IAAI,MAAM,GAAG,8BAAgB,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBACtE,IAAI,KAAK,GAAG,IAAI,wBAAU,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;oBACtF,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;oBACjD,MAAM;gBACR,KA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;SACrC,CAAC,CAAC;QAEH,IAAI,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAyB;YAC3D,OAAO,EAAE;gBACP,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,GAAG;aACX;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAErD,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAwBD,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
package/package.json CHANGED
@@ -2,9 +2,10 @@
2
2
  "name": "@livekit/rtc-node",
3
3
  "description": "LiveKit RTC Node",
4
4
  "license": "Apache-2.0",
5
- "version": "0.0.7",
5
+ "version": "0.2.0",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "type": "module",
8
9
  "files": [
9
10
  "dist",
10
11
  "src",
@@ -30,28 +31,27 @@
30
31
  "typed-emitter": "^2.1.0"
31
32
  },
32
33
  "devDependencies": {
33
- "@napi-rs/cli": "^2.16.5",
34
+ "@napi-rs/cli": "^2.18.0",
34
35
  "@types/node": "^20.9.2",
35
36
  "typescript": "^5.2.2",
36
37
  "prettier": "^3.0.3"
37
38
  },
38
39
  "engines": {
39
- "node": ">= 10"
40
+ "node": ">= 18"
41
+ },
42
+ "optionalDependencies": {
43
+ "@livekit/rtc-node-darwin-arm64": "0.2.0",
44
+ "@livekit/rtc-node-darwin-x64": "0.2.0",
45
+ "@livekit/rtc-node-linux-arm64-gnu": "0.2.0",
46
+ "@livekit/rtc-node-linux-x64-gnu": "0.2.0",
47
+ "@livekit/rtc-node-win32-x64-msvc": "0.2.0"
40
48
  },
41
49
  "scripts": {
42
- "build:tsc": "tsc && cp src/native.d.ts dist/native.d.ts",
43
- "build": "yarn build:tsc && napi build --platform --release --dts src/native.d.ts --js src/native.js --pipe \"prettier -w\"",
44
- "artifacts": "yarn build:tsc && napi artifacts",
50
+ "build:tsc": "tsc && cp -r src/napi dist/napi",
51
+ "build": "pnpm build:tsc && napi build --platform --release --dts native.d.ts --js native.cjs --pipe \"prettier -w\" src/napi",
52
+ "artifacts": "pnpm build:tsc && napi artifacts",
45
53
  "build:debug": "napi build --platform",
46
- "prepublishOnly": "napi prepublish -t npm",
47
54
  "universal": "napi universal",
48
55
  "version": "napi version"
49
- },
50
- "optionalDependencies": {
51
- "@livekit/rtc-node-darwin-arm64": "0.0.7",
52
- "@livekit/rtc-node-darwin-x64": "0.0.7",
53
- "@livekit/rtc-node-linux-arm64-gnu": "0.0.7",
54
- "@livekit/rtc-node-linux-x64-gnu": "0.0.7",
55
- "@livekit/rtc-node-win32-x64-msvc": "0.0.7"
56
56
  }
57
57
  }
@@ -1,5 +1,9 @@
1
- import { FfiClient, FfiHandle } from './ffi_client';
2
- import { AudioFrameBufferInfo, OwnedAudioFrameBuffer } from './proto/audio_frame_pb';
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { FfiClient, FfiHandle } from './ffi_client.js';
6
+ import { AudioFrameBufferInfo, OwnedAudioFrameBuffer } from './proto/audio_frame_pb.js';
3
7
 
4
8
  export class AudioFrame {
5
9
  data: Uint16Array;
@@ -1,7 +1,11 @@
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
1
5
  import EventEmitter from 'events';
2
6
  import TypedEmitter from 'typed-emitter';
3
- import { FfiHandle } from './native';
4
- import { AudioFrame } from './audio_frame';
7
+ import { FfiHandle } from './napi/native.js';
8
+ import { AudioFrame } from './audio_frame.js';
5
9
  import {
6
10
  AudioSourceInfo,
7
11
  AudioSourceType,
@@ -10,8 +14,8 @@ import {
10
14
  CaptureAudioFrameResponse,
11
15
  NewAudioSourceRequest,
12
16
  NewAudioSourceResponse,
13
- } from './proto/audio_frame_pb';
14
- import { FfiClient, FfiRequest } from './ffi_client';
17
+ } from './proto/audio_frame_pb.js';
18
+ import { FfiClient, FfiRequest } from './ffi_client.js';
15
19
 
16
20
  export class AudioSource {
17
21
  /** @internal */
@@ -1,17 +1,25 @@
1
- import { AudioFrame } from './audio_frame';
2
- import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client';
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { AudioFrame } from './audio_frame.js';
6
+ import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client.js';
3
7
  import {
4
8
  AudioStreamInfo,
5
9
  AudioStreamType,
6
10
  NewAudioStreamRequest,
7
11
  NewAudioStreamResponse,
8
- } from './proto/audio_frame_pb';
9
- import { Track } from './track';
12
+ } from './proto/audio_frame_pb.js';
13
+ import { Track } from './track.js';
10
14
  import EventEmitter from 'events';
11
15
  import TypedEmitter from 'typed-emitter';
12
16
 
17
+ export type AudioFrameEvent = {
18
+ frame: AudioFrame
19
+ }
20
+
13
21
  export type AudioStreamCallbacks = {
14
- frameReceived: (frame: AudioFrame) => void;
22
+ frameReceived: (frame: AudioFrameEvent) => void;
15
23
  };
16
24
 
17
25
  export enum AudioStreamEvent {
@@ -60,13 +68,13 @@ export class AudioStream extends (EventEmitter as new () => TypedEmitter<AudioSt
60
68
  switch (streamEvent.case) {
61
69
  case 'frameReceived':
62
70
  let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
63
- this.emit(AudioStreamEvent.FrameReceived, frame);
71
+ this.emit(AudioStreamEvent.FrameReceived, { frame });
64
72
  break;
65
73
  case 'eos':
66
74
  FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);
67
75
  break;
68
76
  }
69
- }
77
+ };
70
78
 
71
79
  close() {
72
80
  this.ffiHandle.dispose();
package/src/e2ee.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { FfiClient, FfiRequest } from './ffi_client';
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { FfiClient, FfiRequest } from './ffi_client.js';
2
6
  import {
3
7
  E2eeManagerGetFrameCryptorsResponse,
4
8
  E2eeManagerSetEnabledRequest,
@@ -17,7 +21,7 @@ import {
17
21
  RatchetSharedKeyResponse,
18
22
  SetKeyRequest,
19
23
  SetSharedKeyRequest,
20
- } from './proto/e2ee_pb';
24
+ } from './proto/e2ee_pb.js';
21
25
 
22
26
  const DEFAULT_RATCHET_SALT = new TextEncoder().encode('LKFrameEncryptionKey');
23
27
  const DEFAULT_RATCHET_WINDOW_SIZE = 16;
package/src/ffi_client.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { FfiRequest, FfiResponse, FfiEvent } from './proto/ffi_pb';
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { FfiRequest, FfiResponse, FfiEvent } from './proto/ffi_pb.js';
2
6
  import EventEmitter from 'events';
3
7
  import TypedEmitter from 'typed-emitter';
4
8
  import {
@@ -7,7 +11,7 @@ import {
7
11
  livekitInitialize,
8
12
  livekitCopyBuffer,
9
13
  livekitRetrievePtr,
10
- } from './native';
14
+ } from './napi/native.js';
11
15
  import { PartialMessage } from '@bufbuild/protobuf';
12
16
 
13
17
  export { FfiHandle, FfiEvent, FfiResponse, FfiRequest };
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
- export { Room, RoomEvent, ConnectError, RoomOptions, RtcConfiguration } from './room';
2
- export { Participant, RemoteParticipant, LocalParticipant } from './participant';
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ export { Room, RoomEvent, ConnectError, RoomOptions, RtcConfiguration } from './room.js';
6
+ export { Participant, RemoteParticipant, LocalParticipant } from './participant.js';
3
7
  export {
4
8
  Track,
5
9
  LocalTrack,
@@ -10,34 +14,21 @@ export {
10
14
  RemoteAudioTrack,
11
15
  RemoteVideoTrack,
12
16
  AudioTrack,
13
- } from './track';
17
+ } from './track.js';
14
18
  export {
15
19
  VideoFrame,
16
- VideoFrameBuffer,
17
- I420Buffer,
18
- I422Buffer,
19
- I444Buffer,
20
- I420ABuffer,
21
- NV12Buffer,
22
- NativeBuffer,
23
- I010Buffer,
24
- PlanarYuvBuffer,
25
- PlanarYuv8Buffer,
26
- PlanarYuv16Buffer,
27
- ArgbFrame,
28
- BiplanarYuv8Buffer,
29
- } from './video_frame';
30
- export { AudioFrame } from './audio_frame';
31
- export { AudioStream } from './audio_stream';
32
- export { VideoStream } from './video_stream';
33
- export { AudioSource } from './audio_source';
34
- export { VideoSource } from './video_source';
20
+ } from './video_frame.js';
21
+ export { AudioFrame } from './audio_frame.js';
22
+ export { AudioStream, AudioFrameEvent } from './audio_stream.js';
23
+ export { VideoStream, VideoFrameEvent } from './video_stream.js';
24
+ export { AudioSource } from './audio_source.js';
25
+ export { VideoSource } from './video_source.js';
35
26
  export {
36
27
  TrackPublication,
37
28
  RemoteTrackPublication,
38
29
  LocalTrackPublication,
39
- } from './track_publication';
40
- export { E2EEManager, E2EEOptions, KeyProviderOptions, KeyProvider, FrameCryptor } from './e2ee';
30
+ } from './track_publication.js';
31
+ export { E2EEManager, E2EEOptions, KeyProviderOptions, KeyProvider, FrameCryptor } from './e2ee.js';
41
32
  export {
42
33
  ConnectionQuality,
43
34
  IceServer,
@@ -46,7 +37,7 @@ export {
46
37
  ContinualGatheringPolicy,
47
38
  TrackPublishOptions,
48
39
  ConnectionState,
49
- } from './proto/room_pb';
50
- export { EncryptionType, EncryptionState } from './proto/e2ee_pb';
51
- export { StreamState, TrackKind, TrackSource } from './proto/track_pb';
52
- export { VideoFormatType, VideoFrameBufferType, VideoRotation } from './proto/video_frame_pb';
40
+ } from './proto/room_pb.js';
41
+ export { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';
42
+ export { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';
43
+ export { VideoBufferType, VideoRotation } from './proto/video_frame_pb.js';
package/src/lib.rs CHANGED
@@ -1,5 +1,9 @@
1
1
  #![deny(clippy::all)]
2
2
 
3
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
4
+ //
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
3
7
  extern crate napi_derive;
4
8
 
5
9
  pub mod nodejs;
@@ -0,0 +1,281 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path');
9
+
10
+ const { platform, arch } = process;
11
+
12
+ let nativeBinding = null;
13
+ let localFileExisted = false;
14
+ let loadError = null;
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
21
+ return readFileSync(lddPath, 'utf8').includes('musl');
22
+ } catch (e) {
23
+ return true;
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header;
27
+ return !glibcVersionRuntime;
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.android-arm64.node'));
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./rtc-node.android-arm64.node');
39
+ } else {
40
+ nativeBinding = require('@livekit/rtc-node-android-arm64');
41
+ }
42
+ } catch (e) {
43
+ loadError = e;
44
+ }
45
+ break;
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.android-arm-eabi.node'));
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./rtc-node.android-arm-eabi.node');
51
+ } else {
52
+ nativeBinding = require('@livekit/rtc-node-android-arm-eabi');
53
+ }
54
+ } catch (e) {
55
+ loadError = e;
56
+ }
57
+ break;
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`);
60
+ }
61
+ break;
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.win32-x64-msvc.node'));
66
+ try {
67
+ if (localFileExisted) {
68
+ nativeBinding = require('./rtc-node.win32-x64-msvc.node');
69
+ } else {
70
+ nativeBinding = require('@livekit/rtc-node-win32-x64-msvc');
71
+ }
72
+ } catch (e) {
73
+ loadError = e;
74
+ }
75
+ break;
76
+ case 'ia32':
77
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.win32-ia32-msvc.node'));
78
+ try {
79
+ if (localFileExisted) {
80
+ nativeBinding = require('./rtc-node.win32-ia32-msvc.node');
81
+ } else {
82
+ nativeBinding = require('@livekit/rtc-node-win32-ia32-msvc');
83
+ }
84
+ } catch (e) {
85
+ loadError = e;
86
+ }
87
+ break;
88
+ case 'arm64':
89
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.win32-arm64-msvc.node'));
90
+ try {
91
+ if (localFileExisted) {
92
+ nativeBinding = require('./rtc-node.win32-arm64-msvc.node');
93
+ } else {
94
+ nativeBinding = require('@livekit/rtc-node-win32-arm64-msvc');
95
+ }
96
+ } catch (e) {
97
+ loadError = e;
98
+ }
99
+ break;
100
+ default:
101
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
102
+ }
103
+ break;
104
+ case 'darwin':
105
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.darwin-universal.node'));
106
+ try {
107
+ if (localFileExisted) {
108
+ nativeBinding = require('./rtc-node.darwin-universal.node');
109
+ } else {
110
+ nativeBinding = require('@livekit/rtc-node-darwin-universal');
111
+ }
112
+ break;
113
+ } catch {}
114
+ switch (arch) {
115
+ case 'x64':
116
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.darwin-x64.node'));
117
+ try {
118
+ if (localFileExisted) {
119
+ nativeBinding = require('./rtc-node.darwin-x64.node');
120
+ } else {
121
+ nativeBinding = require('@livekit/rtc-node-darwin-x64');
122
+ }
123
+ } catch (e) {
124
+ loadError = e;
125
+ }
126
+ break;
127
+ case 'arm64':
128
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.darwin-arm64.node'));
129
+ try {
130
+ if (localFileExisted) {
131
+ nativeBinding = require('./rtc-node.darwin-arm64.node');
132
+ } else {
133
+ nativeBinding = require('@livekit/rtc-node-darwin-arm64');
134
+ }
135
+ } catch (e) {
136
+ loadError = e;
137
+ }
138
+ break;
139
+ default:
140
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
141
+ }
142
+ break;
143
+ case 'freebsd':
144
+ if (arch !== 'x64') {
145
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
146
+ }
147
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.freebsd-x64.node'));
148
+ try {
149
+ if (localFileExisted) {
150
+ nativeBinding = require('./rtc-node.freebsd-x64.node');
151
+ } else {
152
+ nativeBinding = require('@livekit/rtc-node-freebsd-x64');
153
+ }
154
+ } catch (e) {
155
+ loadError = e;
156
+ }
157
+ break;
158
+ case 'linux':
159
+ switch (arch) {
160
+ case 'x64':
161
+ if (isMusl()) {
162
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-x64-musl.node'));
163
+ try {
164
+ if (localFileExisted) {
165
+ nativeBinding = require('./rtc-node.linux-x64-musl.node');
166
+ } else {
167
+ nativeBinding = require('@livekit/rtc-node-linux-x64-musl');
168
+ }
169
+ } catch (e) {
170
+ loadError = e;
171
+ }
172
+ } else {
173
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-x64-gnu.node'));
174
+ try {
175
+ if (localFileExisted) {
176
+ nativeBinding = require('./rtc-node.linux-x64-gnu.node');
177
+ } else {
178
+ nativeBinding = require('@livekit/rtc-node-linux-x64-gnu');
179
+ }
180
+ } catch (e) {
181
+ loadError = e;
182
+ }
183
+ }
184
+ break;
185
+ case 'arm64':
186
+ if (isMusl()) {
187
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-arm64-musl.node'));
188
+ try {
189
+ if (localFileExisted) {
190
+ nativeBinding = require('./rtc-node.linux-arm64-musl.node');
191
+ } else {
192
+ nativeBinding = require('@livekit/rtc-node-linux-arm64-musl');
193
+ }
194
+ } catch (e) {
195
+ loadError = e;
196
+ }
197
+ } else {
198
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-arm64-gnu.node'));
199
+ try {
200
+ if (localFileExisted) {
201
+ nativeBinding = require('./rtc-node.linux-arm64-gnu.node');
202
+ } else {
203
+ nativeBinding = require('@livekit/rtc-node-linux-arm64-gnu');
204
+ }
205
+ } catch (e) {
206
+ loadError = e;
207
+ }
208
+ }
209
+ break;
210
+ case 'arm':
211
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-arm-gnueabihf.node'));
212
+ try {
213
+ if (localFileExisted) {
214
+ nativeBinding = require('./rtc-node.linux-arm-gnueabihf.node');
215
+ } else {
216
+ nativeBinding = require('@livekit/rtc-node-linux-arm-gnueabihf');
217
+ }
218
+ } catch (e) {
219
+ loadError = e;
220
+ }
221
+ break;
222
+ case 'riscv64':
223
+ if (isMusl()) {
224
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-riscv64-musl.node'));
225
+ try {
226
+ if (localFileExisted) {
227
+ nativeBinding = require('./rtc-node.linux-riscv64-musl.node');
228
+ } else {
229
+ nativeBinding = require('@livekit/rtc-node-linux-riscv64-musl');
230
+ }
231
+ } catch (e) {
232
+ loadError = e;
233
+ }
234
+ } else {
235
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-riscv64-gnu.node'));
236
+ try {
237
+ if (localFileExisted) {
238
+ nativeBinding = require('./rtc-node.linux-riscv64-gnu.node');
239
+ } else {
240
+ nativeBinding = require('@livekit/rtc-node-linux-riscv64-gnu');
241
+ }
242
+ } catch (e) {
243
+ loadError = e;
244
+ }
245
+ }
246
+ break;
247
+ case 's390x':
248
+ localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-s390x-gnu.node'));
249
+ try {
250
+ if (localFileExisted) {
251
+ nativeBinding = require('./rtc-node.linux-s390x-gnu.node');
252
+ } else {
253
+ nativeBinding = require('@livekit/rtc-node-linux-s390x-gnu');
254
+ }
255
+ } catch (e) {
256
+ loadError = e;
257
+ }
258
+ break;
259
+ default:
260
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
261
+ }
262
+ break;
263
+ default:
264
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
265
+ }
266
+
267
+ if (!nativeBinding) {
268
+ if (loadError) {
269
+ throw loadError;
270
+ }
271
+ throw new Error(`Failed to load native binding`);
272
+ }
273
+
274
+ const { livekitInitialize, livekitFfiRequest, livekitRetrievePtr, livekitCopyBuffer, FfiHandle } =
275
+ nativeBinding;
276
+
277
+ module.exports.livekitInitialize = livekitInitialize;
278
+ module.exports.livekitFfiRequest = livekitFfiRequest;
279
+ module.exports.livekitRetrievePtr = livekitRetrievePtr;
280
+ module.exports.livekitCopyBuffer = livekitCopyBuffer;
281
+ module.exports.FfiHandle = FfiHandle;