@livekit/rtc-node 0.13.23 → 0.13.25

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 (290) hide show
  1. package/dist/audio_filter.cjs +2 -2
  2. package/dist/audio_filter.cjs.map +1 -1
  3. package/dist/audio_filter.js +1 -1
  4. package/dist/audio_filter.js.map +1 -1
  5. package/dist/audio_frame.cjs +11 -7
  6. package/dist/audio_frame.cjs.map +1 -1
  7. package/dist/audio_frame.d.cts +3 -8
  8. package/dist/audio_frame.d.ts +3 -8
  9. package/dist/audio_frame.d.ts.map +1 -1
  10. package/dist/audio_frame.js +10 -6
  11. package/dist/audio_frame.js.map +1 -1
  12. package/dist/audio_mixer.cjs +11 -4
  13. package/dist/audio_mixer.cjs.map +1 -1
  14. package/dist/audio_mixer.d.cts +1 -6
  15. package/dist/audio_mixer.d.ts +1 -6
  16. package/dist/audio_mixer.d.ts.map +1 -1
  17. package/dist/audio_mixer.js +11 -4
  18. package/dist/audio_mixer.js.map +1 -1
  19. package/dist/audio_resampler.cjs +20 -12
  20. package/dist/audio_resampler.cjs.map +1 -1
  21. package/dist/audio_resampler.d.cts +6 -6
  22. package/dist/audio_resampler.d.ts +6 -6
  23. package/dist/audio_resampler.d.ts.map +1 -1
  24. package/dist/audio_resampler.js +12 -4
  25. package/dist/audio_resampler.js.map +1 -1
  26. package/dist/audio_source.cjs +11 -7
  27. package/dist/audio_source.cjs.map +1 -1
  28. package/dist/audio_source.d.cts +1 -7
  29. package/dist/audio_source.d.ts +1 -7
  30. package/dist/audio_source.d.ts.map +1 -1
  31. package/dist/audio_source.js +8 -3
  32. package/dist/audio_source.js.map +1 -1
  33. package/dist/audio_stream.cjs +17 -5
  34. package/dist/audio_stream.cjs.map +1 -1
  35. package/dist/audio_stream.d.cts +1 -14
  36. package/dist/audio_stream.d.ts +1 -14
  37. package/dist/audio_stream.d.ts.map +1 -1
  38. package/dist/audio_stream.js +16 -4
  39. package/dist/audio_stream.js.map +1 -1
  40. package/dist/data_streams/index.d.cts +2 -10
  41. package/dist/data_streams/index.d.ts +2 -10
  42. package/dist/data_streams/stream_reader.cjs +8 -0
  43. package/dist/data_streams/stream_reader.cjs.map +1 -1
  44. package/dist/data_streams/stream_reader.d.cts +2 -10
  45. package/dist/data_streams/stream_reader.d.ts +2 -10
  46. package/dist/data_streams/stream_reader.d.ts.map +1 -1
  47. package/dist/data_streams/stream_reader.js +8 -0
  48. package/dist/data_streams/stream_reader.js.map +1 -1
  49. package/dist/data_streams/stream_writer.d.cts +2 -10
  50. package/dist/data_streams/stream_writer.d.ts +2 -10
  51. package/dist/data_streams/types.cjs.map +1 -1
  52. package/dist/data_streams/types.d.cts +2 -10
  53. package/dist/data_streams/types.d.ts +2 -10
  54. package/dist/data_streams/types.d.ts.map +1 -1
  55. package/dist/e2ee.cjs +21 -21
  56. package/dist/e2ee.cjs.map +1 -1
  57. package/dist/e2ee.d.cts +1 -2
  58. package/dist/e2ee.d.ts +1 -2
  59. package/dist/e2ee.d.ts.map +1 -1
  60. package/dist/e2ee.js +2 -2
  61. package/dist/e2ee.js.map +1 -1
  62. package/dist/ffi_client.cjs +11 -12
  63. package/dist/ffi_client.cjs.map +1 -1
  64. package/dist/ffi_client.d.cts +3 -16
  65. package/dist/ffi_client.d.ts +3 -16
  66. package/dist/ffi_client.d.ts.map +1 -1
  67. package/dist/ffi_client.js +5 -3
  68. package/dist/ffi_client.js.map +1 -1
  69. package/dist/frame_processor.cjs +13 -2
  70. package/dist/frame_processor.cjs.map +1 -1
  71. package/dist/frame_processor.d.cts +5 -8
  72. package/dist/frame_processor.d.ts +5 -8
  73. package/dist/frame_processor.d.ts.map +1 -1
  74. package/dist/frame_processor.js +10 -1
  75. package/dist/frame_processor.js.map +1 -1
  76. package/dist/index.cjs +25 -23
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +3 -16
  79. package/dist/index.d.ts +3 -16
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +9 -7
  82. package/dist/index.js.map +1 -1
  83. package/dist/log.cjs +1 -10
  84. package/dist/log.cjs.map +1 -1
  85. package/dist/log.d.cts +4 -0
  86. package/dist/log.d.ts +4 -0
  87. package/dist/log.d.ts.map +1 -1
  88. package/dist/log.js +1 -10
  89. package/dist/log.js.map +1 -1
  90. package/dist/participant.cjs +38 -38
  91. package/dist/participant.cjs.map +1 -1
  92. package/dist/participant.d.cts +2 -15
  93. package/dist/participant.d.ts +2 -15
  94. package/dist/participant.d.ts.map +1 -1
  95. package/dist/participant.js +12 -12
  96. package/dist/participant.js.map +1 -1
  97. package/dist/room.cjs +48 -30
  98. package/dist/room.cjs.map +1 -1
  99. package/dist/room.d.cts +11 -16
  100. package/dist/room.d.ts +11 -16
  101. package/dist/room.d.ts.map +1 -1
  102. package/dist/room.js +44 -26
  103. package/dist/room.js.map +1 -1
  104. package/dist/rpc.cjs.map +1 -1
  105. package/dist/rpc.d.cts +1 -2
  106. package/dist/rpc.d.ts +1 -2
  107. package/dist/rpc.d.ts.map +1 -1
  108. package/dist/rpc.js.map +1 -1
  109. package/dist/{stream_reader-Ch2zvjU3.d.cts → stream_reader-CuG4b8Y-.d.cts} +1 -1
  110. package/dist/{stream_reader-DRyR29vo.d.ts → stream_reader-CuG4b8Y-.d.ts} +1 -1
  111. package/dist/track.cjs +3 -3
  112. package/dist/track.cjs.map +1 -1
  113. package/dist/track.d.cts +1 -14
  114. package/dist/track.d.ts +1 -14
  115. package/dist/track.d.ts.map +1 -1
  116. package/dist/track.js +1 -1
  117. package/dist/track.js.map +1 -1
  118. package/dist/track_publication.cjs +4 -4
  119. package/dist/track_publication.cjs.map +1 -1
  120. package/dist/track_publication.d.cts +1 -14
  121. package/dist/track_publication.d.ts +1 -14
  122. package/dist/track_publication.d.ts.map +1 -1
  123. package/dist/track_publication.js +2 -2
  124. package/dist/track_publication.js.map +1 -1
  125. package/dist/version.cjs +1 -1
  126. package/dist/version.cjs.map +1 -1
  127. package/dist/version.d.cts +1 -1
  128. package/dist/version.d.ts +1 -1
  129. package/dist/version.js +1 -1
  130. package/dist/version.js.map +1 -1
  131. package/dist/video_frame.cjs +42 -42
  132. package/dist/video_frame.cjs.map +1 -1
  133. package/dist/video_frame.d.cts +1 -6
  134. package/dist/video_frame.d.ts +1 -6
  135. package/dist/video_frame.d.ts.map +1 -1
  136. package/dist/video_frame.js +2 -2
  137. package/dist/video_frame.js.map +1 -1
  138. package/dist/video_source.cjs +5 -5
  139. package/dist/video_source.cjs.map +1 -1
  140. package/dist/video_source.d.cts +1 -14
  141. package/dist/video_source.d.ts +1 -14
  142. package/dist/video_source.d.ts.map +1 -1
  143. package/dist/video_source.js +2 -2
  144. package/dist/video_source.js.map +1 -1
  145. package/dist/video_stream.cjs +12 -4
  146. package/dist/video_stream.cjs.map +1 -1
  147. package/dist/video_stream.d.cts +1 -14
  148. package/dist/video_stream.d.ts +1 -14
  149. package/dist/video_stream.d.ts.map +1 -1
  150. package/dist/video_stream.js +10 -2
  151. package/dist/video_stream.js.map +1 -1
  152. package/package.json +9 -35
  153. package/src/audio_filter.ts +2 -2
  154. package/src/audio_frame.ts +26 -7
  155. package/src/audio_mixer.ts +15 -4
  156. package/src/audio_resampler.ts +14 -4
  157. package/src/audio_source.ts +13 -5
  158. package/src/audio_stream.ts +21 -5
  159. package/src/data_streams/stream_reader.ts +19 -1
  160. package/src/data_streams/types.ts +1 -1
  161. package/src/e2ee.ts +3 -3
  162. package/src/ffi_client.ts +7 -5
  163. package/src/frame_processor.ts +21 -0
  164. package/src/index.ts +6 -5
  165. package/src/log.ts +14 -10
  166. package/src/participant.ts +17 -17
  167. package/src/room.ts +65 -38
  168. package/src/rpc.ts +1 -1
  169. package/src/tests/e2e.test.ts +517 -0
  170. package/src/track.ts +4 -4
  171. package/src/track_publication.ts +6 -6
  172. package/src/version.ts +1 -1
  173. package/src/video_frame.ts +3 -3
  174. package/src/video_source.ts +3 -3
  175. package/src/video_stream.ts +15 -3
  176. package/Cargo.toml +0 -25
  177. package/build.rs +0 -9
  178. package/dist/napi/native.cjs +0 -301
  179. package/dist/napi/native.d.cjs +0 -17
  180. package/dist/napi/native.d.cjs.map +0 -1
  181. package/dist/napi/native.d.d.cts +0 -21
  182. package/dist/napi/native.d.d.ts +0 -21
  183. package/dist/napi/native.d.js +0 -1
  184. package/dist/napi/native.d.js.map +0 -1
  185. package/dist/napi/native.d.ts +0 -19
  186. package/dist/napi/native.js +0 -15
  187. package/dist/native.cjs +0 -301
  188. package/dist/native.d.ts +0 -19
  189. package/dist/native.js +0 -15
  190. package/dist/proto/audio_frame_pb.cjs +0 -1357
  191. package/dist/proto/audio_frame_pb.cjs.map +0 -1
  192. package/dist/proto/audio_frame_pb.d.cts +0 -1183
  193. package/dist/proto/audio_frame_pb.d.ts +0 -1183
  194. package/dist/proto/audio_frame_pb.d.ts.map +0 -1
  195. package/dist/proto/audio_frame_pb.js +0 -1283
  196. package/dist/proto/audio_frame_pb.js.map +0 -1
  197. package/dist/proto/data_stream_pb.cjs +0 -1638
  198. package/dist/proto/data_stream_pb.cjs.map +0 -1
  199. package/dist/proto/data_stream_pb.d.cts +0 -1449
  200. package/dist/proto/data_stream_pb.d.ts +0 -1449
  201. package/dist/proto/data_stream_pb.d.ts.map +0 -1
  202. package/dist/proto/data_stream_pb.js +0 -1559
  203. package/dist/proto/data_stream_pb.js.map +0 -1
  204. package/dist/proto/e2ee_pb.cjs +0 -746
  205. package/dist/proto/e2ee_pb.cjs.map +0 -1
  206. package/dist/proto/e2ee_pb.d.cts +0 -653
  207. package/dist/proto/e2ee_pb.d.ts +0 -653
  208. package/dist/proto/e2ee_pb.d.ts.map +0 -1
  209. package/dist/proto/e2ee_pb.js +0 -696
  210. package/dist/proto/e2ee_pb.js.map +0 -1
  211. package/dist/proto/ffi_pb.cjs +0 -477
  212. package/dist/proto/ffi_pb.cjs.map +0 -1
  213. package/dist/proto/ffi_pb.d.cts +0 -1321
  214. package/dist/proto/ffi_pb.d.ts +0 -1321
  215. package/dist/proto/ffi_pb.d.ts.map +0 -1
  216. package/dist/proto/ffi_pb.js +0 -444
  217. package/dist/proto/ffi_pb.js.map +0 -1
  218. package/dist/proto/handle_pb.cjs +0 -53
  219. package/dist/proto/handle_pb.cjs.map +0 -1
  220. package/dist/proto/handle_pb.d.cts +0 -31
  221. package/dist/proto/handle_pb.d.ts +0 -31
  222. package/dist/proto/handle_pb.d.ts.map +0 -1
  223. package/dist/proto/handle_pb.js +0 -29
  224. package/dist/proto/handle_pb.js.map +0 -1
  225. package/dist/proto/participant_pb.cjs +0 -173
  226. package/dist/proto/participant_pb.cjs.map +0 -1
  227. package/dist/proto/participant_pb.d.cts +0 -218
  228. package/dist/proto/participant_pb.d.ts +0 -218
  229. package/dist/proto/participant_pb.d.ts.map +0 -1
  230. package/dist/proto/participant_pb.js +0 -145
  231. package/dist/proto/participant_pb.js.map +0 -1
  232. package/dist/proto/room_pb.cjs +0 -3374
  233. package/dist/proto/room_pb.cjs.map +0 -1
  234. package/dist/proto/room_pb.d.cts +0 -3028
  235. package/dist/proto/room_pb.d.ts +0 -3028
  236. package/dist/proto/room_pb.d.ts.map +0 -1
  237. package/dist/proto/room_pb.js +0 -3232
  238. package/dist/proto/room_pb.js.map +0 -1
  239. package/dist/proto/rpc_pb.cjs +0 -328
  240. package/dist/proto/rpc_pb.cjs.map +0 -1
  241. package/dist/proto/rpc_pb.d.cts +0 -267
  242. package/dist/proto/rpc_pb.d.ts +0 -267
  243. package/dist/proto/rpc_pb.d.ts.map +0 -1
  244. package/dist/proto/rpc_pb.js +0 -294
  245. package/dist/proto/rpc_pb.js.map +0 -1
  246. package/dist/proto/stats_pb.cjs +0 -1370
  247. package/dist/proto/stats_pb.cjs.map +0 -1
  248. package/dist/proto/stats_pb.d.cts +0 -1764
  249. package/dist/proto/stats_pb.d.ts +0 -1764
  250. package/dist/proto/stats_pb.d.ts.map +0 -1
  251. package/dist/proto/stats_pb.js +0 -1300
  252. package/dist/proto/stats_pb.js.map +0 -1
  253. package/dist/proto/track_pb.cjs +0 -630
  254. package/dist/proto/track_pb.cjs.map +0 -1
  255. package/dist/proto/track_pb.d.cts +0 -542
  256. package/dist/proto/track_pb.d.ts +0 -542
  257. package/dist/proto/track_pb.d.ts.map +0 -1
  258. package/dist/proto/track_pb.js +0 -584
  259. package/dist/proto/track_pb.js.map +0 -1
  260. package/dist/proto/track_publication_pb.cjs +0 -194
  261. package/dist/proto/track_publication_pb.cjs.map +0 -1
  262. package/dist/proto/track_publication_pb.d.cts +0 -135
  263. package/dist/proto/track_publication_pb.d.ts +0 -135
  264. package/dist/proto/track_publication_pb.d.ts.map +0 -1
  265. package/dist/proto/track_publication_pb.js +0 -164
  266. package/dist/proto/track_publication_pb.js.map +0 -1
  267. package/dist/proto/video_frame_pb.cjs +0 -723
  268. package/dist/proto/video_frame_pb.cjs.map +0 -1
  269. package/dist/proto/video_frame_pb.d.cts +0 -667
  270. package/dist/proto/video_frame_pb.d.ts +0 -667
  271. package/dist/proto/video_frame_pb.d.ts.map +0 -1
  272. package/dist/proto/video_frame_pb.js +0 -673
  273. package/dist/proto/video_frame_pb.js.map +0 -1
  274. package/src/lib.rs +0 -9
  275. package/src/napi/native.cjs +0 -301
  276. package/src/napi/native.d.ts +0 -19
  277. package/src/napi/native.js +0 -15
  278. package/src/nodejs.rs +0 -134
  279. package/src/proto/audio_frame_pb.ts +0 -2270
  280. package/src/proto/data_stream_pb.ts +0 -2674
  281. package/src/proto/e2ee_pb.ts +0 -1231
  282. package/src/proto/ffi_pb.ts +0 -1700
  283. package/src/proto/handle_pb.ts +0 -69
  284. package/src/proto/participant_pb.ts +0 -351
  285. package/src/proto/room_pb.ts +0 -5661
  286. package/src/proto/rpc_pb.ts +0 -539
  287. package/src/proto/stats_pb.ts +0 -3050
  288. package/src/proto/track_pb.ts +0 -1040
  289. package/src/proto/track_publication_pb.ts +0 -284
  290. package/src/proto/video_frame_pb.ts +0 -1236
