@abrar71/lib-jitsi-meet 0.0.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 (350) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +26 -0
  3. package/dist/esm/JitsiConference.js +3692 -0
  4. package/dist/esm/JitsiConference.js.map +1 -0
  5. package/dist/esm/JitsiConferenceErrors.js +126 -0
  6. package/dist/esm/JitsiConferenceErrors.js.map +1 -0
  7. package/dist/esm/JitsiConferenceEventManager.js +424 -0
  8. package/dist/esm/JitsiConferenceEventManager.js.map +1 -0
  9. package/dist/esm/JitsiConferenceEvents.js +431 -0
  10. package/dist/esm/JitsiConferenceEvents.js.map +1 -0
  11. package/dist/esm/JitsiConnection.js +187 -0
  12. package/dist/esm/JitsiConnection.js.map +1 -0
  13. package/dist/esm/JitsiConnectionErrors.js +52 -0
  14. package/dist/esm/JitsiConnectionErrors.js.map +1 -0
  15. package/dist/esm/JitsiConnectionEvents.js +57 -0
  16. package/dist/esm/JitsiConnectionEvents.js.map +1 -0
  17. package/dist/esm/JitsiMediaDevices.js +221 -0
  18. package/dist/esm/JitsiMediaDevices.js.map +1 -0
  19. package/dist/esm/JitsiMediaDevicesEvents.js +29 -0
  20. package/dist/esm/JitsiMediaDevicesEvents.js.map +1 -0
  21. package/dist/esm/JitsiMeetJS.js +499 -0
  22. package/dist/esm/JitsiMeetJS.js.map +1 -0
  23. package/dist/esm/JitsiParticipant.js +323 -0
  24. package/dist/esm/JitsiParticipant.js.map +1 -0
  25. package/dist/esm/JitsiTrackError.js +122 -0
  26. package/dist/esm/JitsiTrackError.js.map +1 -0
  27. package/dist/esm/JitsiTrackErrors.js +91 -0
  28. package/dist/esm/JitsiTrackErrors.js.map +1 -0
  29. package/dist/esm/JitsiTrackEvents.js +60 -0
  30. package/dist/esm/JitsiTrackEvents.js.map +1 -0
  31. package/dist/esm/JitsiTranscriptionStatus.js +15 -0
  32. package/dist/esm/JitsiTranscriptionStatus.js.map +1 -0
  33. package/dist/esm/modules/RTC/BridgeChannel.js +398 -0
  34. package/dist/esm/modules/RTC/BridgeChannel.js.map +1 -0
  35. package/dist/esm/modules/RTC/JitsiLocalTrack.js +896 -0
  36. package/dist/esm/modules/RTC/JitsiLocalTrack.js.map +1 -0
  37. package/dist/esm/modules/RTC/JitsiRemoteTrack.js +427 -0
  38. package/dist/esm/modules/RTC/JitsiRemoteTrack.js.map +1 -0
  39. package/dist/esm/modules/RTC/JitsiTrack.js +453 -0
  40. package/dist/esm/modules/RTC/JitsiTrack.js.map +1 -0
  41. package/dist/esm/modules/RTC/MockClasses.js +388 -0
  42. package/dist/esm/modules/RTC/MockClasses.js.map +1 -0
  43. package/dist/esm/modules/RTC/RTC.js +658 -0
  44. package/dist/esm/modules/RTC/RTC.js.map +1 -0
  45. package/dist/esm/modules/RTC/RTCUtils.js +762 -0
  46. package/dist/esm/modules/RTC/RTCUtils.js.map +1 -0
  47. package/dist/esm/modules/RTC/ScreenObtainer.js +380 -0
  48. package/dist/esm/modules/RTC/ScreenObtainer.js.map +1 -0
  49. package/dist/esm/modules/RTC/TPCUtils.js +803 -0
  50. package/dist/esm/modules/RTC/TPCUtils.js.map +1 -0
  51. package/dist/esm/modules/RTC/TraceablePeerConnection.js +2223 -0
  52. package/dist/esm/modules/RTC/TraceablePeerConnection.js.map +1 -0
  53. package/dist/esm/modules/RTCStats/DefaulLogStorage.js +35 -0
  54. package/dist/esm/modules/RTCStats/DefaulLogStorage.js.map +1 -0
  55. package/dist/esm/modules/RTCStats/RTCStats.js +219 -0
  56. package/dist/esm/modules/RTCStats/RTCStats.js.map +1 -0
  57. package/dist/esm/modules/RTCStats/RTCStatsEvents.js +92 -0
  58. package/dist/esm/modules/RTCStats/RTCStatsEvents.js.map +1 -0
  59. package/dist/esm/modules/RTCStats/interfaces.js +2 -0
  60. package/dist/esm/modules/RTCStats/interfaces.js.map +1 -0
  61. package/dist/esm/modules/browser/BrowserCapabilities.js +345 -0
  62. package/dist/esm/modules/browser/BrowserCapabilities.js.map +1 -0
  63. package/dist/esm/modules/browser/index.js +3 -0
  64. package/dist/esm/modules/browser/index.js.map +1 -0
  65. package/dist/esm/modules/connectivity/ConnectionQuality.js +389 -0
  66. package/dist/esm/modules/connectivity/ConnectionQuality.js.map +1 -0
  67. package/dist/esm/modules/connectivity/IceFailedHandling.js +84 -0
  68. package/dist/esm/modules/connectivity/IceFailedHandling.js.map +1 -0
  69. package/dist/esm/modules/connectivity/NetworkInfo.js +49 -0
  70. package/dist/esm/modules/connectivity/NetworkInfo.js.map +1 -0
  71. package/dist/esm/modules/connectivity/TrackStreamingStatus.js +453 -0
  72. package/dist/esm/modules/connectivity/TrackStreamingStatus.js.map +1 -0
  73. package/dist/esm/modules/detection/ActiveDeviceDetector.js +79 -0
  74. package/dist/esm/modules/detection/ActiveDeviceDetector.js.map +1 -0
  75. package/dist/esm/modules/detection/DetectionEvents.js +58 -0
  76. package/dist/esm/modules/detection/DetectionEvents.js.map +1 -0
  77. package/dist/esm/modules/detection/NoAudioSignalDetection.js +127 -0
  78. package/dist/esm/modules/detection/NoAudioSignalDetection.js.map +1 -0
  79. package/dist/esm/modules/detection/P2PDominantSpeakerDetection.js +47 -0
  80. package/dist/esm/modules/detection/P2PDominantSpeakerDetection.js.map +1 -0
  81. package/dist/esm/modules/detection/TrackVADEmitter.js +190 -0
  82. package/dist/esm/modules/detection/TrackVADEmitter.js.map +1 -0
  83. package/dist/esm/modules/detection/VADAudioAnalyser.js +199 -0
  84. package/dist/esm/modules/detection/VADAudioAnalyser.js.map +1 -0
  85. package/dist/esm/modules/detection/VADNoiseDetection.js +168 -0
  86. package/dist/esm/modules/detection/VADNoiseDetection.js.map +1 -0
  87. package/dist/esm/modules/detection/VADReportingService.js +203 -0
  88. package/dist/esm/modules/detection/VADReportingService.js.map +1 -0
  89. package/dist/esm/modules/detection/VADTalkMutedDetection.js +131 -0
  90. package/dist/esm/modules/detection/VADTalkMutedDetection.js.map +1 -0
  91. package/dist/esm/modules/e2ee/Context.js +274 -0
  92. package/dist/esm/modules/e2ee/Context.js.map +1 -0
  93. package/dist/esm/modules/e2ee/E2EEContext.js +158 -0
  94. package/dist/esm/modules/e2ee/E2EEContext.js.map +1 -0
  95. package/dist/esm/modules/e2ee/E2EEErrors.js +10 -0
  96. package/dist/esm/modules/e2ee/E2EEErrors.js.map +1 -0
  97. package/dist/esm/modules/e2ee/E2EEncryption.js +87 -0
  98. package/dist/esm/modules/e2ee/E2EEncryption.js.map +1 -0
  99. package/dist/esm/modules/e2ee/ExternallyManagedKeyHandler.js +24 -0
  100. package/dist/esm/modules/e2ee/ExternallyManagedKeyHandler.js.map +1 -0
  101. package/dist/esm/modules/e2ee/KeyHandler.js +137 -0
  102. package/dist/esm/modules/e2ee/KeyHandler.js.map +1 -0
  103. package/dist/esm/modules/e2ee/ManagedKeyHandler.js +182 -0
  104. package/dist/esm/modules/e2ee/ManagedKeyHandler.js.map +1 -0
  105. package/dist/esm/modules/e2ee/OlmAdapter.js +860 -0
  106. package/dist/esm/modules/e2ee/OlmAdapter.js.map +1 -0
  107. package/dist/esm/modules/e2ee/SAS.js +128 -0
  108. package/dist/esm/modules/e2ee/SAS.js.map +1 -0
  109. package/dist/esm/modules/e2ee/Worker.js +102 -0
  110. package/dist/esm/modules/e2ee/Worker.js.map +1 -0
  111. package/dist/esm/modules/e2ee/crypto-utils.js +53 -0
  112. package/dist/esm/modules/e2ee/crypto-utils.js.map +1 -0
  113. package/dist/esm/modules/e2ee/utils.js +15 -0
  114. package/dist/esm/modules/e2ee/utils.js.map +1 -0
  115. package/dist/esm/modules/e2eping/e2eping.js +314 -0
  116. package/dist/esm/modules/e2eping/e2eping.js.map +1 -0
  117. package/dist/esm/modules/flags/FeatureFlags.js +36 -0
  118. package/dist/esm/modules/flags/FeatureFlags.js.map +1 -0
  119. package/dist/esm/modules/litemode/LiteModeContext.js +50 -0
  120. package/dist/esm/modules/litemode/LiteModeContext.js.map +1 -0
  121. package/dist/esm/modules/proxyconnection/CustomSignalingLayer.js +98 -0
  122. package/dist/esm/modules/proxyconnection/CustomSignalingLayer.js.map +1 -0
  123. package/dist/esm/modules/proxyconnection/ProxyConnectionPC.js +348 -0
  124. package/dist/esm/modules/proxyconnection/ProxyConnectionPC.js.map +1 -0
  125. package/dist/esm/modules/proxyconnection/ProxyConnectionService.js +279 -0
  126. package/dist/esm/modules/proxyconnection/ProxyConnectionService.js.map +1 -0
  127. package/dist/esm/modules/proxyconnection/constants.js +14 -0
  128. package/dist/esm/modules/proxyconnection/constants.js.map +1 -0
  129. package/dist/esm/modules/qualitycontrol/CodecSelection.js +222 -0
  130. package/dist/esm/modules/qualitycontrol/CodecSelection.js.map +1 -0
  131. package/dist/esm/modules/qualitycontrol/MockClasses.js +120 -0
  132. package/dist/esm/modules/qualitycontrol/MockClasses.js.map +1 -0
  133. package/dist/esm/modules/qualitycontrol/QualityController.js +366 -0
  134. package/dist/esm/modules/qualitycontrol/QualityController.js.map +1 -0
  135. package/dist/esm/modules/qualitycontrol/ReceiveAudioController.js +73 -0
  136. package/dist/esm/modules/qualitycontrol/ReceiveAudioController.js.map +1 -0
  137. package/dist/esm/modules/qualitycontrol/ReceiveVideoController.js +216 -0
  138. package/dist/esm/modules/qualitycontrol/ReceiveVideoController.js.map +1 -0
  139. package/dist/esm/modules/qualitycontrol/SendVideoController.js +133 -0
  140. package/dist/esm/modules/qualitycontrol/SendVideoController.js.map +1 -0
  141. package/dist/esm/modules/recording/JibriSession.js +279 -0
  142. package/dist/esm/modules/recording/JibriSession.js.map +1 -0
  143. package/dist/esm/modules/recording/RecordingManager.js +257 -0
  144. package/dist/esm/modules/recording/RecordingManager.js.map +1 -0
  145. package/dist/esm/modules/recording/recordingConstants.js +21 -0
  146. package/dist/esm/modules/recording/recordingConstants.js.map +1 -0
  147. package/dist/esm/modules/recording/recordingXMLUtils.js +69 -0
  148. package/dist/esm/modules/recording/recordingXMLUtils.js.map +1 -0
  149. package/dist/esm/modules/red/red.js +108 -0
  150. package/dist/esm/modules/red/red.js.map +1 -0
  151. package/dist/esm/modules/sdp/LocalSdpMunger.js +143 -0
  152. package/dist/esm/modules/sdp/LocalSdpMunger.js.map +1 -0
  153. package/dist/esm/modules/sdp/RtxModifier.js +179 -0
  154. package/dist/esm/modules/sdp/RtxModifier.js.map +1 -0
  155. package/dist/esm/modules/sdp/SDP.js +848 -0
  156. package/dist/esm/modules/sdp/SDP.js.map +1 -0
  157. package/dist/esm/modules/sdp/SDPDiffer.js +96 -0
  158. package/dist/esm/modules/sdp/SDPDiffer.js.map +1 -0
  159. package/dist/esm/modules/sdp/SDPUtil.js +798 -0
  160. package/dist/esm/modules/sdp/SDPUtil.js.map +1 -0
  161. package/dist/esm/modules/sdp/SampleSdpStrings.js +589 -0
  162. package/dist/esm/modules/sdp/SampleSdpStrings.js.map +1 -0
  163. package/dist/esm/modules/sdp/SdpSimulcast.js +196 -0
  164. package/dist/esm/modules/sdp/SdpSimulcast.js.map +1 -0
  165. package/dist/esm/modules/sdp/SdpTransformUtil.js +337 -0
  166. package/dist/esm/modules/sdp/SdpTransformUtil.js.map +1 -0
  167. package/dist/esm/modules/sdp/constants.js +2 -0
  168. package/dist/esm/modules/sdp/constants.js.map +1 -0
  169. package/dist/esm/modules/settings/Settings.js +95 -0
  170. package/dist/esm/modules/settings/Settings.js.map +1 -0
  171. package/dist/esm/modules/statistics/AnalyticsAdapter.js +277 -0
  172. package/dist/esm/modules/statistics/AnalyticsAdapter.js.map +1 -0
  173. package/dist/esm/modules/statistics/AvgRTPStatsReporter.js +817 -0
  174. package/dist/esm/modules/statistics/AvgRTPStatsReporter.js.map +1 -0
  175. package/dist/esm/modules/statistics/LocalStatsCollector.js +149 -0
  176. package/dist/esm/modules/statistics/LocalStatsCollector.js.map +1 -0
  177. package/dist/esm/modules/statistics/PreCallTest.js +15 -0
  178. package/dist/esm/modules/statistics/PreCallTest.js.map +1 -0
  179. package/dist/esm/modules/statistics/RTPStatsCollector.js +601 -0
  180. package/dist/esm/modules/statistics/RTPStatsCollector.js.map +1 -0
  181. package/dist/esm/modules/statistics/SpeakerStats.js +163 -0
  182. package/dist/esm/modules/statistics/SpeakerStats.js.map +1 -0
  183. package/dist/esm/modules/statistics/SpeakerStatsCollector.js +161 -0
  184. package/dist/esm/modules/statistics/SpeakerStatsCollector.js.map +1 -0
  185. package/dist/esm/modules/statistics/constants.js +7 -0
  186. package/dist/esm/modules/statistics/constants.js.map +1 -0
  187. package/dist/esm/modules/statistics/statistics.js +362 -0
  188. package/dist/esm/modules/statistics/statistics.js.map +1 -0
  189. package/dist/esm/modules/util/AsyncQueue.js +102 -0
  190. package/dist/esm/modules/util/AsyncQueue.js.map +1 -0
  191. package/dist/esm/modules/util/Deferred.js +41 -0
  192. package/dist/esm/modules/util/Deferred.js.map +1 -0
  193. package/dist/esm/modules/util/EventEmitter.js +17 -0
  194. package/dist/esm/modules/util/EventEmitter.js.map +1 -0
  195. package/dist/esm/modules/util/EventEmitterForwarder.js +52 -0
  196. package/dist/esm/modules/util/EventEmitterForwarder.js.map +1 -0
  197. package/dist/esm/modules/util/Listenable.js +106 -0
  198. package/dist/esm/modules/util/Listenable.js.map +1 -0
  199. package/dist/esm/modules/util/MathUtil.js +103 -0
  200. package/dist/esm/modules/util/MathUtil.js.map +1 -0
  201. package/dist/esm/modules/util/RandomUtil.js +66 -0
  202. package/dist/esm/modules/util/RandomUtil.js.map +1 -0
  203. package/dist/esm/modules/util/Retry.js +15 -0
  204. package/dist/esm/modules/util/Retry.js.map +1 -0
  205. package/dist/esm/modules/util/ScriptUtil.js +58 -0
  206. package/dist/esm/modules/util/ScriptUtil.js.map +1 -0
  207. package/dist/esm/modules/util/StringUtils.js +21 -0
  208. package/dist/esm/modules/util/StringUtils.js.map +1 -0
  209. package/dist/esm/modules/util/TestUtils.js +14 -0
  210. package/dist/esm/modules/util/TestUtils.js.map +1 -0
  211. package/dist/esm/modules/util/UsernameGenerator.js +436 -0
  212. package/dist/esm/modules/util/UsernameGenerator.js.map +1 -0
  213. package/dist/esm/modules/util/XMLUtils.js +135 -0
  214. package/dist/esm/modules/util/XMLUtils.js.map +1 -0
  215. package/dist/esm/modules/version/ComponentsVersions.js +52 -0
  216. package/dist/esm/modules/version/ComponentsVersions.js.map +1 -0
  217. package/dist/esm/modules/videosipgw/JitsiVideoSIPGWSession.js +137 -0
  218. package/dist/esm/modules/videosipgw/JitsiVideoSIPGWSession.js.map +1 -0
  219. package/dist/esm/modules/videosipgw/VideoSIPGW.js +102 -0
  220. package/dist/esm/modules/videosipgw/VideoSIPGW.js.map +1 -0
  221. package/dist/esm/modules/videosipgw/VideoSIPGWConstants.js +65 -0
  222. package/dist/esm/modules/videosipgw/VideoSIPGWConstants.js.map +1 -0
  223. package/dist/esm/modules/watchRTC/WatchRTC.js +69 -0
  224. package/dist/esm/modules/watchRTC/WatchRTC.js.map +1 -0
  225. package/dist/esm/modules/watchRTC/functions.js +31 -0
  226. package/dist/esm/modules/watchRTC/functions.js.map +1 -0
  227. package/dist/esm/modules/watchRTC/interfaces.js +2 -0
  228. package/dist/esm/modules/watchRTC/interfaces.js.map +1 -0
  229. package/dist/esm/modules/webaudio/AudioMixer.js +74 -0
  230. package/dist/esm/modules/webaudio/AudioMixer.js.map +1 -0
  231. package/dist/esm/modules/webaudio/WebAudioUtils.js +13 -0
  232. package/dist/esm/modules/webaudio/WebAudioUtils.js.map +1 -0
  233. package/dist/esm/modules/xmpp/AVModeration.js +156 -0
  234. package/dist/esm/modules/xmpp/AVModeration.js.map +1 -0
  235. package/dist/esm/modules/xmpp/BreakoutRooms.js +230 -0
  236. package/dist/esm/modules/xmpp/BreakoutRooms.js.map +1 -0
  237. package/dist/esm/modules/xmpp/Caps.js +223 -0
  238. package/dist/esm/modules/xmpp/Caps.js.map +1 -0
  239. package/dist/esm/modules/xmpp/ChatRoom.js +1877 -0
  240. package/dist/esm/modules/xmpp/ChatRoom.js.map +1 -0
  241. package/dist/esm/modules/xmpp/ConnectionPlugin.js +37 -0
  242. package/dist/esm/modules/xmpp/ConnectionPlugin.js.map +1 -0
  243. package/dist/esm/modules/xmpp/FileSharing.js +95 -0
  244. package/dist/esm/modules/xmpp/FileSharing.js.map +1 -0
  245. package/dist/esm/modules/xmpp/JingleHelperFunctions.js +168 -0
  246. package/dist/esm/modules/xmpp/JingleHelperFunctions.js.map +1 -0
  247. package/dist/esm/modules/xmpp/JingleSession.js +166 -0
  248. package/dist/esm/modules/xmpp/JingleSession.js.map +1 -0
  249. package/dist/esm/modules/xmpp/JingleSessionPC.js +1969 -0
  250. package/dist/esm/modules/xmpp/JingleSessionPC.js.map +1 -0
  251. package/dist/esm/modules/xmpp/JingleSessionState.js +23 -0
  252. package/dist/esm/modules/xmpp/JingleSessionState.js.map +1 -0
  253. package/dist/esm/modules/xmpp/Lobby.js +384 -0
  254. package/dist/esm/modules/xmpp/Lobby.js.map +1 -0
  255. package/dist/esm/modules/xmpp/MediaSessionEvents.js +12 -0
  256. package/dist/esm/modules/xmpp/MediaSessionEvents.js.map +1 -0
  257. package/dist/esm/modules/xmpp/MockClasses.js +77 -0
  258. package/dist/esm/modules/xmpp/MockClasses.js.map +1 -0
  259. package/dist/esm/modules/xmpp/Polls.js +87 -0
  260. package/dist/esm/modules/xmpp/Polls.js.map +1 -0
  261. package/dist/esm/modules/xmpp/ResumeTask.js +149 -0
  262. package/dist/esm/modules/xmpp/ResumeTask.js.map +1 -0
  263. package/dist/esm/modules/xmpp/RoomMetadata.js +96 -0
  264. package/dist/esm/modules/xmpp/RoomMetadata.js.map +1 -0
  265. package/dist/esm/modules/xmpp/SignalingLayerImpl.js +313 -0
  266. package/dist/esm/modules/xmpp/SignalingLayerImpl.js.map +1 -0
  267. package/dist/esm/modules/xmpp/StropheErrorHandler.js +53 -0
  268. package/dist/esm/modules/xmpp/StropheErrorHandler.js.map +1 -0
  269. package/dist/esm/modules/xmpp/StropheLastSuccess.js +52 -0
  270. package/dist/esm/modules/xmpp/StropheLastSuccess.js.map +1 -0
  271. package/dist/esm/modules/xmpp/XmppConnection.js +579 -0
  272. package/dist/esm/modules/xmpp/XmppConnection.js.map +1 -0
  273. package/dist/esm/modules/xmpp/moderator.js +524 -0
  274. package/dist/esm/modules/xmpp/moderator.js.map +1 -0
  275. package/dist/esm/modules/xmpp/sha1.js +165 -0
  276. package/dist/esm/modules/xmpp/sha1.js.map +1 -0
  277. package/dist/esm/modules/xmpp/strophe.disco.js +222 -0
  278. package/dist/esm/modules/xmpp/strophe.disco.js.map +1 -0
  279. package/dist/esm/modules/xmpp/strophe.emuc.js +206 -0
  280. package/dist/esm/modules/xmpp/strophe.emuc.js.map +1 -0
  281. package/dist/esm/modules/xmpp/strophe.jingle.js +404 -0
  282. package/dist/esm/modules/xmpp/strophe.jingle.js.map +1 -0
  283. package/dist/esm/modules/xmpp/strophe.logger.js +44 -0
  284. package/dist/esm/modules/xmpp/strophe.logger.js.map +1 -0
  285. package/dist/esm/modules/xmpp/strophe.ping.js +170 -0
  286. package/dist/esm/modules/xmpp/strophe.ping.js.map +1 -0
  287. package/dist/esm/modules/xmpp/strophe.rayo.js +117 -0
  288. package/dist/esm/modules/xmpp/strophe.rayo.js.map +1 -0
  289. package/dist/esm/modules/xmpp/strophe.stream-management.js +365 -0
  290. package/dist/esm/modules/xmpp/strophe.stream-management.js.map +1 -0
  291. package/dist/esm/modules/xmpp/strophe.util.js +116 -0
  292. package/dist/esm/modules/xmpp/strophe.util.js.map +1 -0
  293. package/dist/esm/modules/xmpp/xmpp.js +973 -0
  294. package/dist/esm/modules/xmpp/xmpp.js.map +1 -0
  295. package/dist/esm/service/RTC/BridgeVideoType.js +24 -0
  296. package/dist/esm/service/RTC/BridgeVideoType.js.map +1 -0
  297. package/dist/esm/service/RTC/CameraFacingMode.js +21 -0
  298. package/dist/esm/service/RTC/CameraFacingMode.js.map +1 -0
  299. package/dist/esm/service/RTC/CodecMimeType.js +36 -0
  300. package/dist/esm/service/RTC/CodecMimeType.js.map +1 -0
  301. package/dist/esm/service/RTC/MediaDirection.js +23 -0
  302. package/dist/esm/service/RTC/MediaDirection.js.map +1 -0
  303. package/dist/esm/service/RTC/MediaType.js +20 -0
  304. package/dist/esm/service/RTC/MediaType.js.map +1 -0
  305. package/dist/esm/service/RTC/RTCEvents.js +111 -0
  306. package/dist/esm/service/RTC/RTCEvents.js.map +1 -0
  307. package/dist/esm/service/RTC/ReceiverAudioSubscription.js +27 -0
  308. package/dist/esm/service/RTC/ReceiverAudioSubscription.js.map +1 -0
  309. package/dist/esm/service/RTC/Resolutions.js +56 -0
  310. package/dist/esm/service/RTC/Resolutions.js.map +1 -0
  311. package/dist/esm/service/RTC/SignalingEvents.js +42 -0
  312. package/dist/esm/service/RTC/SignalingEvents.js.map +1 -0
  313. package/dist/esm/service/RTC/SignalingLayer.js +153 -0
  314. package/dist/esm/service/RTC/SignalingLayer.js.map +1 -0
  315. package/dist/esm/service/RTC/StandardVideoQualitySettings.js +180 -0
  316. package/dist/esm/service/RTC/StandardVideoQualitySettings.js.map +1 -0
  317. package/dist/esm/service/RTC/VideoEncoderScalabilityMode.js +36 -0
  318. package/dist/esm/service/RTC/VideoEncoderScalabilityMode.js.map +1 -0
  319. package/dist/esm/service/RTC/VideoType.js +19 -0
  320. package/dist/esm/service/RTC/VideoType.js.map +1 -0
  321. package/dist/esm/service/authentication/AuthenticationEvents.js +13 -0
  322. package/dist/esm/service/authentication/AuthenticationEvents.js.map +1 -0
  323. package/dist/esm/service/connectivity/ConnectionQualityEvents.js +13 -0
  324. package/dist/esm/service/connectivity/ConnectionQualityEvents.js.map +1 -0
  325. package/dist/esm/service/connectivity/Constants.js +3 -0
  326. package/dist/esm/service/connectivity/Constants.js.map +1 -0
  327. package/dist/esm/service/e2eping/E2ePingEvents.js +8 -0
  328. package/dist/esm/service/e2eping/E2ePingEvents.js.map +1 -0
  329. package/dist/esm/service/statistics/AnalyticsEvents.js +521 -0
  330. package/dist/esm/service/statistics/AnalyticsEvents.js.map +1 -0
  331. package/dist/esm/service/statistics/Events.js +36 -0
  332. package/dist/esm/service/statistics/Events.js.map +1 -0
  333. package/dist/esm/service/statistics/constants.js +2 -0
  334. package/dist/esm/service/statistics/constants.js.map +1 -0
  335. package/dist/esm/service/xmpp/XMPPEvents.js +359 -0
  336. package/dist/esm/service/xmpp/XMPPEvents.js.map +1 -0
  337. package/dist/esm/service/xmpp/XMPPExtensioProtocols.js +64 -0
  338. package/dist/esm/service/xmpp/XMPPExtensioProtocols.js.map +1 -0
  339. package/dist/esm/test-setup-polyfill.js +34 -0
  340. package/dist/esm/test-setup-polyfill.js.map +1 -0
  341. package/dist/esm/tools/gen-version.js +15 -0
  342. package/dist/esm/tools/gen-version.js.map +1 -0
  343. package/dist/esm/version.js +3 -0
  344. package/dist/esm/version.js.map +1 -0
  345. package/dist/umd/lib-jitsi-meet.e2ee-worker.js +484 -0
  346. package/dist/umd/lib-jitsi-meet.min.js +3 -0
  347. package/dist/umd/lib-jitsi-meet.min.js.LICENSE.txt +18 -0
  348. package/dist/umd/lib-jitsi-meet.min.map +1 -0
  349. package/package.json +93 -0
  350. package/types/index.d.ts +16180 -0
