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

VideoLayout.js 23KB

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