livekit-client 1.4.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. package/dist/livekit-client.esm.mjs +2478 -5368
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +3 -2
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  8. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
  9. package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
  10. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
  11. package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  12. package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
  13. package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  14. package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
  15. package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
  16. package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
  17. package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
  18. package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
  19. package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
  20. package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
  21. package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
  22. package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
  23. package/dist/src/index.d.ts +6 -3
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/logger.d.ts +3 -3
  26. package/dist/src/logger.d.ts.map +1 -1
  27. package/dist/src/options.d.ts +4 -1
  28. package/dist/src/options.d.ts.map +1 -1
  29. package/dist/src/proto/google/protobuf/timestamp.d.ts +4 -4
  30. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
  31. package/dist/src/proto/livekit_models.d.ts +4 -4
  32. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  33. package/dist/src/proto/livekit_rtc.d.ts +12 -4
  34. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  35. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  36. package/dist/src/room/RTCEngine.d.ts +4 -3
  37. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  38. package/dist/src/room/Room.d.ts +27 -4
  39. package/dist/src/room/Room.d.ts.map +1 -1
  40. package/dist/src/room/events.d.ts +9 -1
  41. package/dist/src/room/events.d.ts.map +1 -1
  42. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  43. package/dist/src/room/participant/Participant.d.ts +1 -1
  44. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  45. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  46. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
  47. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  48. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  49. package/dist/src/room/track/Track.d.ts +2 -1
  50. package/dist/src/room/track/Track.d.ts.map +1 -1
  51. package/dist/src/room/track/TrackPublication.d.ts +1 -1
  52. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  53. package/dist/src/room/track/options.d.ts +3 -3
  54. package/dist/src/room/track/options.d.ts.map +1 -1
  55. package/dist/src/room/track/types.d.ts +3 -3
  56. package/dist/src/room/track/types.d.ts.map +1 -1
  57. package/dist/src/room/types.d.ts +13 -0
  58. package/dist/src/room/types.d.ts.map +1 -0
  59. package/dist/src/room/utils.d.ts +44 -0
  60. package/dist/src/room/utils.d.ts.map +1 -1
  61. package/dist/ts4.2/src/api/SignalClient.d.ts +86 -0
  62. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  63. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
  64. package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  65. package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  66. package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
  67. package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
  68. package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
  69. package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
  70. package/dist/ts4.2/src/index.d.ts +31 -0
  71. package/dist/ts4.2/src/logger.d.ts +26 -0
  72. package/dist/ts4.2/src/options.d.ts +94 -0
  73. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
  74. package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
  75. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
  76. package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
  77. package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
  78. package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
  79. package/dist/ts4.2/src/room/RTCEngine.d.ts +97 -0
  80. package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
  81. package/dist/ts4.2/src/room/Room.d.ts +220 -0
  82. package/dist/ts4.2/src/room/defaults.d.ts +8 -0
  83. package/dist/ts4.2/src/room/errors.d.ts +39 -0
  84. package/dist/ts4.2/src/room/events.d.ts +426 -0
  85. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
  86. package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
  87. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  88. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
  89. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
  90. package/dist/ts4.2/src/room/stats.d.ts +67 -0
  91. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
  92. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
  93. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
  94. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
  95. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
  96. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
  97. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
  98. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
  99. package/dist/ts4.2/src/room/track/Track.d.ts +122 -0
  100. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
  101. package/dist/ts4.2/src/room/track/create.d.ts +24 -0
  102. package/dist/ts4.2/src/room/track/options.d.ts +241 -0
  103. package/dist/ts4.2/src/room/track/types.d.ts +23 -0
  104. package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
  105. package/dist/ts4.2/src/room/types.d.ts +13 -0
  106. package/dist/ts4.2/src/room/utils.d.ts +79 -0
  107. package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
  108. package/dist/ts4.2/src/test/mocks.d.ts +11 -0
  109. package/dist/ts4.2/src/version.d.ts +3 -0
  110. package/package.json +32 -22
  111. package/src/api/SignalClient.ts +41 -17
  112. package/src/connectionHelper/ConnectionCheck.ts +90 -0
  113. package/src/connectionHelper/checks/Checker.ts +164 -0
  114. package/src/connectionHelper/checks/publishAudio.ts +33 -0
  115. package/src/connectionHelper/checks/publishVideo.ts +33 -0
  116. package/src/connectionHelper/checks/reconnect.ts +45 -0
  117. package/src/connectionHelper/checks/turn.ts +53 -0
  118. package/src/connectionHelper/checks/webrtc.ts +18 -0
  119. package/src/connectionHelper/checks/websocket.ts +22 -0
  120. package/src/index.ts +8 -1
  121. package/src/options.ts +5 -1
  122. package/src/proto/livekit_rtc.ts +12 -1
  123. package/src/room/DeviceManager.ts +0 -17
  124. package/src/room/RTCEngine.ts +35 -26
  125. package/src/room/Room.ts +231 -63
  126. package/src/room/events.ts +9 -0
  127. package/src/room/participant/LocalParticipant.ts +18 -11
  128. package/src/room/participant/publishUtils.ts +1 -1
  129. package/src/room/track/LocalAudioTrack.ts +1 -1
  130. package/src/room/track/LocalTrack.ts +4 -0
  131. package/src/room/track/LocalVideoTrack.ts +1 -1
  132. package/src/room/track/RemoteTrackPublication.ts +20 -0
  133. package/src/room/track/RemoteVideoTrack.ts +4 -0
  134. package/src/room/track/Track.ts +1 -0
  135. package/src/room/types.ts +12 -0
  136. package/src/room/utils.ts +150 -12
