Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

VideoLayout.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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,
  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.onAudioMute(id, stream.isMuted());
  145. } else {
  146. this.onVideoMute(id, stream.isMuted());
  147. }
  148. },
  149. onRemoteStreamRemoved(stream) {
  150. const id = stream.getParticipantId();
  151. const remoteVideo = remoteVideos[id];
  152. // Remote stream may be removed after participant left the conference.
  153. if (remoteVideo) {
  154. remoteVideo.removeRemoteStreamElement(stream);
  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, true);
  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 audio muted event.
  272. */
  273. onAudioMute(id, isMuted) {
  274. if (APP.conference.isLocalId(id)) {
  275. localVideoThumbnail.showAudioIndicator(isMuted);
  276. } else {
  277. const remoteVideo = remoteVideos[id];
  278. if (!remoteVideo) {
  279. return;
  280. }
  281. remoteVideo.showAudioIndicator(isMuted);
  282. remoteVideo.updateRemoteVideoMenu();
  283. }
  284. },
  285. /**
  286. * On video muted event.
  287. */
  288. onVideoMute(id, value) {
  289. if (APP.conference.isLocalId(id)) {
  290. localVideoThumbnail && localVideoThumbnail.setVideoMutedView(value);
  291. } else {
  292. const remoteVideo = remoteVideos[id];
  293. if (remoteVideo) {
  294. remoteVideo.setVideoMutedView(value);
  295. }
  296. }
  297. // large video will show avatar instead of muted stream
  298. this._updateLargeVideoIfDisplayed(id, true);
  299. },
  300. /**
  301. * Display name changed.
  302. */
  303. onDisplayNameChanged(id) {
  304. if (id === 'localVideoContainer'
  305. || APP.conference.isLocalId(id)) {
  306. localVideoThumbnail.updateDisplayName();
  307. } else {
  308. const remoteVideo = remoteVideos[id];
  309. if (remoteVideo) {
  310. remoteVideo.updateDisplayName();
  311. }
  312. }
  313. },
  314. /**
  315. * On dominant speaker changed event.
  316. *
  317. * @param {string} id - The participant ID of the new dominant speaker.
  318. * @returns {void}
  319. */
  320. onDominantSpeakerChanged(id) {
  321. getAllThumbnails().forEach(thumbnail =>
  322. thumbnail.showDominantSpeakerIndicator(id === thumbnail.getId()));
  323. },
  324. /**
  325. * Shows/hides warning about a user's connectivity issues.
  326. *
  327. * @param {string} id - The ID of the remote participant(MUC nickname).
  328. * @returns {void}
  329. */
  330. onParticipantConnectionStatusChanged(id) {
  331. if (APP.conference.isLocalId(id)) {
  332. return;
  333. }
  334. // We have to trigger full large video update to transition from
  335. // avatar to video on connectivity restored.
  336. this._updateLargeVideoIfDisplayed(id, true);
  337. const remoteVideo = remoteVideos[id];
  338. if (remoteVideo) {
  339. // Updating only connection status indicator is not enough, because
  340. // when we the connection is restored while the avatar was displayed
  341. // (due to 'muted while disconnected' condition) we may want to show
  342. // the video stream again and in order to do that the display mode
  343. // must be updated.
  344. // remoteVideo.updateConnectionStatusIndicator(isActive);
  345. remoteVideo.updateView();
  346. }
  347. },
  348. /**
  349. * On last N change event.
  350. *
  351. * @param endpointsLeavingLastN the list currently leaving last N
  352. * endpoints
  353. * @param endpointsEnteringLastN the list currently entering last N
  354. * endpoints
  355. */
  356. onLastNEndpointsChanged(endpointsLeavingLastN, endpointsEnteringLastN) {
  357. if (endpointsLeavingLastN) {
  358. endpointsLeavingLastN.forEach(this._updateRemoteVideo, this);
  359. }
  360. if (endpointsEnteringLastN) {
  361. endpointsEnteringLastN.forEach(this._updateRemoteVideo, this);
  362. }
  363. },
  364. /**
  365. * Updates remote video by id if it exists.
  366. * @param {string} id of the remote video
  367. * @private
  368. */
  369. _updateRemoteVideo(id) {
  370. const remoteVideo = remoteVideos[id];
  371. if (remoteVideo) {
  372. remoteVideo.updateView();
  373. this._updateLargeVideoIfDisplayed(id);
  374. }
  375. },
  376. /**
  377. * Hides all the indicators
  378. */
  379. hideStats() {
  380. for (const video in remoteVideos) { // eslint-disable-line guard-for-in
  381. const remoteVideo = remoteVideos[video];
  382. if (remoteVideo) {
  383. remoteVideo.removeConnectionIndicator();
  384. }
  385. }
  386. localVideoThumbnail.removeConnectionIndicator();
  387. },
  388. removeParticipantContainer(id) {
  389. // Unlock large video
  390. if (this.getPinnedId() === id) {
  391. logger.info('Focused video owner has left the conference');
  392. APP.store.dispatch(pinParticipant(null));
  393. }
  394. const remoteVideo = remoteVideos[id];
  395. if (remoteVideo) {
  396. // Remove remote video
  397. logger.info(`Removing remote video: ${id}`);
  398. delete remoteVideos[id];
  399. remoteVideo.remove();
  400. } else {
  401. logger.warn(`No remote video for ${id}`);
  402. }
  403. },
  404. onVideoTypeChanged(id, newVideoType) {
  405. if (VideoLayout.getRemoteVideoType(id) === newVideoType) {
  406. return;
  407. }
  408. logger.info('Peer video type changed: ', id, newVideoType);
  409. this._updateLargeVideoIfDisplayed(id, true);
  410. },
  411. /**
  412. * Resizes the video area.
  413. */
  414. resizeVideoArea() {
  415. if (largeVideo) {
  416. largeVideo.updateContainerSize();
  417. largeVideo.resize(false);
  418. }
  419. },
  420. getSmallVideo(id) {
  421. if (APP.conference.isLocalId(id)) {
  422. return localVideoThumbnail;
  423. }
  424. return remoteVideos[id];
  425. },
  426. changeUserAvatar(id, avatarUrl) {
  427. const smallVideo = VideoLayout.getSmallVideo(id);
  428. if (smallVideo) {
  429. smallVideo.initializeAvatar();
  430. } else {
  431. logger.warn(
  432. `Missed avatar update - no small video yet for ${id}`
  433. );
  434. }
  435. if (this.isCurrentlyOnLarge(id)) {
  436. largeVideo.updateAvatar(avatarUrl);
  437. }
  438. },
  439. isLargeVideoVisible() {
  440. return this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE);
  441. },
  442. /**
  443. * @return {LargeContainer} the currently displayed container on large
  444. * video.
  445. */
  446. getCurrentlyOnLargeContainer() {
  447. return largeVideo.getCurrentContainer();
  448. },
  449. isCurrentlyOnLarge(id) {
  450. return largeVideo && largeVideo.id === id;
  451. },
  452. /**
  453. * Triggers an update of remote video and large video displays so they may
  454. * pick up any state changes that have occurred elsewhere.
  455. *
  456. * @returns {void}
  457. */
  458. updateAllVideos() {
  459. const displayedUserId = this.getLargeVideoID();
  460. if (displayedUserId) {
  461. this.updateLargeVideo(displayedUserId, true);
  462. }
  463. Object.keys(remoteVideos).forEach(video => {
  464. remoteVideos[video].updateView();
  465. });
  466. },
  467. updateLargeVideo(id, forceUpdate) {
  468. if (!largeVideo) {
  469. return;
  470. }
  471. const currentContainer = largeVideo.getCurrentContainer();
  472. const currentContainerType = largeVideo.getCurrentContainerType();
  473. const isOnLarge = this.isCurrentlyOnLarge(id);
  474. const state = APP.store.getState();
  475. const videoTrack = getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
  476. const videoStream = videoTrack?.jitsiTrack;
  477. if (isOnLarge && !forceUpdate
  478. && LargeVideoManager.isVideoContainer(currentContainerType)
  479. && videoStream) {
  480. const currentStreamId = currentContainer.getStreamID();
  481. const newStreamId = videoStream?.getId() || null;
  482. // FIXME it might be possible to get rid of 'forceUpdate' argument
  483. if (currentStreamId !== newStreamId) {
  484. logger.debug('Enforcing large video update for stream change');
  485. forceUpdate = true; // eslint-disable-line no-param-reassign
  486. }
  487. }
  488. if (!isOnLarge || forceUpdate) {
  489. const videoType = this.getRemoteVideoType(id);
  490. largeVideo.updateLargeVideo(
  491. id,
  492. videoStream,
  493. videoType || VIDEO_TYPE.CAMERA
  494. ).catch(() => {
  495. // do nothing
  496. });
  497. }
  498. },
  499. addLargeVideoContainer(type, container) {
  500. largeVideo && largeVideo.addContainer(type, container);
  501. },
  502. removeLargeVideoContainer(type) {
  503. largeVideo && largeVideo.removeContainer(type);
  504. },
  505. /**
  506. * @returns Promise
  507. */
  508. showLargeVideoContainer(type, show) {
  509. if (!largeVideo) {
  510. return Promise.reject();
  511. }
  512. const isVisible = this.isLargeContainerTypeVisible(type);
  513. if (isVisible === show) {
  514. return Promise.resolve();
  515. }
  516. const currentId = largeVideo.id;
  517. let oldSmallVideo;
  518. if (currentId) {
  519. oldSmallVideo = this.getSmallVideo(currentId);
  520. }
  521. let containerTypeToShow = type;
  522. // if we are hiding a container and there is focusedVideo
  523. // (pinned remote video) use its video type,
  524. // if not then use default type - large video
  525. if (!show) {
  526. const pinnedId = this.getPinnedId();
  527. if (pinnedId) {
  528. containerTypeToShow = this.getRemoteVideoType(pinnedId);
  529. } else {
  530. containerTypeToShow = VIDEO_CONTAINER_TYPE;
  531. }
  532. }
  533. return largeVideo.showContainer(containerTypeToShow)
  534. .then(() => {
  535. if (oldSmallVideo) {
  536. oldSmallVideo && oldSmallVideo.updateView();
  537. }
  538. });
  539. },
  540. isLargeContainerTypeVisible(type) {
  541. return largeVideo && largeVideo.state === type;
  542. },
  543. /**
  544. * Returns the id of the current video shown on large.
  545. * Currently used by tests (torture).
  546. */
  547. getLargeVideoID() {
  548. return largeVideo && largeVideo.id;
  549. },
  550. /**
  551. * Returns the the current video shown on large.
  552. * Currently used by tests (torture).
  553. */
  554. getLargeVideo() {
  555. return largeVideo;
  556. },
  557. /**
  558. * Sets the flipX state of the local video.
  559. * @param {boolean} true for flipped otherwise false;
  560. */
  561. setLocalFlipX(val) {
  562. this.localFlipX = val;
  563. },
  564. /**
  565. * Handles user's features changes.
  566. */
  567. onUserFeaturesChanged(user) {
  568. const video = this.getSmallVideo(user.getId());
  569. if (!video) {
  570. return;
  571. }
  572. this._setRemoteControlProperties(user, video);
  573. },
  574. /**
  575. * Sets the remote control properties (checks whether remote control
  576. * is supported and executes remoteVideo.setRemoteControlSupport).
  577. * @param {JitsiParticipant} user the user that will be checked for remote
  578. * control support.
  579. * @param {RemoteVideo} remoteVideo the remoteVideo on which the properties
  580. * will be set.
  581. */
  582. _setRemoteControlProperties(user, remoteVideo) {
  583. APP.remoteControl.checkUserRemoteControlSupport(user)
  584. .then(result => remoteVideo.setRemoteControlSupport(result))
  585. .catch(error =>
  586. logger.warn(`could not get remote control properties for: ${user.getJid()}`, error));
  587. },
  588. /**
  589. * Returns the wrapper jquery selector for the largeVideo
  590. * @returns {JQuerySelector} the wrapper jquery selector for the largeVideo
  591. */
  592. getLargeVideoWrapper() {
  593. return this.getCurrentlyOnLargeContainer().$wrapper;
  594. },
  595. /**
  596. * Returns the number of remove video ids.
  597. *
  598. * @returns {number} The number of remote videos.
  599. */
  600. getRemoteVideosCount() {
  601. return Object.keys(remoteVideos).length;
  602. },
  603. /**
  604. * Sets the remote control active status for a remote participant.
  605. *
  606. * @param {string} participantID - The id of the remote participant.
  607. * @param {boolean} isActive - The new remote control active status.
  608. * @returns {void}
  609. */
  610. setRemoteControlActiveStatus(participantID, isActive) {
  611. remoteVideos[participantID].setRemoteControlActiveStatus(isActive);
  612. },
  613. /**
  614. * Sets the remote control active status for the local participant.
  615. *
  616. * @returns {void}
  617. */
  618. setLocalRemoteControlActiveChanged() {
  619. Object.values(remoteVideos).forEach(
  620. remoteVideo => remoteVideo.updateRemoteVideoMenu()
  621. );
  622. },
  623. /**
  624. * Helper method to invoke when the video layout has changed and elements
  625. * have to be re-arranged and resized.
  626. *
  627. * @returns {void}
  628. */
  629. refreshLayout() {
  630. localVideoThumbnail && localVideoThumbnail.updateDOMLocation();
  631. VideoLayout.resizeVideoArea();
  632. // Rerender the thumbnails since they are dependant on the layout because of the tooltip positioning.
  633. localVideoThumbnail && localVideoThumbnail.rerender();
  634. Object.values(remoteVideos).forEach(remoteVideoThumbnail => remoteVideoThumbnail.rerender());
  635. },
  636. /**
  637. * Cleans up any existing largeVideo instance.
  638. *
  639. * @private
  640. * @returns {void}
  641. */
  642. _resetLargeVideo() {
  643. if (largeVideo) {
  644. largeVideo.destroy();
  645. }
  646. largeVideo = null;
  647. },
  648. /**
  649. * Cleans up filmstrip state. While a separate {@code Filmstrip} exists, its
  650. * implementation is mainly for querying and manipulating the DOM while
  651. * state mostly remains in {@code VideoLayout}.
  652. *
  653. * @private
  654. * @returns {void}
  655. */
  656. _resetFilmstrip() {
  657. Object.keys(remoteVideos).forEach(remoteVideoId => {
  658. this.removeParticipantContainer(remoteVideoId);
  659. delete remoteVideos[remoteVideoId];
  660. });
  661. if (localVideoThumbnail) {
  662. localVideoThumbnail.remove();
  663. localVideoThumbnail = null;
  664. }
  665. },
  666. /**
  667. * Triggers an update of large video if the passed in participant is
  668. * currently displayed on large video.
  669. *
  670. * @param {string} participantId - The participant ID that should trigger an
  671. * update of large video if displayed.
  672. * @param {boolean} force - Whether or not the large video update should
  673. * happen no matter what.
  674. * @returns {void}
  675. */
  676. _updateLargeVideoIfDisplayed(participantId, force = false) {
  677. if (this.isCurrentlyOnLarge(participantId)) {
  678. this.updateLargeVideo(participantId, force);
  679. }
  680. },
  681. /**
  682. * Handles window resizes.
  683. */
  684. onResize() {
  685. VideoLayout.resizeVideoArea();
  686. }
  687. };
  688. export default VideoLayout;