@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,798 @@
1
+ import { getLogger } from '@jitsi/logger';
2
+ import { CodecMimeType } from '../../service/RTC/CodecMimeType';
3
+ import { MediaDirection } from '../../service/RTC/MediaDirection';
4
+ import { SSRC_GROUP_SEMANTICS } from '../../service/RTC/StandardVideoQualitySettings';
5
+ import browser from '../browser';
6
+ import RandomUtil from '../util/RandomUtil';
7
+ const logger = getLogger('sdp:SDPUtils');
8
+ const SDPUtil = {
9
+ /**
10
+ * Builds an ICE candidate line for SDP.
11
+ *
12
+ * @param {IICECandidate} cand - The ICE candidate object.
13
+ * @returns {string} - The SDP line for the ICE candidate.
14
+ */
15
+ buildICECandidate(cand) {
16
+ let line = [
17
+ `a=candidate:${cand.foundation}`,
18
+ cand.component,
19
+ cand.protocol,
20
+ cand.priority,
21
+ cand.ip,
22
+ cand.port,
23
+ 'typ',
24
+ cand.type
25
+ ].join(' ');
26
+ line += ' ';
27
+ switch (cand.type) {
28
+ case 'srflx':
29
+ case 'prflx':
30
+ case 'relay':
31
+ if (cand.hasOwnAttribute('rel-addr')
32
+ && cand.hasOwnAttribute('rel-port')) {
33
+ line += 'raddr';
34
+ line += ' ';
35
+ line += cand['rel-addr'];
36
+ line += ' ';
37
+ line += 'rport';
38
+ line += ' ';
39
+ line += cand['rel-port'];
40
+ line += ' ';
41
+ }
42
+ break;
43
+ }
44
+ if (cand.hasOwnAttribute('tcptype')) {
45
+ line += 'tcptype';
46
+ line += ' ';
47
+ line += cand.tcptype;
48
+ line += ' ';
49
+ }
50
+ line += 'generation';
51
+ line += ' ';
52
+ line += cand.hasOwnAttribute('generation') ? cand.generation : '0';
53
+ return line;
54
+ },
55
+ /**
56
+ * Builds an ICE password line for SDP.
57
+ *
58
+ * @param {string} pwd - The ICE password.
59
+ * @returns {string} - The SDP line for the ICE password.
60
+ */
61
+ buildICEPwd(pwd) {
62
+ return `a=ice-pwd:${pwd}`;
63
+ },
64
+ /**
65
+ * Builds an ICE ufrag line for SDP.
66
+ *
67
+ * @param {string} frag - The ICE ufrag.
68
+ * @returns {string} - The SDP line for the ICE ufrag.
69
+ */
70
+ buildICEUfrag(frag) {
71
+ return `a=ice-ufrag:${frag}`;
72
+ },
73
+ /**
74
+ * Builds an SDP media line.
75
+ *
76
+ * @param {IMediaLine} mline - The media line object.
77
+ * @returns {string} - The SDP media line.
78
+ */
79
+ buildMLine(mline) {
80
+ return (`m=${mline.media} ${mline.port} ${mline.proto} ${mline.fmt.join(' ')}`);
81
+ },
82
+ /**
83
+ * Builds an RTP map line for SDP.
84
+ *
85
+ * @param {Element} el - The RTP map element.
86
+ * @returns {String} - The SDP line for the RTP map.
87
+ */
88
+ buildRTPMap(el) {
89
+ let line = `a=rtpmap:${el.getAttribute('id')} ${el.getAttribute('name')}/${el.getAttribute('clockrate')}`;
90
+ if (el.getAttribute('channels')
91
+ && el.getAttribute('channels') !== '1') {
92
+ line += `/${el.getAttribute('channels')}`;
93
+ }
94
+ return line;
95
+ },
96
+ /**
97
+ * Builds an ICE candidate line for SDP.
98
+ *
99
+ * @param {Element} cand - The ICE candidate object.
100
+ * @returns {string} - The SDP line for the ICE candidate.
101
+ */
102
+ candidateFromJingle(cand) {
103
+ let line = 'a=candidate:';
104
+ line += cand.getAttribute('foundation');
105
+ line += ' ';
106
+ line += cand.getAttribute('component');
107
+ line += ' ';
108
+ let protocol = cand.getAttribute('protocol');
109
+ // use tcp candidates for FF
110
+ if (browser.isFirefox() && protocol.toLowerCase() === 'ssltcp') {
111
+ protocol = 'tcp';
112
+ }
113
+ line += protocol; // .toUpperCase(); // chrome M23 doesn't like this
114
+ line += ' ';
115
+ line += cand.getAttribute('priority');
116
+ line += ' ';
117
+ line += cand.getAttribute('ip');
118
+ line += ' ';
119
+ line += cand.getAttribute('port');
120
+ line += ' ';
121
+ line += 'typ';
122
+ line += ` ${cand.getAttribute('type')}`;
123
+ line += ' ';
124
+ switch (cand.getAttribute('type')) {
125
+ case 'srflx':
126
+ case 'prflx':
127
+ case 'relay':
128
+ if (cand.getAttribute('rel-addr')
129
+ && cand.getAttribute('rel-port')) {
130
+ line += 'raddr';
131
+ line += ' ';
132
+ line += cand.getAttribute('rel-addr');
133
+ line += ' ';
134
+ line += 'rport';
135
+ line += ' ';
136
+ line += cand.getAttribute('rel-port');
137
+ line += ' ';
138
+ }
139
+ break;
140
+ }
141
+ if (protocol.toLowerCase() === 'tcp') {
142
+ line += 'tcptype';
143
+ line += ' ';
144
+ line += cand.getAttribute('tcptype');
145
+ line += ' ';
146
+ }
147
+ line += 'generation';
148
+ line += ' ';
149
+ line += cand.getAttribute('generation') || '0';
150
+ return `${line}\r\n`;
151
+ },
152
+ /**
153
+ * Builds an ICE candidate from SDP.
154
+ *
155
+ * @param {string} line - The SDP line for the ICE candidate.
156
+ * @returns {Nullable<IICECandidate>} - The Jingle XML representation of the ICE candidate.
157
+ */
158
+ candidateToJingle(line) {
159
+ // a=candidate:2979166662 1 udp 2113937151 192.168.2.100 57698 typ host
160
+ // generation 0
161
+ // <candidate component=... foundation=... generation=... id=...
162
+ // ip=... network=... port=... priority=... protocol=... type=.../>
163
+ if (line.indexOf('candidate:') === 0) {
164
+ // eslint-disable-next-line no-param-reassign
165
+ line = `a=${line}`;
166
+ }
167
+ else if (line.substring(0, 12) !== 'a=candidate:') {
168
+ logger.warn('parseCandidate called with a line that is not a candidate'
169
+ + ' line');
170
+ logger.warn(line);
171
+ return null;
172
+ }
173
+ if (line.substring(line.length - 2) === '\r\n') { // chomp it
174
+ // eslint-disable-next-line no-param-reassign
175
+ line = line.substring(0, line.length - 2);
176
+ }
177
+ const candidate = {};
178
+ const elems = line.split(' ');
179
+ if (elems[6] !== 'typ') {
180
+ logger.warn('did not find typ in the right place');
181
+ logger.warn(line);
182
+ return null;
183
+ }
184
+ candidate.foundation = elems[0].substring(12);
185
+ candidate.component = elems[1];
186
+ candidate.protocol = elems[2].toLowerCase();
187
+ candidate.priority = elems[3];
188
+ candidate.ip = elems[4];
189
+ candidate.port = elems[5];
190
+ // elems[6] => "typ"
191
+ candidate.type = elems[7];
192
+ candidate.generation = '0'; // default, may be overwritten below
193
+ for (let i = 8; i < elems.length; i += 2) {
194
+ switch (elems[i]) {
195
+ case 'raddr':
196
+ candidate['rel-addr'] = elems[i + 1];
197
+ break;
198
+ case 'rport':
199
+ candidate['rel-port'] = elems[i + 1];
200
+ break;
201
+ case 'generation':
202
+ candidate.generation = elems[i + 1];
203
+ break;
204
+ case 'tcptype':
205
+ candidate.tcptype = elems[i + 1];
206
+ break;
207
+ default: // TODO
208
+ logger.debug(`not translating "${elems[i]}" = "${elems[i + 1]}"`);
209
+ }
210
+ }
211
+ candidate.network = '1';
212
+ // not applicable to SDP -- FIXME: should be unique, not just random
213
+ // eslint-disable-next-line newline-per-chained-call
214
+ candidate.id = Math.random().toString(36).substr(2, 10);
215
+ return candidate;
216
+ },
217
+ filterSpecialChars(text) {
218
+ // XXX Neither one of the falsy values (e.g. null, undefined, false,
219
+ // "", etc.) "contain" special chars.
220
+ // eslint-disable-next-line no-useless-escape
221
+ return text ? text.replace(/[\\\/\{,\}\+]/g, '') : text;
222
+ },
223
+ /**
224
+ * Finds a line in the SDP that starts with the given search pattern.
225
+ *
226
+ * @param {string} haystack - The SDP string to search.
227
+ * @param {string} needle - The line prefix to find.
228
+ * @param {string} sessionpart - The session part to search within.
229
+ * @returns {Optional<string>} - The found line or false if not found.
230
+ */
231
+ findLine(haystack, needle, sessionpart) {
232
+ let lines = haystack.split('\r\n');
233
+ for (let i = 0; i < lines.length; i++) {
234
+ if (lines[i].substring(0, needle.length) === needle) {
235
+ return lines[i];
236
+ }
237
+ }
238
+ if (!sessionpart) {
239
+ return undefined;
240
+ }
241
+ // search session part
242
+ lines = sessionpart.split('\r\n');
243
+ for (let j = 0; j < lines.length; j++) {
244
+ if (lines[j].substring(0, needle.length) === needle) {
245
+ return lines[j];
246
+ }
247
+ }
248
+ return undefined;
249
+ },
250
+ /**
251
+ * Finds all lines in the SDP that start with the given search pattern.
252
+ *
253
+ * @param {string} haystack - The SDP string to search.
254
+ * @param {string} needle - The line prefix to find.
255
+ * @param {string} sessionpart - The session part to search within.
256
+ * @returns {string[]} - An array of found lines.
257
+ */
258
+ findLines(haystack, needle, sessionpart) {
259
+ let lines = haystack.split('\r\n');
260
+ const needles = [];
261
+ for (let i = 0; i < lines.length; i++) {
262
+ if (lines[i].substring(0, needle.length) === needle) {
263
+ needles.push(lines[i]);
264
+ }
265
+ }
266
+ if (needles.length || !sessionpart) {
267
+ return needles;
268
+ }
269
+ // search session part
270
+ lines = sessionpart.split('\r\n');
271
+ for (let j = 0; j < lines.length; j++) {
272
+ if (lines[j].substring(0, needle.length) === needle) {
273
+ needles.push(lines[j]);
274
+ }
275
+ }
276
+ return needles;
277
+ },
278
+ /**
279
+ * Generates a random SSRC value.
280
+ *
281
+ * @returns {number} - A random SSRC value.
282
+ */
283
+ generateSsrc() {
284
+ return RandomUtil.randomInt(1, 0xffffffff);
285
+ },
286
+ /**
287
+ * Gets the SSRC attribute value from the media line.
288
+ *
289
+ * @param {MediaDescription} mLine - The media line object.
290
+ * @param {number} ssrc - The SSRC value to search for.
291
+ * @param {string} attributeName - The attribute name to search for.
292
+ * @returns {string|null} - The attribute value or null if not found.
293
+ */
294
+ getSsrcAttribute(mLine, ssrc, attributeName) {
295
+ for (let i = 0; i < mLine.ssrcs.length; ++i) {
296
+ const ssrcLine = mLine.ssrcs[i];
297
+ if (ssrcLine.id === ssrc
298
+ && ssrcLine.attribute === attributeName) {
299
+ return ssrcLine.value;
300
+ }
301
+ }
302
+ },
303
+ /**
304
+ * Gets the ICE ufrag from the SDP.
305
+ *
306
+ * @param {string} sdp - The SDP string to search.
307
+ * @returns {Optional<string>} - The ICE ufrag value or undefined if not found.
308
+ */
309
+ getUfrag(sdp) {
310
+ const ufragLines = sdp.split('\n').filter(line => line.startsWith('a=ice-ufrag:'));
311
+ if (ufragLines.length > 0) {
312
+ return ufragLines[0].substr('a=ice-ufrag:'.length);
313
+ }
314
+ },
315
+ /**
316
+ * Gets the ICE parameters from the media description and session description.
317
+ *
318
+ * @param {string} mediadesc - The media description string.
319
+ * @param {string} sessiondesc - The session description string.
320
+ * @returns {Nullable<IICEParams>} - The ICE parameters object or null if not found.
321
+ */
322
+ iceparams(mediadesc, sessiondesc) {
323
+ let data = null;
324
+ let pwd, ufrag;
325
+ if ((ufrag = SDPUtil.findLine(mediadesc, 'a=ice-ufrag:', sessiondesc))
326
+ && (pwd
327
+ = SDPUtil.findLine(mediadesc, 'a=ice-pwd:', sessiondesc))) {
328
+ data = {
329
+ pwd: SDPUtil.parseICEPwd(pwd),
330
+ ufrag: SDPUtil.parseICEUfrag(ufrag)
331
+ };
332
+ }
333
+ return data;
334
+ },
335
+ /**
336
+ * Parses a crypto line from the SDP.
337
+ *
338
+ * @param {string} line - The crypto line to parse.
339
+ * @returns {ICryptoData} - The parsed crypto parameters.
340
+ */
341
+ parseCrypto(line) {
342
+ const data = {};
343
+ const parts = line.substring(9).split(' ');
344
+ data.tag = parts.shift();
345
+ data['crypto-suite'] = parts.shift();
346
+ data['key-params'] = parts.shift();
347
+ if (parts.length) {
348
+ data['session-params'] = parts.join(' ');
349
+ }
350
+ return data;
351
+ },
352
+ /**
353
+ * Parses an extmap line from the SDP.
354
+ *
355
+ * @param {string} line - The extmap line to parse.
356
+ * @returns {IExtmapData} - The parsed extmap parameters.
357
+ */
358
+ parseExtmap(line) {
359
+ const parts = line.substr(9).split(' ');
360
+ const data = {};
361
+ data.value = parts.shift();
362
+ if (data.value.indexOf('/') === -1) {
363
+ data.direction = 'both';
364
+ }
365
+ else {
366
+ data.direction = data.value.substr(data.value.indexOf('/') + 1);
367
+ data.value = data.value.substr(0, data.value.indexOf('/'));
368
+ }
369
+ data.uri = parts.shift();
370
+ data.params = parts;
371
+ return data;
372
+ },
373
+ /**
374
+ * Parses a fingerprint line from the SDP.
375
+ *
376
+ * @param {string} line - The fingerprint line to parse.
377
+ * @returns {IFingerprintData} - The parsed fingerprint parameters.
378
+ */
379
+ parseFingerprint(line) {
380
+ const data = {};
381
+ const parts = line.substring(14).split(' ');
382
+ data.hash = parts.shift();
383
+ data.fingerprint = parts.shift();
384
+ // TODO assert that fingerprint satisfies 2UHEX *(":" 2UHEX) ?
385
+ return data;
386
+ },
387
+ /**
388
+ * Parses a fmtp line from the SDP.
389
+ *
390
+ * @param {string} line - The fmtp line to parse.
391
+ * @returns {IFmtpParameter[]} - The parsed fmtp parameters.
392
+ */
393
+ parseFmtp(line) {
394
+ const data = [];
395
+ let parts = line.split(' ');
396
+ parts.shift();
397
+ parts = parts.join(' ').split(';');
398
+ for (let i = 0; i < parts.length; i++) {
399
+ let key = parts[i].split('=')[0];
400
+ while (key.length && key[0] === ' ') {
401
+ key = key.substring(1);
402
+ }
403
+ const value = parts[i].split('=')[1];
404
+ if (key && value) {
405
+ data.push({ name: key,
406
+ value });
407
+ }
408
+ else if (key) {
409
+ // rfc 4733 (DTMF) style stuff
410
+ data.push({ name: '',
411
+ value: key });
412
+ }
413
+ }
414
+ return data;
415
+ },
416
+ /**
417
+ * Parses the SSRCs from a group description.
418
+ *
419
+ * @param {MediaDescription['ssrcGroups'][number]} ssrcGroup - The SSRC group object.
420
+ * @returns {number[]} - The list of SSRCs in the group.
421
+ */
422
+ parseGroupSsrcs(ssrcGroup) {
423
+ return ssrcGroup
424
+ .ssrcs
425
+ .split(' ')
426
+ .map(ssrcStr => parseInt(ssrcStr, 10));
427
+ },
428
+ /**
429
+ * Parses an ICE candidate line from the SDP.
430
+ *
431
+ * @param {string} line - The ICE candidate line to parse.
432
+ * @returns {IICECandidate} - The parsed ICE candidate parameters.
433
+ */
434
+ parseICECandidate(line) {
435
+ const candidate = {};
436
+ const elems = line.split(' ');
437
+ candidate.foundation = elems[0].substring(12);
438
+ candidate.component = elems[1];
439
+ candidate.protocol = elems[2].toLowerCase();
440
+ candidate.priority = elems[3];
441
+ candidate.ip = elems[4];
442
+ candidate.port = elems[5];
443
+ // elems[6] => "typ"
444
+ candidate.type = elems[7];
445
+ candidate.generation = '0'; // default value, may be overwritten below
446
+ for (let i = 8; i < elems.length; i += 2) {
447
+ switch (elems[i]) {
448
+ case 'raddr':
449
+ candidate['rel-addr'] = elems[i + 1];
450
+ break;
451
+ case 'rport':
452
+ candidate['rel-port'] = elems[i + 1];
453
+ break;
454
+ case 'generation':
455
+ candidate.generation = elems[i + 1];
456
+ break;
457
+ case 'tcptype':
458
+ candidate.tcptype = elems[i + 1];
459
+ break;
460
+ default: // TODO
461
+ logger.debug(`parseICECandidate not translating "${elems[i]}" = "${elems[i + 1]}"`);
462
+ }
463
+ }
464
+ candidate.network = '1';
465
+ // not applicable to SDP -- FIXME: should be unique, not just random
466
+ // eslint-disable-next-line newline-per-chained-call
467
+ candidate.id = Math.random().toString(36).substr(2, 10);
468
+ return candidate;
469
+ },
470
+ /**
471
+ * Parses an ICE password line from the SDP.
472
+ *
473
+ * @param {string} line - The ICE password line to parse.
474
+ * @returns {string} - The parsed ICE password.
475
+ */
476
+ parseICEPwd(line) {
477
+ return line.substring(10);
478
+ },
479
+ /**
480
+ * Parses an ICE ufrag line from the SDP.
481
+ *
482
+ * @param {string} line - The ICE ufrag line to parse.
483
+ * @returns {string} - The parsed ICE ufrag.
484
+ */
485
+ parseICEUfrag(line) {
486
+ return line.substring(12);
487
+ },
488
+ /**
489
+ * Parses a media ID line from the SDP.
490
+ *
491
+ * @param {string} line - The media ID line to parse.
492
+ * @returns {string} - The parsed media ID.
493
+ */
494
+ parseMID(line) {
495
+ return line.substring(6);
496
+ },
497
+ /**
498
+ * Parses a media line from the SDP.
499
+ *
500
+ * @param {string} line - The media line to parse.
501
+ * @returns {IMediaLine} - The parsed media line data.
502
+ */
503
+ parseMLine(line) {
504
+ const data = {};
505
+ const parts = line.substring(2).split(' ');
506
+ data.media = parts.shift();
507
+ data.port = parts.shift();
508
+ data.proto = parts.shift();
509
+ if (parts[parts.length - 1] === '') { // trailing whitespace
510
+ parts.pop();
511
+ }
512
+ data.fmt = parts;
513
+ return data;
514
+ },
515
+ /**
516
+ * Parses the MSID attribute from the given SSRC lines.
517
+ *
518
+ * @param {string[]} ssrcLines - The SSRC lines to search.
519
+ * @returns {Optional<string>} - The parsed MSID or undefined if not found.
520
+ */
521
+ parseMSIDAttribute(ssrcLines) {
522
+ const msidLine = ssrcLines.find(line => line.indexOf(' msid:') > 0);
523
+ if (!msidLine) {
524
+ return undefined;
525
+ }
526
+ const v = msidLine.substring(msidLine.indexOf(' msid:') + 6 /* the length of ' msid:' */);
527
+ return SDPUtil.filterSpecialChars(v);
528
+ },
529
+ /**
530
+ * Parse the 'most' primary video ssrc from the given m line
531
+ * @param {MediaDescription} videoMLine object as parsed from transform.parse
532
+ * @return {Optional<number>} the primary video ssrc from the given m line
533
+ */
534
+ parsePrimaryVideoSsrc(videoMLine) {
535
+ const numSsrcs = (videoMLine.ssrcs)
536
+ .map(ssrcInfo => ssrcInfo.id)
537
+ .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
538
+ .length;
539
+ const numGroups = (videoMLine?.ssrcGroups?.length) || 0;
540
+ if (numSsrcs > 1 && numGroups === 0) {
541
+ // Ambiguous, can't figure out the primary
542
+ return;
543
+ }
544
+ let primarySsrc = null;
545
+ if (numSsrcs === 1) {
546
+ primarySsrc = videoMLine.ssrcs[0].id;
547
+ }
548
+ else if (numSsrcs === 2) {
549
+ // Can figure it out if there's an FID group
550
+ const fidGroup = videoMLine.ssrcGroups.find(group => group.semantics === SSRC_GROUP_SEMANTICS.FID);
551
+ if (fidGroup) {
552
+ primarySsrc = parseInt(fidGroup.ssrcs.split(' ')[0], 10);
553
+ }
554
+ }
555
+ else if (numSsrcs >= 3) {
556
+ // Can figure it out if there's a sim group
557
+ const simGroup = videoMLine.ssrcGroups.find(group => group.semantics === SSRC_GROUP_SEMANTICS.SIM);
558
+ if (simGroup) {
559
+ primarySsrc = parseInt(simGroup.ssrcs.split(' ')[0], 10);
560
+ }
561
+ }
562
+ return primarySsrc;
563
+ },
564
+ /**
565
+ * Parses an RTCP feedback line from the SDP.
566
+ *
567
+ * @param {string} line - The RTCP feedback line to parse.
568
+ * @returns {IRTCPFBData} - The parsed RTCP feedback data.
569
+ */
570
+ parseRTCPFB(line) {
571
+ const parts = line.substr(10).split(' ');
572
+ const data = {};
573
+ data.pt = parts.shift();
574
+ data.type = parts.shift();
575
+ data.params = parts;
576
+ return data;
577
+ },
578
+ /**
579
+ * Parses an RTP map line from the SDP.
580
+ *
581
+ * @param {string} line - The RTP map line to parse.
582
+ * @returns {IRTPMapData} - The parsed RTP map data.
583
+ */
584
+ parseRTPMap(line) {
585
+ const data = {};
586
+ let parts = line.substring(9).split(' ');
587
+ data.id = parts.shift();
588
+ parts = parts[0].split('/');
589
+ data.name = parts.shift();
590
+ data.clockrate = parts.shift();
591
+ data.channels = parts.length ? parts.shift() : '1';
592
+ return data;
593
+ },
594
+ /**
595
+ * Parses SDP line "a=sctpmap:..." and extracts SCTP port from it.
596
+ *
597
+ * @param {string} line eg. "a=sctpmap:5000 webrtc-datachannel"
598
+ * @returns {[string, string, Nullable<string>]} [SCTP port number, protocol, streams]
599
+ */
600
+ parseSCTPMap(line) {
601
+ const parts = line.substring(10).split(' ');
602
+ const sctpPort = parts[0];
603
+ const protocol = parts[1];
604
+ // Stream count is optional
605
+ const streamCount = parts.length > 2 ? parts[2] : null;
606
+ return [sctpPort, protocol, streamCount]; // SCTP port
607
+ },
608
+ /**
609
+ * Parses the SCTP port line from the SDP.
610
+ *
611
+ * @param {string} line - The SCTP port line to parse.
612
+ * @returns {string} - The parsed SCTP port.
613
+ */
614
+ parseSCTPPort(line) {
615
+ return line.substring(12);
616
+ },
617
+ /**
618
+ * Parses the SSRC lines from the SDP.
619
+ *
620
+ * @param {string} desc - The SDP description to parse.
621
+ * @returns {Map<string, string[]>} - A map of SSRCs to their corresponding lines.
622
+ */
623
+ parseSSRC(desc) {
624
+ // proprietary mapping of a=ssrc lines
625
+ // TODO: see "Jingle RTP Source Description" by Juberti and P. Thatcher
626
+ // on google docs and parse according to that
627
+ const data = new Map();
628
+ const lines = desc.split('\r\n');
629
+ for (let i = 0; i < lines.length; i++) {
630
+ if (lines[i].substring(0, 7) === 'a=ssrc:') {
631
+ // FIXME: Use regex to smartly find the ssrc.
632
+ const ssrc = lines[i].split('a=ssrc:')[1].split(' ')[0];
633
+ if (!data.get(ssrc)) {
634
+ data.set(ssrc, []);
635
+ }
636
+ data.get(ssrc).push(lines[i]);
637
+ }
638
+ }
639
+ return data;
640
+ },
641
+ /**
642
+ * Parses the 'a=ssrc-group' line.
643
+ *
644
+ * @param {string} line - The media line to parse.
645
+ * @returns {ISsrcGroup}
646
+ */
647
+ parseSSRCGroupLine(line) {
648
+ const parts = line.substr(13).split(' ');
649
+ return {
650
+ semantics: parts.shift(),
651
+ ssrcs: parts
652
+ };
653
+ },
654
+ /**
655
+ * Gets the source name out of the name attribute "a=ssrc:254321 name:name1".
656
+ *
657
+ * @param {string[]} ssrcLines
658
+ * @returns {Optional<string>}
659
+ */
660
+ parseSourceNameLine(ssrcLines) {
661
+ const sourceNameLine = ssrcLines.find(ssrcSdpLine => ssrcSdpLine.indexOf(' name:') > 0);
662
+ // Everything past the "name:" part
663
+ return sourceNameLine?.substring(sourceNameLine.indexOf(' name:') + 6);
664
+ },
665
+ /**
666
+ * Parse the "videoType" attribute encoded in a set of SSRC attributes (e.g.
667
+ * "a=ssrc:1234 videoType:desktop")
668
+ *
669
+ * @param {string[]} ssrcLines
670
+ * @returns {Optional<string>}
671
+ */
672
+ parseVideoTypeLine(ssrcLines) {
673
+ const s = ' videoType:';
674
+ const videoTypeLine = ssrcLines.find(ssrcSdpLine => ssrcSdpLine.indexOf(s) > 0);
675
+ return videoTypeLine?.substring(videoTypeLine.indexOf(s) + s.length);
676
+ },
677
+ /**
678
+ * Sets the given codecName as the preferred codec by moving it to the beginning
679
+ * of the payload types list (modifies the given mline in place). All instances
680
+ * of the codec are moved up.
681
+ * @param {MediaDescription} mLine the mline object from an sdp as parsed by transform.parse.
682
+ * @param {string} codecName the name of the preferred codec.
683
+ * @param {boolean} sortPayloadTypes whether the payloadtypes need to be sorted for a given codec.
684
+ */
685
+ preferCodec(mline, codecName, sortPayloadTypes = false) {
686
+ if (!mline || !codecName) {
687
+ return;
688
+ }
689
+ const matchingPayloadTypes = mline.rtp
690
+ .filter(rtp => rtp.codec && rtp.codec.toLowerCase() === codecName.toLowerCase())
691
+ .map(rtp => rtp.payload);
692
+ if (matchingPayloadTypes) {
693
+ if (sortPayloadTypes && codecName === CodecMimeType.H264) {
694
+ // Move all the H.264 codecs with packetization-mode=0 to top of the list.
695
+ const payloadsWithMode0 = matchingPayloadTypes.filter(payload => {
696
+ const fmtp = mline.fmtp.find(item => item.payload === payload);
697
+ if (fmtp) {
698
+ return fmtp.config.includes('packetization-mode=0');
699
+ }
700
+ return false;
701
+ });
702
+ for (const pt of payloadsWithMode0.reverse()) {
703
+ const idx = matchingPayloadTypes.findIndex(payloadType => payloadType === pt);
704
+ if (idx >= 0) {
705
+ matchingPayloadTypes.splice(idx, 1);
706
+ matchingPayloadTypes.unshift(pt);
707
+ }
708
+ }
709
+ }
710
+ // Call toString() on payloads to get around an issue within SDPTransform that sets
711
+ // payloads as a number, instead of a string, when there is only one payload.
712
+ const payloadTypes = mline.payloads
713
+ .toString()
714
+ .split(' ')
715
+ .map(p => parseInt(p, 10));
716
+ for (const pt of matchingPayloadTypes.reverse()) {
717
+ const payloadIndex = payloadTypes.indexOf(pt);
718
+ payloadTypes.splice(payloadIndex, 1);
719
+ payloadTypes.unshift(pt);
720
+ }
721
+ mline.payloads = payloadTypes.join(' ');
722
+ }
723
+ else {
724
+ logger.error(`No matching RTP payload type found for ${codecName}, failed to set preferred codecs`);
725
+ }
726
+ },
727
+ /**
728
+ * Strips the given codec from the given mline. All related RTX payload
729
+ * types are also stripped. If the resulting mline would have no codecs,
730
+ * it's disabled.
731
+ *
732
+ * @param {MediaDescription} mLine the mline object from an sdp as parsed by transform.parse.
733
+ * @param {string} codecName the name of the codec which will be stripped.
734
+ * @param {boolean} highProfile determines if only the high profile codec needs to be stripped from the sdp for a
735
+ * given codec type.
736
+ */
737
+ stripCodec(mLine, codecName, highProfile = false) {
738
+ if (!mLine || !codecName) {
739
+ return;
740
+ }
741
+ const highProfileCodecs = new Map();
742
+ let removePts = [];
743
+ for (const rtp of mLine.rtp) {
744
+ if (rtp.codec && rtp.codec.toLowerCase() === codecName.toLowerCase()) {
745
+ if (highProfile) {
746
+ highProfileCodecs.set(rtp.payload, rtp.codec);
747
+ }
748
+ else {
749
+ removePts.push(rtp.payload);
750
+ }
751
+ }
752
+ }
753
+ if (highProfile) {
754
+ removePts = mLine.fmtp
755
+ .filter(item => {
756
+ const codec = highProfileCodecs.get(item.payload);
757
+ if (codec) {
758
+ return codec.toLowerCase() === CodecMimeType.VP9
759
+ ? !item.config.includes('profile-id=0')
760
+ : !item.config.includes('profile-level-id=42');
761
+ }
762
+ return false;
763
+ })
764
+ .map(item => item.payload);
765
+ }
766
+ if (removePts.length > 0) {
767
+ // We also need to remove the payload types that are related to RTX
768
+ // for the codecs we want to disable.
769
+ const rtxApts = removePts.map(item => `apt=${item}`);
770
+ const rtxPts = mLine.fmtp.filter(item => rtxApts.indexOf(item.config) !== -1);
771
+ removePts.push(...rtxPts.map(item => item.payload));
772
+ // Call toString() on payloads to get around an issue within
773
+ // SDPTransform that sets payloads as a number, instead of a string,
774
+ // when there is only one payload.
775
+ const allPts = mLine.payloads
776
+ .toString()
777
+ .split(' ')
778
+ .map(Number);
779
+ const keepPts = allPts.filter(pt => removePts.indexOf(pt) === -1);
780
+ if (keepPts.length === 0) {
781
+ // There are no other codecs, disable the stream.
782
+ mLine.port = 0;
783
+ mLine.direction = MediaDirection.INACTIVE;
784
+ mLine.payloads = '*';
785
+ }
786
+ else {
787
+ mLine.payloads = keepPts.join(' ');
788
+ }
789
+ mLine.rtp = mLine.rtp.filter(item => keepPts.indexOf(item.payload) !== -1);
790
+ mLine.fmtp = mLine.fmtp.filter(item => keepPts.indexOf(item.payload) !== -1);
791
+ if (mLine.rtcpFb) {
792
+ mLine.rtcpFb = mLine.rtcpFb.filter(item => keepPts.indexOf(Number(item.payload)) !== -1);
793
+ }
794
+ }
795
+ }
796
+ };
797
+ export default SDPUtil;
798
+ //# sourceMappingURL=SDPUtil.js.map