選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

conference.js 90KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517
  1. /* global APP, JitsiMeetJS, config, interfaceConfig */
  2. import { jitsiLocalStorage } from '@jitsi/js-utils';
  3. import Logger from '@jitsi/logger';
  4. import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
  5. import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
  6. import Recorder from './modules/recorder/Recorder';
  7. import { createTaskQueue } from './modules/util/helpers';
  8. import {
  9. createDeviceChangedEvent,
  10. createScreenSharingEvent,
  11. createStartSilentEvent,
  12. createTrackMutedEvent
  13. } from './react/features/analytics/AnalyticsEvents';
  14. import { sendAnalytics } from './react/features/analytics/functions';
  15. import {
  16. maybeRedirectToWelcomePage,
  17. reloadWithStoredParams
  18. } from './react/features/app/actions';
  19. import { showModeratedNotification } from './react/features/av-moderation/actions';
  20. import { shouldShowModeratedNotification } from './react/features/av-moderation/functions';
  21. import {
  22. _conferenceWillJoin,
  23. authStatusChanged,
  24. conferenceFailed,
  25. conferenceJoinInProgress,
  26. conferenceJoined,
  27. conferenceLeft,
  28. conferencePropertiesChanged,
  29. conferenceSubjectChanged,
  30. conferenceTimestampChanged,
  31. conferenceUniqueIdSet,
  32. conferenceWillInit,
  33. conferenceWillLeave,
  34. dataChannelClosed,
  35. dataChannelOpened,
  36. e2eRttChanged,
  37. endpointMessageReceived,
  38. kickedOut,
  39. lockStateChanged,
  40. nonParticipantMessageReceived,
  41. onStartMutedPolicyChanged,
  42. p2pStatusChanged
  43. } from './react/features/base/conference/actions';
  44. import {
  45. AVATAR_URL_COMMAND,
  46. CONFERENCE_LEAVE_REASONS,
  47. EMAIL_COMMAND
  48. } from './react/features/base/conference/constants';
  49. import {
  50. commonUserJoinedHandling,
  51. commonUserLeftHandling,
  52. getConferenceOptions,
  53. sendLocalParticipant
  54. } from './react/features/base/conference/functions';
  55. import { getReplaceParticipant, getSsrcRewritingFeatureFlag } from './react/features/base/config/functions';
  56. import { connect } from './react/features/base/connection/actions.web';
  57. import {
  58. checkAndNotifyForNewDevice,
  59. getAvailableDevices,
  60. notifyCameraError,
  61. notifyMicError,
  62. updateDeviceList
  63. } from './react/features/base/devices/actions.web';
  64. import {
  65. areDevicesDifferent,
  66. filterIgnoredDevices,
  67. flattenAvailableDevices,
  68. getDefaultDeviceId,
  69. logDevices,
  70. setAudioOutputDeviceId
  71. } from './react/features/base/devices/functions.web';
  72. import {
  73. JitsiConferenceErrors,
  74. JitsiConferenceEvents,
  75. JitsiE2ePingEvents,
  76. JitsiMediaDevicesEvents,
  77. JitsiTrackEvents,
  78. browser
  79. } from './react/features/base/lib-jitsi-meet';
  80. import {
  81. gumPending,
  82. setAudioAvailable,
  83. setAudioMuted,
  84. setAudioUnmutePermissions,
  85. setInitialGUMPromise,
  86. setVideoAvailable,
  87. setVideoMuted,
  88. setVideoUnmutePermissions
  89. } from './react/features/base/media/actions';
  90. import { MEDIA_TYPE, VIDEO_TYPE } from './react/features/base/media/constants';
  91. import {
  92. getStartWithAudioMuted,
  93. getStartWithVideoMuted,
  94. isVideoMutedByUser
  95. } from './react/features/base/media/functions';
  96. import { IGUMPendingState } from './react/features/base/media/types';
  97. import {
  98. dominantSpeakerChanged,
  99. localParticipantAudioLevelChanged,
  100. localParticipantRoleChanged,
  101. participantKicked,
  102. participantMutedUs,
  103. participantPresenceChanged,
  104. participantRoleChanged,
  105. participantSourcesUpdated,
  106. participantUpdated,
  107. screenshareParticipantDisplayNameChanged,
  108. updateRemoteParticipantFeatures
  109. } from './react/features/base/participants/actions';
  110. import {
  111. getLocalParticipant,
  112. getNormalizedDisplayName,
  113. getParticipantByIdOrUndefined,
  114. getVirtualScreenshareParticipantByOwnerId
  115. } from './react/features/base/participants/functions';
  116. import { updateSettings } from './react/features/base/settings/actions';
  117. import {
  118. addLocalTrack,
  119. createInitialAVTracks,
  120. destroyLocalTracks,
  121. displayErrorsForCreateInitialLocalTracks,
  122. replaceLocalTrack,
  123. setGUMPendingStateOnFailedTracks,
  124. toggleScreensharing as toggleScreensharingA,
  125. trackAdded,
  126. trackRemoved
  127. } from './react/features/base/tracks/actions';
  128. import {
  129. createLocalTracksF,
  130. getLocalJitsiAudioTrack,
  131. getLocalJitsiVideoTrack,
  132. getLocalTracks,
  133. getLocalVideoTrack,
  134. isLocalTrackMuted,
  135. isUserInteractionRequiredForUnmute
  136. } from './react/features/base/tracks/functions';
  137. import { downloadJSON } from './react/features/base/util/downloadJSON';
  138. import { getJitsiMeetGlobalNSConnectionTimes } from './react/features/base/util/helpers';
  139. import { openLeaveReasonDialog } from './react/features/conference/actions.web';
  140. import { showDesktopPicker } from './react/features/desktop-picker/actions';
  141. import { appendSuffix } from './react/features/display-name/functions';
  142. import { maybeOpenFeedbackDialog, submitFeedback } from './react/features/feedback/actions';
  143. import { maybeSetLobbyChatMessageListener } from './react/features/lobby/actions.any';
  144. import { setNoiseSuppressionEnabled } from './react/features/noise-suppression/actions';
  145. import {
  146. hideNotification,
  147. showErrorNotification,
  148. showNotification,
  149. showWarningNotification
  150. } from './react/features/notifications/actions';
  151. import {
  152. DATA_CHANNEL_CLOSED_NOTIFICATION_ID,
  153. NOTIFICATION_TIMEOUT_TYPE
  154. } from './react/features/notifications/constants';
  155. import { isModerationNotificationDisplayed } from './react/features/notifications/functions';
  156. import { suspendDetected } from './react/features/power-monitor/actions';
  157. import { initPrejoin, isPrejoinPageVisible } from './react/features/prejoin/functions';
  158. import { disableReceiver, stopReceiver } from './react/features/remote-control/actions';
  159. import { setScreenAudioShareState } from './react/features/screen-share/actions.web';
  160. import { isScreenAudioShared } from './react/features/screen-share/functions';
  161. import { toggleScreenshotCaptureSummary } from './react/features/screenshot-capture/actions';
  162. import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/AudioMixerEffect';
  163. import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
  164. import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
  165. import { transcriberJoined, transcriberLeft } from './react/features/transcribing/actions';
  166. import { muteLocal } from './react/features/video-menu/actions.any';
  167. const logger = Logger.getLogger(__filename);
  168. let room;
  169. /*
  170. * Logic to open a desktop picker put on the window global for
  171. * lib-jitsi-meet to detect and invoke.
  172. *
  173. * TODO: remove once the Electron SDK supporting gDM has been out for a while.
  174. */
  175. window.JitsiMeetScreenObtainer = {
  176. openDesktopPicker(options, onSourceChoose) {
  177. APP.store.dispatch(showDesktopPicker(options, onSourceChoose));
  178. }
  179. };
  180. /**
  181. * Known custom conference commands.
  182. */
  183. const commands = {
  184. AVATAR_URL: AVATAR_URL_COMMAND,
  185. CUSTOM_ROLE: 'custom-role',
  186. EMAIL: EMAIL_COMMAND,
  187. ETHERPAD: 'etherpad'
  188. };
  189. /**
  190. * Share data to other users.
  191. * @param command the command
  192. * @param {string} value new value
  193. */
  194. function sendData(command, value) {
  195. if (!room) {
  196. return;
  197. }
  198. room.removeCommand(command);
  199. room.sendCommand(command, { value });
  200. }
  201. /**
  202. * Mute or unmute local audio stream if it exists.
  203. * @param {boolean} muted - if audio stream should be muted or unmuted.
  204. */
  205. function muteLocalAudio(muted) {
  206. APP.store.dispatch(setAudioMuted(muted));
  207. }
  208. /**
  209. * Mute or unmute local video stream if it exists.
  210. * @param {boolean} muted if video stream should be muted or unmuted.
  211. *
  212. */
  213. function muteLocalVideo(muted) {
  214. APP.store.dispatch(setVideoMuted(muted));
  215. }
  216. /**
  217. * A queue for the async replaceLocalTrack action so that multiple audio
  218. * replacements cannot happen simultaneously. This solves the issue where
  219. * replaceLocalTrack is called multiple times with an oldTrack of null, causing
  220. * multiple local tracks of the same type to be used.
  221. *
  222. * @private
  223. * @type {Object}
  224. */
  225. const _replaceLocalAudioTrackQueue = createTaskQueue();
  226. /**
  227. * A task queue for replacement local video tracks. This separate queue exists
  228. * so video replacement is not blocked by audio replacement tasks in the queue
  229. * {@link _replaceLocalAudioTrackQueue}.
  230. *
  231. * @private
  232. * @type {Object}
  233. */
  234. const _replaceLocalVideoTrackQueue = createTaskQueue();
  235. /**
  236. *
  237. */
  238. class ConferenceConnector {
  239. /**
  240. *
  241. */
  242. constructor(resolve, reject, conference) {
  243. this._conference = conference;
  244. this._resolve = resolve;
  245. this._reject = reject;
  246. this.reconnectTimeout = null;
  247. room.on(JitsiConferenceEvents.CONFERENCE_JOINED,
  248. this._handleConferenceJoined.bind(this));
  249. room.on(JitsiConferenceEvents.CONFERENCE_FAILED,
  250. this._onConferenceFailed.bind(this));
  251. }
  252. /**
  253. *
  254. */
  255. _handleConferenceFailed(err) {
  256. this._unsubscribe();
  257. this._reject(err);
  258. }
  259. /**
  260. *
  261. */
  262. _onConferenceFailed(err, ...params) {
  263. APP.store.dispatch(conferenceFailed(room, err, ...params));
  264. logger.error('CONFERENCE FAILED:', err, ...params);
  265. switch (err) {
  266. case JitsiConferenceErrors.RESERVATION_ERROR: {
  267. const [ code, msg ] = params;
  268. APP.store.dispatch(showErrorNotification({
  269. descriptionArguments: {
  270. code,
  271. msg
  272. },
  273. descriptionKey: 'dialog.reservationErrorMsg',
  274. titleKey: 'dialog.reservationError'
  275. }));
  276. break;
  277. }
  278. case JitsiConferenceErrors.GRACEFUL_SHUTDOWN:
  279. APP.store.dispatch(showErrorNotification({
  280. descriptionKey: 'dialog.gracefulShutdown',
  281. titleKey: 'dialog.serviceUnavailable'
  282. }));
  283. break;
  284. // FIXME FOCUS_DISCONNECTED is a confusing event name.
  285. // What really happens there is that the library is not ready yet,
  286. // because Jicofo is not available, but it is going to give it another
  287. // try.
  288. case JitsiConferenceErrors.FOCUS_DISCONNECTED: {
  289. const [ focus, retrySec ] = params;
  290. APP.store.dispatch(showNotification({
  291. descriptionKey: focus,
  292. titleKey: retrySec
  293. }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
  294. break;
  295. }
  296. case JitsiConferenceErrors.FOCUS_LEFT:
  297. case JitsiConferenceErrors.ICE_FAILED:
  298. case JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE:
  299. case JitsiConferenceErrors.OFFER_ANSWER_FAILED:
  300. APP.store.dispatch(conferenceWillLeave(room));
  301. // FIXME the conference should be stopped by the library and not by
  302. // the app. Both the errors above are unrecoverable from the library
  303. // perspective.
  304. room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).then(() => APP.connection.disconnect());
  305. break;
  306. case JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS:
  307. APP.store.dispatch(reloadWithStoredParams());
  308. break;
  309. default:
  310. this._handleConferenceFailed(err, ...params);
  311. }
  312. }
  313. /**
  314. *
  315. */
  316. _unsubscribe() {
  317. room.off(
  318. JitsiConferenceEvents.CONFERENCE_JOINED,
  319. this._handleConferenceJoined);
  320. room.off(
  321. JitsiConferenceEvents.CONFERENCE_FAILED,
  322. this._onConferenceFailed);
  323. if (this.reconnectTimeout !== null) {
  324. clearTimeout(this.reconnectTimeout);
  325. }
  326. }
  327. /**
  328. *
  329. */
  330. _handleConferenceJoined() {
  331. this._unsubscribe();
  332. this._resolve();
  333. }
  334. /**
  335. *
  336. */
  337. connect() {
  338. const replaceParticipant = getReplaceParticipant(APP.store.getState());
  339. // the local storage overrides here and in connection.js can be used by jibri
  340. room.join(jitsiLocalStorage.getItem('xmpp_conference_password_override'), replaceParticipant);
  341. }
  342. }
  343. /**
  344. * Disconnects the connection.
  345. * @returns resolved Promise. We need this in order to make the Promise.all
  346. * call in hangup() to resolve when all operations are finished.
  347. */
  348. function disconnect() {
  349. const onDisconnected = () => {
  350. APP.API.notifyConferenceLeft(APP.conference.roomName);
  351. return Promise.resolve();
  352. };
  353. if (!APP.connection) {
  354. return onDisconnected();
  355. }
  356. return APP.connection.disconnect().then(onDisconnected, onDisconnected);
  357. }
  358. export default {
  359. /**
  360. * Flag used to delay modification of the muted status of local media tracks
  361. * until those are created (or not, but at that point it's certain that
  362. * the tracks won't exist).
  363. */
  364. _localTracksInitialized: false,
  365. /**
  366. * Flag used to prevent the creation of another local video track in this.muteVideo if one is already in progress.
  367. */
  368. isCreatingLocalTrack: false,
  369. isSharingScreen: false,
  370. /**
  371. * Returns an object containing a promise which resolves with the created tracks &
  372. * the errors resulting from that process.
  373. * @param {object} options
  374. * @param {boolean} options.startAudioOnly=false - if <tt>true</tt> then
  375. * only audio track will be created and the audio only mode will be turned
  376. * on.
  377. * @param {boolean} options.startScreenSharing=false - if <tt>true</tt>
  378. * should start with screensharing instead of camera video.
  379. * @param {boolean} options.startWithAudioMuted - will start the conference
  380. * without any audio tracks.
  381. * @param {boolean} options.startWithVideoMuted - will start the conference
  382. * without any video tracks.
  383. * @param {boolean} recordTimeMetrics - If true time metrics will be recorded.
  384. * @returns {Promise<JitsiLocalTrack[]>, Object}
  385. */
  386. createInitialLocalTracks(options = {}, recordTimeMetrics = false) {
  387. const errors = {};
  388. // Always get a handle on the audio input device so that we have statistics (such as "No audio input" or
  389. // "Are you trying to speak?" ) even if the user joins the conference muted.
  390. const initialDevices = config.startSilent || config.disableInitialGUM ? [] : [ MEDIA_TYPE.AUDIO ];
  391. const requestedAudio = !config.disableInitialGUM;
  392. let requestedVideo = false;
  393. if (!config.disableInitialGUM
  394. && !options.startWithVideoMuted
  395. && !options.startAudioOnly
  396. && !options.startScreenSharing) {
  397. initialDevices.push(MEDIA_TYPE.VIDEO);
  398. requestedVideo = true;
  399. }
  400. let tryCreateLocalTracks = Promise.resolve([]);
  401. // On Electron there is no permission prompt for granting permissions. That's why we don't need to
  402. // spend much time displaying the overlay screen. If GUM is not resolved within 15 seconds it will
  403. // probably never resolve.
  404. const timeout = browser.isElectron() ? 15000 : 60000;
  405. const audioOptions = {
  406. devices: [ MEDIA_TYPE.AUDIO ],
  407. timeout
  408. };
  409. // Spot uses the _desktopSharingSourceDevice config option to use an external video input device label as
  410. // screenshare and calls getUserMedia instead of getDisplayMedia for capturing the media.
  411. if (options.startScreenSharing && config._desktopSharingSourceDevice) {
  412. tryCreateLocalTracks = this._createDesktopTrack()
  413. .then(([ desktopStream ]) => {
  414. if (!requestedAudio) {
  415. return [ desktopStream ];
  416. }
  417. return createLocalTracksF(audioOptions)
  418. .then(([ audioStream ]) =>
  419. [ desktopStream, audioStream ])
  420. .catch(error => {
  421. errors.audioOnlyError = error;
  422. return [ desktopStream ];
  423. });
  424. })
  425. .catch(error => {
  426. logger.error('Failed to obtain desktop stream', error);
  427. errors.screenSharingError = error;
  428. return requestedAudio ? createLocalTracksF(audioOptions) : [];
  429. })
  430. .catch(error => {
  431. errors.audioOnlyError = error;
  432. return [];
  433. });
  434. } else if (requestedAudio || requestedVideo) {
  435. tryCreateLocalTracks = APP.store.dispatch(createInitialAVTracks({
  436. devices: initialDevices,
  437. timeout
  438. }, recordTimeMetrics)).then(({ tracks, errors: pErrors }) => {
  439. Object.assign(errors, pErrors);
  440. return tracks;
  441. });
  442. }
  443. return {
  444. tryCreateLocalTracks,
  445. errors
  446. };
  447. },
  448. startConference(tracks) {
  449. tracks.forEach(track => {
  450. if ((track.isAudioTrack() && this.isLocalAudioMuted())
  451. || (track.isVideoTrack() && this.isLocalVideoMuted())) {
  452. const mediaType = track.getType();
  453. sendAnalytics(
  454. createTrackMutedEvent(mediaType, 'initial mute'));
  455. logger.log(`${mediaType} mute: initially muted.`);
  456. track.mute();
  457. }
  458. });
  459. this._createRoom(tracks);
  460. // if user didn't give access to mic or camera or doesn't have
  461. // them at all, we mark corresponding toolbar buttons as muted,
  462. // so that the user can try unmute later on and add audio/video
  463. // to the conference
  464. if (!tracks.find(t => t.isAudioTrack())) {
  465. this.updateAudioIconEnabled();
  466. }
  467. if (!tracks.find(t => t.isVideoTrack())) {
  468. this.setVideoMuteStatus();
  469. }
  470. if (config.iAmRecorder) {
  471. this.recorder = new Recorder();
  472. }
  473. if (config.startSilent) {
  474. sendAnalytics(createStartSilentEvent());
  475. APP.store.dispatch(showNotification({
  476. descriptionKey: 'notify.startSilentDescription',
  477. titleKey: 'notify.startSilentTitle'
  478. }, NOTIFICATION_TIMEOUT_TYPE.LONG));
  479. }
  480. // XXX The API will take care of disconnecting from the XMPP
  481. // server (and, thus, leaving the room) on unload.
  482. return new Promise((resolve, reject) => {
  483. new ConferenceConnector(resolve, reject, this).connect();
  484. });
  485. },
  486. /**
  487. * Open new connection and join the conference when prejoin page is not enabled.
  488. * If prejoin page is enabled open an new connection in the background
  489. * and create local tracks.
  490. *
  491. * @param {{ roomName: string, shouldDispatchConnect }} options
  492. * @returns {Promise}
  493. */
  494. async init({ roomName, shouldDispatchConnect }) {
  495. const state = APP.store.getState();
  496. const initialOptions = {
  497. startAudioOnly: config.startAudioOnly,
  498. startScreenSharing: config.startScreenSharing,
  499. startWithAudioMuted: getStartWithAudioMuted(state) || isUserInteractionRequiredForUnmute(state),
  500. startWithVideoMuted: getStartWithVideoMuted(state) || isUserInteractionRequiredForUnmute(state)
  501. };
  502. const connectionTimes = getJitsiMeetGlobalNSConnectionTimes();
  503. const startTime = window.performance.now();
  504. connectionTimes['conference.init.start'] = startTime;
  505. logger.debug(`Executed conference.init with roomName: ${roomName} (performance.now=${startTime})`);
  506. this.roomName = roomName;
  507. try {
  508. // Initialize the device list first. This way, when creating tracks based on preferred devices, loose label
  509. // matching can be done in cases where the exact ID match is no longer available, such as -
  510. // 1. When the camera device has switched USB ports.
  511. // 2. When in startSilent mode we want to start with audio muted
  512. await this._initDeviceList();
  513. } catch (error) {
  514. logger.warn('initial device list initialization failed', error);
  515. }
  516. // Filter out the local tracks based on various config options, i.e., when user joins muted or is muted by
  517. // focus. However, audio track will always be created even though it is not added to the conference since we
  518. // want audio related features (noisy mic, talk while muted, etc.) to work even if the mic is muted.
  519. const handleInitialTracks = (options, tracks) => {
  520. let localTracks = tracks;
  521. if (options.startWithAudioMuted) {
  522. // Always add the track on Safari because of a known issue where audio playout doesn't happen
  523. // if the user joins audio and video muted, i.e., if there is no local media capture.
  524. if (browser.isWebKitBased()) {
  525. this.muteAudio(true, true);
  526. } else {
  527. localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.AUDIO);
  528. }
  529. }
  530. return localTracks;
  531. };
  532. const { dispatch, getState } = APP.store;
  533. const createLocalTracksStart = window.performance.now();
  534. connectionTimes['conference.init.createLocalTracks.start'] = createLocalTracksStart;
  535. logger.debug(`(TIME) createInitialLocalTracks: ${createLocalTracksStart} `);
  536. const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions, true);
  537. tryCreateLocalTracks.then(async tr => {
  538. const createLocalTracksEnd = window.performance.now();
  539. connectionTimes['conference.init.createLocalTracks.end'] = createLocalTracksEnd;
  540. logger.debug(`(TIME) createInitialLocalTracks finished: ${createLocalTracksEnd} `);
  541. const tracks = handleInitialTracks(initialOptions, tr);
  542. this._initDeviceList(true);
  543. const { initialGUMPromise } = getState()['features/base/media'];
  544. if (isPrejoinPageVisible(getState())) {
  545. dispatch(gumPending([ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ], IGUMPendingState.NONE));
  546. // Since the conference is not yet created in redux this function will execute synchronous
  547. // which will guarantee us that the local tracks are added to redux before we proceed.
  548. initPrejoin(tracks, errors, dispatch);
  549. connectionTimes['conference.init.end'] = window.performance.now();
  550. // resolve the initialGUMPromise in case connect have finished so that we can proceed to join.
  551. if (initialGUMPromise) {
  552. logger.debug('Resolving the initialGUM promise! (prejoinVisible=true)');
  553. initialGUMPromise.resolve({
  554. tracks,
  555. errors
  556. });
  557. }
  558. logger.debug('Clear the initialGUM promise! (prejoinVisible=true)');
  559. // For prejoin we don't need the initial GUM promise since the tracks are already added to the store
  560. // via initPrejoin
  561. dispatch(setInitialGUMPromise());
  562. } else {
  563. APP.store.dispatch(displayErrorsForCreateInitialLocalTracks(errors));
  564. setGUMPendingStateOnFailedTracks(tracks, APP.store.dispatch);
  565. connectionTimes['conference.init.end'] = window.performance.now();
  566. if (initialGUMPromise) {
  567. logger.debug('Resolving the initialGUM promise!');
  568. initialGUMPromise.resolve({
  569. tracks,
  570. errors
  571. });
  572. }
  573. }
  574. });
  575. if (shouldDispatchConnect) {
  576. logger.info('Dispatching connect from init since prejoin is not visible.');
  577. dispatch(connect());
  578. }
  579. },
  580. /**
  581. * Check if id is id of the local user.
  582. * @param {string} id id to check
  583. * @returns {boolean}
  584. */
  585. isLocalId(id) {
  586. return this.getMyUserId() === id;
  587. },
  588. /**
  589. * Tells whether the local video is muted or not.
  590. * @return {boolean}
  591. */
  592. isLocalVideoMuted() {
  593. // If the tracks are not ready, read from base/media state
  594. return this._localTracksInitialized
  595. ? isLocalTrackMuted(APP.store.getState()['features/base/tracks'], MEDIA_TYPE.VIDEO)
  596. : isVideoMutedByUser(APP.store);
  597. },
  598. /**
  599. * Verify if there is an ongoing system audio sharing session and apply to the provided track
  600. * as a AudioMixer effect.
  601. *
  602. * @param {*} localAudioTrack - track to which system audio track will be applied as an effect, most likely
  603. * microphone local audio track.
  604. */
  605. async _maybeApplyAudioMixerEffect(localAudioTrack) {
  606. // At the time of writing this comment there were two separate flows for toggling screen-sharing
  607. // and system audio sharing, the first is the legacy method using the functionality from conference.js
  608. // the second is used when both sendMultipleVideoStreams and sourceNameSignaling flags are set to true.
  609. // The second flow uses functionality from base/conference/middleware.web.js.
  610. // We check if system audio sharing was done using the first flow by verifying this._desktopAudioStream and
  611. // for the second by checking 'features/screen-share' state.
  612. const { desktopAudioTrack } = APP.store.getState()['features/screen-share'];
  613. const currentDesktopAudioTrack = this._desktopAudioStream || desktopAudioTrack;
  614. // If system audio is already being sent, mix it with the provided audio track.
  615. if (currentDesktopAudioTrack) {
  616. // In case system audio sharing was done in the absence of an initial mic audio track, there is no
  617. // AudioMixerEffect so we have to remove system audio track from the room before setting it as an effect.
  618. await room.replaceTrack(currentDesktopAudioTrack, null);
  619. this._mixerEffect = new AudioMixerEffect(currentDesktopAudioTrack);
  620. logger.debug('Mixing new audio track with existing screen audio track.');
  621. await localAudioTrack.setEffect(this._mixerEffect);
  622. }
  623. },
  624. /**
  625. * Simulates toolbar button click for audio mute. Used by shortcuts and API.
  626. *
  627. * @param {boolean} mute true for mute and false for unmute.
  628. * @param {boolean} [showUI] when set to false will not display any error
  629. * dialogs in case of media permissions error.
  630. * @returns {Promise}
  631. */
  632. async muteAudio(mute, showUI = true) {
  633. const state = APP.store.getState();
  634. if (!mute
  635. && isUserInteractionRequiredForUnmute(state)) {
  636. logger.error('Unmuting audio requires user interaction');
  637. return;
  638. }
  639. // check for A/V Moderation when trying to unmute
  640. if (!mute && shouldShowModeratedNotification(MEDIA_TYPE.AUDIO, state)) {
  641. if (!isModerationNotificationDisplayed(MEDIA_TYPE.AUDIO, state)) {
  642. APP.store.dispatch(showModeratedNotification(MEDIA_TYPE.AUDIO));
  643. }
  644. return;
  645. }
  646. // Not ready to modify track's state yet
  647. if (!this._localTracksInitialized) {
  648. // This will only modify base/media.audio.muted which is then synced
  649. // up with the track at the end of local tracks initialization.
  650. muteLocalAudio(mute);
  651. this.updateAudioIconEnabled();
  652. return;
  653. } else if (this.isLocalAudioMuted() === mute) {
  654. // NO-OP
  655. return;
  656. }
  657. const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
  658. if (!localAudio && !mute) {
  659. const maybeShowErrorDialog = error => {
  660. showUI && APP.store.dispatch(notifyMicError(error));
  661. };
  662. APP.store.dispatch(gumPending([ MEDIA_TYPE.AUDIO ], IGUMPendingState.PENDING_UNMUTE));
  663. await createLocalTracksF({ devices: [ 'audio' ] })
  664. .then(([ audioTrack ]) => audioTrack)
  665. .catch(error => {
  666. maybeShowErrorDialog(error);
  667. // Rollback the audio muted status by using null track
  668. return null;
  669. })
  670. .then(async audioTrack => {
  671. await this._maybeApplyAudioMixerEffect(audioTrack);
  672. return this.useAudioStream(audioTrack);
  673. })
  674. .finally(() => {
  675. APP.store.dispatch(gumPending([ MEDIA_TYPE.AUDIO ], IGUMPendingState.NONE));
  676. });
  677. } else {
  678. muteLocalAudio(mute);
  679. }
  680. },
  681. /**
  682. * Returns whether local audio is muted or not.
  683. * @returns {boolean}
  684. */
  685. isLocalAudioMuted() {
  686. // If the tracks are not ready, read from base/media state
  687. return this._localTracksInitialized
  688. ? isLocalTrackMuted(
  689. APP.store.getState()['features/base/tracks'],
  690. MEDIA_TYPE.AUDIO)
  691. : Boolean(
  692. APP.store.getState()['features/base/media'].audio.muted);
  693. },
  694. /**
  695. * Simulates toolbar button click for audio mute. Used by shortcuts
  696. * and API.
  697. * @param {boolean} [showUI] when set to false will not display any error
  698. * dialogs in case of media permissions error.
  699. */
  700. toggleAudioMuted(showUI = true) {
  701. this.muteAudio(!this.isLocalAudioMuted(), showUI);
  702. },
  703. /**
  704. * Simulates toolbar button click for video mute. Used by shortcuts and API.
  705. * @param mute true for mute and false for unmute.
  706. * @param {boolean} [showUI] when set to false will not display any error
  707. * dialogs in case of media permissions error.
  708. */
  709. muteVideo(mute, showUI = true) {
  710. if (this.videoSwitchInProgress) {
  711. logger.warn('muteVideo - unable to perform operations while video switch is in progress');
  712. return;
  713. }
  714. const state = APP.store.getState();
  715. if (!mute
  716. && isUserInteractionRequiredForUnmute(state)) {
  717. logger.error('Unmuting video requires user interaction');
  718. return;
  719. }
  720. // check for A/V Moderation when trying to unmute and return early
  721. if (!mute && shouldShowModeratedNotification(MEDIA_TYPE.VIDEO, state)) {
  722. return;
  723. }
  724. // If not ready to modify track's state yet adjust the base/media
  725. if (!this._localTracksInitialized) {
  726. // This will only modify base/media.video.muted which is then synced
  727. // up with the track at the end of local tracks initialization.
  728. muteLocalVideo(mute);
  729. this.setVideoMuteStatus();
  730. return;
  731. } else if (this.isLocalVideoMuted() === mute) {
  732. // NO-OP
  733. return;
  734. }
  735. const localVideo = getLocalJitsiVideoTrack(state);
  736. if (!localVideo && !mute && !this.isCreatingLocalTrack) {
  737. const maybeShowErrorDialog = error => {
  738. showUI && APP.store.dispatch(notifyCameraError(error));
  739. };
  740. this.isCreatingLocalTrack = true;
  741. APP.store.dispatch(gumPending([ MEDIA_TYPE.VIDEO ], IGUMPendingState.PENDING_UNMUTE));
  742. // Try to create local video if there wasn't any.
  743. // This handles the case when user joined with no video
  744. // (dismissed screen sharing screen or in audio only mode), but
  745. // decided to add it later on by clicking on muted video icon or
  746. // turning off the audio only mode.
  747. //
  748. // FIXME when local track creation is moved to react/redux
  749. // it should take care of the use case described above
  750. createLocalTracksF({ devices: [ 'video' ] })
  751. .then(([ videoTrack ]) => videoTrack)
  752. .catch(error => {
  753. // FIXME should send some feedback to the API on error ?
  754. maybeShowErrorDialog(error);
  755. // Rollback the video muted status by using null track
  756. return null;
  757. })
  758. .then(videoTrack => {
  759. logger.debug(`muteVideo: calling useVideoStream for track: ${videoTrack}`);
  760. return this.useVideoStream(videoTrack);
  761. })
  762. .finally(() => {
  763. this.isCreatingLocalTrack = false;
  764. APP.store.dispatch(gumPending([ MEDIA_TYPE.VIDEO ], IGUMPendingState.NONE));
  765. });
  766. } else {
  767. // FIXME show error dialog if it fails (should be handled by react)
  768. muteLocalVideo(mute);
  769. }
  770. },
  771. /**
  772. * Simulates toolbar button click for video mute. Used by shortcuts and API.
  773. * @param {boolean} [showUI] when set to false will not display any error
  774. * dialogs in case of media permissions error.
  775. * @param {boolean} ensureTrack - True if we want to ensure that a new track is
  776. * created if missing.
  777. */
  778. toggleVideoMuted(showUI = true, ensureTrack = false) {
  779. const mute = !this.isLocalVideoMuted();
  780. APP.store.dispatch(handleToggleVideoMuted(mute, showUI, ensureTrack));
  781. },
  782. /**
  783. * Retrieve list of ids of conference participants (without local user).
  784. * @returns {string[]}
  785. */
  786. listMembersIds() {
  787. return room.getParticipants().map(p => p.getId());
  788. },
  789. /**
  790. * Checks whether the participant identified by id is a moderator.
  791. * @id id to search for participant
  792. * @return {boolean} whether the participant is moderator
  793. */
  794. isParticipantModerator(id) {
  795. const user = room.getParticipantById(id);
  796. return user && user.isModerator();
  797. },
  798. /**
  799. * Retrieve list of conference participants (without local user).
  800. * @returns {JitsiParticipant[]}
  801. *
  802. * NOTE: Used by jitsi-meet-torture!
  803. */
  804. listMembers() {
  805. return room.getParticipants();
  806. },
  807. /**
  808. * Used by Jibri to detect when it's alone and the meeting should be terminated.
  809. */
  810. get membersCount() {
  811. return room.getParticipants()
  812. .filter(p => !p.isHidden() || !(config.iAmRecorder && p.isHiddenFromRecorder())).length + 1;
  813. },
  814. /**
  815. * Get speaker stats that track total dominant speaker time.
  816. *
  817. * @returns {object} A hash with keys being user ids and values being the
  818. * library's SpeakerStats model used for calculating time as dominant
  819. * speaker.
  820. */
  821. getSpeakerStats() {
  822. return room.getSpeakerStats();
  823. },
  824. // used by torture currently
  825. isJoined() {
  826. return room && room.isJoined();
  827. },
  828. getConnectionState() {
  829. return room && room.getConnectionState();
  830. },
  831. /**
  832. * Obtains current P2P ICE connection state.
  833. * @return {string|null} ICE connection state or <tt>null</tt> if there's no
  834. * P2P connection
  835. */
  836. getP2PConnectionState() {
  837. return room && room.getP2PConnectionState();
  838. },
  839. /**
  840. * Starts P2P (for tests only)
  841. * @private
  842. */
  843. _startP2P() {
  844. try {
  845. room && room.startP2PSession();
  846. } catch (error) {
  847. logger.error('Start P2P failed', error);
  848. throw error;
  849. }
  850. },
  851. /**
  852. * Stops P2P (for tests only)
  853. * @private
  854. */
  855. _stopP2P() {
  856. try {
  857. room && room.stopP2PSession();
  858. } catch (error) {
  859. logger.error('Stop P2P failed', error);
  860. throw error;
  861. }
  862. },
  863. /**
  864. * Checks whether or not our connection is currently in interrupted and
  865. * reconnect attempts are in progress.
  866. *
  867. * @returns {boolean} true if the connection is in interrupted state or
  868. * false otherwise.
  869. */
  870. isConnectionInterrupted() {
  871. return room.isConnectionInterrupted();
  872. },
  873. /**
  874. * Finds JitsiParticipant for given id.
  875. *
  876. * @param {string} id participant's identifier(MUC nickname).
  877. *
  878. * @returns {JitsiParticipant|null} participant instance for given id or
  879. * null if not found.
  880. */
  881. getParticipantById(id) {
  882. return room ? room.getParticipantById(id) : null;
  883. },
  884. getMyUserId() {
  885. return room && room.myUserId();
  886. },
  887. /**
  888. * Will be filled with values only when config.testing.testMode is true.
  889. * Its used by torture to check audio levels.
  890. */
  891. audioLevelsMap: {},
  892. /**
  893. * Returns the stored audio level (stored only if config.debug is enabled)
  894. * @param id the id for the user audio level to return (the id value is
  895. * returned for the participant using getMyUserId() method)
  896. */
  897. getPeerSSRCAudioLevel(id) {
  898. return this.audioLevelsMap[id];
  899. },
  900. /**
  901. * @return {number} the number of participants in the conference with at
  902. * least one track.
  903. */
  904. getNumberOfParticipantsWithTracks() {
  905. return room.getParticipants()
  906. .filter(p => p.getTracks().length > 0)
  907. .length;
  908. },
  909. /**
  910. * Returns the stats.
  911. */
  912. getStats() {
  913. return room.connectionQuality.getStats();
  914. },
  915. // end used by torture
  916. /**
  917. * Download logs, a function that can be called from console while
  918. * debugging.
  919. * @param filename (optional) specify target filename
  920. */
  921. saveLogs(filename = 'meetlog.json') {
  922. // this can be called from console and will not have reference to this
  923. // that's why we reference the global var
  924. const logs = APP.connection.getLogs();
  925. downloadJSON(logs, filename);
  926. },
  927. /**
  928. * Exposes a Command(s) API on this instance. It is necessitated by (1) the
  929. * desire to keep room private to this instance and (2) the need of other
  930. * modules to send and receive commands to and from participants.
  931. * Eventually, this instance remains in control with respect to the
  932. * decision whether the Command(s) API of room (i.e. lib-jitsi-meet's
  933. * JitsiConference) is to be used in the implementation of the Command(s)
  934. * API of this instance.
  935. */
  936. commands: {
  937. /**
  938. * Known custom conference commands.
  939. */
  940. defaults: commands,
  941. /**
  942. * Receives notifications from other participants about commands aka
  943. * custom events (sent by sendCommand or sendCommandOnce methods).
  944. * @param command {String} the name of the command
  945. * @param handler {Function} handler for the command
  946. */
  947. addCommandListener() {
  948. // eslint-disable-next-line prefer-rest-params
  949. room.addCommandListener(...arguments);
  950. },
  951. /**
  952. * Removes command.
  953. * @param name {String} the name of the command.
  954. */
  955. removeCommand() {
  956. // eslint-disable-next-line prefer-rest-params
  957. room.removeCommand(...arguments);
  958. },
  959. /**
  960. * Sends command.
  961. * @param name {String} the name of the command.
  962. * @param values {Object} with keys and values that will be sent.
  963. */
  964. sendCommand() {
  965. // eslint-disable-next-line prefer-rest-params
  966. room.sendCommand(...arguments);
  967. },
  968. /**
  969. * Sends command one time.
  970. * @param name {String} the name of the command.
  971. * @param values {Object} with keys and values that will be sent.
  972. */
  973. sendCommandOnce() {
  974. // eslint-disable-next-line prefer-rest-params
  975. room.sendCommandOnce(...arguments);
  976. }
  977. },
  978. /**
  979. * Used by the Breakout Rooms feature to join a breakout room or go back to the main room.
  980. */
  981. async joinRoom(roomName, options) {
  982. APP.store.dispatch(conferenceWillInit());
  983. // Restore initial state.
  984. this._localTracksInitialized = false;
  985. this.isSharingScreen = false;
  986. this.roomName = roomName;
  987. const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(options);
  988. const localTracks = await tryCreateLocalTracks;
  989. APP.store.dispatch(displayErrorsForCreateInitialLocalTracks(errors));
  990. localTracks.forEach(track => {
  991. if ((track.isAudioTrack() && this.isLocalAudioMuted())
  992. || (track.isVideoTrack() && this.isLocalVideoMuted())) {
  993. track.mute();
  994. }
  995. });
  996. this._createRoom(localTracks);
  997. return new Promise((resolve, reject) => {
  998. new ConferenceConnector(resolve, reject, this).connect();
  999. });
  1000. },
  1001. _createRoom(localTracks) {
  1002. room = APP.connection.initJitsiConference(APP.conference.roomName, this._getConferenceOptions());
  1003. // Filter out the tracks that are muted (except on Safari).
  1004. let tracks = localTracks;
  1005. if (!browser.isWebKitBased()) {
  1006. const mutedTrackTypes = [];
  1007. tracks = localTracks.filter(track => {
  1008. if (!track.isMuted()) {
  1009. return true;
  1010. }
  1011. if (track.getVideoType() !== VIDEO_TYPE.DESKTOP) {
  1012. mutedTrackTypes.push(track.getType());
  1013. }
  1014. return false;
  1015. });
  1016. APP.store.dispatch(gumPending(mutedTrackTypes, IGUMPendingState.NONE));
  1017. }
  1018. this._room = room; // FIXME do not use this
  1019. APP.store.dispatch(_conferenceWillJoin(room));
  1020. this._setLocalAudioVideoStreams(tracks);
  1021. sendLocalParticipant(APP.store, room);
  1022. this._setupListeners();
  1023. },
  1024. /**
  1025. * Sets local video and audio streams.
  1026. * @param {JitsiLocalTrack[]} tracks=[]
  1027. * @returns {Promise[]}
  1028. * @private
  1029. */
  1030. _setLocalAudioVideoStreams(tracks = []) {
  1031. const { dispatch } = APP.store;
  1032. const pendingGUMDevicesToRemove = [];
  1033. const promises = tracks.map(track => {
  1034. if (track.isAudioTrack()) {
  1035. pendingGUMDevicesToRemove.push(MEDIA_TYPE.AUDIO);
  1036. return this.useAudioStream(track);
  1037. } else if (track.isVideoTrack()) {
  1038. logger.debug(`_setLocalAudioVideoStreams is calling useVideoStream with track: ${track}`);
  1039. pendingGUMDevicesToRemove.push(MEDIA_TYPE.VIDEO);
  1040. return this.useVideoStream(track);
  1041. }
  1042. logger.error('Ignored not an audio nor a video track: ', track);
  1043. return Promise.resolve();
  1044. });
  1045. return Promise.allSettled(promises).then(() => {
  1046. if (pendingGUMDevicesToRemove.length > 0) {
  1047. dispatch(gumPending(pendingGUMDevicesToRemove, IGUMPendingState.NONE));
  1048. }
  1049. this._localTracksInitialized = true;
  1050. logger.log(`Initialized with ${tracks.length} local tracks`);
  1051. });
  1052. },
  1053. _getConferenceOptions() {
  1054. const options = getConferenceOptions(APP.store.getState());
  1055. options.createVADProcessor = createRnnoiseProcessor;
  1056. return options;
  1057. },
  1058. /**
  1059. * Start using provided video stream.
  1060. * Stops previous video stream.
  1061. * @param {JitsiLocalTrack} newTrack - new track to use or null
  1062. * @returns {Promise}
  1063. */
  1064. useVideoStream(newTrack) {
  1065. logger.debug(`useVideoStream: ${newTrack}`);
  1066. return new Promise((resolve, reject) => {
  1067. _replaceLocalVideoTrackQueue.enqueue(onFinish => {
  1068. const state = APP.store.getState();
  1069. const oldTrack = getLocalJitsiVideoTrack(state);
  1070. logger.debug(`useVideoStream: Replacing ${oldTrack} with ${newTrack}`);
  1071. if (oldTrack === newTrack || (!oldTrack && !newTrack)) {
  1072. resolve();
  1073. onFinish();
  1074. return;
  1075. }
  1076. // Add the track to the conference if there is no existing track, replace it otherwise.
  1077. const trackAction = oldTrack
  1078. ? replaceLocalTrack(oldTrack, newTrack, room)
  1079. : addLocalTrack(newTrack);
  1080. APP.store.dispatch(trackAction)
  1081. .then(() => {
  1082. this.setVideoMuteStatus();
  1083. })
  1084. .then(resolve)
  1085. .catch(error => {
  1086. logger.error(`useVideoStream failed: ${error}`);
  1087. reject(error);
  1088. })
  1089. .then(onFinish);
  1090. });
  1091. });
  1092. },
  1093. /**
  1094. * Start using provided audio stream.
  1095. * Stops previous audio stream.
  1096. * @param {JitsiLocalTrack} newTrack - new track to use or null
  1097. * @returns {Promise}
  1098. */
  1099. useAudioStream(newTrack) {
  1100. return new Promise((resolve, reject) => {
  1101. _replaceLocalAudioTrackQueue.enqueue(onFinish => {
  1102. const oldTrack = getLocalJitsiAudioTrack(APP.store.getState());
  1103. if (oldTrack === newTrack) {
  1104. resolve();
  1105. onFinish();
  1106. return;
  1107. }
  1108. APP.store.dispatch(replaceLocalTrack(oldTrack, newTrack, room))
  1109. .then(() => {
  1110. this.updateAudioIconEnabled();
  1111. })
  1112. .then(resolve)
  1113. .catch(reject)
  1114. .then(onFinish);
  1115. });
  1116. });
  1117. },
  1118. /**
  1119. * Returns whether or not the conference is currently in audio only mode.
  1120. *
  1121. * @returns {boolean}
  1122. */
  1123. isAudioOnly() {
  1124. return Boolean(APP.store.getState()['features/base/audio-only'].enabled);
  1125. },
  1126. videoSwitchInProgress: false,
  1127. /**
  1128. * This fields stores a handler which will create a Promise which turns off
  1129. * the screen sharing and restores the previous video state (was there
  1130. * any video, before switching to screen sharing ? was it muted ?).
  1131. *
  1132. * Once called this fields is cleared to <tt>null</tt>.
  1133. * @type {Function|null}
  1134. */
  1135. _untoggleScreenSharing: null,
  1136. /**
  1137. * Creates a Promise which turns off the screen sharing and restores
  1138. * the previous state described by the arguments.
  1139. *
  1140. * This method is bound to the appropriate values, after switching to screen
  1141. * sharing and stored in {@link _untoggleScreenSharing}.
  1142. *
  1143. * @param {boolean} didHaveVideo indicates if there was a camera video being
  1144. * used, before switching to screen sharing.
  1145. * @param {boolean} ignoreDidHaveVideo indicates if the camera video should be
  1146. * ignored when switching screen sharing off.
  1147. * @return {Promise} resolved after the screen sharing is turned off, or
  1148. * rejected with some error (no idea what kind of error, possible GUM error)
  1149. * in case it fails.
  1150. * @private
  1151. */
  1152. async _turnScreenSharingOff(didHaveVideo, ignoreDidHaveVideo) {
  1153. this._untoggleScreenSharing = null;
  1154. this.videoSwitchInProgress = true;
  1155. APP.store.dispatch(stopReceiver());
  1156. this._stopProxyConnection();
  1157. APP.store.dispatch(toggleScreenshotCaptureSummary(false));
  1158. const tracks = APP.store.getState()['features/base/tracks'];
  1159. const duration = getLocalVideoTrack(tracks)?.jitsiTrack.getDuration() ?? 0;
  1160. // If system audio was also shared stop the AudioMixerEffect and dispose of the desktop audio track.
  1161. if (this._mixerEffect) {
  1162. const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
  1163. await localAudio.setEffect(undefined);
  1164. await this._desktopAudioStream.dispose();
  1165. this._mixerEffect = undefined;
  1166. this._desktopAudioStream = undefined;
  1167. // In case there was no local audio when screen sharing was started the fact that we set the audio stream to
  1168. // null will take care of the desktop audio stream cleanup.
  1169. } else if (this._desktopAudioStream) {
  1170. await room.replaceTrack(this._desktopAudioStream, null);
  1171. this._desktopAudioStream.dispose();
  1172. this._desktopAudioStream = undefined;
  1173. }
  1174. APP.store.dispatch(setScreenAudioShareState(false));
  1175. let promise;
  1176. if (didHaveVideo && !ignoreDidHaveVideo) {
  1177. promise = createLocalTracksF({ devices: [ 'video' ] })
  1178. .then(([ stream ]) => {
  1179. logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
  1180. return this.useVideoStream(stream);
  1181. })
  1182. .catch(error => {
  1183. logger.error('failed to switch back to local video', error);
  1184. return this.useVideoStream(null).then(() =>
  1185. // Still fail with the original err
  1186. Promise.reject(error)
  1187. );
  1188. });
  1189. } else {
  1190. promise = this.useVideoStream(null);
  1191. }
  1192. return promise.then(
  1193. () => {
  1194. this.videoSwitchInProgress = false;
  1195. sendAnalytics(createScreenSharingEvent('stopped',
  1196. duration === 0 ? null : duration));
  1197. logger.info('Screen sharing stopped.');
  1198. },
  1199. error => {
  1200. this.videoSwitchInProgress = false;
  1201. logger.error(`_turnScreenSharingOff failed: ${error}`);
  1202. throw error;
  1203. });
  1204. },
  1205. /**
  1206. * Creates desktop (screensharing) {@link JitsiLocalTrack}
  1207. *
  1208. * @return {Promise.<JitsiLocalTrack>} - A Promise resolved with
  1209. * {@link JitsiLocalTrack} for the screensharing or rejected with
  1210. * {@link JitsiTrackError}.
  1211. *
  1212. * @private
  1213. */
  1214. _createDesktopTrack() {
  1215. const didHaveVideo = !this.isLocalVideoMuted();
  1216. const getDesktopStreamPromise = createLocalTracksF({
  1217. desktopSharingSourceDevice: config._desktopSharingSourceDevice,
  1218. devices: [ 'desktop' ]
  1219. });
  1220. return getDesktopStreamPromise.then(desktopStreams => {
  1221. // Stores the "untoggle" handler which remembers whether was
  1222. // there any video before and whether was it muted.
  1223. this._untoggleScreenSharing
  1224. = this._turnScreenSharingOff.bind(this, didHaveVideo);
  1225. const desktopVideoStream = desktopStreams.find(stream => stream.getType() === MEDIA_TYPE.VIDEO);
  1226. const desktopAudioStream = desktopStreams.find(stream => stream.getType() === MEDIA_TYPE.AUDIO);
  1227. if (desktopAudioStream) {
  1228. desktopAudioStream.on(
  1229. JitsiTrackEvents.LOCAL_TRACK_STOPPED,
  1230. () => {
  1231. logger.debug(`Local screensharing audio track stopped. ${this.isSharingScreen}`);
  1232. // Handle case where screen share was stopped from the browsers 'screen share in progress'
  1233. // window. If audio screen sharing is stopped via the normal UX flow this point shouldn't
  1234. // be reached.
  1235. isScreenAudioShared(APP.store.getState())
  1236. && this._untoggleScreenSharing
  1237. && this._untoggleScreenSharing();
  1238. }
  1239. );
  1240. }
  1241. if (desktopVideoStream) {
  1242. desktopVideoStream.on(
  1243. JitsiTrackEvents.LOCAL_TRACK_STOPPED,
  1244. () => {
  1245. logger.debug(`Local screensharing track stopped. ${this.isSharingScreen}`);
  1246. // If the stream was stopped during screen sharing
  1247. // session then we should switch back to video.
  1248. this.isSharingScreen
  1249. && this._untoggleScreenSharing
  1250. && this._untoggleScreenSharing();
  1251. }
  1252. );
  1253. }
  1254. return desktopStreams;
  1255. }, error => {
  1256. throw error;
  1257. });
  1258. },
  1259. /**
  1260. * Setup interaction between conference and UI.
  1261. */
  1262. _setupListeners() {
  1263. // add local streams when joined to the conference
  1264. room.on(JitsiConferenceEvents.CONFERENCE_JOINED, () => {
  1265. this._onConferenceJoined();
  1266. });
  1267. room.on(
  1268. JitsiConferenceEvents.CONFERENCE_JOIN_IN_PROGRESS,
  1269. () => APP.store.dispatch(conferenceJoinInProgress(room)));
  1270. room.on(
  1271. JitsiConferenceEvents.CONFERENCE_LEFT,
  1272. (...args) => {
  1273. APP.store.dispatch(conferenceTimestampChanged(0));
  1274. APP.store.dispatch(conferenceLeft(room, ...args));
  1275. });
  1276. room.on(
  1277. JitsiConferenceEvents.CONFERENCE_UNIQUE_ID_SET,
  1278. (...args) => {
  1279. // Preserve the sessionId so that the value is accessible even after room
  1280. // is disconnected.
  1281. room.sessionId = room.getMeetingUniqueId();
  1282. APP.store.dispatch(conferenceUniqueIdSet(room, ...args));
  1283. });
  1284. // we want to ignore this event in case of tokenAuthUrl config
  1285. // we are deprecating this and at some point will get rid of it
  1286. if (!config.tokenAuthUrl) {
  1287. room.on(
  1288. JitsiConferenceEvents.AUTH_STATUS_CHANGED,
  1289. (authEnabled, authLogin) =>
  1290. APP.store.dispatch(authStatusChanged(authEnabled, authLogin)));
  1291. }
  1292. room.on(JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED, user => {
  1293. APP.store.dispatch(updateRemoteParticipantFeatures(user));
  1294. });
  1295. room.on(JitsiConferenceEvents.USER_JOINED, (id, user) => {
  1296. if (config.iAmRecorder && user.isHiddenFromRecorder()) {
  1297. return;
  1298. }
  1299. // The logic shared between RN and web.
  1300. commonUserJoinedHandling(APP.store, room, user);
  1301. if (user.isHidden()) {
  1302. return;
  1303. }
  1304. APP.store.dispatch(updateRemoteParticipantFeatures(user));
  1305. logger.log(`USER ${id} connected:`, user);
  1306. APP.UI.addUser(user);
  1307. });
  1308. room.on(JitsiConferenceEvents.USER_LEFT, (id, user) => {
  1309. // The logic shared between RN and web.
  1310. commonUserLeftHandling(APP.store, room, user);
  1311. if (user.isHidden()) {
  1312. return;
  1313. }
  1314. logger.log(`USER ${id} LEFT:`, user);
  1315. });
  1316. room.on(JitsiConferenceEvents.USER_STATUS_CHANGED, (id, status) => {
  1317. APP.store.dispatch(participantPresenceChanged(id, status));
  1318. const user = room.getParticipantById(id);
  1319. if (user) {
  1320. APP.UI.updateUserStatus(user, status);
  1321. }
  1322. });
  1323. room.on(JitsiConferenceEvents.USER_ROLE_CHANGED, (id, role) => {
  1324. if (this.isLocalId(id)) {
  1325. logger.info(`My role changed, new role: ${role}`);
  1326. if (role === 'moderator') {
  1327. APP.store.dispatch(maybeSetLobbyChatMessageListener());
  1328. }
  1329. APP.store.dispatch(localParticipantRoleChanged(role));
  1330. APP.API.notifyUserRoleChanged(id, role);
  1331. } else {
  1332. APP.store.dispatch(participantRoleChanged(id, role));
  1333. }
  1334. });
  1335. room.on(JitsiConferenceEvents.TRACK_ADDED, track => {
  1336. if (!track || track.isLocal()) {
  1337. return;
  1338. }
  1339. if (config.iAmRecorder) {
  1340. const participant = room.getParticipantById(track.getParticipantId());
  1341. if (participant.isHiddenFromRecorder()) {
  1342. return;
  1343. }
  1344. }
  1345. APP.store.dispatch(trackAdded(track));
  1346. });
  1347. room.on(JitsiConferenceEvents.TRACK_REMOVED, track => {
  1348. if (!track || track.isLocal()) {
  1349. return;
  1350. }
  1351. APP.store.dispatch(trackRemoved(track));
  1352. });
  1353. room.on(JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, (id, lvl) => {
  1354. const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
  1355. let newLvl = lvl;
  1356. if (this.isLocalId(id)) {
  1357. APP.store.dispatch(localParticipantAudioLevelChanged(lvl));
  1358. }
  1359. if (this.isLocalId(id) && localAudio?.isMuted()) {
  1360. newLvl = 0;
  1361. }
  1362. if (config.testing?.testMode) {
  1363. this.audioLevelsMap[id] = newLvl;
  1364. if (config.testing?.debugAudioLevels) {
  1365. logger.log(`AudioLevel:${id}/${newLvl}`);
  1366. }
  1367. }
  1368. APP.UI.setAudioLevel(id, newLvl);
  1369. });
  1370. room.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED, (track, participantThatMutedUs) => {
  1371. if (participantThatMutedUs) {
  1372. APP.store.dispatch(participantMutedUs(participantThatMutedUs, track));
  1373. if (this.isSharingScreen && track.isVideoTrack()) {
  1374. logger.debug('TRACK_MUTE_CHANGED while screen sharing');
  1375. this._turnScreenSharingOff(false);
  1376. }
  1377. }
  1378. });
  1379. room.on(JitsiConferenceEvents.TRACK_UNMUTE_REJECTED, track => APP.store.dispatch(destroyLocalTracks(track)));
  1380. room.on(JitsiConferenceEvents.SUBJECT_CHANGED,
  1381. subject => APP.store.dispatch(conferenceSubjectChanged(subject)));
  1382. room.on(
  1383. JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
  1384. (leavingIds, enteringIds) =>
  1385. APP.UI.handleLastNEndpoints(leavingIds, enteringIds));
  1386. room.on(
  1387. JitsiConferenceEvents.P2P_STATUS,
  1388. (jitsiConference, p2p) =>
  1389. APP.store.dispatch(p2pStatusChanged(p2p)));
  1390. room.on(
  1391. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
  1392. (dominant, previous, silence) => {
  1393. APP.store.dispatch(dominantSpeakerChanged(dominant, previous, Boolean(silence), room));
  1394. });
  1395. room.on(
  1396. JitsiConferenceEvents.CONFERENCE_CREATED_TIMESTAMP,
  1397. conferenceTimestamp => {
  1398. APP.store.dispatch(conferenceTimestampChanged(conferenceTimestamp));
  1399. APP.API.notifyConferenceCreatedTimestamp(conferenceTimestamp);
  1400. }
  1401. );
  1402. room.on(
  1403. JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
  1404. (id, displayName) => {
  1405. const formattedDisplayName
  1406. = getNormalizedDisplayName(displayName);
  1407. const state = APP.store.getState();
  1408. const {
  1409. defaultRemoteDisplayName
  1410. } = state['features/base/config'];
  1411. APP.store.dispatch(participantUpdated({
  1412. conference: room,
  1413. id,
  1414. name: formattedDisplayName
  1415. }));
  1416. const virtualScreenshareParticipantId = getVirtualScreenshareParticipantByOwnerId(state, id)?.id;
  1417. if (virtualScreenshareParticipantId) {
  1418. APP.store.dispatch(
  1419. screenshareParticipantDisplayNameChanged(virtualScreenshareParticipantId, formattedDisplayName)
  1420. );
  1421. }
  1422. APP.API.notifyDisplayNameChanged(id, {
  1423. displayName: formattedDisplayName,
  1424. formattedDisplayName:
  1425. appendSuffix(
  1426. formattedDisplayName
  1427. || defaultRemoteDisplayName)
  1428. });
  1429. }
  1430. );
  1431. room.on(
  1432. JitsiConferenceEvents.SILENT_STATUS_CHANGED,
  1433. (id, isSilent) => {
  1434. APP.store.dispatch(participantUpdated({
  1435. conference: room,
  1436. id,
  1437. isSilent
  1438. }));
  1439. }
  1440. );
  1441. room.on(
  1442. JitsiConferenceEvents.BOT_TYPE_CHANGED,
  1443. (id, botType) => {
  1444. APP.store.dispatch(participantUpdated({
  1445. conference: room,
  1446. id,
  1447. botType
  1448. }));
  1449. }
  1450. );
  1451. room.on(
  1452. JitsiConferenceEvents.TRANSCRIPTION_STATUS_CHANGED,
  1453. (status, id, abruptly) => {
  1454. if (status === JitsiMeetJS.constants.transcriptionStatus.ON) {
  1455. APP.store.dispatch(transcriberJoined(id));
  1456. } else if (status === JitsiMeetJS.constants.transcriptionStatus.OFF) {
  1457. APP.store.dispatch(transcriberLeft(id, abruptly));
  1458. }
  1459. });
  1460. room.on(
  1461. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  1462. (participant, data) => {
  1463. APP.store.dispatch(endpointMessageReceived(participant, data));
  1464. if (data?.name === ENDPOINT_TEXT_MESSAGE_NAME) {
  1465. APP.API.notifyEndpointTextMessageReceived({
  1466. senderInfo: {
  1467. jid: participant.getJid(),
  1468. id: participant.getId()
  1469. },
  1470. eventData: data
  1471. });
  1472. }
  1473. });
  1474. room.on(
  1475. JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED,
  1476. (id, data) => {
  1477. APP.store.dispatch(nonParticipantMessageReceived(id, data));
  1478. APP.API.notifyNonParticipantMessageReceived(id, data);
  1479. });
  1480. room.on(
  1481. JitsiConferenceEvents.LOCK_STATE_CHANGED,
  1482. (...args) => APP.store.dispatch(lockStateChanged(room, ...args)));
  1483. room.on(
  1484. JitsiConferenceEvents.PROPERTIES_CHANGED,
  1485. properties => APP.store.dispatch(conferencePropertiesChanged(properties)));
  1486. room.on(JitsiConferenceEvents.KICKED, (participant, reason, isReplaced) => {
  1487. if (isReplaced) {
  1488. // this event triggers when the local participant is kicked, `participant`
  1489. // is the kicker. In replace participant case, kicker is undefined,
  1490. // as the server initiated it. We mark in store the local participant
  1491. // as being replaced based on jwt.
  1492. const localParticipant = getLocalParticipant(APP.store.getState());
  1493. APP.store.dispatch(participantUpdated({
  1494. conference: room,
  1495. id: localParticipant.id,
  1496. isReplaced
  1497. }));
  1498. // we send readyToClose when kicked participant is replace so that
  1499. // embedding app can choose to dispose the iframe API on the handler.
  1500. APP.API.notifyReadyToClose();
  1501. }
  1502. APP.store.dispatch(kickedOut(room, participant));
  1503. });
  1504. room.on(JitsiConferenceEvents.PARTICIPANT_KICKED, (kicker, kicked) => {
  1505. APP.store.dispatch(participantKicked(kicker, kicked));
  1506. });
  1507. room.on(JitsiConferenceEvents.PARTICIPANT_SOURCE_UPDATED,
  1508. jitsiParticipant => {
  1509. APP.store.dispatch(participantSourcesUpdated(jitsiParticipant));
  1510. });
  1511. room.on(JitsiConferenceEvents.SUSPEND_DETECTED, () => {
  1512. APP.store.dispatch(suspendDetected());
  1513. });
  1514. room.on(
  1515. JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
  1516. disableAudioMuteChange => {
  1517. APP.store.dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
  1518. });
  1519. room.on(
  1520. JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
  1521. disableVideoMuteChange => {
  1522. APP.store.dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
  1523. });
  1524. room.on(
  1525. JitsiE2ePingEvents.E2E_RTT_CHANGED,
  1526. (...args) => APP.store.dispatch(e2eRttChanged(...args)));
  1527. room.addCommandListener(this.commands.defaults.ETHERPAD,
  1528. ({ value }) => {
  1529. APP.UI.initEtherpad(value);
  1530. }
  1531. );
  1532. room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
  1533. APP.store.dispatch(participantUpdated({
  1534. conference: room,
  1535. id: from,
  1536. email: data.value
  1537. }));
  1538. });
  1539. room.addCommandListener(
  1540. this.commands.defaults.AVATAR_URL,
  1541. (data, from) => {
  1542. const participant = getParticipantByIdOrUndefined(APP.store, from);
  1543. // if already set from presence(jwt), skip the command processing
  1544. if (!participant?.avatarURL) {
  1545. APP.store.dispatch(
  1546. participantUpdated({
  1547. conference: room,
  1548. id: from,
  1549. avatarURL: data.value
  1550. }));
  1551. }
  1552. });
  1553. room.on(
  1554. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  1555. ({ audio, video }) => {
  1556. APP.store.dispatch(
  1557. onStartMutedPolicyChanged(audio, video));
  1558. }
  1559. );
  1560. room.on(JitsiConferenceEvents.STARTED_MUTED, () => {
  1561. const audioMuted = room.isStartAudioMuted();
  1562. const videoMuted = room.isStartVideoMuted();
  1563. const localTracks = getLocalTracks(APP.store.getState()['features/base/tracks']);
  1564. const promises = [];
  1565. APP.store.dispatch(setAudioMuted(audioMuted));
  1566. APP.store.dispatch(setVideoMuted(videoMuted));
  1567. // Remove the tracks from the peerconnection.
  1568. for (const track of localTracks) {
  1569. // Always add the track on Safari because of a known issue where audio playout doesn't happen
  1570. // if the user joins audio and video muted, i.e., if there is no local media capture.
  1571. if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !browser.isWebKitBased()) {
  1572. promises.push(this.useAudioStream(null));
  1573. }
  1574. if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {
  1575. promises.push(this.useVideoStream(null));
  1576. }
  1577. }
  1578. Promise.allSettled(promises)
  1579. .then(() => {
  1580. APP.store.dispatch(showNotification({
  1581. titleKey: 'notify.mutedTitle',
  1582. descriptionKey: 'notify.muted'
  1583. }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
  1584. });
  1585. });
  1586. room.on(
  1587. JitsiConferenceEvents.DATA_CHANNEL_OPENED, () => {
  1588. APP.store.dispatch(dataChannelOpened());
  1589. APP.store.dispatch(hideNotification(DATA_CHANNEL_CLOSED_NOTIFICATION_ID));
  1590. }
  1591. );
  1592. room.on(
  1593. JitsiConferenceEvents.DATA_CHANNEL_CLOSED, ev => {
  1594. const state = APP.store.getState();
  1595. const { dataChannelOpen } = state['features/base/conference'];
  1596. const timeout = typeof dataChannelOpen === 'undefined' ? 15000 : 60000;
  1597. // Show the notification only when the data channel connection doesn't get re-established in 60 secs if
  1598. // it was already established at the beginning of the call, show it sooner otherwise. This notification
  1599. // can be confusing and alarming to users even when there is no significant impact to user experience
  1600. // if the the reconnect happens immediately.
  1601. setTimeout(() => {
  1602. const { dataChannelOpen: open } = APP.store.getState()['features/base/conference'];
  1603. if (!open) {
  1604. const descriptionKey = getSsrcRewritingFeatureFlag(state)
  1605. ? 'notify.dataChannelClosedDescriptionWithAudio' : 'notify.dataChannelClosedDescription';
  1606. const titleKey = getSsrcRewritingFeatureFlag(state)
  1607. ? 'notify.dataChannelClosedWithAudio' : 'notify.dataChannelClosed';
  1608. APP.store.dispatch(dataChannelClosed(ev.code, ev.reason));
  1609. APP.store.dispatch(showWarningNotification({
  1610. descriptionKey,
  1611. titleKey,
  1612. uid: DATA_CHANNEL_CLOSED_NOTIFICATION_ID
  1613. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  1614. }
  1615. }, timeout);
  1616. }
  1617. );
  1618. },
  1619. /**
  1620. * Handles audio device changes.
  1621. *
  1622. * @param {string} cameraDeviceId - The new device id.
  1623. * @returns {Promise}
  1624. */
  1625. async onAudioDeviceChanged(micDeviceId) {
  1626. const audioWasMuted = this.isLocalAudioMuted();
  1627. // Disable noise suppression if it was enabled on the previous track.
  1628. await APP.store.dispatch(setNoiseSuppressionEnabled(false));
  1629. // When the 'default' mic needs to be selected, we need to pass the real device id to gUM instead of
  1630. // 'default' in order to get the correct MediaStreamTrack from chrome because of the following bug.
  1631. // https://bugs.chromium.org/p/chromium/issues/detail?id=997689.
  1632. const isDefaultMicSelected = micDeviceId === 'default';
  1633. const selectedDeviceId = isDefaultMicSelected
  1634. ? getDefaultDeviceId(APP.store.getState(), 'audioInput')
  1635. : micDeviceId;
  1636. logger.info(`Switching audio input device to ${selectedDeviceId}`);
  1637. sendAnalytics(createDeviceChangedEvent('audio', 'input'));
  1638. createLocalTracksF({
  1639. devices: [ 'audio' ],
  1640. micDeviceId: selectedDeviceId
  1641. })
  1642. .then(([ stream ]) => {
  1643. // if audio was muted before changing the device, mute
  1644. // with the new device
  1645. if (audioWasMuted) {
  1646. return stream.mute()
  1647. .then(() => stream);
  1648. }
  1649. return stream;
  1650. })
  1651. .then(async stream => {
  1652. await this._maybeApplyAudioMixerEffect(stream);
  1653. return this.useAudioStream(stream);
  1654. })
  1655. .then(() => {
  1656. const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
  1657. if (localAudio && isDefaultMicSelected) {
  1658. // workaround for the default device to be shown as selected in the
  1659. // settings even when the real device id was passed to gUM because of the
  1660. // above mentioned chrome bug.
  1661. localAudio._realDeviceId = localAudio.deviceId = 'default';
  1662. }
  1663. })
  1664. .catch(err => {
  1665. logger.error(`Failed to switch to selected audio input device ${selectedDeviceId}, error=${err}`);
  1666. APP.store.dispatch(notifyMicError(err));
  1667. });
  1668. },
  1669. /**
  1670. * Handles video device changes.
  1671. *
  1672. * @param {string} cameraDeviceId - The new device id.
  1673. * @returns {void}
  1674. */
  1675. onVideoDeviceChanged(cameraDeviceId) {
  1676. const videoWasMuted = this.isLocalVideoMuted();
  1677. const localVideoTrack = getLocalJitsiVideoTrack(APP.store.getState());
  1678. if (localVideoTrack?.getDeviceId() === cameraDeviceId) {
  1679. return;
  1680. }
  1681. sendAnalytics(createDeviceChangedEvent('video', 'input'));
  1682. createLocalTracksF({
  1683. devices: [ 'video' ],
  1684. cameraDeviceId
  1685. })
  1686. .then(([ stream ]) => {
  1687. // if we are in audio only mode or video was muted before
  1688. // changing device, then mute
  1689. if (this.isAudioOnly() || videoWasMuted) {
  1690. return stream.mute()
  1691. .then(() => stream);
  1692. }
  1693. return stream;
  1694. })
  1695. .then(stream => {
  1696. logger.info(`Switching the local video device to ${cameraDeviceId}.`);
  1697. return this.useVideoStream(stream);
  1698. })
  1699. .catch(error => {
  1700. logger.error(`Failed to switch to selected camera:${cameraDeviceId}, error:${error}`);
  1701. return APP.store.dispatch(notifyCameraError(error));
  1702. });
  1703. },
  1704. /**
  1705. * Handles audio only changes.
  1706. */
  1707. onToggleAudioOnly() {
  1708. // Immediately update the UI by having remote videos and the large video update themselves.
  1709. const displayedUserId = APP.UI.getLargeVideoID();
  1710. if (displayedUserId) {
  1711. APP.UI.updateLargeVideo(displayedUserId, true);
  1712. }
  1713. },
  1714. /**
  1715. * Cleanups local conference on suspend.
  1716. */
  1717. onSuspendDetected() {
  1718. // After wake up, we will be in a state where conference is left
  1719. // there will be dialog shown to user.
  1720. // We do not want video/audio as we show an overlay and after it
  1721. // user need to rejoin or close, while waking up we can detect
  1722. // camera wakeup as a problem with device.
  1723. // We also do not care about device change, which happens
  1724. // on resume after suspending PC.
  1725. if (this.deviceChangeListener) {
  1726. JitsiMeetJS.mediaDevices.removeEventListener(
  1727. JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
  1728. this.deviceChangeListener);
  1729. }
  1730. },
  1731. /**
  1732. * Callback invoked when the conference has been successfully joined.
  1733. * Initializes the UI and various other features.
  1734. *
  1735. * @private
  1736. * @returns {void}
  1737. */
  1738. _onConferenceJoined() {
  1739. const { dispatch } = APP.store;
  1740. APP.UI.initConference();
  1741. dispatch(conferenceJoined(room));
  1742. const jwt = APP.store.getState()['features/base/jwt'];
  1743. if (jwt?.user?.hiddenFromRecorder) {
  1744. dispatch(muteLocal(true, MEDIA_TYPE.AUDIO));
  1745. dispatch(muteLocal(true, MEDIA_TYPE.VIDEO));
  1746. dispatch(setAudioUnmutePermissions(true, true));
  1747. dispatch(setVideoUnmutePermissions(true, true));
  1748. }
  1749. },
  1750. /**
  1751. * Updates the list of current devices.
  1752. * @param {boolean} setDeviceListChangeHandler - Whether to add the deviceList change handlers.
  1753. * @private
  1754. * @returns {Promise}
  1755. */
  1756. _initDeviceList(setDeviceListChangeHandler = false) {
  1757. const { mediaDevices } = JitsiMeetJS;
  1758. if (mediaDevices.isDeviceListAvailable()
  1759. && mediaDevices.isDeviceChangeAvailable()) {
  1760. if (setDeviceListChangeHandler) {
  1761. this.deviceChangeListener = devices =>
  1762. window.setTimeout(() => this._onDeviceListChanged(devices), 0);
  1763. mediaDevices.addEventListener(
  1764. JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
  1765. this.deviceChangeListener);
  1766. }
  1767. const { dispatch } = APP.store;
  1768. return dispatch(getAvailableDevices())
  1769. .then(() => {
  1770. this.updateAudioIconEnabled();
  1771. this.updateVideoIconEnabled();
  1772. });
  1773. }
  1774. return Promise.resolve();
  1775. },
  1776. /**
  1777. * Event listener for JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED to
  1778. * handle change of available media devices.
  1779. * @private
  1780. * @param {MediaDeviceInfo[]} devices
  1781. * @returns {Promise}
  1782. */
  1783. async _onDeviceListChanged(devices) {
  1784. const state = APP.store.getState();
  1785. const { filteredDevices, ignoredDevices } = filterIgnoredDevices(devices);
  1786. const oldDevices = state['features/base/devices'].availableDevices;
  1787. if (!areDevicesDifferent(flattenAvailableDevices(oldDevices), filteredDevices)) {
  1788. return Promise.resolve();
  1789. }
  1790. logDevices(ignoredDevices, 'Ignored devices on device list changed:');
  1791. const localAudio = getLocalJitsiAudioTrack(state);
  1792. const localVideo = getLocalJitsiVideoTrack(state);
  1793. APP.store.dispatch(updateDeviceList(filteredDevices));
  1794. // Firefox users can choose their preferred device in the gUM prompt. In that case
  1795. // we should respect that and not attempt to switch to the preferred device from
  1796. // our settings.
  1797. const newLabelsOnly = mediaDeviceHelper.newDeviceListAddedLabelsOnly(oldDevices, filteredDevices);
  1798. const newDevices
  1799. = mediaDeviceHelper.getNewMediaDevicesAfterDeviceListChanged(
  1800. filteredDevices,
  1801. localVideo,
  1802. localAudio,
  1803. newLabelsOnly);
  1804. const promises = [];
  1805. const requestedInput = {
  1806. audio: Boolean(newDevices.audioinput),
  1807. video: Boolean(newDevices.videoinput)
  1808. };
  1809. if (typeof newDevices.audiooutput !== 'undefined') {
  1810. const { dispatch } = APP.store;
  1811. const setAudioOutputPromise
  1812. = setAudioOutputDeviceId(newDevices.audiooutput, dispatch)
  1813. .catch(err => {
  1814. logger.error(`Failed to set the audio output device to ${newDevices.audiooutput} - ${err}`);
  1815. });
  1816. promises.push(setAudioOutputPromise);
  1817. }
  1818. // Handles the use case when the default device is changed (we are always stopping the streams because it's
  1819. // simpler):
  1820. // If the default device is changed we need to first stop the local streams and then call GUM. Otherwise GUM
  1821. // will return a stream using the old default device.
  1822. if (requestedInput.audio && localAudio) {
  1823. localAudio.stopStream();
  1824. }
  1825. if (requestedInput.video && localVideo) {
  1826. localVideo.stopStream();
  1827. }
  1828. // Let's handle unknown/non-preferred devices
  1829. const newAvailDevices = APP.store.getState()['features/base/devices'].availableDevices;
  1830. let newAudioDevices = [];
  1831. let oldAudioDevices = [];
  1832. if (typeof newDevices.audiooutput === 'undefined') {
  1833. newAudioDevices = newAvailDevices.audioOutput;
  1834. oldAudioDevices = oldDevices.audioOutput;
  1835. }
  1836. if (!requestedInput.audio) {
  1837. newAudioDevices = newAudioDevices.concat(newAvailDevices.audioInput);
  1838. oldAudioDevices = oldAudioDevices.concat(oldDevices.audioInput);
  1839. }
  1840. // check for audio
  1841. if (newAudioDevices.length > 0) {
  1842. APP.store.dispatch(checkAndNotifyForNewDevice(newAudioDevices, oldAudioDevices));
  1843. }
  1844. // check for video
  1845. if (requestedInput.video) {
  1846. APP.store.dispatch(checkAndNotifyForNewDevice(newAvailDevices.videoInput, oldDevices.videoInput));
  1847. }
  1848. // When the 'default' mic needs to be selected, we need to pass the real device id to gUM instead of 'default'
  1849. // in order to get the correct MediaStreamTrack from chrome because of the following bug.
  1850. // https://bugs.chromium.org/p/chromium/issues/detail?id=997689
  1851. const hasDefaultMicChanged = newDevices.audioinput === 'default';
  1852. // When the local video is muted and a preferred device is connected, update the settings and remove the track
  1853. // from the conference. A new track will be created and replaced when the user unmutes their camera.
  1854. if (requestedInput.video && this.isLocalVideoMuted()) {
  1855. APP.store.dispatch(updateSettings({
  1856. cameraDeviceId: newDevices.videoinput
  1857. }));
  1858. requestedInput.video = false;
  1859. delete newDevices.videoinput;
  1860. // Remove the track from the conference.
  1861. if (localVideo) {
  1862. await this.useVideoStream(null);
  1863. logger.debug('_onDeviceListChanged: Removed the current video track.');
  1864. }
  1865. }
  1866. // When the local audio is muted and a preferred device is connected, update the settings and remove the track
  1867. // from the conference. A new track will be created and replaced when the user unmutes their mic.
  1868. if (requestedInput.audio && this.isLocalAudioMuted()) {
  1869. APP.store.dispatch(updateSettings({
  1870. micDeviceId: newDevices.audioinput
  1871. }));
  1872. requestedInput.audio = false;
  1873. delete newDevices.audioinput;
  1874. // Remove the track from the conference.
  1875. if (localAudio) {
  1876. await this.useAudioStream(null);
  1877. logger.debug('_onDeviceListChanged: Removed the current audio track.');
  1878. }
  1879. }
  1880. // Create the tracks and replace them only if the user is unmuted.
  1881. if (requestedInput.audio || requestedInput.video) {
  1882. let tracks = [];
  1883. const realAudioDeviceId = hasDefaultMicChanged
  1884. ? getDefaultDeviceId(APP.store.getState(), 'audioInput') : newDevices.audioinput;
  1885. try {
  1886. tracks = await mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
  1887. createLocalTracksF,
  1888. requestedInput.video ? newDevices.videoinput : null,
  1889. requestedInput.audio ? realAudioDeviceId : null
  1890. );
  1891. } catch (error) {
  1892. logger.error(`Track creation failed on device change, ${error}`);
  1893. return Promise.reject(error);
  1894. }
  1895. for (const track of tracks) {
  1896. if (track.isAudioTrack()) {
  1897. promises.push(
  1898. this.useAudioStream(track)
  1899. .then(() => {
  1900. hasDefaultMicChanged && (track._realDeviceId = track.deviceId = 'default');
  1901. }));
  1902. } else {
  1903. promises.push(
  1904. this.useVideoStream(track));
  1905. }
  1906. }
  1907. }
  1908. return Promise.all(promises)
  1909. .then(() => {
  1910. this.updateAudioIconEnabled();
  1911. this.updateVideoIconEnabled();
  1912. });
  1913. },
  1914. /**
  1915. * Determines whether or not the audio button should be enabled.
  1916. */
  1917. updateAudioIconEnabled() {
  1918. const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
  1919. const audioMediaDevices = APP.store.getState()['features/base/devices'].availableDevices.audioInput;
  1920. const audioDeviceCount = audioMediaDevices ? audioMediaDevices.length : 0;
  1921. // The audio functionality is considered available if there are any
  1922. // audio devices detected or if the local audio stream already exists.
  1923. const available = audioDeviceCount > 0 || Boolean(localAudio);
  1924. APP.store.dispatch(setAudioAvailable(available));
  1925. },
  1926. /**
  1927. * Determines whether or not the video button should be enabled.
  1928. */
  1929. updateVideoIconEnabled() {
  1930. const videoMediaDevices
  1931. = APP.store.getState()['features/base/devices'].availableDevices.videoInput;
  1932. const videoDeviceCount
  1933. = videoMediaDevices ? videoMediaDevices.length : 0;
  1934. const localVideo = getLocalJitsiVideoTrack(APP.store.getState());
  1935. // The video functionality is considered available if there are any
  1936. // video devices detected or if there is local video stream already
  1937. // active which could be either screensharing stream or a video track
  1938. // created before the permissions were rejected (through browser
  1939. // config).
  1940. const available = videoDeviceCount > 0 || Boolean(localVideo);
  1941. APP.store.dispatch(setVideoAvailable(available));
  1942. APP.API.notifyVideoAvailabilityChanged(available);
  1943. },
  1944. /**
  1945. * Disconnect from the conference and optionally request user feedback.
  1946. * @param {boolean} [requestFeedback=false] if user feedback should be
  1947. * @param {string} [hangupReason] the reason for leaving the meeting
  1948. * requested
  1949. */
  1950. hangup(requestFeedback = false, hangupReason) {
  1951. APP.store.dispatch(disableReceiver());
  1952. this._stopProxyConnection();
  1953. APP.store.dispatch(destroyLocalTracks());
  1954. this._localTracksInitialized = false;
  1955. // Remove unnecessary event listeners from firing callbacks.
  1956. if (this.deviceChangeListener) {
  1957. JitsiMeetJS.mediaDevices.removeEventListener(
  1958. JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
  1959. this.deviceChangeListener);
  1960. }
  1961. let feedbackResultPromise = Promise.resolve({});
  1962. if (requestFeedback) {
  1963. const feedbackDialogClosed = (feedbackResult = {}) => {
  1964. if (!feedbackResult.wasDialogShown && hangupReason) {
  1965. return APP.store.dispatch(
  1966. openLeaveReasonDialog(hangupReason)).then(() => feedbackResult);
  1967. }
  1968. return Promise.resolve(feedbackResult);
  1969. };
  1970. feedbackResultPromise
  1971. = APP.store.dispatch(maybeOpenFeedbackDialog(room, hangupReason))
  1972. .then(feedbackDialogClosed, feedbackDialogClosed);
  1973. }
  1974. const leavePromise = this.leaveRoom().catch(() => Promise.resolve());
  1975. Promise.allSettled([ feedbackResultPromise, leavePromise ]).then(([ feedback, _ ]) => {
  1976. this._room = undefined;
  1977. room = undefined;
  1978. /**
  1979. * Don't call {@code notifyReadyToClose} if the promotional page flag is set
  1980. * and let the page take care of sending the message, since there will be
  1981. * a redirect to the page anyway.
  1982. */
  1983. if (!interfaceConfig.SHOW_PROMOTIONAL_CLOSE_PAGE) {
  1984. APP.API.notifyReadyToClose();
  1985. }
  1986. APP.store.dispatch(maybeRedirectToWelcomePage(feedback.value ?? {}));
  1987. });
  1988. },
  1989. /**
  1990. * Leaves the room.
  1991. *
  1992. * @param {boolean} doDisconnect - Whether leaving the room should also terminate the connection.
  1993. * @param {string} reason - reason for leaving the room.
  1994. * @returns {Promise}
  1995. */
  1996. leaveRoom(doDisconnect = true, reason = '') {
  1997. APP.store.dispatch(conferenceWillLeave(room));
  1998. const maybeDisconnect = () => {
  1999. if (doDisconnect) {
  2000. return disconnect();
  2001. }
  2002. };
  2003. if (room && room.isJoined()) {
  2004. return room.leave(reason).then(() => maybeDisconnect())
  2005. .catch(e => {
  2006. logger.error(e);
  2007. return maybeDisconnect();
  2008. });
  2009. }
  2010. return maybeDisconnect();
  2011. },
  2012. /**
  2013. * Changes the email for the local user
  2014. * @param email {string} the new email
  2015. */
  2016. changeLocalEmail(email = '') {
  2017. const formattedEmail = String(email).trim();
  2018. APP.store.dispatch(updateSettings({
  2019. email: formattedEmail
  2020. }));
  2021. sendData(commands.EMAIL, formattedEmail);
  2022. },
  2023. /**
  2024. * Changes the avatar url for the local user
  2025. * @param url {string} the new url
  2026. */
  2027. changeLocalAvatarUrl(url = '') {
  2028. const formattedUrl = String(url).trim();
  2029. APP.store.dispatch(updateSettings({
  2030. avatarURL: formattedUrl
  2031. }));
  2032. sendData(commands.AVATAR_URL, url);
  2033. },
  2034. /**
  2035. * Sends a message via the data channel.
  2036. * @param {string} to the id of the endpoint that should receive the
  2037. * message. If "" - the message will be sent to all participants.
  2038. * @param {object} payload the payload of the message.
  2039. * @throws NetworkError or InvalidStateError or Error if the operation
  2040. * fails.
  2041. */
  2042. sendEndpointMessage(to, payload) {
  2043. room.sendEndpointMessage(to, payload);
  2044. },
  2045. /**
  2046. * Callback invoked by the external api create or update a direct connection
  2047. * from the local client to an external client.
  2048. *
  2049. * @param {Object} event - The object containing information that should be
  2050. * passed to the {@code ProxyConnectionService}.
  2051. * @returns {void}
  2052. */
  2053. onProxyConnectionEvent(event) {
  2054. if (!this._proxyConnection) {
  2055. this._proxyConnection = new JitsiMeetJS.ProxyConnectionService({
  2056. /**
  2057. * Pass the {@code JitsiConnection} instance which will be used
  2058. * to fetch TURN credentials.
  2059. */
  2060. jitsiConnection: APP.connection,
  2061. /**
  2062. * The proxy connection feature is currently tailored towards
  2063. * taking a proxied video stream and showing it as a local
  2064. * desktop screen.
  2065. */
  2066. convertVideoToDesktop: true,
  2067. /**
  2068. * Callback invoked when the connection has been closed
  2069. * automatically. Triggers cleanup of screensharing if active.
  2070. *
  2071. * @returns {void}
  2072. */
  2073. onConnectionClosed: () => {
  2074. if (this._untoggleScreenSharing) {
  2075. this._untoggleScreenSharing();
  2076. }
  2077. },
  2078. /**
  2079. * Callback invoked to pass messages from the local client back
  2080. * out to the external client.
  2081. *
  2082. * @param {string} peerJid - The jid of the intended recipient
  2083. * of the message.
  2084. * @param {Object} data - The message that should be sent. For
  2085. * screensharing this is an iq.
  2086. * @returns {void}
  2087. */
  2088. onSendMessage: (peerJid, data) =>
  2089. APP.API.sendProxyConnectionEvent({
  2090. data,
  2091. to: peerJid
  2092. }),
  2093. /**
  2094. * Callback invoked when the remote peer of the proxy connection
  2095. * has provided a video stream, intended to be used as a local
  2096. * desktop stream.
  2097. *
  2098. * @param {JitsiLocalTrack} remoteProxyStream - The media
  2099. * stream to use as a local desktop stream.
  2100. * @returns {void}
  2101. */
  2102. onRemoteStream: desktopStream => {
  2103. if (desktopStream.videoType !== 'desktop') {
  2104. logger.warn('Received a non-desktop stream to proxy.');
  2105. desktopStream.dispose();
  2106. return;
  2107. }
  2108. APP.store.dispatch(toggleScreensharingA(undefined, false, { desktopStream }));
  2109. }
  2110. });
  2111. }
  2112. this._proxyConnection.processMessage(event);
  2113. },
  2114. /**
  2115. * Sets the video muted status.
  2116. */
  2117. setVideoMuteStatus() {
  2118. APP.UI.setVideoMuted(this.getMyUserId());
  2119. },
  2120. /**
  2121. * Dispatches the passed in feedback for submission. The submitted score
  2122. * should be a number inclusively between 1 through 5, or -1 for no score.
  2123. *
  2124. * @param {number} score - a number between 1 and 5 (inclusive) or -1 for no
  2125. * score.
  2126. * @param {string} message - An optional message to attach to the feedback
  2127. * in addition to the score.
  2128. * @returns {void}
  2129. */
  2130. submitFeedback(score = -1, message = '') {
  2131. if (score === -1 || (score >= 1 && score <= 5)) {
  2132. APP.store.dispatch(submitFeedback(score, message, room));
  2133. }
  2134. },
  2135. /**
  2136. * Terminates any proxy screensharing connection that is active.
  2137. *
  2138. * @private
  2139. * @returns {void}
  2140. */
  2141. _stopProxyConnection() {
  2142. if (this._proxyConnection) {
  2143. this._proxyConnection.stop();
  2144. }
  2145. this._proxyConnection = null;
  2146. }
  2147. };