You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VideoLayout.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. /* global APP, $, interfaceConfig */
  2. import Logger from 'jitsi-meet-logger';
  3. import { MEDIA_TYPE, VIDEO_TYPE } from '../../../react/features/base/media';
  4. import {
  5. getLocalParticipant as getLocalParticipantFromStore,
  6. getPinnedParticipant,
  7. getParticipantById,
  8. pinParticipant
  9. } from '../../../react/features/base/participants';
  10. import { getTrackByMediaTypeAndParticipant } from '../../../react/features/base/tracks';
  11. import UIEvents from '../../../service/UI/UIEvents';
  12. import { SHARED_VIDEO_CONTAINER_TYPE } from '../shared_video/SharedVideo';
  13. import SharedVideoThumb from '../shared_video/SharedVideoThumb';
  14. import LargeVideoManager from './LargeVideoManager';
  15. import LocalVideo from './LocalVideo';
  16. import RemoteVideo from './RemoteVideo';
  17. import { VIDEO_CONTAINER_TYPE } from './VideoContainer';
  18. const logger = Logger.getLogger(__filename);
  19. const remoteVideos = {};
  20. let localVideoThumbnail = null;
  21. let eventEmitter = null;
  22. let largeVideo;
  23. /**
  24. * flipX state of the localVideo
  25. */
  26. let localFlipX = null;
  27. /**
  28. * Handler for local flip X changed event.
  29. * @param {Object} val
  30. */
  31. function onLocalFlipXChanged(val) {
  32. localFlipX = val;
  33. if (largeVideo) {
  34. largeVideo.onLocalFlipXChange(val);
  35. }
  36. }
  37. /**
  38. * Returns an array of all thumbnails in the filmstrip.
  39. *
  40. * @private
  41. * @returns {Array}
  42. */
  43. function getAllThumbnails() {
  44. return [
  45. ...localVideoThumbnail ? [ localVideoThumbnail ] : [],
  46. ...Object.values(remoteVideos)
  47. ];
  48. }
  49. /**
  50. * Private helper to get the redux representation of the local participant.
  51. *
  52. * @private
  53. * @returns {Object}
  54. */
  55. function getLocalParticipant() {
  56. return getLocalParticipantFromStore(APP.store.getState());
  57. }
  58. const VideoLayout = {
  59. init(emitter) {
  60. eventEmitter = emitter;
  61. localVideoThumbnail = new LocalVideo(
  62. VideoLayout,
  63. emitter,
  64. this._updateLargeVideoIfDisplayed.bind(this));
  65. this.registerListeners();
  66. },
  67. /**
  68. * Registering listeners for UI events in Video layout component.
  69. *
  70. * @returns {void}
  71. */
  72. registerListeners() {
  73. eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED,
  74. onLocalFlipXChanged);
  75. },
  76. /**
  77. * Cleans up state of this singleton {@code VideoLayout}.
  78. *
  79. * @returns {void}
  80. */
  81. reset() {
  82. this._resetLargeVideo();
  83. this._resetFilmstrip();
  84. },
  85. initLargeVideo() {
  86. this._resetLargeVideo();
  87. largeVideo = new LargeVideoManager(eventEmitter);
  88. if (localFlipX) {
  89. largeVideo.onLocalFlipXChange(localFlipX);
  90. }
  91. largeVideo.updateContainerSize();
  92. },
  93. /**
  94. * Sets the audio level of the video elements associated to the given id.
  95. *
  96. * @param id the video identifier in the form it comes from the library
  97. * @param lvl the new audio level to update to
  98. */
  99. setAudioLevel(id, lvl) {
  100. const smallVideo = this.getSmallVideo(id);
  101. if (smallVideo) {
  102. smallVideo.updateAudioLevelIndicator(lvl);
  103. }
  104. if (largeVideo && id === largeVideo.id) {
  105. largeVideo.updateLargeVideoAudioLevel(lvl);
  106. }
  107. },
  108. changeLocalVideo(stream) {
  109. const localId = getLocalParticipant().id;
  110. this.onVideoTypeChanged(localId, stream.videoType);
  111. localVideoThumbnail.changeVideo(stream);
  112. this._updateLargeVideoIfDisplayed(localId);
  113. },
  114. /**
  115. * Get's the localID of the conference and set it to the local video
  116. * (small one). This needs to be called as early as possible, when muc is
  117. * actually joined. Otherwise events can come with information like email
  118. * and setting them assume the id is already set.
  119. */
  120. mucJoined() {
  121. // FIXME: replace this call with a generic update call once SmallVideo
  122. // only contains a ReactElement. Then remove this call once the
  123. // Filmstrip is fully in React.
  124. localVideoThumbnail.updateIndicators();
  125. },
  126. /**
  127. * Shows/hides local video.
  128. * @param {boolean} true to make the local video visible, false - otherwise
  129. */
  130. setLocalVideoVisible(visible) {
  131. localVideoThumbnail.setVisible(visible);
  132. },
  133. onRemoteStreamAdded(stream) {
  134. const id = stream.getParticipantId();
  135. const remoteVideo = remoteVideos[id];
  136. logger.debug(`Received a new ${stream.getType()} stream for ${id}`);
  137. if (!remoteVideo) {
  138. logger.debug('No remote video element to add stream');
  139. return;
  140. }
  141. remoteVideo.addRemoteStreamElement(stream);
  142. // Make sure track's muted state is reflected
  143. if (stream.getType() !== 'audio') {
  144. this.onVideoMute(id);
  145. remoteVideo.updateView();
  146. }
  147. },
  148. onRemoteStreamRemoved(stream) {
  149. const id = stream.getParticipantId();
  150. const remoteVideo = remoteVideos[id];
  151. // Remote stream may be removed after participant left the conference.
  152. if (remoteVideo) {
  153. remoteVideo.removeRemoteStreamElement(stream);
  154. remoteVideo.updateView();
  155. }
  156. this.updateMutedForNoTracks(id, stream.getType());
  157. },
  158. /**
  159. * FIXME get rid of this method once muted indicator are reactified (by
  160. * making sure that user with no tracks is displayed as muted )
  161. *
  162. * If participant has no tracks will make the UI display muted status.
  163. * @param {string} participantId
  164. * @param {string} mediaType 'audio' or 'video'
  165. */
  166. updateMutedForNoTracks(participantId, mediaType) {
  167. const participant = APP.conference.getParticipantById(participantId);
  168. if (participant && !participant.getTracksByMediaType(mediaType).length) {
  169. if (mediaType === 'audio') {
  170. APP.UI.setAudioMuted(participantId, true);
  171. } else if (mediaType === 'video') {
  172. APP.UI.setVideoMuted(participantId);
  173. } else {
  174. logger.error(`Unsupported media type: ${mediaType}`);
  175. }
  176. }
  177. },
  178. /**
  179. * Return the type of the remote video.
  180. * @param id the id for the remote video
  181. * @returns {String} the video type video or screen.
  182. */
  183. getRemoteVideoType(id) {
  184. const state = APP.store.getState();
  185. const participant = getParticipantById(state, id);
  186. if (participant?.isFakeParticipant) {
  187. return SHARED_VIDEO_CONTAINER_TYPE;
  188. }
  189. const videoTrack = getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
  190. return videoTrack?.videoType;
  191. },
  192. isPinned(id) {
  193. return id === this.getPinnedId();
  194. },
  195. getPinnedId() {
  196. const { id } = getPinnedParticipant(APP.store.getState()) || {};
  197. return id || null;
  198. },
  199. /**
  200. * Triggers a thumbnail to pin or unpin itself.
  201. *
  202. * @param {number} videoNumber - The index of the video to toggle pin on.
  203. * @private
  204. */
  205. togglePin(videoNumber) {
  206. const videos = getAllThumbnails();
  207. const videoView = videos[videoNumber];
  208. videoView && videoView.togglePin();
  209. },
  210. /**
  211. * Callback invoked to update display when the pin participant has changed.
  212. *
  213. * @paramn {string|null} pinnedParticipantID - The participant ID of the
  214. * participant that is pinned or null if no one is pinned.
  215. * @returns {void}
  216. */
  217. onPinChange(pinnedParticipantID) {
  218. if (interfaceConfig.filmStripOnly) {
  219. return;
  220. }
  221. getAllThumbnails().forEach(thumbnail =>
  222. thumbnail.focus(pinnedParticipantID === thumbnail.getId()));
  223. },
  224. /**
  225. * Creates a participant container for the given id.
  226. *
  227. * @param {Object} participant - The redux representation of a remote
  228. * participant.
  229. * @returns {void}
  230. */
  231. addRemoteParticipantContainer(participant) {
  232. if (!participant || participant.local) {
  233. return;
  234. } else if (participant.isFakeParticipant) {
  235. const sharedVideoThumb = new SharedVideoThumb(
  236. participant,
  237. SHARED_VIDEO_CONTAINER_TYPE,
  238. VideoLayout);
  239. this.addRemoteVideoContainer(participant.id, sharedVideoThumb);
  240. return;
  241. }
  242. const id = participant.id;
  243. const jitsiParticipant = APP.conference.getParticipantById(id);
  244. const remoteVideo = new RemoteVideo(jitsiParticipant, VideoLayout);
  245. this._setRemoteControlProperties(jitsiParticipant, remoteVideo);
  246. this.addRemoteVideoContainer(id, remoteVideo);
  247. this.updateMutedForNoTracks(id, 'audio');
  248. this.updateMutedForNoTracks(id, 'video');
  249. },
  250. /**
  251. * Adds remote video container for the given id and <tt>SmallVideo</tt>.
  252. *
  253. * @param {string} the id of the video to add
  254. * @param {SmallVideo} smallVideo the small video instance to add as a
  255. * remote video
  256. */
  257. addRemoteVideoContainer(id, remoteVideo) {
  258. remoteVideos[id] = remoteVideo;
  259. // Initialize the view
  260. remoteVideo.updateView();
  261. },
  262. // FIXME: what does this do???
  263. remoteVideoActive(videoElement, resourceJid) {
  264. logger.info(`${resourceJid} video is now active`, videoElement);
  265. if (videoElement) {
  266. $(videoElement).show();
  267. }
  268. this._updateLargeVideoIfDisplayed(resourceJid, true);
  269. },
  270. /**
  271. * On video muted event.
  272. */
  273. onVideoMute(id) {
  274. if (APP.conference.isLocalId(id)) {
  275. localVideoThumbnail && localVideoThumbnail.updateView();
  276. } else {
  277. const remoteVideo = remoteVideos[id];
  278. if (remoteVideo) {
  279. remoteVideo.onVideoMute();
  280. }
  281. }
  282. // large video will show avatar instead of muted stream
  283. this._updateLargeVideoIfDisplayed(id, true);
  284. },
  285. /**
  286. * Display name changed.
  287. */
  288. onDisplayNameChanged(id) {
  289. if (id === 'localVideoContainer'
  290. || APP.conference.isLocalId(id)) {
  291. localVideoThumbnail.updateDisplayName();
  292. } else {
  293. const remoteVideo = remoteVideos[id];
  294. if (remoteVideo) {
  295. remoteVideo.updateDisplayName();
  296. }
  297. }
  298. },
  299. /**
  300. * On dominant speaker changed event.
  301. *
  302. * @param {string} id - The participant ID of the new dominant speaker.
  303. * @returns {void}
  304. */
  305. onDominantSpeakerChanged(id) {
  306. getAllThumbnails().forEach(thumbnail =>
  307. thumbnail.showDominantSpeakerIndicator(id === thumbnail.getId()));
  308. },
  309. /**
  310. * Shows/hides warning about a user's connectivity issues.
  311. *
  312. * @param {string} id - The ID of the remote participant(MUC nickname).
  313. * @returns {void}
  314. */
  315. onParticipantConnectionStatusChanged(id) {
  316. if (APP.conference.isLocalId(id)) {
  317. return;
  318. }
  319. // We have to trigger full large video update to transition from
  320. // avatar to video on connectivity restored.
  321. this._updateLargeVideoIfDisplayed(id, true);
  322. const remoteVideo = remoteVideos[id];
  323. if (remoteVideo) {
  324. // Updating only connection status indicator is not enough, because
  325. // when we the connection is restored while the avatar was displayed
  326. // (due to 'muted while disconnected' condition) we may want to show
  327. // the video stream again and in order to do that the display mode
  328. // must be updated.
  329. // remoteVideo.updateConnectionStatusIndicator(isActive);
  330. remoteVideo.updateView();
  331. }
  332. },
  333. /**
  334. * On last N change event.
  335. *
  336. * @param endpointsLeavingLastN the list currently leaving last N
  337. * endpoints
  338. * @param endpointsEnteringLastN the list currently entering last N
  339. * endpoints
  340. */
  341. onLastNEndpointsChanged(endpointsLeavingLastN, endpointsEnteringLastN) {
  342. if (endpointsLeavingLastN) {
  343. endpointsLeavingLastN.forEach(this._updateRemoteVideo, this);
  344. }
  345. if (endpointsEnteringLastN) {
  346. endpointsEnteringLastN.forEach(this._updateRemoteVideo, this);
  347. }
  348. },
  349. /**
  350. * Updates remote video by id if it exists.
  351. * @param {string} id of the remote video
  352. * @private
  353. */
  354. _updateRemoteVideo(id) {
  355. const remoteVideo = remoteVideos[id];
  356. if (remoteVideo) {
  357. remoteVideo.updateView();
  358. this._updateLargeVideoIfDisplayed(id);
  359. }
  360. },
  361. /**
  362. * Hides all the indicators
  363. */
  364. hideStats() {
  365. for (const video in remoteVideos) { // eslint-disable-line guard-for-in
  366. const remoteVideo = remoteVideos[video];
  367. if (remoteVideo) {
  368. remoteVideo.removeConnectionIndicator();
  369. }
  370. }
  371. localVideoThumbnail.removeConnectionIndicator();
  372. },
  373. removeParticipantContainer(id) {
  374. // Unlock large video
  375. if (this.getPinnedId() === id) {
  376. logger.info('Focused video owner has left the conference');
  377. APP.store.dispatch(pinParticipant(null));
  378. }
  379. const remoteVideo = remoteVideos[id];
  380. if (remoteVideo) {
  381. // Remove remote video
  382. logger.info(`Removing remote video: ${id}`);
  383. delete remoteVideos[id];
  384. remoteVideo.remove();
  385. } else {
  386. logger.warn(`No remote video for ${id}`);
  387. }
  388. },
  389. onVideoTypeChanged(id, newVideoType) {
  390. const remoteVideo = remoteVideos[id];
  391. if (!remoteVideo) {
  392. return;
  393. }
  394. logger.info('Peer video type changed: ', id, newVideoType);
  395. remoteVideo.updateView();
  396. },
  397. /**
  398. * Resizes the video area.
  399. */
  400. resizeVideoArea() {
  401. if (largeVideo) {
  402. largeVideo.updateContainerSize();
  403. largeVideo.resize(false);
  404. }
  405. },
  406. getSmallVideo(id) {
  407. if (APP.conference.isLocalId(id)) {
  408. return localVideoThumbnail;
  409. }
  410. return remoteVideos[id];
  411. },
  412. changeUserAvatar(id, avatarUrl) {
  413. const smallVideo = VideoLayout.getSmallVideo(id);
  414. if (smallVideo) {
  415. smallVideo.initializeAvatar();
  416. } else {
  417. logger.warn(
  418. `Missed avatar update - no small video yet for ${id}`
  419. );
  420. }
  421. if (this.isCurrentlyOnLarge(id)) {
  422. largeVideo.updateAvatar(avatarUrl);
  423. }
  424. },
  425. isLargeVideoVisible() {
  426. return this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE);
  427. },
  428. /**
  429. * @return {LargeContainer} the currently displayed container on large
  430. * video.
  431. */
  432. getCurrentlyOnLargeContainer() {
  433. return largeVideo.getCurrentContainer();
  434. },
  435. isCurrentlyOnLarge(id) {
  436. return largeVideo && largeVideo.id === id;
  437. },
  438. /**
  439. * Triggers an update of remote video and large video displays so they may
  440. * pick up any state changes that have occurred elsewhere.
  441. *
  442. * @returns {void}
  443. */
  444. updateAllVideos() {
  445. const displayedUserId = this.getLargeVideoID();
  446. if (displayedUserId) {
  447. this.updateLargeVideo(displayedUserId, true);
  448. }
  449. Object.keys(remoteVideos).forEach(video => {
  450. remoteVideos[video].updateView();
  451. });
  452. },
  453. updateLargeVideo(id, forceUpdate) {
  454. if (!largeVideo) {
  455. return;
  456. }
  457. const currentContainer = largeVideo.getCurrentContainer();
  458. const currentContainerType = largeVideo.getCurrentContainerType();
  459. const isOnLarge = this.isCurrentlyOnLarge(id);
  460. const state = APP.store.getState();
  461. const videoTrack = getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
  462. const videoStream = videoTrack?.jitsiTrack;
  463. if (isOnLarge && !forceUpdate
  464. && LargeVideoManager.isVideoContainer(currentContainerType)
  465. && videoStream) {
  466. const currentStreamId = currentContainer.getStreamID();
  467. const newStreamId = videoStream?.getId() || null;
  468. // FIXME it might be possible to get rid of 'forceUpdate' argument
  469. if (currentStreamId !== newStreamId) {
  470. logger.debug('Enforcing large video update for stream change');
  471. forceUpdate = true; // eslint-disable-line no-param-reassign
  472. }
  473. }
  474. if (!isOnLarge || forceUpdate) {
  475. const videoType = this.getRemoteVideoType(id);
  476. largeVideo.updateLargeVideo(
  477. id,
  478. videoStream,
  479. videoType || VIDEO_TYPE.CAMERA
  480. ).catch(() => {
  481. // do nothing
  482. });
  483. }
  484. },
  485. addLargeVideoContainer(type, container) {
  486. largeVideo && largeVideo.addContainer(type, container);
  487. },
  488. removeLargeVideoContainer(type) {
  489. largeVideo && largeVideo.removeContainer(type);
  490. },
  491. /**
  492. * @returns Promise
  493. */
  494. showLargeVideoContainer(type, show) {
  495. if (!largeVideo) {
  496. return Promise.reject();
  497. }
  498. const isVisible = this.isLargeContainerTypeVisible(type);
  499. if (isVisible === show) {
  500. return Promise.resolve();
  501. }
  502. const currentId = largeVideo.id;
  503. let oldSmallVideo;
  504. if (currentId) {
  505. oldSmallVideo = this.getSmallVideo(currentId);
  506. }
  507. let containerTypeToShow = type;
  508. // if we are hiding a container and there is focusedVideo
  509. // (pinned remote video) use its video type,
  510. // if not then use default type - large video
  511. if (!show) {
  512. const pinnedId = this.getPinnedId();
  513. if (pinnedId) {
  514. containerTypeToShow = this.getRemoteVideoType(pinnedId);
  515. } else {
  516. containerTypeToShow = VIDEO_CONTAINER_TYPE;
  517. }
  518. }
  519. return largeVideo.showContainer(containerTypeToShow)
  520. .then(() => {
  521. if (oldSmallVideo) {
  522. oldSmallVideo && oldSmallVideo.updateView();
  523. }
  524. });
  525. },
  526. isLargeContainerTypeVisible(type) {
  527. return largeVideo && largeVideo.state === type;
  528. },
  529. /**
  530. * Returns the id of the current video shown on large.
  531. * Currently used by tests (torture).
  532. */
  533. getLargeVideoID() {
  534. return largeVideo && largeVideo.id;
  535. },
  536. /**
  537. * Returns the the current video shown on large.
  538. * Currently used by tests (torture).
  539. */
  540. getLargeVideo() {
  541. return largeVideo;
  542. },
  543. /**
  544. * Sets the flipX state of the local video.
  545. * @param {boolean} true for flipped otherwise false;
  546. */
  547. setLocalFlipX(val) {
  548. this.localFlipX = val;
  549. },
  550. /**
  551. * Handles user's features changes.
  552. */
  553. onUserFeaturesChanged(user) {
  554. const video = this.getSmallVideo(user.getId());
  555. if (!video) {
  556. return;
  557. }
  558. this._setRemoteControlProperties(user, video);
  559. },
  560. /**
  561. * Sets the remote control properties (checks whether remote control
  562. * is supported and executes remoteVideo.setRemoteControlSupport).
  563. * @param {JitsiParticipant} user the user that will be checked for remote
  564. * control support.
  565. * @param {RemoteVideo} remoteVideo the remoteVideo on which the properties
  566. * will be set.
  567. */
  568. _setRemoteControlProperties(user, remoteVideo) {
  569. APP.remoteControl.checkUserRemoteControlSupport(user)
  570. .then(result => remoteVideo.setRemoteControlSupport(result))
  571. .catch(error =>
  572. logger.warn(`could not get remote control properties for: ${user.getJid()}`, error));
  573. },
  574. /**
  575. * Returns the wrapper jquery selector for the largeVideo
  576. * @returns {JQuerySelector} the wrapper jquery selector for the largeVideo
  577. */
  578. getLargeVideoWrapper() {
  579. return this.getCurrentlyOnLargeContainer().$wrapper;
  580. },
  581. /**
  582. * Returns the number of remove video ids.
  583. *
  584. * @returns {number} The number of remote videos.
  585. */
  586. getRemoteVideosCount() {
  587. return Object.keys(remoteVideos).length;
  588. },
  589. /**
  590. * Sets the remote control active status for a remote participant.
  591. *
  592. * @param {string} participantID - The id of the remote participant.
  593. * @param {boolean} isActive - The new remote control active status.
  594. * @returns {void}
  595. */
  596. setRemoteControlActiveStatus(participantID, isActive) {
  597. remoteVideos[participantID].setRemoteControlActiveStatus(isActive);
  598. },
  599. /**
  600. * Sets the remote control active status for the local participant.
  601. *
  602. * @returns {void}
  603. */
  604. setLocalRemoteControlActiveChanged() {
  605. Object.values(remoteVideos).forEach(
  606. remoteVideo => remoteVideo.updateRemoteVideoMenu()
  607. );
  608. },
  609. /**
  610. * Helper method to invoke when the video layout has changed and elements
  611. * have to be re-arranged and resized.
  612. *
  613. * @returns {void}
  614. */
  615. refreshLayout() {
  616. localVideoThumbnail && localVideoThumbnail.updateDOMLocation();
  617. VideoLayout.resizeVideoArea();
  618. // Rerender the thumbnails since they are dependant on the layout because of the tooltip positioning.
  619. localVideoThumbnail && localVideoThumbnail.rerender();
  620. Object.values(remoteVideos).forEach(remoteVideoThumbnail => remoteVideoThumbnail.rerender());
  621. },
  622. /**
  623. * Cleans up any existing largeVideo instance.
  624. *
  625. * @private
  626. * @returns {void}
  627. */
  628. _resetLargeVideo() {
  629. if (largeVideo) {
  630. largeVideo.destroy();
  631. }
  632. largeVideo = null;
  633. },
  634. /**
  635. * Cleans up filmstrip state. While a separate {@code Filmstrip} exists, its
  636. * implementation is mainly for querying and manipulating the DOM while
  637. * state mostly remains in {@code VideoLayout}.
  638. *
  639. * @private
  640. * @returns {void}
  641. */
  642. _resetFilmstrip() {
  643. Object.keys(remoteVideos).forEach(remoteVideoId => {
  644. this.removeParticipantContainer(remoteVideoId);
  645. delete remoteVideos[remoteVideoId];
  646. });
  647. if (localVideoThumbnail) {
  648. localVideoThumbnail.remove();
  649. localVideoThumbnail = null;
  650. }
  651. },
  652. /**
  653. * Triggers an update of large video if the passed in participant is
  654. * currently displayed on large video.
  655. *
  656. * @param {string} participantId - The participant ID that should trigger an
  657. * update of large video if displayed.
  658. * @param {boolean} force - Whether or not the large video update should
  659. * happen no matter what.
  660. * @returns {void}
  661. */
  662. _updateLargeVideoIfDisplayed(participantId, force = false) {
  663. if (this.isCurrentlyOnLarge(participantId)) {
  664. this.updateLargeVideo(participantId, force);
  665. }
  666. },
  667. /**
  668. * Handles window resizes.
  669. */
  670. onResize() {
  671. VideoLayout.resizeVideoArea();
  672. }
  673. };
  674. export default VideoLayout;