From 41c6759a235008751fa6be268da10864b13e82f3 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Tue, 26 Sep 2017 22:18:08 -0500 Subject: [PATCH] Coding style --- react/features/base/media/functions.js | 69 ++++++++++++++++---------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/react/features/base/media/functions.js b/react/features/base/media/functions.js index f4064ee18..f254a74b9 100644 --- a/react/features/base/media/functions.js +++ b/react/features/base/media/functions.js @@ -1,5 +1,46 @@ +/* @flow */ + import { VIDEO_MUTISM_AUTHORITY } from './constants'; +/** + * Determines whether video is currently muted by the audio-only authority. + * + * @param {Store} store - The redux store. + * @returns {boolean} + */ +export function isVideoMutedByAudioOnly(store: { getState: Function }) { + return _isVideoMutedByAuthority(store, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY); +} + +/** + * Determines whether video is currently muted by a specific + * VIDEO_MUTISM_AUTHORITY. + * + * @param {Store} store - The redux store. + * @param {number} videoMutismAuthority - The VIDEO_MUTISM_AUTHORITY + * which is to be checked whether it has muted video. + * @returns {boolean} If video is currently muted by the specified + * videoMutismAuthority, then true; otherwise, false. + */ +function _isVideoMutedByAuthority( + { getState }: { getState: Function }, + videoMutismAuthority: number) { + return Boolean( + + // eslint-disable-next-line no-bitwise + getState()['features/base/media'].video.muted & videoMutismAuthority); +} + +/** + * Determines whether video is currently muted by the user authority. + * + * @param {Store} store - The redux store. + * @returns {boolean} + */ +export function isVideoMutedByUser(store: { getState: Function }) { + return _isVideoMutedByAuthority(store, VIDEO_MUTISM_AUTHORITY.USER); +} + /** * Determines whether a specific videoTrack should be rendered. * @@ -10,33 +51,11 @@ import { VIDEO_MUTISM_AUTHORITY } from './constants'; * @returns {boolean} True if the specified videoTrack should be renderd; * otherwise, false. */ -export function shouldRenderVideoTrack(videoTrack, waitForVideoStarted) { +export function shouldRenderVideoTrack( + videoTrack: { muted: boolean, videoStarted: boolean }, + waitForVideoStarted: boolean) { return ( videoTrack && !videoTrack.muted && (!waitForVideoStarted || videoTrack.videoStarted)); } - -/** - * Checks if video is currently muted by the audio-only authority. - * - * @param {Object} store - The redux store instance. - * @returns {boolean} - */ -export function isVideoMutedByAudioOnly({ getState }) { - return Boolean( - getState()['features/base/media'] // eslint-disable-line no-bitwise - .video.muted & VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY); -} - -/** - * Checks if video is currently muted by the user authority. - * - * @param {Object} store - The redux store instance. - * @returns {boolean} - */ -export function isVideoMutedByUser({ getState }) { - return Boolean( - getState()['features/base/media'] // eslint-disable-line no-bitwise - .video.muted & VIDEO_MUTISM_AUTHORITY.USER); -}