Skip to content

Commit

Permalink
fix(audio-only) Do not enable video automatically when audio-only is …
Browse files Browse the repository at this point in the history
…disabled (jitsi#12056)

* fix(audio-only) Do not enable video automatically when audio-only is disabled.
  • Loading branch information
jallamsetty1 authored Aug 25, 2022
1 parent dfb2a07 commit 7951dc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
25 changes: 2 additions & 23 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -2651,29 +2651,8 @@ export default {
}
);

APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly => {

// FIXME On web video track is stored both in redux and in
// 'localVideo' field, video is attempted to be unmuted twice when
// turning off the audio only mode. This will crash the app with
// 'unmute operation is already in progress'.
// Because there's no logic in redux about creating new track in
// case unmute when not track exists the things have to go through
// muteVideo logic in such case.
const tracks = APP.store.getState()['features/base/tracks'];
const isTrackInRedux
= Boolean(tracks.find(track => track.jitsiTrack && track.jitsiTrack.getType() === MEDIA_TYPE.VIDEO));

if (isTrackInRedux && !this.isSharingScreen) {
this.muteVideo(audioOnly);
}

// Immediately update the UI by having remote videos and the large
// video update themselves instead of waiting for some other event
// to cause the update, usually PARTICIPANT_CONN_STATUS_CHANGED.
// There is no guarantee another event will trigger the update
// immediately and in all situations, for example because a remote
// participant is having connection trouble so no status changes.
APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, () => {
// Immediately update the UI by having remote videos and the large video update themselves.
const displayedUserId = APP.UI.getLargeVideoID();

if (displayedUserId) {
Expand Down
15 changes: 5 additions & 10 deletions react/features/base/audio-only/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ declare let APP: any;
/**
* Sets the audio-only flag for the current JitsiConference.
*
* @param {boolean} audioOnly - True if the conference should be audio only;
* false, otherwise.
* @param {boolean} ensureVideoTrack - Define if conference should ensure
* to create a video track.
* @param {boolean} audioOnly - True if the conference should be audio only; false, otherwise.
* @returns {{
* type: SET_AUDIO_ONLY,
* audioOnly: boolean,
* ensureVideoTrack: boolean
* audioOnly: boolean
* }}
*/
export function setAudioOnly(audioOnly: boolean, ensureVideoTrack = false) {
export function setAudioOnly(audioOnly: boolean) {
return (dispatch: Dispatch<any>, getState: Function) => {
const { enabled: oldValue } = getState()['features/base/audio-only'];

Expand All @@ -35,8 +31,7 @@ export function setAudioOnly(audioOnly: boolean, ensureVideoTrack = false) {

dispatch({
type: SET_AUDIO_ONLY,
audioOnly,
ensureVideoTrack
audioOnly
});

if (typeof APP !== 'undefined') {
Expand All @@ -57,6 +52,6 @@ export function toggleAudioOnly() {
return (dispatch: Dispatch<any>, getState: Function) => {
const { enabled } = getState()['features/base/audio-only'];

return dispatch(setAudioOnly(!enabled, true));
return dispatch(setAudioOnly(!enabled));
};
}
8 changes: 4 additions & 4 deletions react/features/base/media/middleware.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ function _appStateChanged({ dispatch, getState }, next, action) {
* @returns {Object} The value returned by {@code next(action)}.
*/
function _setAudioOnly({ dispatch, getState }, next, action) {
const { audioOnly, ensureVideoTrack } = action;
const { audioOnly } = action;
const state = getState();

sendAnalytics(createTrackMutedEvent('video', 'audio-only mode', audioOnly));

// Make sure we mute both the desktop and video tracks.
dispatch(setVideoMuted(audioOnly, MEDIA_TYPE.VIDEO, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY, ensureVideoTrack));
dispatch(setVideoMuted(audioOnly, MEDIA_TYPE.VIDEO, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY));
if (getMultipleVideoSendingSupportFeatureFlag(state)) {
dispatch(setScreenshareMuted(audioOnly, MEDIA_TYPE.SCREENSHARE, SCREENSHARE_MUTISM_AUTHORITY.AUDIO_ONLY));
} else if (navigator.product !== 'ReactNative') {
dispatch(setVideoMuted(audioOnly, MEDIA_TYPE.PRESENTER, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY, ensureVideoTrack));
dispatch(setVideoMuted(audioOnly, MEDIA_TYPE.PRESENTER, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY));
}

return next(action);
Expand Down Expand Up @@ -281,7 +281,7 @@ function _setRoom({ dispatch, getState }, next, action) {
sendAnalytics(createStartAudioOnlyEvent(audioOnly));
logger.log(`Start audio only set to ${audioOnly.toString()}`);

dispatch(setAudioOnly(audioOnly, false));
dispatch(setAudioOnly(audioOnly));

if (!roomIsValid) {
dispatch(destroyLocalTracks());
Expand Down
3 changes: 1 addition & 2 deletions react/features/toolbox/components/VideoMuteButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class VideoMuteButton extends AbstractVideoMuteButton<Props, *> {
_setVideoMuted(videoMuted: boolean) {
sendAnalytics(createToolbarEvent(VIDEO_MUTE, { enable: videoMuted }));
if (this.props._audioOnly) {
this.props.dispatch(
setAudioOnly(false, /* ensureTrack */ true));
this.props.dispatch(setAudioOnly(false));
}
const mediaType = this.props._videoMediaType;

Expand Down

0 comments on commit 7951dc3

Please sign in to comment.