Coding style

This commit is contained in:
Lyubo Marinov 2017-09-26 22:18:08 -05:00
parent f62288ae17
commit 41c6759a23
1 changed files with 44 additions and 25 deletions

View File

@ -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
* <tt>VIDEO_MUTISM_AUTHORITY</tt>.
*
* @param {Store} store - The redux store.
* @param {number} videoMutismAuthority - The <tt>VIDEO_MUTISM_AUTHORITY</tt>
* which is to be checked whether it has muted video.
* @returns {boolean} If video is currently muted by the specified
* <tt>videoMutismAuthority</tt>, then <tt>true</tt>; otherwise, <tt>false</tt>.
*/
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);
}