From dd839883489c4d76b1ab6547fc78161675f824de Mon Sep 17 00:00:00 2001 From: Parimala032 <156060538+Parimala032@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:51:47 +0530 Subject: [PATCH] fix(plugin-meetings): Eliminate Unnecessary Camera Prompts for Disabled Video (#3855) --- .../plugin-meetings/src/meeting/index.ts | 17 ++++++++++---- .../test/unit/spec/meeting/index.js | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/packages/@webex/plugin-meetings/src/meeting/index.ts b/packages/@webex/plugin-meetings/src/meeting/index.ts index 49f2b4e458a..daf9ed31b96 100644 --- a/packages/@webex/plugin-meetings/src/meeting/index.ts +++ b/packages/@webex/plugin-meetings/src/meeting/index.ts @@ -6521,12 +6521,21 @@ export default class Meeting extends StatelessWebexPlugin { * * @private * @static + * @param {boolean} isAudioEnabled + * @param {boolean} isVideoEnabled * @returns {Promise} */ - private static async handleDeviceLogging(): Promise { - try { - const devices = await getDevices(); + private static async handleDeviceLogging(isAudioEnabled, isVideoEnabled): Promise { + try { + let devices = []; + if (isVideoEnabled && isAudioEnabled) { + devices = await getDevices(); + } else if (isVideoEnabled) { + devices = await getDevices(Media.DeviceKind.VIDEO_INPUT); + } else if (isAudioEnabled) { + devices = await getDevices(Media.DeviceKind.AUDIO_INPUT); + } MeetingUtil.handleDeviceLogging(devices); } catch { // getDevices may fail if we don't have browser permissions, that's ok, we still can have a media connection @@ -7019,7 +7028,7 @@ export default class Meeting extends StatelessWebexPlugin { ); if (audioEnabled || videoEnabled) { - await Meeting.handleDeviceLogging(); + await Meeting.handleDeviceLogging(audioEnabled, videoEnabled); } else { LoggerProxy.logger.info(`${LOG_HEADER} device logging not required`); } diff --git a/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js b/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js index fc9048a9a57..99bcb3a9cd9 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js @@ -4279,6 +4279,20 @@ describe('plugin-meetings', () => { assert.calledTwice(locusMediaRequestStub); }); + it('addMedia() works correctly when media is disabled with no streams to publish', async () => { + const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging'); + await meeting.addMedia({audioEnabled: false}); + //calling handleDeviceLogging with audioEnaled as true adn videoEnabled as false + assert.calledWith(handleDeviceLoggingSpy,false,true); + }); + + it('addMedia() works correctly when video is disabled with no streams to publish', async () => { + const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging'); + await meeting.addMedia({videoEnabled: false}); + //calling handleDeviceLogging audioEnabled as true videoEnabled as false + assert.calledWith(handleDeviceLoggingSpy,true,false); + }); + it('addMedia() works correctly when video is disabled with no streams to publish', async () => { await meeting.addMedia({videoEnabled: false}); await simulateRoapOffer(); @@ -4345,6 +4359,14 @@ describe('plugin-meetings', () => { assert.calledTwice(locusMediaRequestStub); }); + + it('addMedia() works correctly when both shareAudio and shareVideo is disabled with no streams publish', async () => { + const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging'); + await meeting.addMedia({shareAudioEnabled: false, shareVideoEnabled: false}); + //calling handleDeviceLogging with audioEnabled true and videoEnabled as true + assert.calledWith(handleDeviceLoggingSpy,true,true); + }); + describe('publishStreams()/unpublishStreams() calls', () => { [ {mediaEnabled: true, expected: {direction: 'sendrecv', localMuteSentValue: false}},