@livekit/rtc-node 0.12.2 → 0.13.1

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 (217) hide show
  1. package/dist/audio_frame.cjs +2 -2
  2. package/dist/audio_frame.cjs.map +1 -1
  3. package/dist/audio_frame.d.cts +2 -3
  4. package/dist/audio_frame.d.ts +2 -3
  5. package/dist/audio_frame.d.ts.map +1 -1
  6. package/dist/audio_frame.js +3 -3
  7. package/dist/audio_frame.js.map +1 -1
  8. package/dist/audio_resampler.cjs +10 -7
  9. package/dist/audio_resampler.cjs.map +1 -1
  10. package/dist/audio_resampler.d.cts +2 -3
  11. package/dist/audio_resampler.d.ts +2 -3
  12. package/dist/audio_resampler.d.ts.map +1 -1
  13. package/dist/audio_resampler.js +13 -10
  14. package/dist/audio_resampler.js.map +1 -1
  15. package/dist/audio_source.cjs +6 -4
  16. package/dist/audio_source.cjs.map +1 -1
  17. package/dist/audio_source.d.cts +3 -3
  18. package/dist/audio_source.d.ts +3 -3
  19. package/dist/audio_source.d.ts.map +1 -1
  20. package/dist/audio_source.js +9 -7
  21. package/dist/audio_source.js.map +1 -1
  22. package/dist/audio_stream.cjs +1 -2
  23. package/dist/audio_stream.cjs.map +1 -1
  24. package/dist/audio_stream.d.cts +2 -3
  25. package/dist/audio_stream.d.ts +2 -3
  26. package/dist/audio_stream.d.ts.map +1 -1
  27. package/dist/audio_stream.js +2 -3
  28. package/dist/audio_stream.js.map +1 -1
  29. package/dist/e2ee.cjs +19 -20
  30. package/dist/e2ee.cjs.map +1 -1
  31. package/dist/e2ee.d.cts +5 -6
  32. package/dist/e2ee.d.ts +5 -6
  33. package/dist/e2ee.d.ts.map +1 -1
  34. package/dist/e2ee.js +29 -30
  35. package/dist/e2ee.js.map +1 -1
  36. package/dist/ffi_client.cjs +6 -5
  37. package/dist/ffi_client.cjs.map +1 -1
  38. package/dist/ffi_client.d.cts +10 -10
  39. package/dist/ffi_client.d.ts +10 -10
  40. package/dist/ffi_client.d.ts.map +1 -1
  41. package/dist/ffi_client.js +6 -10
  42. package/dist/ffi_client.js.map +1 -1
  43. package/dist/index.cjs +16 -49
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +6 -35
  46. package/dist/index.d.ts +6 -35
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +7 -46
  49. package/dist/index.js.map +1 -1
  50. package/dist/napi/native.d.cjs.map +1 -1
  51. package/dist/napi/native.d.ts +5 -5
  52. package/dist/native.d.ts +5 -5
  53. package/dist/participant.cjs +60 -36
  54. package/dist/participant.cjs.map +1 -1
  55. package/dist/participant.d.cts +11 -11
  56. package/dist/participant.d.ts +11 -11
  57. package/dist/participant.d.ts.map +1 -1
  58. package/dist/participant.js +78 -52
  59. package/dist/participant.js.map +1 -1
  60. package/dist/proto/audio_frame_pb.cjs +977 -125
  61. package/dist/proto/audio_frame_pb.cjs.map +1 -1
  62. package/dist/proto/audio_frame_pb.d.cts +502 -417
  63. package/dist/proto/audio_frame_pb.d.ts +502 -417
  64. package/dist/proto/audio_frame_pb.d.ts.map +1 -1
  65. package/dist/proto/audio_frame_pb.js +943 -85
  66. package/dist/proto/audio_frame_pb.js.map +1 -1
  67. package/dist/proto/e2ee_pb.cjs +700 -85
  68. package/dist/proto/e2ee_pb.cjs.map +1 -1
  69. package/dist/proto/e2ee_pb.d.cts +331 -263
  70. package/dist/proto/e2ee_pb.d.ts +331 -263
  71. package/dist/proto/e2ee_pb.d.ts.map +1 -1
  72. package/dist/proto/e2ee_pb.js +675 -57
  73. package/dist/proto/e2ee_pb.js.map +1 -1
  74. package/dist/proto/ffi_pb.cjs +369 -36
  75. package/dist/proto/ffi_pb.cjs.map +1 -1
  76. package/dist/proto/ffi_pb.d.cts +156 -109
  77. package/dist/proto/ffi_pb.d.ts +156 -109
  78. package/dist/proto/ffi_pb.d.ts.map +1 -1
  79. package/dist/proto/ffi_pb.js +364 -29
  80. package/dist/proto/ffi_pb.js.map +1 -1
  81. package/dist/proto/handle_pb.cjs +27 -7
  82. package/dist/proto/handle_pb.cjs.map +1 -1
  83. package/dist/proto/handle_pb.d.cts +13 -15
  84. package/dist/proto/handle_pb.d.ts +13 -15
  85. package/dist/proto/handle_pb.d.ts.map +1 -1
  86. package/dist/proto/handle_pb.js +26 -5
  87. package/dist/proto/handle_pb.js.map +1 -1
  88. package/dist/proto/participant_pb.cjs +112 -15
  89. package/dist/proto/participant_pb.cjs.map +1 -1
  90. package/dist/proto/participant_pb.d.cts +140 -52
  91. package/dist/proto/participant_pb.d.ts +140 -52
  92. package/dist/proto/participant_pb.d.ts.map +1 -1
  93. package/dist/proto/participant_pb.js +109 -11
  94. package/dist/proto/participant_pb.js.map +1 -1
  95. package/dist/proto/room_pb.cjs +2693 -302
  96. package/dist/proto/room_pb.cjs.map +1 -1
  97. package/dist/proto/room_pb.d.cts +1265 -862
  98. package/dist/proto/room_pb.d.ts +1265 -862
  99. package/dist/proto/room_pb.d.ts.map +1 -1
  100. package/dist/proto/room_pb.js +2603 -210
  101. package/dist/proto/room_pb.js.map +1 -1
  102. package/dist/proto/rpc_pb.cjs +302 -37
  103. package/dist/proto/rpc_pb.cjs.map +1 -1
  104. package/dist/proto/rpc_pb.d.cts +138 -108
  105. package/dist/proto/rpc_pb.d.ts +138 -108
  106. package/dist/proto/rpc_pb.d.ts.map +1 -1
  107. package/dist/proto/rpc_pb.js +291 -25
  108. package/dist/proto/rpc_pb.js.map +1 -1
  109. package/dist/proto/stats_pb.cjs +1253 -139
  110. package/dist/proto/stats_pb.cjs.map +1 -1
  111. package/dist/proto/stats_pb.d.cts +803 -692
  112. package/dist/proto/stats_pb.d.ts +803 -692
  113. package/dist/proto/stats_pb.d.ts.map +1 -1
  114. package/dist/proto/stats_pb.js +1216 -93
  115. package/dist/proto/stats_pb.js.map +1 -1
  116. package/dist/proto/track_pb.cjs +462 -64
  117. package/dist/proto/track_pb.cjs.map +1 -1
  118. package/dist/proto/track_pb.d.cts +250 -218
  119. package/dist/proto/track_pb.d.ts +250 -218
  120. package/dist/proto/track_pb.d.ts.map +1 -1
  121. package/dist/proto/track_pb.js +447 -45
  122. package/dist/proto/track_pb.js.map +1 -1
  123. package/dist/proto/track_publication_pb.cjs +130 -0
  124. package/dist/proto/track_publication_pb.cjs.map +1 -0
  125. package/dist/proto/track_publication_pb.d.cts +80 -0
  126. package/dist/proto/track_publication_pb.d.ts +80 -0
  127. package/dist/proto/track_publication_pb.d.ts.map +1 -0
  128. package/dist/proto/track_publication_pb.js +103 -0
  129. package/dist/proto/track_publication_pb.js.map +1 -0
  130. package/dist/proto/video_frame_pb.cjs +648 -88
  131. package/dist/proto/video_frame_pb.cjs.map +1 -1
  132. package/dist/proto/video_frame_pb.d.cts +371 -328
  133. package/dist/proto/video_frame_pb.d.ts +371 -328
  134. package/dist/proto/video_frame_pb.d.ts.map +1 -1
  135. package/dist/proto/video_frame_pb.js +626 -60
  136. package/dist/proto/video_frame_pb.js.map +1 -1
  137. package/dist/room.cjs +85 -125
  138. package/dist/room.cjs.map +1 -1
  139. package/dist/room.d.cts +6 -17
  140. package/dist/room.d.ts +6 -17
  141. package/dist/room.d.ts.map +1 -1
  142. package/dist/room.js +85 -123
  143. package/dist/room.js.map +1 -1
  144. package/dist/rpc.cjs.map +1 -1
  145. package/dist/rpc.d.cts +0 -1
  146. package/dist/rpc.d.ts +0 -1
  147. package/dist/rpc.js.map +1 -1
  148. package/dist/track.cjs +12 -8
  149. package/dist/track.cjs.map +1 -1
  150. package/dist/track.d.cts +8 -9
  151. package/dist/track.d.ts +8 -9
  152. package/dist/track.d.ts.map +1 -1
  153. package/dist/track.js +13 -9
  154. package/dist/track.js.map +1 -1
  155. package/dist/track_publication.cjs +21 -12
  156. package/dist/track_publication.cjs.map +1 -1
  157. package/dist/track_publication.d.cts +12 -13
  158. package/dist/track_publication.d.ts +12 -13
  159. package/dist/track_publication.d.ts.map +1 -1
  160. package/dist/track_publication.js +22 -13
  161. package/dist/track_publication.js.map +1 -1
  162. package/dist/version.cjs +1 -1
  163. package/dist/version.cjs.map +1 -1
  164. package/dist/version.d.cts +1 -1
  165. package/dist/version.d.ts +1 -1
  166. package/dist/version.js +1 -1
  167. package/dist/version.js.map +1 -1
  168. package/dist/video_frame.cjs +26 -45
  169. package/dist/video_frame.cjs.map +1 -1
  170. package/dist/video_frame.d.cts +2 -3
  171. package/dist/video_frame.d.ts +2 -3
  172. package/dist/video_frame.d.ts.map +1 -1
  173. package/dist/video_frame.js +29 -48
  174. package/dist/video_frame.js.map +1 -1
  175. package/dist/video_source.cjs +7 -4
  176. package/dist/video_source.cjs.map +1 -1
  177. package/dist/video_source.d.cts +4 -4
  178. package/dist/video_source.d.ts +4 -4
  179. package/dist/video_source.d.ts.map +1 -1
  180. package/dist/video_source.js +9 -6
  181. package/dist/video_source.js.map +1 -1
  182. package/dist/video_stream.cjs +16 -5
  183. package/dist/video_stream.cjs.map +1 -1
  184. package/dist/video_stream.d.cts +3 -4
  185. package/dist/video_stream.d.ts +3 -4
  186. package/dist/video_stream.d.ts.map +1 -1
  187. package/dist/video_stream.js +17 -6
  188. package/dist/video_stream.js.map +1 -1
  189. package/package.json +9 -9
  190. package/src/audio_frame.ts +10 -10
  191. package/src/audio_resampler.ts +15 -13
  192. package/src/audio_source.ts +11 -8
  193. package/src/audio_stream.ts +3 -4
  194. package/src/e2ee.ts +41 -42
  195. package/src/ffi_client.ts +8 -16
  196. package/src/index.ts +5 -68
  197. package/src/napi/native.d.ts +5 -5
  198. package/src/participant.ts +102 -73
  199. package/src/proto/audio_frame_pb.ts +1220 -496
  200. package/src/proto/e2ee_pb.ts +858 -337
  201. package/src/proto/ffi_pb.ts +442 -135
  202. package/src/proto/handle_pb.ts +33 -19
  203. package/src/proto/participant_pb.ts +225 -60
  204. package/src/proto/room_pb.ts +3149 -1013
  205. package/src/proto/rpc_pb.ts +358 -129
  206. package/src/proto/stats_pb.ts +1891 -877
  207. package/src/proto/track_pb.ts +587 -253
  208. package/src/proto/track_publication_pb.ts +180 -0
  209. package/src/proto/video_frame_pb.ts +861 -394
  210. package/src/room.ts +137 -189
  211. package/src/rpc.ts +1 -1
  212. package/src/track.ts +16 -17
  213. package/src/track_publication.ts +25 -26
  214. package/src/version.ts +1 -1
  215. package/src/video_frame.ts +48 -72
  216. package/src/video_source.ts +11 -8
  217. package/src/video_stream.ts +18 -8
