Skip to content

Commit

Permalink
feat: mute screenshare_audio, update to the newest OpenAPI schema (#1148
Browse files Browse the repository at this point in the history
)

Allows remote muting of `screenshare_audio` tracks. Also, updates to the
newest OpenAPI schema (GetStream/protocol) that introduces `call.hls_broadcasting_failed` event.
  • Loading branch information
oliverlaz authored Oct 19, 2023
1 parent 57b545e commit 81c45a7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The list of call events:
| `call.blocked_user` | A user is blocked from the call | Call watchers |
| `call.created` | The call was created | All call members |
| `call.ended` | The call was ended | All call members |
| `call.hls_broadcasting_failed` | The call failed to broadcast | Call watchers |
| `call.hls_broadcasting_started` | The call started to broadcast | Call watchers |
| `call.hls_broadcasting_stopped` | The call stopped broadcasting | Call watchers |
| `call.live_started` | The call left backstage mode | Call watchers |
Expand Down
32 changes: 32 additions & 0 deletions packages/client/src/gen/coordinator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,31 @@ export interface CallEndedEvent {
*/
user?: UserResponse;
}
/**
* This event is sent when HLS broadcasting has failed
* @export
* @interface CallHLSBroadcastingFailedEvent
*/
export interface CallHLSBroadcastingFailedEvent {
/**
*
* @type {string}
* @memberof CallHLSBroadcastingFailedEvent
*/
call_cid: string;
/**
*
* @type {string}
* @memberof CallHLSBroadcastingFailedEvent
*/
created_at: string;
/**
* The type of event: "call.hls_broadcasting_failed" in this case
* @type {string}
* @memberof CallHLSBroadcastingFailedEvent
*/
type: string;
}
/**
* This event is sent when HLS broadcasting has started
* @export
Expand Down Expand Up @@ -2967,6 +2992,12 @@ export interface MuteUsersRequest {
* @memberof MuteUsersRequest
*/
screenshare?: boolean;
/**
*
* @type {boolean}
* @memberof MuteUsersRequest
*/
screenshare_audio?: boolean;
/**
*
* @type {Array<string>}
Expand Down Expand Up @@ -4471,6 +4502,7 @@ export type VideoEvent =
| ({ type: 'call.blocked_user' } & BlockedUserEvent)
| ({ type: 'call.created' } & CallCreatedEvent)
| ({ type: 'call.ended' } & CallEndedEvent)
| ({ type: 'call.hls_broadcasting_failed' } & CallHLSBroadcastingFailedEvent)
| ({
type: 'call.hls_broadcasting_started';
} & CallHLSBroadcastingStartedEvent)
Expand Down
12 changes: 10 additions & 2 deletions packages/client/src/store/CallState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ export class CallState {
this.eventHandlers = {
// these events are not updating the call state:
'call.permission_request': undefined,
'call.recording_failed': undefined,
'call.recording_ready': undefined,
'call.user_muted': undefined,
'connection.error': undefined,
'connection.ok': undefined,
'health.check': undefined,
'call.recording_failed': undefined,
'call.recording_ready': undefined,
custom: undefined,

// events that update call state:
Expand All @@ -417,6 +417,7 @@ export class CallState {
this.updateFromCallResponse(e.call);
this.setCurrentValue(this.endedBySubject, e.user);
},
'call.hls_broadcasting_failed': this.updateFromHLSBroadcastingFailed,
'call.hls_broadcasting_started': this.updateFromHLSBroadcastStarted,
'call.hls_broadcasting_stopped': this.updateFromHLSBroadcastStopped,
'call.live_started': (e) => this.updateFromCallResponse(e.call),
Expand Down Expand Up @@ -992,6 +993,13 @@ export class CallState {
}));
};

private updateFromHLSBroadcastingFailed = () => {
this.setCurrentValue(this.egressSubject, (egress) => ({
...egress!,
broadcasting: false,
}));
};

private updateFromHLSBroadcastStarted = (
event: CallHLSBroadcastingStartedEvent,
) => {
Expand Down
9 changes: 9 additions & 0 deletions packages/client/src/store/__tests__/CallState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,15 @@ describe('CallState', () => {
});
expect(state.egress?.broadcasting).toBe(false);
});

it('handles call.hls_broadcasting_failed events', () => {
const state = new CallState();
// @ts-expect-error incomplete data
state.updateFromCallResponse({ egress: { broadcasting: true } });
// @ts-expect-error incomplete data
state.updateFromEvent({ type: 'call.hls_broadcasting_failed' });
expect(state.egress?.broadcasting).toBe(false);
});
});

describe('call.session events', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The list of call events:
| `call.blocked_user` | A user is blocked from the call | Call watchers |
| `call.created` | The call was created | All call members |
| `call.ended` | The call was ended | All call members |
| `call.hls_broadcasting_failed` | The call failed to broadcast | Call watchers |
| `call.hls_broadcasting_started` | The call started to broadcast | Call watchers |
| `call.hls_broadcasting_stopped` | The call stopped broadcasting | Call watchers |
| `call.live_started` | The call left backstage mode | Call watchers |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The list of call events:
| `call.blocked_user` | A user is blocked from the call | Call watchers |
| `call.created` | The call was created | All call members |
| `call.ended` | The call was ended | All call members |
| `call.hls_broadcasting_failed` | The call failed to broadcast | Call watchers |
| `call.hls_broadcasting_started` | The call started to broadcast | Call watchers |
| `call.hls_broadcasting_stopped` | The call stopped broadcasting | Call watchers |
| `call.live_started` | The call left backstage mode | Call watchers |
Expand Down

0 comments on commit 81c45a7

Please sign in to comment.