Skip to content

Commit d401456

Browse files
authored
Add unmute media event (#344)
## Description # Closes FCE-1444 ## Motivation and Context Why is this change required? What problem does it solve? If it fixes an open issue, please link to the issue here. ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1 parent 63edc24 commit d401456

File tree

10 files changed

+107
-16
lines changed

10 files changed

+107
-16
lines changed

e2e-tests/react-client/docker-compose-test.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ version: "3"
22

33
services:
44
fishjam:
5-
image: "ghcr.io/fishjam-cloud/fishjam:0.10.0-dev"
5+
image: "ghcr.io/fishjam-cloud/fishjam:edge"
66
container_name: fishjam
77
restart: on-failure
88
platform: linux/amd64
99
healthcheck:
1010
test: >
11-
curl --fail -H "authorization: Bearer development" http://localhost:5002/room || exit 1
11+
curl --fail -H "authorization: Bearer admin" http://localhost:5002/room || exit 1
1212
interval: 3s
1313
retries: 2
1414
timeout: 2s
@@ -20,7 +20,8 @@ services:
2020
FJ_WEBRTC_TURN_LISTEN_IP: "0.0.0.0"
2121
FJ_WEBRTC_TURN_PORT_RANGE: "50000-50050"
2222
FJ_WEBRTC_TURN_TCP_PORT: "49999"
23-
FJ_SERVER_API_TOKEN: "development"
23+
FJ_ADMIN_TOKEN: "admin"
24+
FJ_TEST_USER_TOKEN: "development"
2425
FJ_CHECK_ORIGIN: "false"
2526
ports:
2627
- "5002:5002"

e2e-tests/webrtc-client/docker-compose-test.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ version: "3"
22

33
services:
44
fishjam:
5-
image: "ghcr.io/fishjam-cloud/fishjam:0.10.0-dev"
5+
image: "ghcr.io/fishjam-cloud/fishjam:edge"
66
container_name: fishjam
77
restart: on-failure
88
platform: linux/amd64
99
healthcheck:
1010
test: >
11-
curl --fail -H "authorization: Bearer development"
11+
curl --fail -H "authorization: Bearer admin"
1212
http://localhost:5002/room || exit 1
1313
interval: 3s
1414
retries: 2
@@ -21,7 +21,8 @@ services:
2121
FJ_WEBRTC_TURN_LISTEN_IP: "0.0.0.0"
2222
FJ_WEBRTC_TURN_PORT_RANGE: "50000-50050"
2323
FJ_WEBRTC_TURN_TCP_PORT: "49999"
24-
FJ_SERVER_API_TOKEN: "development"
24+
FJ_ADMIN_TOKEN: "admin"
25+
FJ_TEST_USER_TOKEN: "development"
2526
FJ_CHECK_ORIGIN: "false"
2627
ports:
2728
- "5002:5002"

packages/protobufs/fishjam/media_events/peer/peer.ts

Lines changed: 83 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protobufs/fishjam/media_events/server/server.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protobufs/fishjam/media_events/shared.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protobufs/fishjam/peer_notifications.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/protobufs/fishjam/server_notifications.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/webrtc-client/src/tracks/LocalTrack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ export class LocalTrack implements TrackCommon {
137137
stream?.addTrack(newTrack);
138138
}
139139

140+
const action = getActionType(this.trackContext.track, newTrack);
141+
140142
this.trackContext.track = newTrack;
141143
this.mediaStreamTrackId = newTrack?.id ?? null;
142144

143-
const action = getActionType(this.trackContext.track, newTrack);
144145
if (action === 'mute' || action === 'unmute') {
145146
emitMutableEvents(action, webrtc, trackId);
146147
}

packages/webrtc-client/src/tracks/muteTrackUtils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import { MediaEvent_UnmuteTrack } from '@fishjam-cloud/protobufs/peer';
2+
3+
import { serializePeerMediaEvent } from '../mediaEvent';
14
import type { WebRTCEndpoint } from '../webRTCEndpoint';
25

36
export function emitMutableEvents(action: 'mute' | 'unmute', webrtc: WebRTCEndpoint, trackId: string) {
47
const localEventType = action === 'mute' ? 'localTrackMuted' : 'localTrackUnmuted';
58

6-
// TODO add the mute/unmute event back if they're needed
7-
// const mediaEvent = generateMediaEvent(mediaEventType, { trackId: trackId });
8-
// webrtc.sendMediaEvent(mediaEvent);
9+
// Sending the media event `unmuteTrack` speeds up the unmuting of this track for other users
10+
// Without this media event, the track may take up to 5-10 seconds to unmute
11+
if (action == 'unmute') {
12+
const unmuteTrack = MediaEvent_UnmuteTrack.create({ trackId });
13+
webrtc.emit('sendMediaEvent', serializePeerMediaEvent({ unmuteTrack }));
14+
}
915

1016
webrtc.emit(localEventType, { trackId });
1117
}

0 commit comments

Comments
 (0)