diff --git a/packages/@webex/plugin-meetings/src/meeting/index.ts b/packages/@webex/plugin-meetings/src/meeting/index.ts index ca9e857b736..425d67cb0b4 100644 --- a/packages/@webex/plugin-meetings/src/meeting/index.ts +++ b/packages/@webex/plugin-meetings/src/meeting/index.ts @@ -8735,15 +8735,19 @@ export default class Meeting extends StatelessWebexPlugin { return; } - if ( - streams?.microphone?.readyState === 'ended' || - streams?.camera?.readyState === 'ended' || - streams?.screenShare?.audio?.readyState === 'ended' || - streams?.screenShare?.video?.readyState === 'ended' - ) { - throw new Error( - `Attempted to publish stream with ended readyState, correlationId=${this.correlationId}` - ); + const streamChecks = [ + {stream: streams?.microphone, name: 'microphone'}, + {stream: streams?.camera, name: 'camera'}, + {stream: streams?.screenShare?.audio, name: 'screenShare audio'}, + {stream: streams?.screenShare?.video, name: 'screenShare video'}, + ]; + + for (const {stream, name} of streamChecks) { + if (stream?.readyState === 'ended') { + throw new Error( + `Attempted to publish ${name} stream with ended readyState, correlationId=${this.correlationId}` + ); + } } let floorRequestNeeded = false; 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 bd71da9a7e2..3c9c8b8d437 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js @@ -3991,6 +3991,7 @@ describe('plugin-meetings', () => { assert.notCalled( meeting.sendSlotManager.getSlot(MediaType.AudioMain).publishStream ); + assert.throws(meeting.publishStreams(localStreams), `Attempted to publish microphone stream with ended readyState, correlationId=${meeting.correlationId}`); } else { assert.calledOnceWithExactly( meeting.sendSlotManager.getSlot(MediaType.AudioMain).publishStream, @@ -4003,6 +4004,7 @@ describe('plugin-meetings', () => { assert.notCalled( meeting.sendSlotManager.getSlot(MediaType.VideoMain).publishStream ); + assert.throws(meeting.publishStreams(localStreams), `Attempted to publish camera stream with ended readyState, correlationId=${meeting.correlationId}`); } else { assert.calledOnceWithExactly( meeting.sendSlotManager.getSlot(MediaType.VideoMain).publishStream, @@ -4015,6 +4017,7 @@ describe('plugin-meetings', () => { assert.notCalled( meeting.sendSlotManager.getSlot(MediaType.AudioSlides).publishStream ); + assert.throws(meeting.publishStreams(localStreams), `Attempted to publish screenShare audio stream with ended readyState, correlationId=${meeting.correlationId}`); } else { assert.calledOnceWithExactly( meeting.sendSlotManager.getSlot(MediaType.AudioSlides).publishStream, @@ -4027,6 +4030,7 @@ describe('plugin-meetings', () => { assert.notCalled( meeting.sendSlotManager.getSlot(MediaType.VideoSlides).publishStream ); + assert.throws(meeting.publishStreams(localStreams), `Attempted to publish screenShare video stream with ended readyState, correlationId=${meeting.correlationId}`); } else { assert.calledOnceWithExactly( meeting.sendSlotManager.getSlot(MediaType.VideoSlides).publishStream,