livekit-client 2.22.3 → 2.23.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 (272) hide show
  1. package/README.md +35 -0
  2. package/dist/livekit-client.e2ee.worker.js +1 -1
  3. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  4. package/dist/livekit-client.e2ee.worker.mjs +71 -8
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +1746 -547
  7. package/dist/livekit-client.esm.mjs.map +1 -1
  8. package/dist/livekit-client.fm.worker.js +1 -1
  9. package/dist/livekit-client.fm.worker.js.map +1 -1
  10. package/dist/livekit-client.fm.worker.mjs +2 -1
  11. package/dist/livekit-client.fm.worker.mjs.map +1 -1
  12. package/dist/livekit-client.umd.js +1 -1
  13. package/dist/livekit-client.umd.js.map +1 -1
  14. package/dist/src/api/SignalClient.d.ts +4 -2
  15. package/dist/src/api/SignalClient.d.ts.map +1 -1
  16. package/dist/src/api/WebSocketStream.d.ts +1 -0
  17. package/dist/src/api/WebSocketStream.d.ts.map +1 -1
  18. package/dist/src/api/utils.d.ts +1 -1
  19. package/dist/src/api/utils.d.ts.map +1 -1
  20. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  21. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  22. package/dist/src/e2ee/worker/naluUtils.d.ts +12 -1
  23. package/dist/src/e2ee/worker/naluUtils.d.ts.map +1 -1
  24. package/dist/src/index.d.ts +2 -2
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/options.d.ts +14 -0
  27. package/dist/src/options.d.ts.map +1 -1
  28. package/dist/src/room/DefaultReconnectPolicy.d.ts.map +1 -1
  29. package/dist/src/room/PCTransport.d.ts +100 -7
  30. package/dist/src/room/PCTransport.d.ts.map +1 -1
  31. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  32. package/dist/src/room/RTCEngine.d.ts +16 -0
  33. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  34. package/dist/src/room/Room.d.ts +54 -1
  35. package/dist/src/room/Room.d.ts.map +1 -1
  36. package/dist/src/room/data-channel/DataChannelManager.d.ts +9 -8
  37. package/dist/src/room/data-channel/DataChannelManager.d.ts.map +1 -1
  38. package/dist/src/room/data-channel/FlowControlledDataChannel.d.ts +25 -12
  39. package/dist/src/room/data-channel/FlowControlledDataChannel.d.ts.map +1 -1
  40. package/dist/src/room/data-channel/LossyDataChannel.d.ts.map +1 -1
  41. package/dist/src/room/data-channel/ReliableDataChannel.d.ts.map +1 -1
  42. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts.map +1 -1
  43. package/dist/src/room/defaults.d.ts.map +1 -1
  44. package/dist/src/room/errors.d.ts +18 -0
  45. package/dist/src/room/errors.d.ts.map +1 -1
  46. package/dist/src/room/events.d.ts +3 -2
  47. package/dist/src/room/events.d.ts.map +1 -1
  48. package/dist/src/room/participant/LocalParticipant.d.ts +4 -0
  49. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  50. package/dist/src/room/participant/Participant.d.ts +1 -1
  51. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  52. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  53. package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
  54. package/dist/src/room/rpc/utils.d.ts.map +1 -1
  55. package/dist/src/room/track/LocalAudioTrack.d.ts +24 -1
  56. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  57. package/dist/src/room/track/LocalTrack.d.ts +18 -0
  58. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  59. package/dist/src/room/track/LocalVideoTrack.d.ts +9 -0
  60. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  61. package/dist/src/room/track/RemoteAudioTrack.d.ts +6 -0
  62. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  63. package/dist/src/room/track/processor/types.d.ts +11 -0
  64. package/dist/src/room/track/processor/types.d.ts.map +1 -1
  65. package/dist/src/room/track/utils.d.ts +13 -0
  66. package/dist/src/room/track/utils.d.ts.map +1 -1
  67. package/dist/src/room/utils.d.ts +60 -1
  68. package/dist/src/room/utils.d.ts.map +1 -1
  69. package/dist/src/test/compressionStreamStubs.d.ts +12 -0
  70. package/dist/src/test/compressionStreamStubs.d.ts.map +1 -0
  71. package/dist/ts4.2/api/SignalClient.d.ts +187 -185
  72. package/dist/ts4.2/api/SignalClientStateMachine.d.ts +85 -85
  73. package/dist/ts4.2/api/WebSocketStream.d.ts +34 -33
  74. package/dist/ts4.2/api/utils.d.ts +9 -9
  75. package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +30 -30
  76. package/dist/ts4.2/connectionHelper/checks/Checker.d.ts +62 -62
  77. package/dist/ts4.2/connectionHelper/checks/cloudRegion.d.ts +18 -18
  78. package/dist/ts4.2/connectionHelper/checks/connectionProtocol.d.ts +20 -20
  79. package/dist/ts4.2/connectionHelper/checks/publishAudio.d.ts +6 -6
  80. package/dist/ts4.2/connectionHelper/checks/publishVideo.d.ts +7 -7
  81. package/dist/ts4.2/connectionHelper/checks/reconnect.d.ts +6 -6
  82. package/dist/ts4.2/connectionHelper/checks/turn.d.ts +6 -6
  83. package/dist/ts4.2/connectionHelper/checks/webrtc.d.ts +6 -6
  84. package/dist/ts4.2/connectionHelper/checks/websocket.d.ts +6 -6
  85. package/dist/ts4.2/e2ee/E2eeManager.d.ts +111 -111
  86. package/dist/ts4.2/e2ee/KeyProvider.d.ts +54 -54
  87. package/dist/ts4.2/e2ee/constants.d.ts +21 -21
  88. package/dist/ts4.2/e2ee/errors.d.ts +12 -12
  89. package/dist/ts4.2/e2ee/events.d.ts +39 -39
  90. package/dist/ts4.2/e2ee/index.d.ts +6 -6
  91. package/dist/ts4.2/e2ee/types.d.ts +231 -231
  92. package/dist/ts4.2/e2ee/utils.d.ts +32 -32
  93. package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +16 -16
  94. package/dist/ts4.2/e2ee/worker/ErrorRateLimiter.d.ts +21 -21
  95. package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +209 -209
  96. package/dist/ts4.2/e2ee/worker/ParticipantKeyHandler.d.ts +81 -84
  97. package/dist/ts4.2/e2ee/worker/e2ee.worker.d.ts +2 -2
  98. package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +39 -28
  99. package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +23 -23
  100. package/dist/ts4.2/frameMetadata/FrameMetadataManager.d.ts +53 -53
  101. package/dist/ts4.2/frameMetadata/frameMetadata.d.ts +33 -33
  102. package/dist/ts4.2/frameMetadata/types.d.ts +62 -62
  103. package/dist/ts4.2/frameMetadata/utils.d.ts +9 -9
  104. package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -2
  105. package/dist/ts4.2/index.d.ts +76 -76
  106. package/dist/ts4.2/logger.d.ts +66 -66
  107. package/dist/ts4.2/options.d.ts +163 -149
  108. package/dist/ts4.2/room/BackOffStrategy.d.ts +27 -27
  109. package/dist/ts4.2/room/DefaultReconnectPolicy.d.ts +8 -8
  110. package/dist/ts4.2/room/DeviceManager.d.ts +12 -12
  111. package/dist/ts4.2/room/PCTransport.d.ts +268 -175
  112. package/dist/ts4.2/room/PCTransportManager.d.ts +77 -77
  113. package/dist/ts4.2/room/RTCEngine.d.ts +277 -262
  114. package/dist/ts4.2/room/ReconnectPolicy.d.ts +24 -24
  115. package/dist/ts4.2/room/RegionUrlProvider.d.ts +36 -36
  116. package/dist/ts4.2/room/Room.d.ts +407 -365
  117. package/dist/ts4.2/room/attribute-typings.d.ts +35 -35
  118. package/dist/ts4.2/room/data-channel/DataChannelManager.d.ts +63 -62
  119. package/dist/ts4.2/room/data-channel/FlowControlledDataChannel.d.ts +107 -95
  120. package/dist/ts4.2/room/data-channel/LossyDataChannel.d.ts +41 -41
  121. package/dist/ts4.2/room/data-channel/ReliableDataChannel.d.ts +57 -57
  122. package/dist/ts4.2/room/data-channel/types.d.ts +12 -12
  123. package/dist/ts4.2/room/data-stream/compression.d.ts +49 -49
  124. package/dist/ts4.2/room/data-stream/constants.d.ts +18 -18
  125. package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +29 -29
  126. package/dist/ts4.2/room/data-stream/incoming/StreamReader.d.ts +80 -80
  127. package/dist/ts4.2/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +73 -73
  128. package/dist/ts4.2/room/data-stream/outgoing/StreamWriter.d.ts +16 -16
  129. package/dist/ts4.2/room/data-stream/outgoing/header-utils.d.ts +18 -18
  130. package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +79 -80
  131. package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +50 -50
  132. package/dist/ts4.2/room/data-track/depacketizer.d.ts +59 -59
  133. package/dist/ts4.2/room/data-track/frame.d.ts +22 -22
  134. package/dist/ts4.2/room/data-track/handle.d.ts +27 -27
  135. package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +124 -124
  136. package/dist/ts4.2/room/data-track/incoming/errors.d.ts +24 -24
  137. package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +41 -41
  138. package/dist/ts4.2/room/data-track/incoming/types.d.ts +20 -20
  139. package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +126 -126
  140. package/dist/ts4.2/room/data-track/outgoing/errors.d.ts +74 -74
  141. package/dist/ts4.2/room/data-track/outgoing/pipeline.d.ts +23 -23
  142. package/dist/ts4.2/room/data-track/outgoing/types.d.ts +48 -48
  143. package/dist/ts4.2/room/data-track/packet/constants.d.ts +20 -20
  144. package/dist/ts4.2/room/data-track/packet/errors.d.ts +40 -40
  145. package/dist/ts4.2/room/data-track/packet/extensions.d.ts +69 -69
  146. package/dist/ts4.2/room/data-track/packet/index.d.ts +98 -98
  147. package/dist/ts4.2/room/data-track/packet/serializable.d.ts +13 -13
  148. package/dist/ts4.2/room/data-track/packetizer.d.ts +43 -43
  149. package/dist/ts4.2/room/data-track/track-interfaces.d.ts +23 -23
  150. package/dist/ts4.2/room/data-track/types.d.ts +22 -22
  151. package/dist/ts4.2/room/data-track/utils.d.ts +60 -60
  152. package/dist/ts4.2/room/debounce.d.ts +11 -11
  153. package/dist/ts4.2/room/defaults.d.ts +9 -9
  154. package/dist/ts4.2/room/errors.d.ts +180 -162
  155. package/dist/ts4.2/room/events.d.ts +638 -637
  156. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +291 -287
  157. package/dist/ts4.2/room/participant/Participant.d.ts +142 -144
  158. package/dist/ts4.2/room/participant/ParticipantTrackPermission.d.ts +26 -26
  159. package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +85 -86
  160. package/dist/ts4.2/room/participant/publishUtils.d.ts +53 -53
  161. package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -43
  162. package/dist/ts4.2/room/rpc/client/events.d.ts +8 -8
  163. package/dist/ts4.2/room/rpc/index.d.ts +7 -7
  164. package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -44
  165. package/dist/ts4.2/room/rpc/server/events.d.ts +8 -8
  166. package/dist/ts4.2/room/rpc/utils.d.ts +131 -131
  167. package/dist/ts4.2/room/stats.d.ts +71 -71
  168. package/dist/ts4.2/room/statsSummary.d.ts +13 -13
  169. package/dist/ts4.2/room/timers.d.ts +12 -12
  170. package/dist/ts4.2/room/token-source/TokenSource.d.ts +82 -82
  171. package/dist/ts4.2/room/token-source/types.d.ts +70 -70
  172. package/dist/ts4.2/room/token-source/utils.d.ts +8 -8
  173. package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -19
  174. package/dist/ts4.2/room/track/LocalAudioTrack.d.ts +62 -42
  175. package/dist/ts4.2/room/track/LocalTrack.d.ts +143 -125
  176. package/dist/ts4.2/room/track/LocalTrackPublication.d.ts +42 -42
  177. package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +109 -100
  178. package/dist/ts4.2/room/track/RemoteAudioTrack.d.ts +61 -55
  179. package/dist/ts4.2/room/track/RemoteTrack.d.ts +38 -38
  180. package/dist/ts4.2/room/track/RemoteTrackPublication.d.ts +72 -75
  181. package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +73 -76
  182. package/dist/ts4.2/room/track/Track.d.ts +156 -166
  183. package/dist/ts4.2/room/track/TrackPublication.d.ts +75 -81
  184. package/dist/ts4.2/room/track/create.d.ts +25 -25
  185. package/dist/ts4.2/room/track/facingMode.d.ts +41 -41
  186. package/dist/ts4.2/room/track/options.d.ts +403 -403
  187. package/dist/ts4.2/room/track/processor/types.d.ts +42 -31
  188. package/dist/ts4.2/room/track/record.d.ts +13 -13
  189. package/dist/ts4.2/room/track/types.d.ts +28 -28
  190. package/dist/ts4.2/room/track/utils.d.ts +60 -47
  191. package/dist/ts4.2/room/types.d.ts +127 -127
  192. package/dist/ts4.2/room/utils.d.ts +273 -214
  193. package/dist/ts4.2/test/MockMediaStreamTrack.d.ts +26 -26
  194. package/dist/ts4.2/test/compressionStreamStubs.d.ts +12 -0
  195. package/dist/ts4.2/test/mocks.d.ts +12 -12
  196. package/dist/ts4.2/test/promiseState.d.ts +12 -12
  197. package/dist/ts4.2/test/signalToken.d.ts +26 -26
  198. package/dist/ts4.2/type-polyfills/non-shared-typed-arrays.d.ts +2 -2
  199. package/dist/ts4.2/utils/AsyncQueue.d.ts +23 -23
  200. package/dist/ts4.2/utils/TypedPromise.d.ts +17 -17
  201. package/dist/ts4.2/utils/abort-signal-polyfill.d.ts +13 -13
  202. package/dist/ts4.2/utils/browserParser.d.ts +13 -13
  203. package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -8
  204. package/dist/ts4.2/utils/cloneDeep.d.ts +2 -2
  205. package/dist/ts4.2/utils/dataPacketBuffer.d.ts +34 -34
  206. package/dist/ts4.2/utils/deferrable-map.d.ts +32 -32
  207. package/dist/ts4.2/utils/machineInspector.d.ts +54 -54
  208. package/dist/ts4.2/utils/serializer.d.ts +48 -48
  209. package/dist/ts4.2/utils/subscribeToEvents.d.ts +15 -15
  210. package/dist/ts4.2/utils/ttlmap.d.ts +20 -20
  211. package/dist/ts4.2/version.d.ts +15 -15
  212. package/package.json +5 -4
  213. package/src/api/SignalClient.e2e.test.ts +1 -3
  214. package/src/api/SignalClient.test.ts +394 -10
  215. package/src/api/SignalClient.ts +132 -76
  216. package/src/api/WebSocketStream.test.ts +11 -0
  217. package/src/api/WebSocketStream.ts +22 -1
  218. package/src/api/utils.ts +1 -1
  219. package/src/e2ee/E2eeManager.test.ts +43 -0
  220. package/src/e2ee/E2eeManager.ts +6 -2
  221. package/src/e2ee/worker/FrameCryptor.test.ts +212 -90
  222. package/src/e2ee/worker/FrameCryptor.ts +21 -4
  223. package/src/e2ee/worker/naluUtils.test.ts +123 -0
  224. package/src/e2ee/worker/naluUtils.ts +57 -2
  225. package/src/index.ts +2 -0
  226. package/src/options.ts +16 -0
  227. package/src/room/DefaultReconnectPolicy.test.ts +58 -0
  228. package/src/room/DefaultReconnectPolicy.ts +14 -2
  229. package/src/room/PCTransport.test.ts +327 -9
  230. package/src/room/PCTransport.ts +339 -36
  231. package/src/room/PCTransportManager.ts +3 -1
  232. package/src/room/RTCEngine.test.ts +318 -2
  233. package/src/room/RTCEngine.ts +126 -12
  234. package/src/room/Room.test.ts +148 -6
  235. package/src/room/Room.ts +312 -80
  236. package/src/room/data-channel/DataChannelManager.test.ts +24 -7
  237. package/src/room/data-channel/DataChannelManager.ts +43 -38
  238. package/src/room/data-channel/FlowControlledDataChannel.test.ts +60 -18
  239. package/src/room/data-channel/FlowControlledDataChannel.ts +40 -22
  240. package/src/room/data-channel/LossyDataChannel.test.ts +38 -0
  241. package/src/room/data-channel/LossyDataChannel.ts +10 -1
  242. package/src/room/data-channel/ReliableDataChannel.test.ts +72 -0
  243. package/src/room/data-channel/ReliableDataChannel.ts +16 -5
  244. package/src/room/data-stream/incoming/IncomingDataStreamManager.test.ts +47 -20
  245. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +16 -5
  246. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.test.ts +60 -39
  247. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +4 -4
  248. package/src/room/defaults.ts +1 -0
  249. package/src/room/errors.test.ts +36 -0
  250. package/src/room/errors.ts +27 -0
  251. package/src/room/events.ts +2 -1
  252. package/src/room/participant/LocalParticipant.test.ts +136 -1
  253. package/src/room/participant/LocalParticipant.ts +66 -17
  254. package/src/room/participant/Participant.ts +6 -3
  255. package/src/room/participant/publishUtils.ts +0 -19
  256. package/src/room/participant/restartOnDefaultAudioDevice.test.ts +177 -0
  257. package/src/room/rpc/client/RpcClientManager.test.ts +51 -0
  258. package/src/room/rpc/client/RpcClientManager.ts +32 -15
  259. package/src/room/rpc/utils.test.ts +32 -0
  260. package/src/room/rpc/utils.ts +7 -0
  261. package/src/room/track/LocalAudioTrack.ts +101 -10
  262. package/src/room/track/LocalTrack.ts +87 -19
  263. package/src/room/track/LocalVideoTrack.ts +17 -3
  264. package/src/room/track/RemoteAudioTrack.ts +59 -14
  265. package/src/room/track/RemoteVideoTrack.test.ts +210 -0
  266. package/src/room/track/RemoteVideoTrack.ts +29 -3
  267. package/src/room/track/processor/types.ts +11 -0
  268. package/src/room/track/utils.test.ts +206 -2
  269. package/src/room/track/utils.ts +117 -5
  270. package/src/room/utils.test.ts +250 -0
  271. package/src/room/utils.ts +152 -19
  272. package/src/test/compressionStreamStubs.ts +53 -0