@@ -0,0 +1,426 @@
1
+ /**
2
+ * Events are the primary way LiveKit notifies your application of changes.
3
+ *
4
+ * The following are events emitted by [[Room]], listen to room events like
5
+ *
6
+ * ```typescript
7
+ * room.on(RoomEvent.TrackPublished, (track, publication, participant) => {})
8
+ * ```
9
+ */
10
+ export declare enum RoomEvent {
11
+ /**
12
+ * When the connection to the server has been established
13
+ */
14
+ Connected = "connected",
15
+ /**
16
+ * When the connection to the server has been interrupted and it's attempting
17
+ * to reconnect.
18
+ */
19
+ Reconnecting = "reconnecting",
20
+ /**
21
+ * Fires when a reconnection has been successful.
22
+ */
23
+ Reconnected = "reconnected",
24
+ /**
25
+ * When disconnected from room. This fires when room.disconnect() is called or
26
+ * when an unrecoverable connection issue had occured
27
+ */
28
+ Disconnected = "disconnected",
29
+ /**
30
+ * Whenever the connection state of the room changes
31
+ *
32
+ * args: ([[ConnectionState]])
33
+ */
34
+ ConnectionStateChanged = "connectionStateChanged",
35
+ /**
36
+ * @deprecated StateChanged has been renamed to ConnectionStateChanged
37
+ */
38
+ StateChanged = "connectionStateChanged",
39
+ /**
40
+ * When input or output devices on the machine have changed.
41
+ */
42
+ MediaDevicesChanged = "mediaDevicesChanged",
43
+ /**
44
+ * When a [[RemoteParticipant]] joins *after* the local
45
+ * participant. It will not emit events for participants that are already
46
+ * in the room
47
+ *
48
+ * args: ([[RemoteParticipant]])
49
+ */
50
+ ParticipantConnected = "participantConnected",
51
+ /**
52
+ * When a [[RemoteParticipant]] leaves *after* the local
53
+ * participant has joined.
54
+ *
55
+ * args: ([[RemoteParticipant]])
56
+ */
57
+ ParticipantDisconnected = "participantDisconnected",
58
+ /**
59
+ * When a new track is published to room *after* the local
60
+ * participant has joined. It will not fire for tracks that are already published.
61
+ *
62
+ * A track published doesn't mean the participant has subscribed to it. It's
63
+ * simply reflecting the state of the room.
64
+ *
65
+ * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
66
+ */
67
+ TrackPublished = "trackPublished",
68
+ /**
69
+ * The [[LocalParticipant]] has subscribed to a new track. This event will **always**
70
+ * fire as long as new tracks are ready for use.
71
+ *
72
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]], [[RemoteParticipant]])
73
+ */
74
+ TrackSubscribed = "trackSubscribed",
75
+ /**
76
+ * Could not subscribe to a track
77
+ *
78
+ * args: (track sid, [[RemoteParticipant]])
79
+ */
80
+ TrackSubscriptionFailed = "trackSubscriptionFailed",
81
+ /**
82
+ * A [[RemoteParticipant]] has unpublished a track
83
+ *
84
+ * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
85
+ */
86
+ TrackUnpublished = "trackUnpublished",
87
+ /**
88
+ * A subscribed track is no longer available. Clients should listen to this
89
+ * event and ensure they detach tracks.
90
+ *
91
+ * args: ([[Track]], [[RemoteTrackPublication]], [[RemoteParticipant]])
92
+ */
93
+ TrackUnsubscribed = "trackUnsubscribed",
94
+ /**
95
+ * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
96
+ *
97
+ * args: ([[TrackPublication]], [[Participant]])
98
+ */
99
+ TrackMuted = "trackMuted",
100
+ /**
101
+ * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
102
+ *
103
+ * args: ([[TrackPublication]], [[Participant]])
104
+ */
105
+ TrackUnmuted = "trackUnmuted",
106
+ /**
107
+ * A local track was published successfully. This event is helpful to know
108
+ * when to update your local UI with the newly published track.
109
+ *
110
+ * args: ([[LocalTrackPublication]], [[LocalParticipant]])
111
+ */
112
+ LocalTrackPublished = "localTrackPublished",
113
+ /**
114
+ * A local track was unpublished. This event is helpful to know when to remove
115
+ * the local track from your UI.
116
+ *
117
+ * When a user stops sharing their screen by pressing "End" on the browser UI,
118
+ * this event will also fire.
119
+ *
120
+ * args: ([[LocalTrackPublication]], [[LocalParticipant]])
121
+ */
122
+ LocalTrackUnpublished = "localTrackUnpublished",
123
+ /**
124
+ * Active speakers changed. List of speakers are ordered by their audio level.
125
+ * loudest speakers first. This will include the LocalParticipant too.
126
+ *
127
+ * Speaker updates are sent only to the publishing participant and their subscribers.
128
+ *
129
+ * args: (Array<[[Participant]]>)
130
+ */
131
+ ActiveSpeakersChanged = "activeSpeakersChanged",
132
+ /**
133
+ * Participant metadata is a simple way for app-specific state to be pushed to
134
+ * all users.
135
+ * When RoomService.UpdateParticipantMetadata is called to change a participant's
136
+ * state, *all* participants in the room will fire this event.
137
+ *
138
+ * args: (prevMetadata: string, [[Participant]])
139
+ *
140
+ */
141
+ ParticipantMetadataChanged = "participantMetadataChanged",
142
+ /**
143
+ * Room metadata is a simple way for app-specific state to be pushed to
144
+ * all users.
145
+ * When RoomService.UpdateRoomMetadata is called to change a room's state,
146
+ * *all* participants in the room will fire this event.
147
+ *
148
+ * args: (string)
149
+ */
150
+ RoomMetadataChanged = "roomMetadataChanged",
151
+ /**
152
+ * Data received from another participant.
153
+ * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
154
+ * All participants in the room will receive the messages sent to the room.
155
+ *
156
+ * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]])
157
+ */
158
+ DataReceived = "dataReceived",
159
+ /**
160
+ * Connection quality was changed for a Participant. It'll receive updates
161
+ * from the local participant, as well as any [[RemoteParticipant]]s that we are
162
+ * subscribed to.
163
+ *
164
+ * args: (connectionQuality: [[ConnectionQuality]], participant: [[Participant]])
165
+ */
166
+ ConnectionQualityChanged = "connectionQualityChanged",
167
+ /**
168
+ * StreamState indicates if a subscribed (remote) track has been paused by the SFU
169
+ * (typically this happens because of subscriber's bandwidth constraints)
170
+ *
171
+ * When bandwidth conditions allow, the track will be resumed automatically.
172
+ * TrackStreamStateChanged will also be emitted when that happens.
173
+ *
174
+ * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]],
175
+ * participant: [[RemoteParticipant]])
176
+ */
177
+ TrackStreamStateChanged = "trackStreamStateChanged",
178
+ /**
179
+ * One of subscribed tracks have changed its permissions for the current
180
+ * participant. If permission was revoked, then the track will no longer
181
+ * be subscribed. If permission was granted, a TrackSubscribed event will
182
+ * be emitted.
183
+ *
184
+ * args: (pub: [[RemoteTrackPublication]],
185
+ * status: [[TrackPublication.SubscriptionStatus]],
186
+ * participant: [[RemoteParticipant]])
187
+ */
188
+ TrackSubscriptionPermissionChanged = "trackSubscriptionPermissionChanged",
189
+ /**
190
+ * One of subscribed tracks have changed its status for the current
191
+ * participant.
192
+ *
193
+ * args: (pub: [[RemoteTrackPublication]],
194
+ * status: [[TrackPublication.SubscriptionStatus]],
195
+ * participant: [[RemoteParticipant]])
196
+ */
197
+ TrackSubscriptionStatusChanged = "trackSubscriptionStatusChanged",
198
+ /**
199
+ * LiveKit will attempt to autoplay all audio tracks when you attach them to
200
+ * audio elements. However, if that fails, we'll notify you via AudioPlaybackStatusChanged.
201
+ * `Room.canPlayAudio` will indicate if audio playback is permitted.
202
+ */
203
+ AudioPlaybackStatusChanged = "audioPlaybackChanged",
204
+ /**
205
+ * When we have encountered an error while attempting to create a track.
206
+ * The errors take place in getUserMedia().
207
+ * Use MediaDeviceFailure.getFailure(error) to get the reason of failure.
208
+ * [[LocalParticipant.lastCameraError]] and [[LocalParticipant.lastMicrophoneError]]
209
+ * will indicate if it had an error while creating the audio or video track respectively.
210
+ *
211
+ * args: (error: Error)
212
+ */
213
+ MediaDevicesError = "mediaDevicesError",
214
+ /**
215
+ * A participant's permission has changed. Currently only fired on LocalParticipant.
216
+ * args: (prevPermissions: [[ParticipantPermission]], participant: [[Participant]])
217
+ */
218
+ ParticipantPermissionsChanged = "participantPermissionsChanged",
219
+ /**
220
+ * Signal connected, can publish tracks.
221
+ */
222
+ SignalConnected = "signalConnected",
223
+ /**
224
+ * Recording of a room has started/stopped.
225
+ */
226
+ RecordingStatusChanged = "recordingStatusChanged"
227
+ }
228
+ export declare enum ParticipantEvent {
229
+ /**
230
+ * When a new track is published to room *after* the local
231
+ * participant has joined. It will not fire for tracks that are already published.
232
+ *
233
+ * A track published doesn't mean the participant has subscribed to it. It's
234
+ * simply reflecting the state of the room.
235
+ *
236
+ * args: ([[RemoteTrackPublication]])
237
+ */
238
+ TrackPublished = "trackPublished",
239
+ /**
240
+ * Successfully subscribed to the [[RemoteParticipant]]'s track.
241
+ * This event will **always** fire as long as new tracks are ready for use.
242
+ *
243
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
244
+ */
245
+ TrackSubscribed = "trackSubscribed",
246
+ /**
247
+ * Could not subscribe to a track
248
+ *
249
+ * args: (track sid)
250
+ */
251
+ TrackSubscriptionFailed = "trackSubscriptionFailed",
252
+ /**
253
+ * A [[RemoteParticipant]] has unpublished a track
254
+ *
255
+ * args: ([[RemoteTrackPublication]])
256
+ */
257
+ TrackUnpublished = "trackUnpublished",
258
+ /**
259
+ * A subscribed track is no longer available. Clients should listen to this
260
+ * event and ensure they detach tracks.
261
+ *
262
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
263
+ */
264
+ TrackUnsubscribed = "trackUnsubscribed",
265
+ /**
266
+ * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
267
+ *
268
+ * args: ([[TrackPublication]])
269
+ */
270
+ TrackMuted = "trackMuted",
271
+ /**
272
+ * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
273
+ *
274
+ * args: ([[TrackPublication]])
275
+ */
276
+ TrackUnmuted = "trackUnmuted",
277
+ /**
278
+ * A local track was published successfully. This event is helpful to know
279
+ * when to update your local UI with the newly published track.
280
+ *
281
+ * args: ([[LocalTrackPublication]])
282
+ */
283
+ LocalTrackPublished = "localTrackPublished",
284
+ /**
285
+ * A local track was unpublished. This event is helpful to know when to remove
286
+ * the local track from your UI.
287
+ *
288
+ * When a user stops sharing their screen by pressing "End" on the browser UI,
289
+ * this event will also fire.
290
+ *
291
+ * args: ([[LocalTrackPublication]])
292
+ */
293
+ LocalTrackUnpublished = "localTrackUnpublished",
294
+ /**
295
+ * Participant metadata is a simple way for app-specific state to be pushed to
296
+ * all users.
297
+ * When RoomService.UpdateParticipantMetadata is called to change a participant's
298
+ * state, *all* participants in the room will fire this event.
299
+ * To access the current metadata, see [[Participant.metadata]].
300
+ *
301
+ * args: (prevMetadata: string)
302
+ *
303
+ */
304
+ ParticipantMetadataChanged = "participantMetadataChanged",
305
+ /**
306
+ * Data received from this participant as sender.
307
+ * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
308
+ * All participants in the room will receive the messages sent to the room.
309
+ *
310
+ * args: (payload: Uint8Array, kind: [[DataPacket_Kind]])
311
+ */
312
+ DataReceived = "dataReceived",
313
+ /**
314
+ * Has speaking status changed for the current participant
315
+ *
316
+ * args: (speaking: boolean)
317
+ */
318
+ IsSpeakingChanged = "isSpeakingChanged",
319
+ /**
320
+ * Connection quality was changed for a Participant. It'll receive updates
321
+ * from the local participant, as well as any [[RemoteParticipant]]s that we are
322
+ * subscribed to.
323
+ *
324
+ * args: (connectionQuality: [[ConnectionQuality]])
325
+ */
326
+ ConnectionQualityChanged = "connectionQualityChanged",
327
+ /**
328
+ * StreamState indicates if a subscribed track has been paused by the SFU
329
+ * (typically this happens because of subscriber's bandwidth constraints)
330
+ *
331
+ * When bandwidth conditions allow, the track will be resumed automatically.
332
+ * TrackStreamStateChanged will also be emitted when that happens.
333
+ *
334
+ * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]])
335
+ */
336
+ TrackStreamStateChanged = "trackStreamStateChanged",
337
+ /**
338
+ * One of subscribed tracks have changed its permissions for the current
339
+ * participant. If permission was revoked, then the track will no longer
340
+ * be subscribed. If permission was granted, a TrackSubscribed event will
341
+ * be emitted.
342
+ *
343
+ * args: (pub: [[RemoteTrackPublication]],
344
+ * status: [[TrackPublication.SubscriptionStatus]])
345
+ */
346
+ TrackSubscriptionPermissionChanged = "trackSubscriptionPermissionChanged",
347
+ /**
348
+ * One of the remote participants publications has changed its subscription status.
349
+ *
350
+ */
351
+ TrackSubscriptionStatusChanged = "trackSubscriptionStatusChanged",
352
+ /** @internal */
353
+ MediaDevicesError = "mediaDevicesError",
354
+ /**
355
+ * A participant's permission has changed. Currently only fired on LocalParticipant.
356
+ * args: (prevPermissions: [[ParticipantPermission]])
357
+ */
358
+ ParticipantPermissionsChanged = "participantPermissionsChanged"
359
+ }
360
+ /** @internal */
361
+ export declare enum EngineEvent {
362
+ TransportsCreated = "transportsCreated",
363
+ Connected = "connected",
364
+ Disconnected = "disconnected",
365
+ Resuming = "resuming",
366
+ Resumed = "resumed",
367
+ Restarting = "restarting",
368
+ Restarted = "restarted",
369
+ SignalResumed = "signalResumed",
370
+ MediaTrackAdded = "mediaTrackAdded",
371
+ ActiveSpeakersUpdate = "activeSpeakersUpdate",
372
+ DataPacketReceived = "dataPacketReceived"
373
+ }
374
+ export declare enum TrackEvent {
375
+ Message = "message",
376
+ Muted = "muted",
377
+ Unmuted = "unmuted",
378
+ /**
379
+ * Only fires on LocalTracks
380
+ */
381
+ Restarted = "restarted",
382
+ Ended = "ended",
383
+ Subscribed = "subscribed",
384
+ Unsubscribed = "unsubscribed",
385
+ /** @internal */
386
+ UpdateSettings = "updateSettings",
387
+ /** @internal */
388
+ UpdateSubscription = "updateSubscription",
389
+ /** @internal */
390
+ AudioPlaybackStarted = "audioPlaybackStarted",
391
+ /** @internal */
392
+ AudioPlaybackFailed = "audioPlaybackFailed",
393
+ /**
394
+ * @internal
395
+ * Only fires on LocalAudioTrack instances
396
+ */
397
+ AudioSilenceDetected = "audioSilenceDetected",
398
+ /** @internal */
399
+ VisibilityChanged = "visibilityChanged",
400
+ /** @internal */
401
+ VideoDimensionsChanged = "videoDimensionsChanged",
402
+ /** @internal */
403
+ ElementAttached = "elementAttached",
404
+ /** @internal */
405
+ ElementDetached = "elementDetached",
406
+ /**
407
+ * @internal
408
+ * Only fires on LocalTracks
409
+ */
410
+ UpstreamPaused = "upstreamPaused",
411
+ /**
412
+ * @internal
413
+ * Only fires on LocalTracks
414
+ */
415
+ UpstreamResumed = "upstreamResumed",
416
+ /**
417
+ * @internal
418
+ * Fires on RemoteTrackPublication
419
+ */
420
+ SubscriptionPermissionChanged = "subscriptionPermissionChanged",
421
+ /**
422
+ * Fires on RemoteTrackPublication
423
+ */
424
+ SubscriptionStatusChanged = "subscriptionStatusChanged"
425
+ }
426
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,141 @@
1
+ import 'webrtc-adapter';
2
+ import type { InternalRoomOptions } from '../../options';
3
+ import { DataPacket_Kind, ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models';
4
+ import { DataChannelInfo, TrackPublishedResponse } from '../../proto/livekit_rtc';
5
+ import type RTCEngine from '../RTCEngine';
6
+ import LocalTrack from '../track/LocalTrack';
7
+ import LocalTrackPublication from '../track/LocalTrackPublication';
8
+ import { AudioCaptureOptions, BackupVideoCodec, CreateLocalTracksOptions, ScreenShareCaptureOptions, TrackPublishOptions, VideoCaptureOptions } from '../track/options';
9
+ import { Track } from '../track/Track';
10
+ import Participant from './Participant';
11
+ import { ParticipantTrackPermission } from './ParticipantTrackPermission';
12
+ import RemoteParticipant from './RemoteParticipant';
13
+ export default class LocalParticipant extends Participant {
14
+ audioTracks: Map<string, LocalTrackPublication>;
15
+ videoTracks: Map<string, LocalTrackPublication>;
16
+ /** map of track sid => all published tracks */
17
+ tracks: Map<string, LocalTrackPublication>;
18
+ /** @internal */
19
+ engine: RTCEngine;
20
+ private pendingPublishing;
21
+ private cameraError;
22
+ private microphoneError;
23
+ private participantTrackPermissions;
24
+ private allParticipantsAllowedToSubscribe;
25
+ private roomOptions;
26
+ /** @internal */
27
+ constructor(sid: string, identity: string, engine: RTCEngine, options: InternalRoomOptions);
28
+ get lastCameraError(): Error | undefined;
29
+ get lastMicrophoneError(): Error | undefined;
30
+ getTrack(source: Track.Source): LocalTrackPublication | undefined;
31
+ getTrackByName(name: string): LocalTrackPublication | undefined;
32
+ /**
33
+ * @internal
34
+ */
35
+ setupEngine(engine: RTCEngine): void;
36
+ /**
37
+ * Enable or disable a participant's camera track.
38
+ *
39
+ * If a track has already published, it'll mute or unmute the track.
40
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
41
+ */
42
+ setCameraEnabled(enabled: boolean, options?: VideoCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
43
+ /**
44
+ * Enable or disable a participant's microphone track.
45
+ *
46
+ * If a track has already published, it'll mute or unmute the track.
47
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
48
+ */
49
+ setMicrophoneEnabled(enabled: boolean, options?: AudioCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
50
+ /**
51
+ * Start or stop sharing a participant's screen
52
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
53
+ */
54
+ setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
55
+ /** @internal */
56
+ setPermissions(permissions: ParticipantPermission): boolean;
57
+ /**
58
+ * Enable or disable publishing for a track by source. This serves as a simple
59
+ * way to manage the common tracks (camera, mic, or screen share).
60
+ * Resolves with LocalTrackPublication if successful and void otherwise
61
+ */
62
+ private setTrackEnabled;
63
+ /**
64
+ * Publish both camera and microphone at the same time. This is useful for
65
+ * displaying a single Permission Dialog box to the end user.
66
+ */
67
+ enableCameraAndMicrophone(): Promise<void>;
68
+ /**
69
+ * Create local camera and/or microphone tracks
70
+ * @param options
71
+ * @returns
72
+ */
73
+ createTracks(options?: CreateLocalTracksOptions): Promise<LocalTrack[]>;
74
+ /**
75
+ * Creates a screen capture tracks with getDisplayMedia().
76
+ * A LocalVideoTrack is always created and returned.
77
+ * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
78
+ */
79
+ createScreenTracks(options?: ScreenShareCaptureOptions): Promise<Array<LocalTrack>>;
80
+ /**
81
+ * Publish a new track to the room
82
+ * @param track
83
+ * @param options
84
+ */
85
+ publishTrack(track: LocalTrack | MediaStreamTrack, options?: TrackPublishOptions): Promise<LocalTrackPublication>;
86
+ get isLocal(): boolean;
87
+ /** @internal
88
+ * publish additional codec to existing track
89
+ */
90
+ publishAdditionalCodecForTrack(track: LocalTrack | MediaStreamTrack, videoCodec: BackupVideoCodec, options?: TrackPublishOptions): Promise<void>;
91
+ unpublishTrack(track: LocalTrack | MediaStreamTrack, stopOnUnpublish?: boolean): LocalTrackPublication | undefined;
92
+ unpublishTracks(tracks: LocalTrack[] | MediaStreamTrack[]): LocalTrackPublication[];
93
+ /**
94
+ * Publish a new data payload to the room. Data will be forwarded to each
95
+ * participant in the room if the destination argument is empty
96
+ *
97
+ * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
98
+ * @param kind whether to send this as reliable or lossy.
99
+ * For data that you need delivery guarantee (such as chat messages), use Reliable.
100
+ * For data that should arrive as quickly as possible, but you are ok with dropped
101
+ * packets, use Lossy.
102
+ * @param destination the participants who will receive the message
103
+ */
104
+ publishData(data: Uint8Array, kind: DataPacket_Kind, destination?: RemoteParticipant[] | string[]): Promise<void>;
105
+ /**
106
+ * Control who can subscribe to LocalParticipant's published tracks.
107
+ *
108
+ * By default, all participants can subscribe. This allows fine-grained control over
109
+ * who is able to subscribe at a participant and track level.
110
+ *
111
+ * Note: if access is given at a track-level (i.e. both [allParticipantsAllowed] and
112
+ * [ParticipantTrackPermission.allTracksAllowed] are false), any newer published tracks
113
+ * will not grant permissions to any participants and will require a subsequent
114
+ * permissions update to allow subscription.
115
+ *
116
+ * @param allParticipantsAllowed Allows all participants to subscribe all tracks.
117
+ * Takes precedence over [[participantTrackPermissions]] if set to true.
118
+ * By default this is set to true.
119
+ * @param participantTrackPermissions Full list of individual permissions per
120
+ * participant/track. Any omitted participants will not receive any permissions.
121
+ */
122
+ setTrackSubscriptionPermissions(allParticipantsAllowed: boolean, participantTrackPermissions?: ParticipantTrackPermission[]): void;
123
+ /** @internal */
124
+ updateInfo(info: ParticipantInfo): void;
125
+ private updateTrackSubscriptionPermissions;
126
+ /** @internal */
127
+ private onTrackUnmuted;
128
+ /** @internal */
129
+ private onTrackMuted;
130
+ private onTrackUpstreamPaused;
131
+ private onTrackUpstreamResumed;
132
+ private handleSubscribedQualityUpdate;
133
+ private handleLocalTrackUnpublished;
134
+ private handleTrackEnded;
135
+ private getPublicationForTrack;
136
+ /** @internal */
137
+ publishedTracksInfo(): TrackPublishedResponse[];
138
+ /** @internal */
139
+ dataChannelsInfo(): DataChannelInfo[];
140
+ }
141
+ //# sourceMappingURL=LocalParticipant.d.ts.map
@@ -0,0 +1,92 @@
1
+ import type TypedEmitter from 'typed-emitter';
2
+ import { ConnectionQuality as ProtoQuality, DataPacket_Kind, ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models';
3
+ import type LocalTrackPublication from '../track/LocalTrackPublication';
4
+ import type RemoteTrack from '../track/RemoteTrack';
5
+ import type RemoteTrackPublication from '../track/RemoteTrackPublication';
6
+ import { Track } from '../track/Track';
7
+ import type { TrackPublication } from '../track/TrackPublication';
8
+ export declare enum ConnectionQuality {
9
+ Excellent = "excellent",
10
+ Good = "good",
11
+ Poor = "poor",
12
+ Unknown = "unknown"
13
+ }
14
+ declare const Participant_base: new () => TypedEmitter<ParticipantEventCallbacks>;
15
+ export default class Participant extends Participant_base {
16
+ protected participantInfo?: ParticipantInfo;
17
+ audioTracks: Map<string, TrackPublication>;
18
+ videoTracks: Map<string, TrackPublication>;
19
+ /** map of track sid => all published tracks */
20
+ tracks: Map<string, TrackPublication>;
21
+ /** audio level between 0-1.0, 1 being loudest, 0 being softest */
22
+ audioLevel: number;
23
+ /** if participant is currently speaking */
24
+ isSpeaking: boolean;
25
+ /** server assigned unique id */
26
+ sid: string;
27
+ /** client assigned identity, encoded in JWT token */
28
+ identity: string;
29
+ /** client assigned display name, encoded in JWT token */
30
+ name?: string;
31
+ /** client metadata, opaque to livekit */
32
+ metadata?: string;
33
+ lastSpokeAt?: Date | undefined;
34
+ permissions?: ParticipantPermission;
35
+ private _connectionQuality;
36
+ /** @internal */
37
+ constructor(sid: string, identity: string, name?: string, metadata?: string);
38
+ getTracks(): TrackPublication[];
39
+ /**
40
+ * Finds the first track that matches the source filter, for example, getting
41
+ * the user's camera track with getTrackBySource(Track.Source.Camera).
42
+ * @param source
43
+ * @returns
44
+ */
45
+ getTrack(source: Track.Source): TrackPublication | undefined;
46
+ /**
47
+ * Finds the first track that matches the track's name.
48
+ * @param name
49
+ * @returns
50
+ */
51
+ getTrackByName(name: string): TrackPublication | undefined;
52
+ get connectionQuality(): ConnectionQuality;
53
+ get isCameraEnabled(): boolean;
54
+ get isMicrophoneEnabled(): boolean;
55
+ get isScreenShareEnabled(): boolean;
56
+ get isLocal(): boolean;
57
+ /** when participant joined the room */
58
+ get joinedAt(): Date | undefined;
59
+ /** @internal */
60
+ updateInfo(info: ParticipantInfo): void;
61
+ /** @internal */
62
+ setMetadata(md: string): void;
63
+ /** @internal */
64
+ setPermissions(permissions: ParticipantPermission): boolean;
65
+ /** @internal */
66
+ setIsSpeaking(speaking: boolean): void;
67
+ /** @internal */
68
+ setConnectionQuality(q: ProtoQuality): void;
69
+ protected addTrackPublication(publication: TrackPublication): void;
70
+ }
71
+ export type ParticipantEventCallbacks = {
72
+ trackPublished: (publication: RemoteTrackPublication) => void;
73
+ trackSubscribed: (track: RemoteTrack, publication: RemoteTrackPublication) => void;
74
+ trackSubscriptionFailed: (trackSid: string) => void;
75
+ trackUnpublished: (publication: RemoteTrackPublication) => void;
76
+ trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication) => void;
77
+ trackMuted: (publication: TrackPublication) => void;
78
+ trackUnmuted: (publication: TrackPublication) => void;
79
+ localTrackPublished: (publication: LocalTrackPublication) => void;
80
+ localTrackUnpublished: (publication: LocalTrackPublication) => void;
81
+ participantMetadataChanged: (prevMetadata: string | undefined, participant?: any) => void;
82
+ dataReceived: (payload: Uint8Array, kind: DataPacket_Kind) => void;
83
+ isSpeakingChanged: (speaking: boolean) => void;
84
+ connectionQualityChanged: (connectionQuality: ConnectionQuality) => void;
85
+ trackStreamStateChanged: (publication: RemoteTrackPublication, streamState: Track.StreamState) => void;
86
+ trackSubscriptionPermissionChanged: (publication: RemoteTrackPublication, status: TrackPublication.PermissionStatus) => void;
87
+ mediaDevicesError: (error: Error) => void;
88
+ participantPermissionsChanged: (prevPermissions: ParticipantPermission) => void;
89
+ trackSubscriptionStatusChanged: (publication: RemoteTrackPublication, status: TrackPublication.SubscriptionStatus) => void;
90
+ };
91
+ export {};
92
+ //# sourceMappingURL=Participant.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { TrackPermission } from '../../proto/livekit_rtc';
2
+ export interface ParticipantTrackPermission {
3
+ /**
4
+ * The participant identity this permission applies to.
5
+ * You can either provide this or `participantSid`
6
+ */
7
+ participantIdentity?: string;
8
+ /**
9
+ * The participant server id this permission applies to.
10
+ * You can either provide this or `participantIdentity`
11
+ */
12
+ participantSid?: string;
13
+ /**
14
+ * Grant permission to all all tracks. Takes precedence over allowedTrackSids.
15
+ * false if unset.
16
+ */
17
+ allowAll?: boolean;
18
+ /**
19
+ * The list of track ids that the target participant can subscribe to.
20
+ * When unset, it'll allow all tracks to be subscribed by the participant.
21
+ * When empty, this participant is disallowed from subscribing to any tracks.
22
+ */
23
+ allowedTrackSids?: string[];
24
+ }
25
+ export declare function trackPermissionToProto(perms: ParticipantTrackPermission): TrackPermission;
26
+ //# sourceMappingURL=ParticipantTrackPermission.d.ts.map