LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
room_event_types.h
1/*
2 * Copyright 2025 LiveKit
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an “AS IS” BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cstdint>
20#include <map>
21#include <memory>
22#include <optional>
23#include <string>
24#include <vector>
25
26namespace livekit {
27
28// Forward declarations to avoid pulling in heavy headers.
29class Track;
30class Participant;
31class RemoteParticipant;
32class RemoteDataTrack;
33class LocalTrackPublication;
34class RemoteTrackPublication;
35class TrackPublication;
36
37enum class VideoCodec;
38enum class TrackSource;
39
42 Poor = 0,
43 Good,
44 Excellent,
45 Lost,
46};
47
49enum class ConnectionState {
50 Disconnected = 0,
51 Connected,
52 Reconnecting,
53};
54
59enum class DataPacketKind {
60 Lossy,
61 Reliable,
62};
63
67enum class EncryptionState {
68 New = 0,
69 Ok,
70 EncryptionFailed,
71 DecryptionFailed,
72 MissingKey,
73 KeyRatcheted,
74 InternalError,
75};
76
80enum class DisconnectReason {
81 Unknown = 0,
82 ClientInitiated,
83 DuplicateIdentity,
84 ServerShutdown,
85 ParticipantRemoved,
86 RoomDeleted,
87 StateMismatch,
88 JoinFailure,
89 Migration,
90 SignalClose,
91 RoomClosed,
92 UserUnavailable,
93 UserRejected,
95 ConnectionTimeout,
96 MediaFailure
97};
98
102 std::vector<std::uint8_t> data;
103
105 std::optional<std::string> topic;
106};
107
118 std::uint32_t code = 0;
119
121 std::optional<std::string> digit;
122};
123
127 std::optional<std::string> sid;
128
130 std::string name;
131
133 std::string metadata;
134
137
140
142 std::uint32_t empty_timeout = 0;
143
145 std::uint32_t departure_timeout = 0;
146
148 std::uint32_t max_participants = 0;
149
151 std::int64_t creation_time = 0;
152
154 std::uint32_t num_participants = 0;
155
157 std::uint32_t num_publishers = 0;
158
160 bool active_recording = false;
161};
162
166 std::string key;
167
169 std::string value;
170
171 AttributeEntry() = default;
172
173 AttributeEntry(std::string k, std::string v) : key(std::move(k)), value(std::move(v)) {}
174};
175
180 std::string stream_id;
181
183 std::int64_t timestamp = 0;
184
186 std::string mime_type;
187
189 std::string topic;
190
192 std::optional<std::uint64_t> total_length;
193
195 std::map<std::string, std::string> attributes;
196
198 enum class ContentType {
199 None,
200 Text,
201 Byte,
202 } content_type = ContentType::None;
203
205 enum class OperationType {
206 Create = 0,
207 Update = 1,
208 Delete = 2,
209 Reaction = 3,
210 };
211
213 std::optional<OperationType> operation_type;
214
216 std::optional<int> version;
217
219 std::optional<std::string> reply_to_stream_id;
220
222 std::vector<std::string> attached_stream_ids;
223
225 std::optional<bool> generated;
226
228 std::optional<std::string> name;
229};
230
234 std::string stream_id;
235
237 std::uint64_t chunk_index = 0;
238
240 std::vector<std::uint8_t> content;
241
243 std::optional<int> version;
244
246 std::vector<std::uint8_t> iv;
247};
248
252 std::string stream_id;
253
255 std::string reason;
256
258 std::map<std::string, std::string> attributes;
259};
260
264 std::uint64_t max_bitrate = 0;
265
267 double max_framerate = 0.0;
268};
269
273 std::uint64_t max_bitrate = 0;
274};
275
279 bool user_timestamp = false;
280
282 bool frame_id = false;
283};
284
288 std::optional<VideoEncodingOptions> video_encoding;
289
291 std::optional<AudioEncodingOptions> audio_encoding;
292
294 std::optional<VideoCodec> video_codec;
295
297 std::optional<bool> dtx;
298
300 std::optional<bool> red;
301
303 std::optional<bool> simulcast;
304
306 std::optional<TrackSource> source;
307
309 std::optional<std::string> stream;
310
312 std::optional<bool> preconnect_buffer;
313
316};
317
318// ---------------------------------------------------------
319// Event structs – public representations of RoomEvent.*
320// ---------------------------------------------------------
321
327
332
334 DisconnectReason reason = DisconnectReason::Unknown;
335};
336
340 std::shared_ptr<LocalTrackPublication> publication;
341
343 std::shared_ptr<Track> track;
344};
345
349 std::shared_ptr<LocalTrackPublication> publication;
350};
351
355 std::shared_ptr<Track> track;
356};
357
361 std::shared_ptr<RemoteTrackPublication> publication;
362
365};
366
370 std::shared_ptr<RemoteTrackPublication> publication;
371
374};
375
379 std::shared_ptr<Track> track;
380
382 std::shared_ptr<RemoteTrackPublication> publication;
383
386};
387
391 std::shared_ptr<Track> track;
392
394 std::shared_ptr<RemoteTrackPublication> publication;
395
398};
399
404
406 std::string track_sid;
407
409 std::string error;
410};
411
416
418 std::shared_ptr<TrackPublication> publication;
419};
420
425
427 std::shared_ptr<TrackPublication> publication;
428};
429
433 std::vector<Participant*> speakers;
434};
435
439 std::string old_metadata;
440
442 std::string new_metadata;
443};
444
448 std::string sid;
449};
450
455
457 std::string old_metadata;
458
460 std::string new_metadata;
461};
462
467
469 std::string old_name;
470
472 std::string new_name;
473};
474
479
481 std::vector<AttributeEntry> changed_attributes;
482};
483
492
497
499 ConnectionQuality quality = ConnectionQuality::Good;
500};
501
505 std::vector<std::uint8_t> data;
506
508 DataPacketKind kind = DataPacketKind::Reliable;
509
513
515 std::string topic;
516};
517
521 int code = 0;
522
524 std::string digit;
525
528};
529
533 ConnectionState state = ConnectionState::Disconnected;
534};
535
539 DisconnectReason reason = DisconnectReason::Unknown;
540};
541
544
547
549struct RoomEosEvent {};
550
559
568
577
581 DataPacketKind kind = DataPacketKind::Reliable;
582
584 std::uint64_t threshold = 0;
585};
586
590 std::uint64_t reader_handle = 0;
591
594};
595
599 std::uint64_t reader_handle = 0;
600
603};
604
610
616
620 std::vector<Participant*> participants;
621};
622
627
629 EncryptionState state = EncryptionState::New;
630};
631
639 std::shared_ptr<RemoteDataTrack> track;
640};
641
645 std::string sid;
646};
647
648} // namespace livekit
Base class for local and remote room participants.
Definition participant.h:34
Represents a remote participant in a LiveKit room.
Definition remote_participant.h:31
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
EncryptionState
End-to-end encryption state for a participant.
Definition room_event_types.h:67
TrackSource
Source category for a published track.
Definition track.h:43
DataPacketKind
Type of data packet delivery semantics.
Definition room_event_types.h:59
ConnectionState
Current connection state of the room.
Definition room_event_types.h:49
DisconnectReason
Reason why a participant or room was disconnected.
Definition room_event_types.h:80
@ SipTrunkFailure
SIP (telephony) trunk connection failed.
ConnectionQuality
Overall quality of a participant's connection.
Definition room_event_types.h:41
Fired when the list of active speakers changes.
Definition room_event_types.h:431
std::vector< Participant * > speakers
Participants currently considered active speakers (owned by Room).
Definition room_event_types.h:433
Key/value pair for participant or room attributes.
Definition room_event_types.h:164
std::string value
Attribute value.
Definition room_event_types.h:169
std::string key
Attribute key.
Definition room_event_types.h:166
Audio encoding configuration used when publishing a track.
Definition room_event_types.h:271
std::uint64_t max_bitrate
Maximum target bitrate in bps.
Definition room_event_types.h:273
Fired when a high-level byte stream reader is opened.
Definition room_event_types.h:588
std::string participant_identity
Identity of the participant that opened the stream.
Definition room_event_types.h:593
std::uint64_t reader_handle
Handle to the underlying byte stream reader.
Definition room_event_types.h:590
Fired when a participant's connection quality estimate changes.
Definition room_event_types.h:494
ConnectionQuality quality
New connection quality.
Definition room_event_types.h:499
Participant * participant
Participant whose connection quality changed (owned by Room).
Definition room_event_types.h:496
Fired when the room's connection state changes.
Definition room_event_types.h:531
ConnectionState state
New connection state.
Definition room_event_types.h:533
Fired when a data channel's buffered amount falls below its low threshold.
Definition room_event_types.h:579
std::uint64_t threshold
New threshold value in bytes.
Definition room_event_types.h:584
DataPacketKind kind
Data channel kind (reliable or lossy).
Definition room_event_types.h:581
One chunk of a data stream’s payload.
Definition room_event_types.h:232
std::optional< int > version
Optional version, mirroring header version if applicable.
Definition room_event_types.h:243
std::uint64_t chunk_index
Zero-based index of this chunk.
Definition room_event_types.h:237
std::vector< std::uint8_t > iv
Optional initialization vector for encrypted payloads.
Definition room_event_types.h:246
std::string stream_id
Stream identifier this chunk belongs to.
Definition room_event_types.h:234
std::vector< std::uint8_t > content
Raw chunk content.
Definition room_event_types.h:240
Fired when a data stream chunk is received.
Definition room_event_types.h:561
std::string participant_identity
Identity of the participant that sent the stream.
Definition room_event_types.h:563
DataStreamChunkData chunk
Chunk payload and metadata.
Definition room_event_types.h:566
Header information for an incoming data stream.
Definition room_event_types.h:178
std::int64_t timestamp
Timestamp (ms since Unix epoch).
Definition room_event_types.h:183
std::optional< std::string > reply_to_stream_id
Optional ID of the stream this one replies to.
Definition room_event_types.h:219
OperationType
Operation type for text streams.
Definition room_event_types.h:205
std::optional< OperationType > operation_type
Optional operation type, for text content.
Definition room_event_types.h:213
std::optional< std::string > name
Optional filename for byte streams.
Definition room_event_types.h:228
std::map< std::string, std::string > attributes
Custom attributes associated with this stream.
Definition room_event_types.h:195
ContentType
Content type carried by this stream.
Definition room_event_types.h:198
std::string stream_id
Unique stream identifier.
Definition room_event_types.h:180
std::optional< bool > generated
True if this stream was generated (e.g. by AI).
Definition room_event_types.h:225
std::optional< std::uint64_t > total_length
Optional total length in bytes, if known.
Definition room_event_types.h:192
std::string mime_type
MIME type of the content (e.g. "application/json").
Definition room_event_types.h:186
std::optional< int > version
Optional version number for the text stream.
Definition room_event_types.h:216
std::vector< std::string > attached_stream_ids
IDs of streams attached to this one.
Definition room_event_types.h:222
std::string topic
Application-defined topic name.
Definition room_event_types.h:189
Fired when a data stream header is received.
Definition room_event_types.h:552
DataStreamHeaderData header
Parsed header data.
Definition room_event_types.h:557
std::string participant_identity
Identity of the participant that sent the stream.
Definition room_event_types.h:554
Trailer metadata for a data stream, sent after all chunks.
Definition room_event_types.h:250
std::string stream_id
Stream identifier.
Definition room_event_types.h:252
std::map< std::string, std::string > attributes
Additional attributes describing the final state of the stream.
Definition room_event_types.h:258
std::string reason
Reason why the stream ended (empty if normal completion).
Definition room_event_types.h:255
Fired when a data stream trailer is received.
Definition room_event_types.h:570
std::string participant_identity
Identity of the participant that sent the stream.
Definition room_event_types.h:572
DataStreamTrailerData trailer
Trailer metadata describing the stream termination.
Definition room_event_types.h:575
Fired when a participant publishes a data track.
Definition room_event_types.h:637
std::shared_ptr< RemoteDataTrack > track
The newly published remote data track.
Definition room_event_types.h:639
Fired when a remote participant unpublishes a data track.
Definition room_event_types.h:643
std::string sid
SID of the track that was unpublished.
Definition room_event_types.h:645
Fired when the room is disconnected.
Definition room_event_types.h:537
DisconnectReason reason
Reason for disconnect, if known.
Definition room_event_types.h:539
Fired when a participant's E2EE state changes.
Definition room_event_types.h:624
EncryptionState state
New encryption state.
Definition room_event_types.h:629
Participant * participant
Local or remote participant whose state changed (owned by Room).
Definition room_event_types.h:626
Fired when a local track is successfully published.
Definition room_event_types.h:338
std::shared_ptr< LocalTrackPublication > publication
Track publication for the local track.
Definition room_event_types.h:340
std::shared_ptr< Track > track
The published local track.
Definition room_event_types.h:343
Fired when a local track gets its first subscriber.
Definition room_event_types.h:353
std::shared_ptr< Track > track
Subscribed local track.
Definition room_event_types.h:355
Fired when a local track is unpublished.
Definition room_event_types.h:347
std::shared_ptr< LocalTrackPublication > publication
Publication that was unpublished.
Definition room_event_types.h:349
Optional RTP packet-trailer features for published video tracks.
Definition room_event_types.h:277
bool user_timestamp
Embed a user-supplied wall-clock timestamp.
Definition room_event_types.h:279
bool frame_id
Embed a monotonically increasing frame identifier.
Definition room_event_types.h:282
Fired when a participant's attributes change.
Definition room_event_types.h:476
std::vector< AttributeEntry > changed_attributes
Set of attributes that changed (key/value pairs).
Definition room_event_types.h:481
Participant * participant
Participant whose attributes changed (owned by Room).
Definition room_event_types.h:478
Fired when a remote participant joins the room.
Definition room_event_types.h:323
RemoteParticipant * participant
The newly connected remote participant (owned by Room).
Definition room_event_types.h:325
Fired when a remote participant leaves the room.
Definition room_event_types.h:329
RemoteParticipant * participant
The participant that disconnected (owned by Room).
Definition room_event_types.h:331
DisconnectReason reason
Reason for the disconnect, if known.
Definition room_event_types.h:334
Fired when a participant's encryption status changes.
Definition room_event_types.h:485
Participant * participant
Participant whose encryption status changed (owned by Room).
Definition room_event_types.h:487
bool is_encrypted
True if the participant is now fully encrypted.
Definition room_event_types.h:490
Fired when a participant's metadata is updated.
Definition room_event_types.h:452
std::string old_metadata
Old metadata value.
Definition room_event_types.h:457
Participant * participant
Participant whose metadata changed (owned by Room).
Definition room_event_types.h:454
std::string new_metadata
New metadata value.
Definition room_event_types.h:460
Fired when a participant's name changes.
Definition room_event_types.h:464
std::string old_name
Previous name.
Definition room_event_types.h:469
std::string new_name
New name.
Definition room_event_types.h:472
Participant * participant
Participant whose name changed (owned by Room).
Definition room_event_types.h:466
Fired when a batch of participants has been updated.
Definition room_event_types.h:618
std::vector< Participant * > participants
Participants updated in this event (owned by Room).
Definition room_event_types.h:620
Fired after successfully reconnecting.
Definition room_event_types.h:546
Fired just before attempting to reconnect.
Definition room_event_types.h:543
Fired when the room has reached end-of-stream (no more events).
Definition room_event_types.h:549
Snapshot of core room information.
Definition room_event_types.h:125
std::string name
Room name.
Definition room_event_types.h:130
std::uint32_t num_participants
Approximate number of participants (eventually consistent).
Definition room_event_types.h:154
std::uint32_t departure_timeout
Time (seconds) to keep room open after last standard participant leaves.
Definition room_event_types.h:145
std::uint32_t empty_timeout
Time (seconds) to keep room open if no participants join.
Definition room_event_types.h:142
std::string metadata
Arbitrary application metadata associated with the room.
Definition room_event_types.h:133
bool active_recording
True if the room is currently being recorded.
Definition room_event_types.h:160
std::int64_t creation_time
Creation time of the room (ms since Unix epoch).
Definition room_event_types.h:151
std::uint32_t num_publishers
Approximate number of publishers (eventually consistent).
Definition room_event_types.h:157
std::uint32_t max_participants
Maximum number of participants allowed in the room.
Definition room_event_types.h:148
std::uint64_t reliable_dc_buffered_amount_low_threshold
Low-watermark threshold for reliable data channel buffer.
Definition room_event_types.h:139
std::uint64_t lossy_dc_buffered_amount_low_threshold
Low-watermark threshold for lossy data channel buffer.
Definition room_event_types.h:136
std::optional< std::string > sid
Room SID, if known.
Definition room_event_types.h:127
Fired when room metadata is updated.
Definition room_event_types.h:437
std::string old_metadata
Previous metadata value.
Definition room_event_types.h:439
std::string new_metadata
New metadata value.
Definition room_event_types.h:442
Fired when the participant has been moved to another room.
Definition room_event_types.h:612
RoomInfoData info
Info about the new room.
Definition room_event_types.h:614
Fired when the room SID changes (e.g., after migration).
Definition room_event_types.h:446
std::string sid
New room SID.
Definition room_event_types.h:448
Fired when the room's info is updated.
Definition room_event_types.h:606
RoomInfoData info
New room info snapshot.
Definition room_event_types.h:608
SIP (Session Initiation Protocol) DTMF payload carried via data packets.
Definition room_event_types.h:116
std::uint32_t code
Numeric DTMF code (0-15, mapping to 0-9, *, #, A-D).
Definition room_event_types.h:118
std::optional< std::string > digit
Human-readable digit representation (e.g. "1", "#").
Definition room_event_types.h:121
Fired when a SIP DTMF packet is received.
Definition room_event_types.h:519
RemoteParticipant * participant
Remote participant that sent the DTMF (owned by Room).
Definition room_event_types.h:527
int code
DTMF code.
Definition room_event_types.h:521
std::string digit
Human-readable DTMF digit.
Definition room_event_types.h:524
Fired when a high-level text stream reader is opened.
Definition room_event_types.h:597
std::string participant_identity
Identity of the participant that opened the stream.
Definition room_event_types.h:602
std::uint64_t reader_handle
Handle to the underlying text stream reader.
Definition room_event_types.h:599
Fired when a track is muted.
Definition room_event_types.h:413
Participant * participant
Local or remote participant who owns the track (owned by Room).
Definition room_event_types.h:415
std::shared_ptr< TrackPublication > publication
Publication that was muted.
Definition room_event_types.h:418
Options for publishing a track to the room.
Definition room_event_types.h:286
std::optional< VideoEncodingOptions > video_encoding
Optional video encoding parameters.
Definition room_event_types.h:288
std::optional< bool > red
Enable or disable RED (redundant encoding).
Definition room_event_types.h:300
PacketTrailerFeatures packet_trailer_features
Optional packet-trailer features to enable for published video.
Definition room_event_types.h:315
std::optional< bool > simulcast
Enable or disable simulcast.
Definition room_event_types.h:303
std::optional< std::string > stream
Optional stream label/group for this track.
Definition room_event_types.h:309
std::optional< bool > dtx
Enable or disable discontinuous transmission (DTX).
Definition room_event_types.h:297
std::optional< VideoCodec > video_codec
Optional video codec to use.
Definition room_event_types.h:294
std::optional< AudioEncodingOptions > audio_encoding
Optional audio encoding parameters.
Definition room_event_types.h:291
std::optional< TrackSource > source
Track source (camera, microphone, screen share, etc.).
Definition room_event_types.h:306
std::optional< bool > preconnect_buffer
Enable pre-connect buffering for lower startup latency.
Definition room_event_types.h:312
Fired when a remote participant publishes a track.
Definition room_event_types.h:359
std::shared_ptr< RemoteTrackPublication > publication
Remote track publication.
Definition room_event_types.h:361
RemoteParticipant * participant
Remote participant who owns this track (owned by Room).
Definition room_event_types.h:364
Fired when a remote track is successfully subscribed.
Definition room_event_types.h:377
std::shared_ptr< Track > track
Subscribed remote track.
Definition room_event_types.h:379
std::shared_ptr< RemoteTrackPublication > publication
Publication associated with the track.
Definition room_event_types.h:382
RemoteParticipant * participant
Remote participant who owns the track (owned by Room).
Definition room_event_types.h:385
Fired when subscribing to a remote track fails.
Definition room_event_types.h:401
std::string error
Error message describing the failure.
Definition room_event_types.h:409
std::string track_sid
SID of the track that failed to subscribe.
Definition room_event_types.h:406
RemoteParticipant * participant
Remote participant for which the subscription failed (owned by Room).
Definition room_event_types.h:403
Fired when a track is unmuted.
Definition room_event_types.h:422
Participant * participant
Local or remote participant who owns the track (owned by Room).
Definition room_event_types.h:424
std::shared_ptr< TrackPublication > publication
Publication that was unmuted.
Definition room_event_types.h:427
Fired when a remote participant unpublishes a track.
Definition room_event_types.h:368
std::shared_ptr< RemoteTrackPublication > publication
Remote track publication that was removed.
Definition room_event_types.h:370
RemoteParticipant * participant
Remote participant who owned this track (owned by Room).
Definition room_event_types.h:373
Fired when a remote track is unsubscribed.
Definition room_event_types.h:389
RemoteParticipant * participant
Remote participant who owns the track (owned by Room).
Definition room_event_types.h:397
std::shared_ptr< Track > track
Track that was unsubscribed.
Definition room_event_types.h:391
std::shared_ptr< RemoteTrackPublication > publication
Publication associated with the track.
Definition room_event_types.h:394
Fired when a user data packet (non-SIP) is received.
Definition room_event_types.h:503
std::vector< std::uint8_t > data
Payload data.
Definition room_event_types.h:505
RemoteParticipant * participant
Remote participant that sent this packet, or nullptr if server (owned by Room).
Definition room_event_types.h:512
std::string topic
Optional topic associated with this data (may be empty).
Definition room_event_types.h:515
DataPacketKind kind
Delivery kind (reliable or lossy).
Definition room_event_types.h:508
Application-level user data carried in a data packet.
Definition room_event_types.h:100
std::vector< std::uint8_t > data
Raw payload bytes.
Definition room_event_types.h:102
std::optional< std::string > topic
Optional topic name associated with this payload.
Definition room_event_types.h:105
Video encoding configuration used when publishing a track.
Definition room_event_types.h:262
double max_framerate
Maximum frame rate in frames per second.
Definition room_event_types.h:267
std::uint64_t max_bitrate
Maximum target bitrate in bps.
Definition room_event_types.h:264