Skip to content

Commit

Permalink
fix(plugin-meetings): improve error handling for stream state ended (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rarajes2 authored Nov 17, 2024
1 parent de66ceb commit 9cc28e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 9cc28e7

Please sign in to comment.