@@ -1,175 +1,268 @@
1
- import type { MediaAttributes, MediaDescription, SessionDescription } from 'sdp-transform';
2
- import type TypedEmitter from 'typed-emitter';
3
- import type { LoggerOptions } from './types';
4
- /** @internal */
5
- interface TrackBitrateInfo {
6
- cid?: string;
7
- transceiver?: RTCRtpTransceiver;
8
- codec: string;
9
- maxbr: number;
10
- isScreenShare?: boolean;
11
- }
12
- /**
13
- * Applies the configured start bitrate when this media section belongs to `cid`.
14
- * This SDP munging is used for a bitrate setting that cannot be applied through
15
- * `RTCRtpEncodingParameters`.
16
- *
17
- * Returns `undefined` when the section does not belong to the track, `0` when
18
- * it does but does not offer the requested codec, and the codec payload when the
19
- * requested codec is present (whether the bitrate was added or already set).
20
- *
21
- * @internal
22
- */
23
- export declare function applyVideoStartBitrate(media: MediaDescription, cid: string, codec: string, maxbr: number, isScreenShare?: boolean): number | undefined;
24
- export declare const PCEvents: {
25
- readonly NegotiationStarted: "negotiationStarted";
26
- readonly NegotiationComplete: "negotiationComplete";
27
- readonly OfferAnswered: "offerAnswered";
28
- readonly RTPVideoPayloadTypes: "rtpVideoPayloadTypes";
29
- };
30
- declare const PCTransport_base: new () => TypedEmitter<PCTransportEventCallbacks>;
31
- /** @internal */
32
- export default class PCTransport extends PCTransport_base {
33
- private _pc;
34
- private get pc();
35
- private config?;
36
- private log;
37
- private iceLog;
38
- private loggerOptions;
39
- private ddExtID;
40
- latestOfferId: number;
41
- latestAcknowledgedOfferId: number;
42
- private offerLock;
43
- private pendingInitialOffer?;
44
- pendingCandidates: RTCIceCandidateInit[];
45
- restartingIce: boolean;
46
- renegotiate: boolean;
47
- trackBitrates: TrackBitrateInfo[];
48
- remoteStereoMids: string[];
49
- remoteNackMids: string[];
50
- onOffer?: (offer: RTCSessionDescriptionInit, offerId: number) => void;
51
- onIceCandidate?: (candidate: RTCIceCandidate) => void;
52
- onIceCandidateError?: (ev: Event) => void;
53
- onConnectionStateChange?: (state: RTCPeerConnectionState) => void;
54
- onIceConnectionStateChange?: (state: RTCIceConnectionState) => void;
55
- onSignalingStatechange?: (state: RTCSignalingState) => void;
56
- onDataChannel?: (ev: RTCDataChannelEvent) => void;
57
- onTrack?: (ev: RTCTrackEvent) => void;
58
- constructor(config?: RTCConfiguration, loggerOptions?: LoggerOptions);
59
- private createPC;
60
- private get logContext();
61
- get isICEConnected(): boolean;
62
- addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>;
63
- setRemoteDescription(sd: RTCSessionDescriptionInit, offerId: number): Promise<boolean>;
64
- negotiate: import("./debounce").DebouncedFunction<any[], (onError?: (e: Error) => void) => Promise<void>>;
65
- createInitialOffer(): Promise<{
66
- offer: RTCSessionDescriptionInit;
67
- offerId: number;
68
- } | undefined>;
69
- createAndSendOffer(options?: RTCOfferOptions): Promise<void>;
70
- createAndSetAnswer(): Promise<RTCSessionDescriptionInit>;
71
- /**
72
- * Returns the mids of transceivers that carry no outgoing track on this
73
- * (publisher) connection: the pre-populated placeholders added by
74
- * `RTCEngine.applyInitialPublisherLayout`, plus any transceiver that was used
75
- * for a track and reverted on unpublish. Their codec fmtp is conformed to the
76
- * published tracks so a shared payload type stays consistent across the bundle.
77
- */
78
- private getPlaceholderMids;
79
- createDataChannel(label: string, dataChannelDict: RTCDataChannelInit): RTCDataChannel;
80
- addTransceiver(mediaStreamTrack: MediaStreamTrack, transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
81
- addTransceiverOfKind(kind: 'audio' | 'video', transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
82
- addTrack(track: MediaStreamTrack): RTCRtpSender;
83
- setTrackCodecBitrate(info: TrackBitrateInfo): void;
84
- setConfiguration(rtcConfig: RTCConfiguration): void;
85
- canRemoveTrack(): boolean;
86
- removeTrack(sender: RTCRtpSender): void | undefined;
87
- getConnectionState(): RTCPeerConnectionState;
88
- getICEConnectionState(): RTCIceConnectionState;
89
- getSignallingState(): RTCSignalingState;
90
- getTransceivers(): RTCRtpTransceiver[];
91
- getSenders(): RTCRtpSender[];
92
- getLocalDescription(): RTCSessionDescription | null | undefined;
93
- getRemoteDescription(): RTCSessionDescription | null;
94
- /** stats of the underlying connection, `undefined` when there is none */
95
- getStats(): Promise<RTCStatsReport> | undefined;
96
- getMaxMessageSize(): number | undefined;
97
- getConnectedAddress(): Promise<string | undefined>;
98
- close: () => void;
99
- private setMungedSDP;
100
- }
101
- /**
102
- * Adds the AV1 dependency descriptor extension to `media` unless it is already there, and
103
- * returns the id it is mapped to so callers can pass it back in as `ddExtID` (0 when no id has
104
- * been chosen yet).
105
- *
106
- * A bundle has to map one URI to one id, so an id already in use for the extension anywhere in
107
- * `sdp` wins over both the cached one and a fresh one: Chrome advertises the extension itself on
108
- * sections it can send on, and an earlier offer may have munged it into others.
109
- * @internal
110
- */
111
- export declare function ensureVideoDDExtension(media: {
112
- type: string;
113
- port: number;
114
- protocol: string;
115
- payloads?: string | undefined;
116
- } & MediaDescription, sdp: SessionDescription, ddExtID: number): number;
117
- /**
118
- * Checks whether an fmtp config declares `param` as an exact, `;`-delimited
119
- * token. A plain substring check conflates distinct opus parameters — e.g.
120
- * `stereo=1` is a substring of `sprop-stereo=1` — so `param` must match a whole
121
- * parameter, not appear anywhere within the config string.
122
- * @internal
123
- */
124
- export declare function fmtpConfigHasParam(config: string, param: string): boolean;
125
- /** @internal */
126
- export declare function ensureAudioNackAndStereo(media: {
127
- type: string;
128
- port: number;
129
- protocol: string;
130
- payloads?: string | undefined;
131
- } & MediaDescription, stereoMids: string[], nackMids: string[]): void;
132
- /**
133
- * Returns the mids of transceivers that carry no outgoing track: the
134
- * pre-populated placeholders added by `RTCEngine.applyInitialPublisherLayout`,
135
- * plus any transceiver that was used for a track and reverted on unpublish. The
136
- * `sender.track` check is the reliable signal — an unpublished section keeps its
137
- * `a=msid` (and its stale send-derived fmtp), so it can't be told apart from a
138
- * real send by SDP alone. Transceiver mids are stable across renegotiations, so
139
- * this works for every offer/answer after the first.
140
- * @internal
141
- */
142
- export declare function placeholderMidsFromTransceivers(transceivers: readonly RTCRtpTransceiver[]): Set<string>;
143
- /**
144
- * Within a BUNDLE group a payload type must map to identical codec parameters
145
- * across every m-line. When the same payload type carries different fmtp between
146
- * sections — e.g. opus `usedtx=1` on the published microphone but not on the
147
- * pre-populated recvonly placeholders, or H.265 with different `level-id` between
148
- * a published video track and a placeholder — libwebrtc flags a "bundled payload
149
- * type collision".
150
- *
151
- * Rewrite the placeholder sections so every shared payload type carries the
152
- * same fmtp. Real (non-placeholder) sections always win the canonical value, so
153
- * a published track's encoder parameters are never altered. When no real
154
- * section declares a payload type — e.g. a placeholder that was reused for a
155
- * track and then reverted to recvonly keeps its send-derived `level-id` while
156
- * fresh placeholders use the default — the placeholders still converge on the
157
- * first value seen, so two placeholders can't disagree either. Only placeholder
158
- * sections are ever rewritten, and it is codec-agnostic (opus, H.265, ...).
159
- * `isPlaceholder` identifies the sections to conform.
160
- * @internal
161
- */
162
- export declare function conformBundledCodecFmtp(media: MediaDescription[], isPlaceholder: (media: MediaDescription) => boolean): void;
163
- /** @internal */
164
- export declare function extractStereoAndNackAudioFromOffer(offer: RTCSessionDescriptionInit): {
165
- stereoMids: string[];
166
- nackMids: string[];
167
- };
168
- type PCTransportEventCallbacks = {
169
- negotiationStarted: () => void;
170
- negotiationComplete: () => void;
171
- offerAnswered: (offerId: number) => void;
172
- rtpVideoPayloadTypes: (attributes: MediaAttributes['rtp']) => void;
173
- };
174
- export {};
175
- //# sourceMappingURL=PCTransport.d.ts.map
1
+ import type { MediaAttributes, MediaDescription, SessionDescription } from 'sdp-transform';
2
+ import type TypedEmitter from 'typed-emitter';
3
+ import type { LoggerOptions } from './types';
4
+ /** @internal */
5
+ interface TrackBitrateInfo {
6
+ cid?: string;
7
+ transceiver?: RTCRtpTransceiver;
8
+ codec: string;
9
+ maxbr: number;
10
+ isScreenShare?: boolean;
11
+ }
12
+ /**
13
+ * Codec payload for `codec` in this media section, when the section carries `cid`.
14
+ *
15
+ * Returns `undefined` when the section does not belong to the track, `0` when it does but
16
+ * does not offer the requested codec, and the codec payload otherwise.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function findTrackCodecPayload(media: MediaDescription, cid: string, codec: string): number | undefined;
21
+ /**
22
+ * Start bitrate hinted for a single track, or `undefined` when its target is too low to
23
+ * be worth seeding.
24
+ *
25
+ * 90% of the target leaves ~10% headroom for the estimator to settle. The same multiplier
26
+ * is used for every codec because the target already reflects the codec's efficiency.
27
+ * Camera is capped at 1 Mbps so the estimator does not open too aggressively on a
28
+ * high-bitrate track; screen share is exempt, because its content needs the bitrate
29
+ * immediately to stay legible.
30
+ *
31
+ * The cap is lowered for a connection that was slow to set up (`computeStartBitrateCap`), and
32
+ * for one the browser reports as slow (`connectionEffectiveTypeStartBitrateCap`), whichever is
33
+ * lower. Screen share is exempt from both, however slow the connection.
34
+ *
35
+ * @internal
36
+ */
37
+ export declare function computeTrackStartBitrate(trackbr: TrackBitrateInfo, connectionSetupTimeMs?: number): number | undefined;
38
+ /**
39
+ * The single start bitrate for this peer connection: the largest hint among the video
40
+ * m-sections of `media` that map to a published track.
41
+ *
42
+ * libwebrtc reads `x-google-start-bitrate` per m-section but applies it to the shared
43
+ * `Call` (`WebRtcVideoSendChannel::ApplyChangedParams` -> `SetSdpBitrateParameters`), where
44
+ * `RtpBitrateConfigurator` holds one config for the whole connection. Differing per-section
45
+ * values are therefore last-writer-wins, decided by m-section order, so every video section
46
+ * gets the same number instead.
47
+ *
48
+ * Only sections that can send local media are considered. `trackBitrates` is append-only and an
49
+ * unpublished section keeps its `a=msid`, so matching on msid alone would still pair a stale
50
+ * entry with its old section — letting an uncapped screen-share target seed a connection that
51
+ * now carries only a camera, or consuming the one-shot hint on a section that sends nothing.
52
+ *
53
+ * The direction is the discriminator, as an exclusion rather than a match: `recvonly` and
54
+ * `inactive` are the only directions that cannot carry local media, and they are exactly the
55
+ * two a dead section lands on — unpublish sets `inactive` (explicitly in
56
+ * `LocalParticipant.unpublishTrack`, and via `removeTrack`'s sendonly -> inactive transition for
57
+ * the simulcast senders), `removeTrack` on a `sendrecv` transceiver leaves `recvonly`, and the
58
+ * pre-populated placeholders are `recvonly`. Everything else sends: `sendonly` from the
59
+ * `addTransceiver` path, `sendrecv` from the legacy `addTrack` fallback (which reuses a
60
+ * transceiver rather than creating a sendonly one), and a section with no direction attribute,
61
+ * which SDP defaults to `sendrecv`.
62
+ *
63
+ * @internal
64
+ */
65
+ export declare function computeConnectionStartBitrate(media: MediaDescription[], trackBitrates: TrackBitrateInfo[], connectionSetupTimeMs?: number): number | undefined;
66
+ /**
67
+ * Declares `x-google-start-bitrate` on `codecPayload`'s fmtp. This SDP munging is used for
68
+ * a bitrate setting that cannot be applied through `RTCRtpEncodingParameters`.
69
+ *
70
+ * Returns whether the section now carries the hint.
71
+ *
72
+ * @internal
73
+ */
74
+ export declare function applyVideoStartBitrate(media: MediaDescription, codecPayload: number, startBitrate: number): boolean;
75
+ export declare const PCEvents: {
76
+ readonly NegotiationStarted: "negotiationStarted";
77
+ readonly NegotiationComplete: "negotiationComplete";
78
+ readonly OfferAnswered: "offerAnswered";
79
+ readonly RTPVideoPayloadTypes: "rtpVideoPayloadTypes";
80
+ };
81
+ declare const PCTransport_base: new () => TypedEmitter<PCTransportEventCallbacks>;
82
+ /** @internal */
83
+ export default class PCTransport extends PCTransport_base {
84
+ private _pc;
85
+ private get pc();
86
+ private config?;
87
+ private log;
88
+ private iceLog;
89
+ private loggerOptions;
90
+ private ddExtID;
91
+ latestOfferId: number;
92
+ private answeredOfferId;
93
+ /** offerId (0 if unnumbered) of the answer being applied right now */
94
+ private answerInFlight;
95
+ latestAcknowledgedOfferId: number;
96
+ private offerLock;
97
+ private pendingInitialOffer?;
98
+ pendingCandidates: RTCIceCandidateInit[];
99
+ restartingIce: boolean;
100
+ renegotiate: boolean;
101
+ trackBitrates: TrackBitrateInfo[];
102
+ /**
103
+ * Whether an offer carrying the connection-level `x-google-start-bitrate` has been
104
+ * accepted locally. The hint is written once per peer connection: libwebrtc retains
105
+ * `start_bitrate_bps` in `RtpBitrateConfigurator` and re-applies it on network route
106
+ * changes, so a later rewrite is at best a no-op and at worst restarts a converged
107
+ * bandwidth estimator. A new peer connection (full reconnect) seeds a new estimator.
108
+ */
109
+ private hasAppliedVideoStartBitrate;
110
+ /**
111
+ * How long this peer connection took to set up, in ms, recorded once the initial connect
112
+ * succeeds. Lowers the start bitrate hint for a slow connection; see `computeStartBitrateCap`.
113
+ */
114
+ private connectionSetupTimeMs?;
115
+ /**
116
+ * When the connection attempt that built this peer connection began (`performance.now()`).
117
+ * Until `connectionSetupTimeMs` is known, the time elapsed since then is used as a lower bound
118
+ * on the setup time, so a video published during connect is still seeded from it rather than
119
+ * waiting for the connection, which would delay the offer.
120
+ */
121
+ private connectionStartedAt?;
122
+ remoteStereoMids: string[];
123
+ remoteNackMids: string[];
124
+ onOffer?: (offer: RTCSessionDescriptionInit, offerId: number) => void;
125
+ onIceCandidate?: (candidate: RTCIceCandidate) => void;
126
+ onIceCandidateError?: (ev: Event) => void;
127
+ onConnectionStateChange?: (state: RTCPeerConnectionState) => void;
128
+ onIceConnectionStateChange?: (state: RTCIceConnectionState) => void;
129
+ onSignalingStatechange?: (state: RTCSignalingState) => void;
130
+ onDataChannel?: (ev: RTCDataChannelEvent) => void;
131
+ onTrack?: (ev: RTCTrackEvent) => void;
132
+ constructor(config?: RTCConfiguration, loggerOptions?: LoggerOptions);
133
+ private createPC;
134
+ private get logContext();
135
+ get isICEConnected(): boolean;
136
+ addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>;
137
+ setRemoteDescription(sd: RTCSessionDescriptionInit, offerId: number): Promise<boolean>;
138
+ private applyRemoteDescription;
139
+ negotiate: import("./debounce").DebouncedFunction<any[], (onError?: (e: Error) => void) => Promise<void>>;
140
+ createInitialOffer(): Promise<{
141
+ offer: RTCSessionDescriptionInit;
142
+ offerId: number;
143
+ } | undefined>;
144
+ createAndSendOffer(options?: RTCOfferOptions): Promise<void>;
145
+ createAndSetAnswer(): Promise<RTCSessionDescriptionInit>;
146
+ /**
147
+ * Returns the mids of transceivers that carry no outgoing track on this
148
+ * (publisher) connection: the pre-populated placeholders added by
149
+ * `RTCEngine.applyInitialPublisherLayout`, plus any transceiver that was used
150
+ * for a track and reverted on unpublish. Their codec fmtp is conformed to the
151
+ * published tracks so a shared payload type stays consistent across the bundle.
152
+ */
153
+ private getPlaceholderMids;
154
+ createDataChannel(label: string, dataChannelDict: RTCDataChannelInit): RTCDataChannel;
155
+ addTransceiver(mediaStreamTrack: MediaStreamTrack, transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
156
+ addTransceiverOfKind(kind: 'audio' | 'video', transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
157
+ addTrack(track: MediaStreamTrack): RTCRtpSender;
158
+ setTrackCodecBitrate(info: TrackBitrateInfo): void;
159
+ /**
160
+ * Record how long this peer connection took to set up. Called once, when the initial connect
161
+ * succeeds; resumes and ICE restarts keep the estimator they have and never call this.
162
+ */
163
+ setConnectionSetupTime(ms: number): void;
164
+ /** Record when the connection attempt that built this peer connection began. */
165
+ setConnectionStartedAt(startedAt: number): void;
166
+ /** The measured setup time, or while still connecting, the time elapsed so far. */
167
+ private connectionSetupTimeEstimateMs;
168
+ setConfiguration(rtcConfig: RTCConfiguration): void;
169
+ canRemoveTrack(): boolean;
170
+ removeTrack(sender: RTCRtpSender): void | undefined;
171
+ getConnectionState(): RTCPeerConnectionState;
172
+ getICEConnectionState(): RTCIceConnectionState;
173
+ getSignallingState(): RTCSignalingState;
174
+ getTransceivers(): RTCRtpTransceiver[];
175
+ getSenders(): RTCRtpSender[];
176
+ getLocalDescription(): RTCSessionDescription | null | undefined;
177
+ getRemoteDescription(): RTCSessionDescription | null;
178
+ /** stats of the underlying connection, `undefined` when there is none */
179
+ getStats(): Promise<RTCStatsReport> | undefined;
180
+ getMaxMessageSize(): number | undefined;
181
+ getConnectedAddress(): Promise<string | undefined>;
182
+ close: () => void;
183
+ private setMungedSDP;
184
+ }
185
+ /**
186
+ * Adds the AV1 dependency descriptor extension to `media` unless it is already there, and
187
+ * returns the id it is mapped to so callers can pass it back in as `ddExtID` (0 when no id has
188
+ * been chosen yet).
189
+ *
190
+ * A bundle has to map one URI to one id, so an id already in use for the extension anywhere in
191
+ * `sdp` wins over both the cached one and a fresh one: Chrome advertises the extension itself on
192
+ * sections it can send on, and an earlier offer may have munged it into others.
193
+ * @internal
194
+ */
195
+ export declare function ensureVideoDDExtension(media: {
196
+ type: string;
197
+ port: number;
198
+ protocol: string;
199
+ payloads?: string | undefined;
200
+ } & MediaDescription, sdp: SessionDescription, ddExtID: number): number;
201
+ /**
202
+ * Checks whether an fmtp config declares `param` as an exact, `;`-delimited
203
+ * token. A plain substring check conflates distinct opus parameters — e.g.
204
+ * `stereo=1` is a substring of `sprop-stereo=1` — so `param` must match a whole
205
+ * parameter, not appear anywhere within the config string.
206
+ * @internal
207
+ */
208
+ export declare function fmtpConfigHasParam(config: string, param: string): boolean;
209
+ /** @internal */
210
+ export declare function ensureAudioNackAndStereo(media: {
211
+ type: string;
212
+ port: number;
213
+ protocol: string;
214
+ payloads?: string | undefined;
215
+ } & MediaDescription, stereoMids: string[], nackMids: string[]): void;
216
+ /**
217
+ * Returns the mids of transceivers that carry no outgoing track: the
218
+ * pre-populated placeholders added by `RTCEngine.applyInitialPublisherLayout`,
219
+ * plus any transceiver that was used for a track and reverted on unpublish. The
220
+ * `sender.track` check is the reliable signal — an unpublished section keeps its
221
+ * `a=msid` (and its stale send-derived fmtp), so it can't be told apart from a
222
+ * real send by SDP alone. Transceiver mids are stable across renegotiations, so
223
+ * this works for every offer/answer after the first.
224
+ * @internal
225
+ */
226
+ export declare function placeholderMidsFromTransceivers(transceivers: readonly RTCRtpTransceiver[]): Set<string>;
227
+ /**
228
+ * Within a BUNDLE group a payload type must map to identical codec parameters
229
+ * across every m-line. When the same payload type carries different fmtp between
230
+ * sections — e.g. opus `usedtx=1` on the published microphone but not on the
231
+ * pre-populated recvonly placeholders, or H.265 with different `level-id` between
232
+ * a published video track and a placeholder — libwebrtc flags a "bundled payload
233
+ * type collision".
234
+ *
235
+ * Rewrite the placeholder sections so every shared payload type carries the
236
+ * same fmtp. Real (non-placeholder) sections always win the canonical value, so
237
+ * a published track's encoder parameters are never altered. When no real
238
+ * section declares a payload type — e.g. a placeholder that was reused for a
239
+ * track and then reverted to recvonly keeps its send-derived `level-id` while
240
+ * fresh placeholders use the default — the placeholders still converge on the
241
+ * first value seen, so two placeholders can't disagree either. Only placeholder
242
+ * sections are ever rewritten, and it is codec-agnostic (opus, H.265, ...).
243
+ * `isPlaceholder` identifies the sections to conform.
244
+ * @internal
245
+ */
246
+ export declare function conformBundledCodecFmtp(media: MediaDescription[], isPlaceholder: (media: MediaDescription) => boolean): void;
247
+ /** @internal */
248
+ /**
249
+ * Whether an incoming answer repeats one already applied or being applied.
250
+ * Any answer for the offer whose answer is in flight is a duplicate, numbered
251
+ * or not. With an offerId (current servers) an answer is also a duplicate if
252
+ * that offer's answer was already applied. Without one, fall back to the
253
+ * signaling state: in `stable` no local offer is pending, unless the initial
254
+ * offer is still deferred (it is set locally only once its answer arrives).
255
+ */
256
+ export declare function isDuplicateAnswer(offerId: number, answerInFlight: number | undefined, answeredOfferId: number, signalingState: RTCSignalingState | undefined, hasPendingInitialOffer: boolean): boolean;
257
+ export declare function extractStereoAndNackAudioFromOffer(offer: RTCSessionDescriptionInit): {
258
+ stereoMids: string[];
259
+ nackMids: string[];
260
+ };
261
+ type PCTransportEventCallbacks = {
262
+ negotiationStarted: () => void;
263
+ negotiationComplete: () => void;
264
+ offerAnswered: (offerId: number) => void;
265
+ rtpVideoPayloadTypes: (attributes: MediaAttributes['rtp']) => void;
266
+ };
267
+ export {};
268
+ //# sourceMappingURL=PCTransport.d.ts.map
@@ -1,77 +1,77 @@
1
- import { SignalTarget } from '@livekit/protocol';
2
- import type { Throws } from '@livekit/throws-transformer/throws';
3
- import PCTransport from './PCTransport';
4
- import { NegotiationError } from './errors';
5
- import type { LoggerOptions } from './types';
6
- export declare enum PCTransportState {
7
- NEW = 0,
8
- CONNECTING = 1,
9
- CONNECTED = 2,
10
- FAILED = 3,
11
- CLOSING = 4,
12
- CLOSED = 5
13
- }
14
- type PCMode = 'subscriber-primary' | 'publisher-primary' | 'publisher-only';
15
- export declare class PCTransportManager {
16
- publisher: PCTransport;
17
- subscriber?: PCTransport;
18
- peerConnectionTimeout: number;
19
- get needsPublisher(): boolean;
20
- get needsSubscriber(): boolean;
21
- get currentState(): PCTransportState;
22
- onStateChange?: (state: PCTransportState, pubState: RTCPeerConnectionState, subState?: RTCPeerConnectionState) => void;
23
- onIceCandidate?: (ev: RTCIceCandidate, target: SignalTarget) => void;
24
- onDataChannel?: (ev: RTCDataChannelEvent) => void;
25
- onTrack?: (ev: RTCTrackEvent) => void;
26
- onPublisherOffer?: (offer: RTCSessionDescriptionInit, offerId: number) => void;
27
- private isPublisherConnectionRequired;
28
- private isSubscriberConnectionRequired;
29
- private state;
30
- private connectionLock;
31
- private remoteOfferLock;
32
- private log;
33
- private iceLog;
34
- private loggerOptions;
35
- private _mode;
36
- get mode(): PCMode;
37
- constructor(mode: PCMode, loggerOptions: LoggerOptions, rtcConfig?: RTCConfiguration);
38
- private get logContext();
39
- requirePublisher(require?: boolean): void;
40
- createAndSendPublisherOffer(options?: RTCOfferOptions): Promise<void>;
41
- setPublisherAnswer(sd: RTCSessionDescriptionInit, offerId: number): Promise<boolean>;
42
- removeTrack(sender: RTCRtpSender): void | undefined;
43
- close(): Promise<void>;
44
- /**
45
- * Restarts ICE on the transports that need it. Only the publisher: the server restarts the
46
- * subscriber's ICE itself and follows with a fresh offer.
47
- *
48
- * The subscriber deliberately does NOT enter `restartingIce` here. Queueing its remote
49
- * candidates would guard against candidates for a new generation arriving before the offer
50
- * that introduces it, but the server does not send them in that order -- on a same-node
51
- * resume it buffers them until the offer has gone out, and on a reconnect that lands on
52
- * another node it withholds subscriber candidates until immediately before creating the
53
- * offer. Setting the flag only risks withholding candidates during the window that decides
54
- * whether the reconnect succeeded.
55
- */
56
- triggerIceRestart(): Promise<void>;
57
- addIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget): Promise<void>;
58
- createSubscriberAnswerFromOffer(sd: RTCSessionDescriptionInit, offerId: number): Promise<RTCSessionDescriptionInit | undefined>;
59
- updateConfiguration(config: RTCConfiguration, iceRestart?: boolean): void;
60
- ensurePCTransportConnection(abortController?: AbortController, timeout?: number): Promise<void>;
61
- negotiate(abortController: AbortController): Promise<Throws<void, NegotiationError | Error>>;
62
- addPublisherTransceiver(track: MediaStreamTrack, transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
63
- addPublisherTransceiverOfKind(kind: 'audio' | 'video', transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
64
- getMidForReceiver(receiver: RTCRtpReceiver): string | null | undefined;
65
- getMaxPublisherMessageSize(): number | undefined;
66
- addPublisherTrack(track: MediaStreamTrack): RTCRtpSender;
67
- createPublisherDataChannel(label: string, dataChannelDict: RTCDataChannelInit): RTCDataChannel;
68
- /**
69
- * Returns the first required transport's address if no explicit target is specified
70
- */
71
- getConnectedAddress(target?: SignalTarget): Promise<string | undefined>;
72
- private get requiredTransports();
73
- private updateState;
74
- private ensureTransportConnected;
75
- }
76
- export {};
77
- //# sourceMappingURL=PCTransportManager.d.ts.map
1
+ import { SignalTarget } from '@livekit/protocol';
2
+ import type { Throws } from '@livekit/throws-transformer/throws';
3
+ import PCTransport from './PCTransport';
4
+ import { NegotiationError } from './errors';
5
+ import type { LoggerOptions } from './types';
6
+ export declare enum PCTransportState {
7
+ NEW = 0,
8
+ CONNECTING = 1,
9
+ CONNECTED = 2,
10
+ FAILED = 3,
11
+ CLOSING = 4,
12
+ CLOSED = 5
13
+ }
14
+ type PCMode = 'subscriber-primary' | 'publisher-primary' | 'publisher-only';
15
+ export declare class PCTransportManager {
16
+ publisher: PCTransport;
17
+ subscriber?: PCTransport;
18
+ peerConnectionTimeout: number;
19
+ get needsPublisher(): boolean;
20
+ get needsSubscriber(): boolean;
21
+ get currentState(): PCTransportState;
22
+ onStateChange?: (state: PCTransportState, pubState: RTCPeerConnectionState, subState?: RTCPeerConnectionState) => void;
23
+ onIceCandidate?: (ev: RTCIceCandidate, target: SignalTarget) => void;
24
+ onDataChannel?: (ev: RTCDataChannelEvent) => void;
25
+ onTrack?: (ev: RTCTrackEvent) => void;
26
+ onPublisherOffer?: (offer: RTCSessionDescriptionInit, offerId: number) => void;
27
+ private isPublisherConnectionRequired;
28
+ private isSubscriberConnectionRequired;
29
+ private state;
30
+ private connectionLock;
31
+ private remoteOfferLock;
32
+ private log;
33
+ private iceLog;
34
+ private loggerOptions;
35
+ private _mode;
36
+ get mode(): PCMode;
37
+ constructor(mode: PCMode, loggerOptions: LoggerOptions, rtcConfig?: RTCConfiguration);
38
+ private get logContext();
39
+ requirePublisher(require?: boolean): void;
40
+ createAndSendPublisherOffer(options?: RTCOfferOptions): Promise<void>;
41
+ setPublisherAnswer(sd: RTCSessionDescriptionInit, offerId: number): Promise<boolean>;
42
+ removeTrack(sender: RTCRtpSender): void | undefined;
43
+ close(): Promise<void>;
44
+ /**
45
+ * Restarts ICE on the transports that need it. Only the publisher: the server restarts the
46
+ * subscriber's ICE itself and follows with a fresh offer.
47
+ *
48
+ * The subscriber deliberately does NOT enter `restartingIce` here. Queueing its remote
49
+ * candidates would guard against candidates for a new generation arriving before the offer
50
+ * that introduces it, but the server does not send them in that order -- on a same-node
51
+ * resume it buffers them until the offer has gone out, and on a reconnect that lands on
52
+ * another node it withholds subscriber candidates until immediately before creating the
53
+ * offer. Setting the flag only risks withholding candidates during the window that decides
54
+ * whether the reconnect succeeded.
55
+ */
56
+ triggerIceRestart(): Promise<void>;
57
+ addIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget): Promise<void>;
58
+ createSubscriberAnswerFromOffer(sd: RTCSessionDescriptionInit, offerId: number): Promise<RTCSessionDescriptionInit | undefined>;
59
+ updateConfiguration(config: RTCConfiguration, iceRestart?: boolean): void;
60
+ ensurePCTransportConnection(abortController?: AbortController, timeout?: number): Promise<void>;
61
+ negotiate(abortController: AbortController): Promise<Throws<void, NegotiationError | Error>>;
62
+ addPublisherTransceiver(track: MediaStreamTrack, transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
63
+ addPublisherTransceiverOfKind(kind: 'audio' | 'video', transceiverInit: RTCRtpTransceiverInit): RTCRtpTransceiver;
64
+ getMidForReceiver(receiver: RTCRtpReceiver): string | null | undefined;
65
+ getMaxPublisherMessageSize(): number | undefined;
66
+ addPublisherTrack(track: MediaStreamTrack): RTCRtpSender;
67
+ createPublisherDataChannel(label: string, dataChannelDict: RTCDataChannelInit): RTCDataChannel;
68
+ /**
69
+ * Returns the first required transport's address if no explicit target is specified
70
+ */
71
+ getConnectedAddress(target?: SignalTarget): Promise<string | undefined>;
72
+ private get requiredTransports();
73
+ private updateState;
74
+ private ensureTransportConnected;
75
+ }
76
+ export {};
77
+ //# sourceMappingURL=PCTransportManager.d.ts.map