package/src/room.ts CHANGED
@@ -2,6 +2,27 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import { Mutex } from '@livekit/mutex';
5
+ import { EncryptionState, type EncryptionType } from '@livekit/rtc-ffi-bindings';
6
+ import type { FfiEvent } from '@livekit/rtc-ffi-bindings';
7
+ import type { DisconnectReason, OwnedParticipant } from '@livekit/rtc-ffi-bindings';
8
+ import type { DataStream_Trailer, DisconnectCallback } from '@livekit/rtc-ffi-bindings';
9
+ import {
10
+ type ConnectCallback,
11
+ ConnectRequest,
12
+ type ConnectResponse,
13
+ type ConnectionQuality,
14
+ ConnectionState,
15
+ ContinualGatheringPolicy,
16
+ type DataPacketKind,
17
+ type DataStream_Chunk,
18
+ type DataStream_Header,
19
+ type DisconnectResponse,
20
+ RoomOptions as FfiRoomOptions,
21
+ type IceServer,
22
+ IceTransportType,
23
+ type RoomInfo,
24
+ } from '@livekit/rtc-ffi-bindings';
25
+ import { TrackKind } from '@livekit/rtc-ffi-bindings';
5
26
  import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
6
27
  import EventEmitter from 'events';
7
28
  import { ByteStreamReader, TextStreamReader } from './data_streams/stream_reader.js';
