Skip to content

Commit af73c2b

Browse files
Brazold3xvn
andauthored
feat: expose single event stream in Call combining sfu and coordinator events (#625)
* single call event stream exposed combining sfu and coordinator events * tweaks * tweaks to call event * roadmap update * rename to StreamCallEvent * docs * vale fix * typo * Update docusaurus/docs/Flutter/03-core-concepts/09-call-events.mdx * Update packages/stream_video/CHANGELOG.md * removed cid requirement --------- Co-authored-by: Deven Joshi <[email protected]>
1 parent c0a55ae commit af73c2b

File tree

8 files changed

+1027
-43
lines changed

8 files changed

+1027
-43
lines changed

development.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
- [x] Android foreground service
2424

2525
### 0.3.0 milestone
26-
- [ ] Publish apps to Android/iOS [Deven]
27-
- - [ ] Check the stores' descriptions
28-
- - [ ] Publish Dogfooding app
29-
- [ ] Participant sort bug [Efthymis]
26+
- [x] Publish apps to Android/iOS [Deven]
27+
- - [x] Check the stores' descriptions
28+
- - [x] Publish Dogfooding app
29+
- [x] Participant sort bug [Efthymis]
3030
- [x] Android/iOS ringing flow
3131
- [x] Live streaming component(s) [Deven]
3232
- [x] Deeplinking
33-
- [ ] Tap to focus (flutter_webrtc) [Kanat]
3433
- [x] Push notifications [Maciej]
3534
- - [x] Customization of the incoming/outgoing call screens
3635
- - [x] Customizing CallKit ringing calls
@@ -48,29 +47,32 @@
4847
- [x] Fix analysis issues [Maciej]
4948

5049
### 0.4.0 milestone
51-
- [ ] Implement Chat overlay for Dogfooding app
50+
- [x] Implement Chat overlay for Dogfooding app
5251
- [x] Support SFU migration
52+
- [x] Send raw stats to backend
53+
- [x] Bluetooth fixes (check support of BT media devices in flutter)
54+
- [x] Switch the earpiece/microphone button *(depends on "Bluetooth fixes")*
55+
- [x] Align custom event support to other SDKs
56+
- [ ] Tap to focus (flutter_webrtc)
5357
- [ ] Video filters / audio filters
54-
- [ ] Bluetooth fixes (check support of BT media devices in flutter)
55-
- [ ] Switch the earpiece/microphone button *(depends on "Bluetooth fixes")*
5658
- [ ] Local audio levels (maybe from webrtc)
5759
- [ ] Test coverage
5860
- - [ ] stream_video (75%)
5961
- - [ ] stream_video_flutter (75%)
6062
- - [ ] stream_video_push_notification
6163
- - [ ] Coverage check for PRs
62-
- [ ] Align custom event support to other SDKs
63-
- [ ] Send raw stats to backend
6464
- [ ] Documentation parity
6565
- - [ ] UI components
6666
- - [ ] Cookbook
6767
- - [ ] Advanced guides
6868

6969
### 0.5.0 milestone
70-
- [ ] Dynascale 2.0
7170
- [ ] Picture-in-picture
71+
- - [x] Android
72+
- - [ ] iOS
73+
- [ ] Dynascale 2.0
7274
- [ ] SFU switching
7375
- [ ] Buttons to simulate ICE restarts / SFU switching
7476
- [ ] Proximity button support
75-
- [ ] Call stats component
77+
- [x] Call stats component
7678
- [ ] Transcription
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Call Events
3+
slug: /call-events
4+
description: How to listen and leverage call events
5+
---
6+
7+
There are multiple events that you can listen to during a call. You can use them to update the UI, show notifications, or log the call events. You can listen to them via `callEvents` stream in the `Call` object.
8+
9+
Here are some of the events you can listen to:
10+
11+
12+
| Call Event | Description |
13+
| --------------------------------------------- | ----------------------------------------------------- |
14+
| **General Call Events** | |
15+
| `StreamCallCreatedEvent` | Triggered when a call is created. |
16+
| `StreamCallJoinedEvent` | Triggered when a user joins a call. |
17+
| `StreamCallEndedEvent` | Triggered when the call ends. |
18+
| `StreamCallUpdatedEvent` | Triggered when the call metadata are updated. |
19+
| **Participant Events** | |
20+
| `StreamCallParticipantJoinedEvent` | Triggered when a participant joins the call. |
21+
| `StreamCallParticipantLeftEvent` | Triggered when a participant leaves the call. |
22+
| `StreamCallDominantSpeakerChangedEvent` | Triggered when the dominant speaker changes. |
23+
| **Quality and Control Events** | |
24+
| `StreamCallConnectionQualityChangedEvent` | Triggered when connection quality changes for participants. |
25+
| `StreamCallAudioLevelChangedEvent` | Triggered when audio levels change for participants. |
26+
| `StreamCallPermissionRequestEvent` | Triggered when there is a permission request for a call. |
27+
| `StreamCallPermissionsUpdatedEvent` | Triggered when permissions for a call are updated. |
28+
| **Call Ringing Events** | |
29+
| `StreamCallRingingEvent` | Triggered when the call is ringing. |
30+
| `StreamCallAcceptedEvent` | Triggered when the call is accepted. |
31+
| `StreamCallRejectedEvent` | Triggered when the call is rejected. |
32+
| **Media Events** | |
33+
| `StreamCallRecordingStartedEvent` | Triggered when recording starts for a call. |
34+
| `StreamCallRecordingStoppedEvent` | Triggered when recording stops for a call. |
35+
| `StreamCallBroadcastingStartedEvent` | Triggered when broadcasting starts for a call. |
36+
| `StreamCallBroadcastingStoppedEvent` | Triggered when broadcasting stops for a call. |
37+
| **Session Events** | |
38+
| `StreamCallSessionStartedEvent` | Triggered when a new session starts for a call. |
39+
| `StreamCallSessionEndedEvent` | Triggered when a session ends for a call. |
40+
| `StreamCallSessionParticipantJoinedEvent` | Triggered when a participant joins the call session. |
41+
| `StreamCallSessionParticipantLeftEvent` | Triggered when a participant leaves the call session. |
42+
| **Other Events** | |
43+
| `StreamCallUserBlockedEvent` | Triggered when a user is blocked in a call. |
44+
| `StreamCallUserUnblockedEvent` | Triggered when a user is unblocked in a call. |
45+
| `StreamCallReactionEvent` | Triggered when someone sends a reaction during a call.|
46+
47+
## Custom event
48+
49+
Stream Video also supports custom events. This is a real-time layer that you can broadcast your own events to.
50+
51+
### Sending custom events
52+
53+
You can use the `sendCustomEvent` method of the `Call` instance to send custom events:
54+
55+
```dart
56+
call.sendCustomEvent(
57+
eventType: 'my-custom-event',
58+
custom: {
59+
'key': 'value',
60+
},
61+
);
62+
```
63+
64+
### Receiving custom events
65+
66+
You can listen to custom events by listening to the `StreamCallCustomEvent` event via the same `callEvents` stream:
67+
68+
```dart
69+
call.callEvents.on<StreamCallCustomEvent>((event) { });
70+
```

packages/stream_video/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Unrelease
2+
✅ Added
3+
4+
* Added `callEvents` stream to `Call` that replaces `events` and `coordinatorEvents` streams (both are now deprecated)
5+
6+
🚧 Breaking changes
7+
8+
* Removed the `callCid` parameter requirement from `sendCustomEvent` method in `Call` class
9+
110
## 0.3.5
211
✅ Added
312

packages/stream_video/lib/src/call/call.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,18 @@ class Call {
242242
SharedEmitter<CallStats> get stats => _stats;
243243
late final _stats = MutableSharedEmitterImpl<CallStats>();
244244

245+
@Deprecated('Use `callEvents` instead')
245246
SharedEmitter<SfuEvent> get events => _events;
246247
final _events = MutableSharedEmitterImpl<SfuEvent>();
247248

249+
@Deprecated('Use `callEvents` instead')
248250
SharedEmitter<CoordinatorCallEvent> get coordinatorEvents =>
249251
_coordinatorEvents;
250252
final _coordinatorEvents = MutableSharedEmitterImpl<CoordinatorCallEvent>();
251253

254+
SharedEmitter<StreamCallEvent> get callEvents => _callEvents;
255+
final _callEvents = MutableSharedEmitterImpl<StreamCallEvent>();
256+
252257
OnCallPermissionRequest? onPermissionRequest;
253258

254259
final _status = MutableStateEmitterImpl<_ConnectionStatus>(
@@ -294,6 +299,7 @@ class Call {
294299
_idCoordEvents,
295300
_coordinatorClient.events.on<CoordinatorCallEvent>((event) async {
296301
_coordinatorEvents.emit(event);
302+
event.mapToCallEvent(state.value).emitIfNotNull(_callEvents);
297303
await _onCoordinatorEvent(event);
298304
}),
299305
);
@@ -593,6 +599,7 @@ class Call {
593599
() => '[listenSfuEvent] event.type: ${event.runtimeType}',
594600
);
595601
_events.emit(event);
602+
event.mapToCallEvent(state.value).emitIfNotNull(_callEvents);
596603
_onSfuEvent(event);
597604
}),
598605
);
@@ -1760,7 +1767,6 @@ class Call {
17601767
}
17611768

17621769
Future<Result<None>> sendCustomEvent({
1763-
required StreamCallCid callCid,
17641770
required String eventType,
17651771
Map<String, Object> custom = const {},
17661772
}) {

0 commit comments

Comments
 (0)