@@ -1,9 +1,13 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { FfiClient, FfiHandle } from './ffi_client.js';
6
- import type { OwnedParticipant, ParticipantInfo, ParticipantKind } from './proto/participant_pb.js';
5
+ import {
6
+ DisconnectReason,
7
+ type OwnedParticipant,
8
+ type ParticipantInfo,
9
+ type ParticipantKind,
10
+ } from './proto/participant_pb.js';
7
11
  import type {
8
12
  PublishDataCallback,
9
13
  PublishDataResponse,
@@ -25,26 +29,20 @@ import type {
25
29
  UnpublishTrackCallback,
26
30
  UnpublishTrackResponse,
27
31
  } from './proto/room_pb.js';
32
+ import { ChatMessage as ChatMessageModel } from './proto/room_pb.js';
28
33
  import {
29
- ChatMessageSchema,
30
- EditChatMessageRequestSchema,
31
- PublishDataRequestSchema,
32
- PublishSipDtmfRequestSchema,
33
- PublishTrackRequestSchema,
34
- PublishTranscriptionRequestSchema,
35
- SendChatMessageRequestSchema,
36
- SetLocalAttributesRequestSchema,
37
- SetLocalMetadataRequestSchema,
38
- SetLocalNameRequestSchema,
39
- UnpublishTrackRequestSchema,
34
+ EditChatMessageRequest,
35
+ TranscriptionSegment as ProtoTranscriptionSegment,
36
+ PublishDataRequest,
37
+ PublishSipDtmfRequest,
38
+ PublishTrackRequest,
39
+ PublishTranscriptionRequest,
40
+ SendChatMessageRequest,
41
+ SetLocalAttributesRequest,
42
+ SetLocalMetadataRequest,
43
+ SetLocalNameRequest,
44
+ UnpublishTrackRequest,
40
45
  } from './proto/room_pb.js';
41
- import { TranscriptionSegmentSchema } from './proto/room_pb.js';
42
- import {
43
- PerformRpcRequestSchema,
44
- RegisterRpcMethodRequestSchema,
45
- RpcMethodInvocationResponseRequestSchema,
46
- UnregisterRpcMethodRequestSchema,
47
- } from './proto/rpc_pb.js';
48
46
  import type {
49
47
  PerformRpcCallback,
50
48
  PerformRpcResponse,
@@ -52,6 +50,12 @@ import type {
52
50
  RpcMethodInvocationResponseResponse,
53
51
  UnregisterRpcMethodResponse,
54
52
  } from './proto/rpc_pb.js';
53
+ import {
54
+ PerformRpcRequest,
55
+ RegisterRpcMethodRequest,
56
+ RpcMethodInvocationResponseRequest,
57
+ UnregisterRpcMethodRequest,
58
+ } from './proto/rpc_pb.js';
55
59
  import { type PerformRpcParams, RpcError, type RpcInvocationData } from './rpc.js';
56
60
  import type { LocalTrack } from './track.js';
57
61
  import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
@@ -69,33 +73,40 @@ export abstract class Participant {
69
73
  trackPublications = new Map<string, TrackPublication>();
70
74
 
71
75
  constructor(owned_info: OwnedParticipant) {
72
- this.info = owned_info.info!;
73
- this.ffi_handle = new FfiHandle(owned_info.handle!.id);
76
+ this.info = owned_info!.info!;
77
+ this.ffi_handle = new FfiHandle(owned_info.handle!.id!);
74
78
  }
75
79
 
76
- get sid(): string {
80
+ get sid(): string | undefined {
77
81
  return this.info.sid;
78
82
  }
79
83
 
80
- get name(): string {
84
+ get name(): string | undefined {
81
85
  return this.info.name;
82
86
  }
83
87
 
84
- get identity(): string {
88
+ get identity(): string | undefined {
85
89
  return this.info.identity;
86
90
  }
87
91
 
88
- get metadata(): string {
92
+ get metadata(): string | undefined {
89
93
  return this.info.metadata;
90
94
  }
91
95
 
92
- get attributes(): Record<string, string> {
96
+ get attributes(): Record<string, string> | undefined {
93
97
  return this.info.attributes;
94
98
  }
95
99
 
96
- get kind(): ParticipantKind {
100
+ get kind(): ParticipantKind | undefined {
97
101
  return this.info.kind;
98
102
  }
103
+
104
+ get disconnectReason(): DisconnectReason | undefined {
105
+ if (this.info.disconnectReason === DisconnectReason.UNKNOWN_REASON) {
106
+ return undefined;
107
+ }
108
+ return this.info.disconnectReason;
109
+ }
99
110
  }
100
111
 
101
112
  export type DataPublishOptions = {
@@ -120,7 +131,7 @@ export class LocalParticipant extends Participant {
120
131
  trackPublications: Map<string, LocalTrackPublication> = new Map();
121
132
 
122
133
  async publishData(data: Uint8Array, options: DataPublishOptions) {
123
- const req = create(PublishDataRequestSchema, {
134
+ const req = new PublishDataRequest({
124
135
  localParticipantHandle: this.ffi_handle.handle,
125
136
  dataPtr: FfiClient.instance.retrievePtr(data),
126
137
  dataLen: BigInt(data.byteLength),
@@ -143,7 +154,7 @@ export class LocalParticipant extends Participant {
143
154
  }
144
155
 
145
156
  async publishDtmf(code: number, digit: string) {
146
- const req = create(PublishSipDtmfRequestSchema, {
157
+ const req = new PublishSipDtmfRequest({
147
158
  localParticipantHandle: this.ffi_handle.handle,
148
159
  code,
149
160
  digit,
@@ -163,18 +174,19 @@ export class LocalParticipant extends Participant {
163
174
  }
164
175
 
165
176
  async publishTranscription(transcription: Transcription) {
166
- const req = create(PublishTranscriptionRequestSchema, {
177
+ const req = new PublishTranscriptionRequest({
167
178
  localParticipantHandle: this.ffi_handle.handle,
168
179
  participantIdentity: transcription.participantIdentity,
169
- segments: transcription.segments.map((s) =>
170
- create(TranscriptionSegmentSchema, {
171
- id: s.id,
172
- text: s.text,
173
- startTime: s.startTime,
174
- endTime: s.endTime,
175
- final: s.final,
176
- language: s.language,
177
- }),
180
+ segments: transcription.segments.map(
181
+ (s) =>
182
+ new ProtoTranscriptionSegment({
183
+ id: s.id,
184
+ text: s.text,
185
+ startTime: s.startTime,
186
+ endTime: s.endTime,
187
+ final: s.final,
188
+ language: s.language,
189
+ }),
178
190
  ),
179
191
  trackId: transcription.trackSid,
180
192
  });
@@ -193,7 +205,7 @@ export class LocalParticipant extends Participant {
193
205
  }
194
206
 
195
207
  async updateMetadata(metadata: string) {
196
- const req = create(SetLocalMetadataRequestSchema, {
208
+ const req = new SetLocalMetadataRequest({
197
209
  localParticipantHandle: this.ffi_handle.handle,
198
210
  metadata: metadata,
199
211
  });
@@ -220,7 +232,7 @@ export class LocalParticipant extends Participant {
220
232
  destinationIdentities?: Array<string>,
221
233
  senderIdentity?: string,
222
234
  ): Promise<ChatMessage> {
223
- const req = create(SendChatMessageRequestSchema, {
235
+ const req = new SendChatMessageRequest({
224
236
  localParticipantHandle: this.ffi_handle.handle,
225
237
  message: text,
226
238
  destinationIdentities,
@@ -235,11 +247,19 @@ export class LocalParticipant extends Participant {
235
247
  return ev.message.case == 'chatMessage' && ev.message.value.asyncId == res.asyncId;
236
248
  });
237
249
 
238
- if (cb.message.case !== 'chatMessage') {
239
- throw new Error(cb.message.value ?? 'Unknown Error');
250
+ switch (cb.message.case) {
251
+ case 'chatMessage':
252
+ const { id, timestamp, editTimestamp, message } = cb.message.value!;
253
+ return {
254
+ id: id!,
255
+ timestamp: Number(timestamp),
256
+ editTimestamp: Number(editTimestamp),
257
+ message: message!,
258
+ };
259
+ case 'error':
260
+ default:
261
+ throw new Error(cb.message.value);
240
262
  }
241
- const { id, timestamp, editTimestamp, message } = cb.message.value;
242
- return { id, timestamp: Number(timestamp), editTimestamp: Number(editTimestamp), message };
243
263
  }
244
264
 
245
265
  /**
@@ -251,10 +271,10 @@ export class LocalParticipant extends Participant {
251
271
  destinationIdentities?: Array<string>,
252
272
  senderIdentity?: string,
253
273
  ): Promise<ChatMessage> {
254
- const req = create(EditChatMessageRequestSchema, {
274
+ const req = new EditChatMessageRequest({
255
275
  localParticipantHandle: this.ffi_handle.handle,
256
276
  editText,
257
- originalMessage: create(ChatMessageSchema, {
277
+ originalMessage: new ChatMessageModel({
258
278
  ...originalMessage,
259
279
  timestamp: BigInt(originalMessage.timestamp),
260
280
  editTimestamp: originalMessage.editTimestamp
@@ -273,15 +293,23 @@ export class LocalParticipant extends Participant {
273
293
  return ev.message.case == 'chatMessage' && ev.message.value.asyncId == res.asyncId;
274
294
  });
275
295
 
276
- if (cb.message.case !== 'chatMessage') {
277
- throw new Error(cb.message.value ?? 'Unknown Error');
296
+ switch (cb.message.case) {
297
+ case 'chatMessage':
298
+ const { id, timestamp, editTimestamp, message } = cb.message.value!;
299
+ return {
300
+ id: id!,
301
+ timestamp: Number(timestamp),
302
+ editTimestamp: Number(editTimestamp),
303
+ message: message!,
304
+ };
305
+ case 'error':
306
+ default:
307
+ throw new Error(cb.message.value);
278
308
  }
279
- const { id, timestamp, editTimestamp, message } = cb.message.value;
280
- return { id, timestamp: Number(timestamp), editTimestamp: Number(editTimestamp), message };
281
309
  }
282
310
 
283
311
  async updateName(name: string) {
284
- const req = create(SetLocalNameRequestSchema, {
312
+ const req = new SetLocalNameRequest({
285
313
  localParticipantHandle: this.ffi_handle.handle,
286
314
  name: name,
287
315
  });
@@ -296,11 +324,9 @@ export class LocalParticipant extends Participant {
296
324
  }
297
325
 
298
326
  async setAttributes(attributes: Record<string, string>) {
299
- const req = create(SetLocalAttributesRequestSchema, {
327
+ const req = new SetLocalAttributesRequest({
300
328
  localParticipantHandle: this.ffi_handle.handle,
301
- attributes: Array.from(Object.entries(attributes)).map(([key, value]) => {
302
- return { key, value };
303
- }),
329
+ attributes: Object.entries(attributes).map(([key, value]) => ({ key, value })),
304
330
  });
305
331
 
306
332
  const res = FfiClient.instance.request<SetLocalAttributesResponse>({
@@ -316,7 +342,7 @@ export class LocalParticipant extends Participant {
316
342
  track: LocalTrack,
317
343
  options: TrackPublishOptions,
318
344
  ): Promise<LocalTrackPublication> {
319
- const req = create(PublishTrackRequestSchema, {
345
+ const req = new PublishTrackRequest({
320
346
  localParticipantHandle: this.ffi_handle.handle,
321
347
  trackHandle: track.ffi_handle.handle,
322
348
  options: options,
@@ -330,21 +356,24 @@ export class LocalParticipant extends Participant {
330
356
  return ev.message.case == 'publishTrack' && ev.message.value.asyncId == res.asyncId;
331
357
  });
332
358
 
333
- if (cb.message.case !== 'publication') {
334
- throw new Error(cb.message.value ?? 'Unknown Error');
335
- }
336
-
337
- const track_publication = new LocalTrackPublication(cb.message.value!);
338
- track_publication.track = track;
339
- this.trackPublications.set(track_publication.sid, track_publication);
359
+ switch (cb.message.case) {
360
+ case 'publication':
361
+ const track_publication = new LocalTrackPublication(cb.message.value!);
362
+ track_publication.track = track;
363
+ this.trackPublications.set(track_publication.sid!, track_publication);
340
364
 
341
- return track_publication;
365
+ return track_publication;
366
+ case 'error':
367
+ default:
368
+ throw new Error(cb.message.value);
369
+ }
342
370
  }
343
371
 
344
- async unpublishTrack(trackSid: string) {
345
- const req = create(UnpublishTrackRequestSchema, {
372
+ async unpublishTrack(trackSid: string, stopOnUnpublish?: boolean) {
373
+ const req = new UnpublishTrackRequest({
346
374
  localParticipantHandle: this.ffi_handle.handle,
347
375
  trackSid: trackSid,
376
+ stopOnUnpublish: stopOnUnpublish ?? true,
348
377
  });
349
378
 
350
379
  const res = FfiClient.instance.request<UnpublishTrackResponse>({
@@ -378,7 +407,7 @@ export class LocalParticipant extends Participant {
378
407
  payload,
379
408
  responseTimeout,
380
409
  }: PerformRpcParams): Promise<string> {
381
- const req = create(PerformRpcRequestSchema, {
410
+ const req = new PerformRpcRequest({
382
411
  localParticipantHandle: this.ffi_handle.handle,
383
412
  destinationIdentity,
384
413
  method,
@@ -398,7 +427,7 @@ export class LocalParticipant extends Participant {
398
427
  throw RpcError.fromProto(cb.error);
399
428
  }
400
429
 
401
- return cb.payload;
430
+ return cb.payload!;
402
431
  }
403
432
 
404
433
  /**
@@ -432,7 +461,7 @@ export class LocalParticipant extends Participant {
432
461
  registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise<string>) {
433
462
  this.rpcHandlers.set(method, handler);
434
463
 
435
- const req = create(RegisterRpcMethodRequestSchema, {
464
+ const req = new RegisterRpcMethodRequest({
436
465
  localParticipantHandle: this.ffi_handle.handle,
437
466
  method,
438
467
  });
@@ -450,7 +479,7 @@ export class LocalParticipant extends Participant {
450
479
  unregisterRpcMethod(method: string) {
451
480
  this.rpcHandlers.delete(method);
452
481
 
453
- const req = create(UnregisterRpcMethodRequestSchema, {
482
+ const req = new UnregisterRpcMethodRequest({
454
483
  localParticipantHandle: this.ffi_handle.handle,
455
484
  method,
456
485
  });
@@ -492,7 +521,7 @@ export class LocalParticipant extends Participant {
492
521
  }
493
522
  }
494
523
 
495
- const req = create(RpcMethodInvocationResponseRequestSchema, {
524
+ const req = new RpcMethodInvocationResponseRequest({
496
525
  localParticipantHandle: this.ffi_handle.handle,
497
526
  invocationId,
498
527
  error: responseError ? responseError.toProto() : undefined,