@@ -0,0 +1,803 @@
1
+ import { getLogger } from '@jitsi/logger';
2
+ import { cloneDeep } from 'lodash-es';
3
+ import transform from 'sdp-transform';
4
+ import { CodecMimeType } from '../../service/RTC/CodecMimeType';
5
+ import { MediaDirection } from '../../service/RTC/MediaDirection';
6
+ import { MediaType } from '../../service/RTC/MediaType';
7
+ import { SIM_LAYERS, SSRC_GROUP_SEMANTICS, STANDARD_CODEC_SETTINGS, VIDEO_QUALITY_LEVELS, VIDEO_QUALITY_SETTINGS } from '../../service/RTC/StandardVideoQualitySettings';
8
+ import { VideoEncoderScalabilityMode } from '../../service/RTC/VideoEncoderScalabilityMode';
9
+ import { VideoType } from '../../service/RTC/VideoType';
10
+ import browser from '../browser';
11
+ import SDPUtil from '../sdp/SDPUtil';
12
+ const logger = getLogger('rtc:TPCUtils');
13
+ const VIDEO_CODECS = [CodecMimeType.AV1, CodecMimeType.H264, CodecMimeType.VP8, CodecMimeType.VP9];
14
+ /**
15
+ * Handles all the utility functions for the TraceablePeerConnection class, like calculating the encoding parameters,
16
+ * determining the media direction, calculating bitrates based on the current codec settings, etc.
17
+ */
18
+ export class TPCUtils {
19
+ /**
20
+ * Creates a new instance for a given TraceablePeerConnection
21
+ *
22
+ * @param peerconnection - the tpc instance for which we have utility functions.
23
+ * @param options - additional options that can be passed to the utility functions.
24
+ * @param options.audioQuality - the audio quality settings that are used to calculate the audio codec parameters.
25
+ * @param options.isP2P - whether the connection is a P2P connection.
26
+ * @param options.videoQuality - the video quality settings that are used to calculate the encoding parameters.
27
+ */
28
+ constructor(peerconnection, options = {}) {
29
+ this.pc = peerconnection;
30
+ this.options = options;
31
+ this.codecSettings = cloneDeep(STANDARD_CODEC_SETTINGS);
32
+ /**
33
+ * Reads videoQuality settings from config.js and overrides the code defaults for video codecs.
34
+ */
35
+ const videoQualitySettings = this.options.videoQuality;
36
+ if (videoQualitySettings) {
37
+ for (const codec of VIDEO_CODECS) {
38
+ const codecConfig = videoQualitySettings[codec];
39
+ const bitrateSettings = codecConfig?.maxBitratesVideo
40
+ // Read the deprecated settings for max bitrates.
41
+ ?? (videoQualitySettings?.maxbitratesvideo?.[codec.toUpperCase()]);
42
+ if (bitrateSettings) {
43
+ const settings = Object.values(VIDEO_QUALITY_SETTINGS);
44
+ [...settings, 'ssHigh'].forEach(value => {
45
+ if (bitrateSettings[value]) {
46
+ this.codecSettings[codec].maxBitratesVideo[value] = bitrateSettings[value];
47
+ }
48
+ });
49
+ }
50
+ if (!codecConfig) {
51
+ continue; // eslint-disable-line no-continue
52
+ }
53
+ const scalabilityModeEnabled = this.codecSettings[codec].scalabilityModeEnabled
54
+ && (typeof codecConfig.scalabilityModeEnabled === 'undefined'
55
+ || codecConfig.scalabilityModeEnabled);
56
+ if (scalabilityModeEnabled) {
57
+ typeof codecConfig.useSimulcast !== 'undefined'
58
+ && (this.codecSettings[codec].useSimulcast = codecConfig.useSimulcast);
59
+ typeof codecConfig.useKSVC !== 'undefined'
60
+ && (this.codecSettings[codec].useKSVC = codecConfig.useKSVC);
61
+ }
62
+ else {
63
+ this.codecSettings[codec].scalabilityModeEnabled = false;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ /**
69
+ * Calculates the configuration of the active encoding when the browser sends only one stream, i,e,, when there is
70
+ * no spatial scalability configure (p2p) or when it is running in full SVC mode.
71
+ *
72
+ * @param {JitsiLocalTrack} localVideoTrack - The local video track.
73
+ * @param {CodecMimeType} codec - The video codec.
74
+ * @param {number} newHeight - The resolution that needs to be configured for the local video track.
75
+ * @returns {Object} configuration.
76
+ * @private
77
+ */
78
+ _calculateActiveEncodingParams(localVideoTrack, codec, newHeight) {
79
+ const codecBitrates = this.codecSettings[codec].maxBitratesVideo;
80
+ const trackCaptureHeight = localVideoTrack.getCaptureResolution();
81
+ const effectiveNewHeight = newHeight > trackCaptureHeight ? trackCaptureHeight : newHeight;
82
+ const desktopShareBitrate = this.options.videoQuality?.desktopbitrate || codecBitrates.ssHigh;
83
+ const isScreenshare = localVideoTrack.getVideoType() === VideoType.DESKTOP;
84
+ let scalabilityMode = this.codecSettings[codec].useKSVC
85
+ ? VideoEncoderScalabilityMode.L3T3_KEY : VideoEncoderScalabilityMode.L3T3;
86
+ const { height, level } = VIDEO_QUALITY_LEVELS.find(lvl => lvl.height <= effectiveNewHeight);
87
+ let maxBitrate;
88
+ let scaleResolutionDownBy = SIM_LAYERS[2].scaleFactor;
89
+ if (this._isScreenshareBitrateCapped(localVideoTrack)) {
90
+ scalabilityMode = VideoEncoderScalabilityMode.L1T3;
91
+ maxBitrate = desktopShareBitrate;
92
+ }
93
+ else if (isScreenshare) {
94
+ maxBitrate = codecBitrates.ssHigh;
95
+ }
96
+ else {
97
+ maxBitrate = codecBitrates[level];
98
+ effectiveNewHeight && (scaleResolutionDownBy = trackCaptureHeight / effectiveNewHeight);
99
+ if (height !== effectiveNewHeight) {
100
+ logger.debug(`Quality level with height=${height} was picked when requested height=${newHeight} for`
101
+ + `track with capture height=${trackCaptureHeight}`);
102
+ }
103
+ }
104
+ const config = {
105
+ active: effectiveNewHeight > 0,
106
+ maxBitrate,
107
+ rid: undefined,
108
+ scalabilityMode,
109
+ scaleResolutionDownBy
110
+ };
111
+ if (!config.active || isScreenshare) {
112
+ return config;
113
+ }
114
+ // Configure the sender to send all 3 spatial layers for resolutions 720p and higher.
115
+ switch (level) {
116
+ case VIDEO_QUALITY_SETTINGS.ULTRA:
117
+ case VIDEO_QUALITY_SETTINGS.FULL:
118
+ case VIDEO_QUALITY_SETTINGS.HIGH:
119
+ config.scalabilityMode = this.codecSettings[codec].useKSVC
120
+ ? VideoEncoderScalabilityMode.L3T3_KEY : VideoEncoderScalabilityMode.L3T3;
121
+ break;
122
+ case VIDEO_QUALITY_SETTINGS.STANDARD:
123
+ config.scalabilityMode = this.codecSettings[codec].useKSVC
124
+ ? VideoEncoderScalabilityMode.L2T3_KEY : VideoEncoderScalabilityMode.L2T3;
125
+ break;
126
+ default:
127
+ config.scalabilityMode = VideoEncoderScalabilityMode.L1T3;
128
+ }
129
+ return config;
130
+ }
131
+ /**
132
+ * Returns the codecs in the current order of preference in the SDP provided.
133
+ *
134
+ * @param {SessionDescription} parsedSdp the parsed SDP object.
135
+ * @returns {Array<CodecMimeType>}
136
+ * @private
137
+ */
138
+ _getConfiguredVideoCodecsImpl(parsedSdp) {
139
+ const mLine = parsedSdp.media.find(m => m.type === MediaType.VIDEO);
140
+ const codecs = new Set(mLine.rtp
141
+ .filter(pt => pt.codec.toLowerCase() !== 'rtx')
142
+ .map(pt => pt.codec.toLowerCase()));
143
+ return Array.from(codecs);
144
+ }
145
+ /**
146
+ * The startup configuration for the stream encodings that are applicable to the video stream when a new sender is
147
+ * created on the peerconnection. The initial config takes into account the differences in browser's simulcast
148
+ * implementation.
149
+ *
150
+ * Encoding parameters:
151
+ * active - determine the on/off state of a particular encoding.
152
+ * maxBitrate - max. bitrate value to be applied to that particular encoding based on the encoding's resolution and
153
+ * config.js videoQuality settings if applicable.
154
+ * rid - Rtp Stream ID that is configured for a particular simulcast stream.
155
+ * scaleResolutionDownBy - the factor by which the encoding is scaled down from the original resolution of the
156
+ * captured video.
157
+ *
158
+ * @param {JitsiLocalTrack} localTrack - The local video track.
159
+ * @param {String} codec - The codec currently in use.
160
+ * @returns {Array<Object>} - The initial configuration for the stream encodings.
161
+ * @private
162
+ */
163
+ _getVideoStreamEncodings(localTrack, codec) {
164
+ const captureResolution = localTrack.getCaptureResolution();
165
+ const codecBitrates = this.codecSettings[codec].maxBitratesVideo;
166
+ const videoType = localTrack.getVideoType();
167
+ let effectiveScaleFactors = SIM_LAYERS.map(sim => sim.scaleFactor);
168
+ let cameraMaxbitrate;
169
+ if (videoType === VideoType.CAMERA) {
170
+ const { level } = VIDEO_QUALITY_LEVELS.find(lvl => lvl.height <= captureResolution);
171
+ cameraMaxbitrate = codecBitrates[level];
172
+ if (level === VIDEO_QUALITY_SETTINGS.ULTRA) {
173
+ effectiveScaleFactors[1] = 6.0; // 360p
174
+ effectiveScaleFactors[0] = 12.0; // 180p
175
+ }
176
+ else if (level === VIDEO_QUALITY_SETTINGS.FULL) {
177
+ effectiveScaleFactors[1] = 3.0; // 360p
178
+ effectiveScaleFactors[0] = 6.0; // 180p
179
+ }
180
+ }
181
+ const maxBitrate = videoType === VideoType.DESKTOP
182
+ ? codecBitrates.ssHigh : cameraMaxbitrate;
183
+ let effectiveBitrates = [codecBitrates.low, codecBitrates.standard, maxBitrate];
184
+ // The SSRCs on older versions of Firefox are reversed in SDP, i.e., they have resolution order of 1:2:4 as
185
+ // opposed to Chromium and other browsers. This has been reverted in Firefox 117 as part of the below commit.
186
+ // https://hg.mozilla.org/mozilla-central/rev/b0348f1f8d7197fb87158ba74542d28d46133997
187
+ // This revert seems to be applied only to camera tracks, the desktop stream encodings still have the
188
+ // resolution order of 4:2:1.
189
+ if (browser.isFirefox()
190
+ && !browser.supportsScalabilityModeAPI()
191
+ && (videoType === VideoType.DESKTOP || browser.isVersionLessThan(117))) {
192
+ effectiveBitrates = effectiveBitrates.reverse();
193
+ effectiveScaleFactors = effectiveScaleFactors.reverse();
194
+ }
195
+ const standardSimulcastEncodings = [
196
+ {
197
+ active: this.pc.videoTransferActive,
198
+ maxBitrate: effectiveBitrates[0],
199
+ rid: SIM_LAYERS[0].rid,
200
+ scaleResolutionDownBy: effectiveScaleFactors[0]
201
+ },
202
+ {
203
+ active: this.pc.videoTransferActive,
204
+ maxBitrate: effectiveBitrates[1],
205
+ rid: SIM_LAYERS[1].rid,
206
+ scaleResolutionDownBy: effectiveScaleFactors[1]
207
+ },
208
+ {
209
+ active: this.pc.videoTransferActive,
210
+ maxBitrate: effectiveBitrates[2],
211
+ rid: SIM_LAYERS[2].rid,
212
+ scaleResolutionDownBy: effectiveScaleFactors[2]
213
+ }
214
+ ];
215
+ if (this.codecSettings[codec].scalabilityModeEnabled) {
216
+ // Configure all 3 encodings when simulcast is requested through config.js for AV1 and VP9 and for H.264
217
+ // always since that is the only supported mode when DD header extension is negotiated for H.264.
218
+ if (this.codecSettings[codec].useSimulcast || codec === CodecMimeType.H264) {
219
+ for (const encoding of standardSimulcastEncodings) {
220
+ encoding.scalabilityMode = VideoEncoderScalabilityMode.L1T3;
221
+ }
222
+ return standardSimulcastEncodings;
223
+ }
224
+ // Configure only one encoding for the SVC mode.
225
+ return [
226
+ {
227
+ active: this.pc.videoTransferActive,
228
+ maxBitrate: effectiveBitrates[2],
229
+ rid: SIM_LAYERS[0].rid,
230
+ scalabilityMode: this.codecSettings[codec].useKSVC
231
+ ? VideoEncoderScalabilityMode.L3T3_KEY : VideoEncoderScalabilityMode.L3T3,
232
+ scaleResolutionDownBy: effectiveScaleFactors[2]
233
+ },
234
+ {
235
+ active: false,
236
+ maxBitrate: 0
237
+ },
238
+ {
239
+ active: false,
240
+ maxBitrate: 0
241
+ }
242
+ ];
243
+ }
244
+ return standardSimulcastEncodings;
245
+ }
246
+ /**
247
+ * Returns a boolean indicating whether the video encoder is running in full SVC mode, i.e., it sends only one
248
+ * video stream that has both temporal and spatial scalability.
249
+ *
250
+ * @param {CodecMimeType} codec - The video codec in use.
251
+ * @returns boolean - true if the video encoder is running in full SVC mode, false otherwise.
252
+ * @private
253
+ */
254
+ _isRunningInFullSvcMode(codec) {
255
+ return (codec === CodecMimeType.VP9 || codec === CodecMimeType.AV1)
256
+ && this.codecSettings[codec].scalabilityModeEnabled
257
+ && !this.codecSettings[codec].useSimulcast;
258
+ }
259
+ /**
260
+ * Returns a boolean indicating whether the bitrate needs to be capped for the local video track if it happens to
261
+ * be a screenshare track. The lower spatial layers for screensharing are disabled when low fps screensharing is in
262
+ * progress. Sending all three streams often results in the browser suspending the high resolution in low b/w and
263
+ * and low cpu conditions, especially on the low end machines. Suspending the low resolution streams ensures that
264
+ * the highest resolution stream is available always. Safari is an exception here since it does not send the
265
+ * desktop stream at all if only the high resolution stream is enabled.
266
+ *
267
+ * @param {JitsiLocalTrack} localVideoTrack - The local video track.
268
+ * @returns {boolean} - true if the bitrate needs to be capped for the screenshare track, false otherwise.
269
+ * @private
270
+ */
271
+ _isScreenshareBitrateCapped(localVideoTrack) {
272
+ return localVideoTrack.getVideoType() === VideoType.DESKTOP
273
+ && this.pc._capScreenshareBitrate
274
+ && !browser.isWebKitBased();
275
+ }
276
+ /**
277
+ * Returns the calculated active state of the stream encodings based on the frame height requested for the send
278
+ * stream. All the encodings that have a resolution lower than the frame height requested will be enabled.
279
+ *
280
+ * @param {JitsiLocalTrack} localVideoTrack The local video track.
281
+ * @param {CodecMimeType} codec - The codec currently in use.
282
+ * @param {number} newHeight The resolution requested for the video track.
283
+ * @returns {Array<boolean>}
284
+ * @internal
285
+ */
286
+ calculateEncodingsActiveState(localVideoTrack, codec, newHeight) {
287
+ const height = localVideoTrack.getCaptureResolution();
288
+ const videoStreamEncodings = this._getVideoStreamEncodings(localVideoTrack, codec);
289
+ const encodingsState = videoStreamEncodings
290
+ .map(encoding => height / encoding.scaleResolutionDownBy)
291
+ .map((frameHeight, idx) => {
292
+ let activeState = false;
293
+ // When video is suspended on the media session.
294
+ if (!this.pc.videoTransferActive) {
295
+ return activeState;
296
+ }
297
+ // Single video stream.
298
+ if (!this.pc.isSpatialScalabilityOn() || this._isRunningInFullSvcMode(codec)) {
299
+ const { active } = this._calculateActiveEncodingParams(localVideoTrack, codec, newHeight);
300
+ return idx === 0 ? active : activeState;
301
+ }
302
+ if (newHeight > 0) {
303
+ if (localVideoTrack.getVideoType() === VideoType.CAMERA) {
304
+ activeState = frameHeight <= newHeight
305
+ // Keep the LD stream enabled even when the LD stream's resolution is higher than of the
306
+ // requested resolution. This can happen when camera is captured at high resolutions like 4k
307
+ // but the requested resolution is 180. Since getParameters doesn't give us information about
308
+ // the resolutions of the simulcast encodings, we have to rely on our initial config for the
309
+ // simulcast streams.
310
+ || videoStreamEncodings[idx]?.scaleResolutionDownBy === SIM_LAYERS[0].scaleFactor;
311
+ }
312
+ else {
313
+ // For screenshare, keep the HD layer enabled always and the lower layers only for high fps
314
+ // screensharing.
315
+ activeState = videoStreamEncodings[idx].scaleResolutionDownBy === SIM_LAYERS[2].scaleFactor
316
+ || !this._isScreenshareBitrateCapped(localVideoTrack);
317
+ }
318
+ }
319
+ return activeState;
320
+ });
321
+ return encodingsState;
322
+ }
323
+ /**
324
+ * Returns the calculated max bitrates that need to be configured on the stream encodings based on the video
325
+ * type and other considerations associated with screenshare.
326
+ *
327
+ * @param {JitsiLocalTrack} localVideoTrack The local video track.
328
+ * @param {CodecMimeType} codec - The codec currently in use.
329
+ * @param {number} newHeight The resolution requested for the video track.
330
+ * @returns {Array<number>}
331
+ * @internal
332
+ */
333
+ calculateEncodingsBitrates(localVideoTrack, codec, newHeight) {
334
+ const codecBitrates = this.codecSettings[codec].maxBitratesVideo;
335
+ const desktopShareBitrate = this.options.videoQuality?.desktopbitrate || codecBitrates.ssHigh;
336
+ const encodingsBitrates = this._getVideoStreamEncodings(localVideoTrack, codec)
337
+ .map((encoding, idx) => {
338
+ let bitrate = encoding.maxBitrate;
339
+ // Single video stream.
340
+ if (!this.pc.isSpatialScalabilityOn() || this._isRunningInFullSvcMode(codec)) {
341
+ const { maxBitrate } = this._calculateActiveEncodingParams(localVideoTrack, codec, newHeight);
342
+ return idx === 0 ? maxBitrate : 0;
343
+ }
344
+ // Multiple video streams.
345
+ if (this._isScreenshareBitrateCapped(localVideoTrack)) {
346
+ bitrate = desktopShareBitrate;
347
+ }
348
+ return bitrate;
349
+ });
350
+ return encodingsBitrates;
351
+ }
352
+ /**
353
+ * Returns the calculated scalability modes for the video encodings when scalability modes are supported.
354
+ *
355
+ * @param {JitsiLocalTrack} localVideoTrack The local video track.
356
+ * @param {CodecMimeType} codec - The codec currently in use.
357
+ * @param {number} maxHeight The resolution requested for the video track.
358
+ * @returns {Optional<Array<VideoEncoderScalabilityMode>>}
359
+ * @internal
360
+ */
361
+ calculateEncodingsScalabilityMode(localVideoTrack, codec, maxHeight) {
362
+ if (!this.codecSettings[codec].scalabilityModeEnabled) {
363
+ return;
364
+ }
365
+ // Use LIT3 for P2P wherever its supported.
366
+ if (!this.pc.isSpatialScalabilityOn()) {
367
+ return [VideoEncoderScalabilityMode.L1T3];
368
+ }
369
+ // Default modes for simulcast.
370
+ const scalabilityModes = [
371
+ VideoEncoderScalabilityMode.L1T3,
372
+ VideoEncoderScalabilityMode.L1T3,
373
+ VideoEncoderScalabilityMode.L1T3
374
+ ];
375
+ // Full SVC mode.
376
+ if (this._isRunningInFullSvcMode(codec)) {
377
+ const { scalabilityMode } = this._calculateActiveEncodingParams(localVideoTrack, codec, maxHeight);
378
+ scalabilityModes[0] = scalabilityMode;
379
+ scalabilityModes[1] = undefined;
380
+ scalabilityModes[2] = undefined;
381
+ return scalabilityModes;
382
+ }
383
+ return scalabilityModes;
384
+ }
385
+ /**
386
+ * Returns the scale factor that needs to be applied on the local video stream based on the desired resolution
387
+ * and the codec in use.
388
+ *
389
+ * @param {JitsiLocalTrack} localVideoTrack The local video track.
390
+ * @param {CodecMimeType} codec - The codec currently in use.
391
+ * @param {number} maxHeight The resolution requested for the video track.
392
+ * @returns {Array<float>}
393
+ * @internal
394
+ */
395
+ calculateEncodingsScaleFactor(localVideoTrack, codec, maxHeight) {
396
+ if (this.pc.isSpatialScalabilityOn() && this.isRunningInSimulcastMode(codec)) {
397
+ return this._getVideoStreamEncodings(localVideoTrack, codec)
398
+ .map(encoding => encoding.scaleResolutionDownBy);
399
+ }
400
+ // Single video stream.
401
+ const { scaleResolutionDownBy } = this._calculateActiveEncodingParams(localVideoTrack, codec, maxHeight);
402
+ return [scaleResolutionDownBy, undefined, undefined];
403
+ }
404
+ /**
405
+ * Ensures that the ssrcs associated with a FID ssrc-group appear in the correct order, i.e., the primary ssrc
406
+ * first and the secondary rtx ssrc later. This is important for unified plan since we have only one FID group per
407
+ * media description.
408
+ * @param {Object} description the webRTC session description instance for the remote description.
409
+ * @returns {Object} the modified webRTC session description instance.
410
+ * @internal
411
+ */
412
+ ensureCorrectOrderOfSsrcs(description) {
413
+ const parsedSdp = transform.parse(description.sdp);
414
+ parsedSdp.media.forEach(mLine => {
415
+ if (mLine.type === MediaType.AUDIO) {
416
+ return;
417
+ }
418
+ if (!mLine.ssrcGroups?.length) {
419
+ return;
420
+ }
421
+ let reorderedSsrcs = [];
422
+ const ssrcs = new Set();
423
+ mLine.ssrcGroups.map(group => group.ssrcs
424
+ .split(' ')
425
+ .filter(Boolean)
426
+ .forEach(ssrc => ssrcs.add(ssrc)));
427
+ ssrcs.forEach(ssrc => {
428
+ const sources = mLine.ssrcs.filter(source => source.id.toString() === ssrc);
429
+ reorderedSsrcs = reorderedSsrcs.concat(sources);
430
+ });
431
+ mLine.ssrcs = reorderedSsrcs;
432
+ });
433
+ return new RTCSessionDescription({
434
+ sdp: transform.write(parsedSdp),
435
+ type: description.type
436
+ });
437
+ }
438
+ /**
439
+ * Returns the codec that is configured on the client as the preferred video codec for the given local video track.
440
+ *
441
+ * @param {JitsiLocalTrack} localTrack - The local video track.
442
+ * @returns {CodecMimeType} The codec that is set as the preferred codec for the given local video track.
443
+ * @internal
444
+ */
445
+ getConfiguredVideoCodec(localTrack) {
446
+ const localVideoTrack = localTrack ?? this.pc.getLocalVideoTracks()[0];
447
+ const rtpSender = this.pc.findSenderForTrack(localVideoTrack.getTrack());
448
+ if (this.pc.usesCodecSelectionAPI() && rtpSender) {
449
+ // added any to remove the subsequrnt @ts-ignore comments
450
+ const { encodings } = rtpSender.getParameters();
451
+ if (encodings[0].codec) {
452
+ return encodings[0].codec.mimeType.split('/')[1].toLowerCase();
453
+ }
454
+ }
455
+ const sdp = this.pc.remoteDescription?.sdp;
456
+ if (!sdp) {
457
+ return CodecMimeType.VP8;
458
+ }
459
+ const parsedSdp = transform.parse(sdp);
460
+ const mLine = parsedSdp.media
461
+ .find(m => m.mid.toString() === this.pc.localTrackTransceiverMids.get(localVideoTrack.rtcId));
462
+ const payload = mLine.payloads.split(' ')[0];
463
+ const { codec } = mLine.rtp.find(rtp => rtp.payload === Number(payload));
464
+ if (codec) {
465
+ return Object.values(CodecMimeType).find(value => value === codec.toLowerCase());
466
+ }
467
+ return CodecMimeType.VP8;
468
+ }
469
+ /**
470
+ * Returns the codecs in the current order of preference as configured on the peerconnection.
471
+ *
472
+ * @param {string} - The local SDP to be used.
473
+ * @returns {Array}
474
+ * @internal
475
+ */
476
+ getConfiguredVideoCodecs(sdp) {
477
+ const currentSdp = sdp ?? this.pc.localDescription?.sdp;
478
+ if (!currentSdp) {
479
+ return [];
480
+ }
481
+ const parsedSdp = transform.parse(currentSdp);
482
+ return this._getConfiguredVideoCodecsImpl(parsedSdp);
483
+ }
484
+ /**
485
+ * Returns the desired media direction for the given media type based on the current state of the peerconnection.
486
+ *
487
+ * @param {MediaType} mediaType - The media type for which the desired media direction is to be obtained.
488
+ * @param {boolean} isAddOperation - Whether the direction is being set for a source add operation.
489
+ * @returns {MediaDirection} - The desired media direction for the given media type.
490
+ * @internal
491
+ */
492
+ getDesiredMediaDirection(mediaType, isAddOperation = false) {
493
+ const hasLocalSource = this.pc.getLocalTracks(mediaType).length > 0;
494
+ if (isAddOperation) {
495
+ return hasLocalSource ? MediaDirection.SENDRECV : MediaDirection.SENDONLY;
496
+ }
497
+ return hasLocalSource ? MediaDirection.RECVONLY : MediaDirection.INACTIVE;
498
+ }
499
+ /**
500
+ * Obtains stream encodings that need to be configured on the given track based
501
+ * on the track media type and the simulcast setting.
502
+ * @param {JitsiLocalTrack} localTrack
503
+ * @internal
504
+ */
505
+ getStreamEncodings(localTrack) {
506
+ if (localTrack.isAudioTrack()) {
507
+ return [{ active: this.pc.audioTransferActive }];
508
+ }
509
+ const codec = this.getConfiguredVideoCodec(localTrack);
510
+ if (this.pc.isSpatialScalabilityOn()) {
511
+ return this._getVideoStreamEncodings(localTrack, codec);
512
+ }
513
+ return [{
514
+ active: this.pc.videoTransferActive,
515
+ maxBitrate: this.codecSettings[codec].maxBitratesVideo.high
516
+ }];
517
+ }
518
+ /**
519
+ * Injects a 'SIM' ssrc-group line for simulcast into the given session description object to make Jicofo happy.
520
+ * This is needed only for Firefox since it does not generate it when simulcast is enabled but we run the check
521
+ * on all browsers just in case as it would break the functionality otherwise.
522
+ *
523
+ * @param desc A session description object (with 'type' and 'sdp' fields)
524
+ * @return A session description object with its sdp field modified to contain an inject ssrc-group for simulcast.
525
+ * @internal
526
+ */
527
+ injectSsrcGroupForSimulcast(desc) {
528
+ const sdp = transform.parse(desc.sdp);
529
+ const video = sdp.media.find(mline => mline.type === 'video');
530
+ // Check if the browser supports RTX, add only the primary ssrcs to the SIM group if that is the case.
531
+ video.ssrcGroups = video.ssrcGroups || [];
532
+ const fidGroups = video.ssrcGroups.filter(group => group.semantics === SSRC_GROUP_SEMANTICS.FID);
533
+ if (video.simulcast || video.simulcast_03) {
534
+ const ssrcs = [];
535
+ if (fidGroups?.length) {
536
+ fidGroups.forEach(group => {
537
+ ssrcs.push(group.ssrcs.split(' ')[0]);
538
+ });
539
+ }
540
+ else {
541
+ video.ssrcs.forEach(ssrc => {
542
+ if (ssrc.attribute === 'msid') {
543
+ ssrcs.push(ssrc.id);
544
+ }
545
+ });
546
+ }
547
+ if (video.ssrcGroups.find(group => group.semantics === SSRC_GROUP_SEMANTICS.SIM)) {
548
+ // Group already exists, no need to do anything
549
+ return desc;
550
+ }
551
+ // Add a SIM group for every 3 FID groups.
552
+ for (let i = 0; i < ssrcs.length; i += 3) {
553
+ const simSsrcs = ssrcs.slice(i, i + 3);
554
+ video.ssrcGroups.push({
555
+ semantics: SSRC_GROUP_SEMANTICS.SIM,
556
+ ssrcs: simSsrcs.join(' ')
557
+ });
558
+ }
559
+ }
560
+ return new RTCSessionDescription({
561
+ sdp: transform.write(sdp),
562
+ type: desc.type
563
+ });
564
+ }
565
+ /**
566
+ * Takes in a *unified plan* offer and inserts the appropriate parameters for adding simulcast receive support.
567
+ * @param {Object} desc - A session description object
568
+ * @param {String} desc.type - the type (offer/answer)
569
+ * @param {String} desc.sdp - the sdp content
570
+ * @internal
571
+ * @return {Object} A session description (same format as above) object with its sdp field modified to advertise
572
+ * simulcast receive support.
573
+ */
574
+ insertUnifiedPlanSimulcastReceive(desc) {
575
+ // a=simulcast line is not needed on browsers where we SDP munging is used for enabling on simulcast.
576
+ // Remove this check when the client switches to RID/MID based simulcast on all browsers.
577
+ if (browser.usesSdpMungingForSimulcast()) {
578
+ return desc;
579
+ }
580
+ const rids = [
581
+ {
582
+ direction: 'recv',
583
+ id: SIM_LAYERS[0].rid
584
+ },
585
+ {
586
+ direction: 'recv',
587
+ id: SIM_LAYERS[1].rid
588
+ },
589
+ {
590
+ direction: 'recv',
591
+ id: SIM_LAYERS[2].rid
592
+ }
593
+ ];
594
+ const ridLine = rids.map(val => val.id).join(';');
595
+ const simulcastLine = `recv ${ridLine}`;
596
+ const sdp = transform.parse(desc.sdp);
597
+ const mLines = sdp.media.filter(m => m.type === MediaType.VIDEO);
598
+ const senderMids = Array.from(this.pc.localTrackTransceiverMids.values());
599
+ mLines.forEach((mLine, idx) => {
600
+ // Make sure the simulcast recv line is only set on video descriptions that are associated with senders.
601
+ if (senderMids.find(sender => mLine.mid.toString() === sender.toString()) || idx === 0) {
602
+ if (!mLine.simulcast_03 || !mLine.simulcast) {
603
+ mLine.rids = rids;
604
+ // eslint-disable-next-line camelcase
605
+ mLine.simulcast_03 = {
606
+ value: simulcastLine
607
+ };
608
+ }
609
+ }
610
+ else {
611
+ mLine.rids = undefined;
612
+ mLine.simulcast = undefined;
613
+ // eslint-disable-next-line camelcase
614
+ mLine.simulcast_03 = undefined;
615
+ }
616
+ });
617
+ return new RTCSessionDescription({
618
+ sdp: transform.write(sdp),
619
+ type: desc.type
620
+ });
621
+ }
622
+ /**
623
+ * Returns a boolean indicating whether the video encoder is running in Simulcast mode, i.e., three encodings need
624
+ * to be configured in 4:2:1 resolution order with temporal scalability.
625
+ *
626
+ * @param {CodecMimeType} videoCodec - The video codec in use.
627
+ * @returns {boolean}
628
+ * @internal
629
+ */
630
+ isRunningInSimulcastMode(videoCodec) {
631
+ if (!this.codecSettings?.[videoCodec]) {
632
+ // If codec settings are not available, assume no simulcast
633
+ return false;
634
+ }
635
+ return videoCodec === CodecMimeType.VP8 // VP8 always
636
+ // For FF: scalabilityModeEnabled is not supported and we have to use simulcast.
637
+ // For other browsers we use K-SVC mode for VP9 when no scalability mode is set. Although
638
+ // only one outbound-rtp stream is present, three separate encodings have to be configured.
639
+ || (!this.codecSettings[videoCodec].scalabilityModeEnabled && videoCodec === CodecMimeType.VP9)
640
+ // FF uses simulcast with AV1.
641
+ || (!this.codecSettings[videoCodec].scalabilityModeEnabled
642
+ && this.codecSettings[videoCodec].useSimulcast
643
+ && videoCodec === CodecMimeType.AV1)
644
+ // When scalability is enabled, always for H.264, and only when simulcast is explicitly enabled via
645
+ // config.js for VP9 and AV1 since full SVC is the default mode for these 2 codecs.
646
+ || (this.codecSettings[videoCodec].scalabilityModeEnabled
647
+ && (videoCodec === CodecMimeType.H264 || this.codecSettings[videoCodec].useSimulcast));
648
+ }
649
+ /**
650
+ * Munges the session description to ensure that the codec order is as per the preferred codec settings.
651
+ *
652
+ * @param {SessionDescription} parsedSdp that needs to be munged
653
+ * @returns {SessionDescription} the munged SDP.
654
+ * @internal
655
+ */
656
+ mungeCodecOrder(parsedSdp) {
657
+ const codecSettings = this.pc.codecSettings;
658
+ if (!codecSettings) {
659
+ return parsedSdp;
660
+ }
661
+ const mungedSdp = parsedSdp;
662
+ const { isP2P } = this.options;
663
+ const mLines = mungedSdp.media.filter(m => m.type === codecSettings.mediaType);
664
+ for (const mLine of mLines) {
665
+ const currentCodecs = this._getConfiguredVideoCodecsImpl(mungedSdp);
666
+ for (const codec of currentCodecs) {
667
+ if (isP2P) {
668
+ // 1. Strip the high profile H264 codecs on all clients. macOS started offering encoder for H.264
669
+ // level 5.2 but a decoder only for level 3.1. Therfore, strip all main and high level codecs for
670
+ // H.264.
671
+ // 2. There are multiple VP9 payload types generated by the browser, more payload types are added
672
+ // if the endpoint doesn't have a local video source. Therefore, strip all the high profile codec
673
+ // variants for VP9 so that only one payload type for VP9 is negotiated between the peers.
674
+ if (codec === CodecMimeType.H264 || codec === CodecMimeType.VP9) {
675
+ SDPUtil.stripCodec(mLine, codec, true /* high profile */);
676
+ }
677
+ // Do not negotiate ULPFEC and RED either.
678
+ if (codec === CodecMimeType.ULPFEC || codec === CodecMimeType.RED) {
679
+ SDPUtil.stripCodec(mLine, codec, false);
680
+ }
681
+ }
682
+ }
683
+ // Reorder the codecs based on the preferred settings.
684
+ if (!this.pc.usesCodecSelectionAPI()) {
685
+ for (const codec of codecSettings.codecList.slice().reverse()) {
686
+ SDPUtil.preferCodec(mLine, codec, isP2P);
687
+ }
688
+ }
689
+ }
690
+ return mungedSdp;
691
+ }
692
+ /**
693
+ * Munges the stereo flag as well as the opusMaxAverageBitrate in the SDP, based on values set through config.js,
694
+ * if present.
695
+ *
696
+ * @param {SessionDescription} parsedSdp that needs to be munged.
697
+ * @returns {SessionDescription} the munged SDP.
698
+ * @internal
699
+ */
700
+ mungeOpus(parsedSdp) {
701
+ const { audioQuality } = this.options;
702
+ if (!audioQuality?.enableOpusDtx && !audioQuality?.stereo && !audioQuality?.opusMaxAverageBitrate) {
703
+ return parsedSdp;
704
+ }
705
+ const mungedSdp = parsedSdp;
706
+ const mLines = mungedSdp.media.filter(m => m.type === MediaType.AUDIO);
707
+ for (const mLine of mLines) {
708
+ const { payload } = mLine.rtp.find(protocol => protocol.codec === CodecMimeType.OPUS);
709
+ if (!payload) {
710
+ // eslint-disable-next-line no-continue
711
+ continue;
712
+ }
713
+ let fmtpOpus = mLine.fmtp.find(protocol => protocol.payload === payload);
714
+ if (!fmtpOpus) {
715
+ fmtpOpus = {
716
+ config: '',
717
+ payload
718
+ };
719
+ }
720
+ const fmtpConfig = transform.parseParams(fmtpOpus.config);
721
+ let sdpChanged = false;
722
+ if (audioQuality?.stereo) {
723
+ fmtpConfig.stereo = 1;
724
+ sdpChanged = true;
725
+ }
726
+ if (audioQuality?.opusMaxAverageBitrate) {
727
+ fmtpConfig.maxaveragebitrate = audioQuality.opusMaxAverageBitrate;
728
+ sdpChanged = true;
729
+ }
730
+ // On Firefox, the OpusDtx enablement has no effect
731
+ if (!browser.isFirefox() && audioQuality?.enableOpusDtx) {
732
+ fmtpConfig.usedtx = 1;
733
+ sdpChanged = true;
734
+ }
735
+ if (!sdpChanged) {
736
+ // eslint-disable-next-line no-continue
737
+ continue;
738
+ }
739
+ let mungedConfig = '';
740
+ for (const key of Object.keys(fmtpConfig)) {
741
+ mungedConfig += `${key}=${fmtpConfig[key]}; `;
742
+ }
743
+ fmtpOpus.config = mungedConfig.trim();
744
+ }
745
+ return mungedSdp;
746
+ }
747
+ /**
748
+ * Munges the session SDP by setting the max bitrates on the video m-lines when VP9 K-SVC codec is in use.
749
+ *
750
+ * @param {SessionDescription} parsedSdp that needs to be munged.
751
+ * @param {boolean} isLocalSdp - Whether the max bitrate (via b=AS line in SDP) is set on local SDP.
752
+ * @returns {SessionDescription} The munged SDP.
753
+ * @internal
754
+ */
755
+ setMaxBitrates(parsedSdp, isLocalSdp = false) {
756
+ const pcCodecSettings = this.pc.codecSettings;
757
+ if (!pcCodecSettings) {
758
+ return parsedSdp;
759
+ }
760
+ // Find all the m-lines associated with the local sources.
761
+ const mungedSdp = parsedSdp;
762
+ const direction = isLocalSdp ? MediaDirection.RECVONLY : MediaDirection.SENDONLY;
763
+ const mLines = mungedSdp.media.filter(m => m.type === MediaType.VIDEO && m.direction !== direction);
764
+ const currentCodec = pcCodecSettings.codecList[0];
765
+ const codecScalabilityModeSettings = this.codecSettings[currentCodec];
766
+ for (const mLine of mLines) {
767
+ const isDoingVp9KSvc = currentCodec === CodecMimeType.VP9
768
+ && !codecScalabilityModeSettings.scalabilityModeEnabled;
769
+ const localTrack = this.pc.getLocalVideoTracks()
770
+ .find(track => this.pc.localTrackTransceiverMids.get(track.rtcId) === mLine.mid.toString());
771
+ if (localTrack
772
+ && (isDoingVp9KSvc
773
+ // Setting bitrates in the SDP for SVC codecs is no longer needed in the newer versions where
774
+ // maxBitrates from the RTCRtpEncodingParameters directly affect the target bitrate for the encoder.
775
+ || (this._isRunningInFullSvcMode(currentCodec) && !this.pc.usesCodecSelectionAPI()))) {
776
+ let maxBitrate;
777
+ if (localTrack.getVideoType() === VideoType.DESKTOP) {
778
+ maxBitrate = codecScalabilityModeSettings.maxBitratesVideo.ssHigh;
779
+ }
780
+ else {
781
+ const { level } = VIDEO_QUALITY_LEVELS.find(lvl => lvl.height <= localTrack.getCaptureResolution());
782
+ maxBitrate = codecScalabilityModeSettings.maxBitratesVideo[level];
783
+ }
784
+ const limit = Math.floor(maxBitrate / 1000);
785
+ // Use only the highest spatial layer bitrates for now as there is no API available yet for configuring
786
+ // the bitrates on the individual SVC layers.
787
+ mLine.bandwidth = [{
788
+ limit,
789
+ type: 'AS'
790
+ }];
791
+ }
792
+ else {
793
+ // Clear the bandwidth limit in SDP when VP9 is no longer the preferred codec.
794
+ // This is needed on react native clients as react-native-webrtc returns the
795
+ // SDP that the application passed instead of returning the SDP off the native side.
796
+ // This line automatically gets cleared on web on every renegotiation.
797
+ mLine.bandwidth = undefined;
798
+ }
799
+ }
800
+ return mungedSdp;
801
+ }
802
+ }
803
+ //# sourceMappingURL=TPCUtils.js.map