@@ -18,27 +39,6 @@ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
18
39
  import { log } from './log.js';
19
40
  import type { Participant } from './participant.js';
20
41
  import { LocalParticipant, RemoteParticipant } from './participant.js';
21
- import { EncryptionState, type EncryptionType } from './proto/e2ee_pb.js';
22
- import type { FfiEvent } from './proto/ffi_pb.js';
23
- import type { DisconnectReason, OwnedParticipant } from './proto/participant_pb.js';
24
- import type { DataStream_Trailer, DisconnectCallback } from './proto/room_pb.js';
25
- import {
26
- type ConnectCallback,
27
- ConnectRequest,
28
- type ConnectResponse,
29
- type ConnectionQuality,
30
- ConnectionState,
31
- ContinualGatheringPolicy,
32
- type DataPacketKind,
33
- type DataStream_Chunk,
34
- type DataStream_Header,
35
- type DisconnectResponse,
36
- RoomOptions as FfiRoomOptions,
37
- type IceServer,
38
- IceTransportType,
39
- type RoomInfo,
40
- } from './proto/room_pb.js';
41
- import { TrackKind } from './proto/track_pb.js';
42
42
  import type { LocalTrack, RemoteTrack } from './track.js';
43
43
  import { RemoteAudioTrack, RemoteVideoTrack } from './track.js';
