Skip to content

Commit

Permalink
fix(plugin-meetings): Eliminate Unnecessary Camera Prompts for Disabl…
Browse files Browse the repository at this point in the history
…ed Video (#3855)
  • Loading branch information
Parimala032 authored Oct 1, 2024
1 parent 2a9f66c commit dd83988
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6521,12 +6521,21 @@ export default class Meeting extends StatelessWebexPlugin {
*
* @private
* @static
* @param {boolean} isAudioEnabled
* @param {boolean} isVideoEnabled
* @returns {Promise<void>}
*/
private static async handleDeviceLogging(): Promise<void> {
try {
const devices = await getDevices();

private static async handleDeviceLogging(isAudioEnabled, isVideoEnabled): Promise<void> {
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
Expand Down Expand Up @@ -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`);
}
Expand Down
22 changes: 22 additions & 0 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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}},
Expand Down

0 comments on commit dd83988

Please sign in to comment.