44
44
  import type { LocalTrackPublication, TrackPublication } from './track_publication.js';
@@ -96,6 +96,9 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
96
96
 
97
97
  private preConnectEvents: FfiEvent[] = [];
98
98
 
99
+ private _token?: string;
100
+ private _serverUrl?: string;
101
+
99
102
  e2eeManager?: E2EEManager;
100
103
  connectionState: ConnectionState = ConnectionState.CONN_DISCONNECTED;
101
104
 
@@ -118,6 +121,16 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
118
121
  return this.ffiHandle != undefined && this.connectionState != ConnectionState.CONN_DISCONNECTED;
119
122
  }
120
123
 
124
+ /** @internal */
125
+ get token(): string | undefined {
126
+ return this._token;
127
+ }
128
+
129
+ /** @internal */
130
+ get serverUrl(): string | undefined {
131
+ return this._serverUrl;
132
+ }
133
+
121
134
  /**
122
135
  * Gets the room's server ID. This ID is assigned by the LiveKit server
123
136
  * and is unique for each room session.
@@ -155,7 +168,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
155
168
  }
156
169
 
157
170
  get creationTime(): Date {
158
- return new Date(Number(this.info?.creationTime ?? 0));
171
+ // TODO: workaround for Rust SDK bug, remove after updating to:
172
+ // https://github.com/livekit/rust-sdks/pull/822
173
+ // check if creationTime looks like seconds (less than year 3000 in ms), convert to ms if needed
174
+ let creationTimeMs = Number(this.info?.creationTime ?? 0);
175
+ if (creationTimeMs > 0 && creationTimeMs < 1e12) {
176
+ creationTimeMs *= 1000;
177
+ }
178
+ return new Date(creationTimeMs);
159
179
  }
160
180
 
161
181
  get isRecording(): boolean {
@@ -217,6 +237,8 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
217
237
  this.ffiHandle = new FfiHandle(cb.message.value.room!.handle!.id!);
218
238
  this.e2eeManager = e2eeEnabled && new E2EEManager(this.ffiHandle.handle, e2eeOptions);
219
239
 
240
+ this._token = token;
241
+ this._serverUrl = url;
220
242
  this.info = cb.message.value.room!.info;
221
243
  this.connectionState = ConnectionState.CONN_CONNECTED;
222
244
  this.localParticipant = new LocalParticipant(
@@ -362,7 +384,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
362
384
  participant.info.disconnectReason = ev.value.disconnectReason;
363
385
  this.emit(RoomEvent.ParticipantDisconnected, participant);
364
386
  } else {
365
- console.log(`RoomEvent.ParticipantDisconnected: Could not find participant`);
387
+ log.warn(`RoomEvent.ParticipantDisconnected: Could not find participant`);
366
388
  }
367
389
  } else if (ev.case == 'localTrackPublished') {
368
390
  const publication = this.localParticipant.trackPublications.get(ev.value.trackSid!);
@@ -377,7 +399,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
377
399
  publication.resolveFirstSubscription();
378
400
  this.emit(RoomEvent.LocalTrackSubscribed, publication!.track!);
379
401
  } else {
380
- console.warn(`RoomEvent.LocalTrackSubscribed: Publication not found: ${ev.value.trackSid}`);
402
+ log.warn(`RoomEvent.LocalTrackSubscribed: Publication not found: ${ev.value.trackSid}`);
381
403
  }
382
404
  } else if (ev.case == 'trackPublished') {
383
405
  const participant = this.remoteParticipants.get(ev.value.participantIdentity!);
@@ -385,7 +407,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
385
407
  if (participant) {
386
408
  participant.trackPublications.set(publication.sid!, publication);
387
409
  } else {
388
- console.warn(
410
+ log.warn(
389
411
  `RoomEvent.TrackPublished: Could not find participant: ${ev.value.participantIdentity}`,
390
412
  );
391
413
  }
@@ -397,7 +419,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
397
419
  if (publication) {
398
420
  this.emit(RoomEvent.TrackUnpublished, publication, participant);
399
421
  } else {
400
- console.warn(`RoomEvent.TrackUnpublished: Could not find publication`);
422
+ log.warn(`RoomEvent.TrackUnpublished: Could not find publication`);
401
423
  }
402
424
  } else if (ev.case == 'trackSubscribed') {
403
425
  const ownedTrack = ev.value.track!;
@@ -416,7 +438,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
416
438
 
417
439
  this.emit(RoomEvent.TrackSubscribed, publication.track!, publication, participant);
418
440
  } catch (e: unknown) {
419
- console.warn(`RoomEvent.TrackSubscribed: ${(e as Error).message}`);
441
+ log.warn(`RoomEvent.TrackSubscribed: ${(e as Error).message}`);
420
442
  }
421
443
  } else if (ev.case == 'trackUnsubscribed') {
422
444
  try {
@@ -429,7 +451,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
429
451
  publication.subscribed = false;
430
452
  this.emit(RoomEvent.TrackUnsubscribed, track, publication, participant);
431
453
  } catch (e: unknown) {
432
- console.warn(`RoomEvent.TrackUnsubscribed: ${(e as Error).message}`);
454
+ log.warn(`RoomEvent.TrackUnsubscribed: ${(e as Error).message}`);
433
455
  }
434
456
  } else if (ev.case == 'trackSubscriptionFailed') {
435
457
  try {
@@ -441,7 +463,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
441
463
  ev.value.error,
442
464
  );
443
465
  } catch (e: unknown) {
444
- console.warn(`RoomEvent.TrackSubscriptionFailed: ${(e as Error).message}`);
466
+ log.warn(`RoomEvent.TrackSubscriptionFailed: ${(e as Error).message}`);
445
467
  }
446
468
  } else if (ev.case == 'trackMuted') {
447
469
  try {
@@ -455,7 +477,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
455
477
  }
456
478
  this.emit(RoomEvent.TrackMuted, publication, participant);
457
479
  } catch (e: unknown) {
458
- console.warn(`RoomEvent.TrackMuted: ${(e as Error).message}`);
480
+ log.warn(`RoomEvent.TrackMuted: ${(e as Error).message}`);
459
481
  }
460
482
  } else if (ev.case == 'trackUnmuted') {
461
483
  try {
@@ -469,7 +491,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
469
491
  }
470
492
  this.emit(RoomEvent.TrackUnmuted, publication, participant);
471
493
  } catch (e: unknown) {
472
- console.warn(`RoomEvent.TrackUnmuted: ${(e as Error).message}`);
494
+ log.warn(`RoomEvent.TrackUnmuted: ${(e as Error).message}`);
473
495
  }
474
496
  } else if (ev.case == 'activeSpeakersChanged') {
475
497
  try {
@@ -478,7 +500,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
478
500
  );
479
501
  this.emit(RoomEvent.ActiveSpeakersChanged, activeSpeakers);
480
502
  } catch (e: unknown) {
481
- console.warn(`RoomEvent.ActiveSpeakersChanged: ${(e as Error).message}`);
503
+ log.warn(`RoomEvent.ActiveSpeakersChanged: ${(e as Error).message}`);
482
504
  }
483
505
  } else if (ev.case == 'roomMetadataChanged') {
484
506
  this.info.metadata = ev.value.metadata ?? '';
@@ -489,7 +511,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
489
511
  participant.info.metadata = ev.value.metadata;
490
512
  this.emit(RoomEvent.ParticipantMetadataChanged, participant.metadata, participant);
491
513
  } catch (e: unknown) {
492
- console.warn(`RoomEvent.ParticipantMetadataChanged: ${(e as Error).message}`);
514
+ log.warn(`RoomEvent.ParticipantMetadataChanged: ${(e as Error).message}`);
493
515
  }
494
516
  } else if (ev.case == 'participantNameChanged') {
495
517
  try {
@@ -497,7 +519,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
497
519
  participant.info.name = ev.value.name;
498
520
  this.emit(RoomEvent.ParticipantNameChanged, participant.name!, participant);
499
521
  } catch (e: unknown) {
500
- console.warn(`RoomEvent.ParticipantNameChanged: ${(e as Error).message}`);
522
+ log.warn(`RoomEvent.ParticipantNameChanged: ${(e as Error).message}`);
501
523
  }
502
524
  } else if (ev.case == 'participantAttributesChanged') {
503
525
  try {
@@ -520,14 +542,14 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
520
542
  this.emit(RoomEvent.ParticipantAttributesChanged, changedAttributes, participant);
521
543
  }
522
544
  } catch (e: unknown) {
523
- console.warn(`RoomEvent.ParticipantAttributesChanged: ${(e as Error).message}`);
545
+ log.warn(`RoomEvent.ParticipantAttributesChanged: ${(e as Error).message}`);
524
546
  }
525
547
  } else if (ev.case == 'connectionQualityChanged') {
526
548
  try {
527
549
  const participant = this.requireParticipantByIdentity(ev.value.participantIdentity!);
528
550
  this.emit(RoomEvent.ConnectionQualityChanged, ev.value.quality!, participant);
529
551
  } catch (e: unknown) {
530
- console.warn(`RoomEvent.ConnectionQualityChanged: ${(e as Error).message}`);
552
+ log.warn(`RoomEvent.ConnectionQualityChanged: ${(e as Error).message}`);
531
553
  }
532
554
  } else if (ev.case == 'chatMessage') {
533
555
  const participant = this.retrieveParticipantByIdentity(ev.value.participantIdentity!);
@@ -612,8 +634,11 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
612
634
  participant,
613
635
  );
614
636
  } catch (e: unknown) {
615
- console.warn(`RoomEvent.ParticipantEncryptionStatusChanged: ${(e as Error).message}`);
637
+ log.warn(`RoomEvent.ParticipantEncryptionStatusChanged: ${(e as Error).message}`);
616
638
  }
639
+ } else if (ev.case === 'tokenRefreshed') {
640
+ this._token = ev.value.token;
641
+ this.emit('tokenRefreshed');
617
642
  }
618
643
  };
619
644
 
@@ -767,7 +792,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
767
792
  const textBuffer = this.textStreamControllers.get(streamId);
768
793
  if (textBuffer) {
769
794
  textBuffer.controller.close();
770
- this.byteStreamControllers.delete(streamId);
795
+ this.textStreamControllers.delete(streamId);
771
796
  }
772
797
  }
773
798
  }
@@ -835,6 +860,7 @@ export type RoomCallbacks = {
835
860
  roomSidChanged: (sid: string) => void;
836
861
  roomUpdated: () => void;
837
862
  moved: () => void;
863
+ tokenRefreshed: () => void;
838
864
  };
839
865
 
840
866
  export enum RoomEvent {
@@ -869,4 +895,5 @@ export enum RoomEvent {
869
895
  Reconnected = 'reconnected',
870
896
  RoomUpdated = 'roomUpdated',
871
897
  Moved = 'moved',
898
+ TokenRefreshed = 'tokenRefreshed',
872
899
  }
package/src/rpc.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { RpcError as RpcError_Proto } from './proto/rpc_pb.js';
4
+ import type { RpcError as RpcError_Proto } from '@livekit/rtc-ffi-bindings';
5
5
 
6
6
  /** Parameters for initiating an RPC call */
7
7
  export interface PerformRpcParams {