LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
participant.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 <memory>
21#include <string>
22#include <unordered_map>
23
24#include "livekit/ffi_handle.h"
25#include "livekit/room_delegate.h"
26#include "livekit/visibility.h"
27
28namespace livekit {
29
31enum class ParticipantKind { Standard = 0, Ingress, Egress, Sip, Agent };
32
34class LIVEKIT_API Participant {
35public:
36 Participant(FfiHandle handle, std::string sid, std::string name, std::string identity, std::string metadata,
37 std::unordered_map<std::string, std::string> attributes, ParticipantKind kind, DisconnectReason reason)
38 : handle_(std::move(handle)),
39 sid_(std::move(sid)),
40 name_(std::move(name)),
41 identity_(std::move(identity)),
42 metadata_(std::move(metadata)),
43 attributes_(std::move(attributes)),
44 kind_(kind),
45 reason_(reason) {}
46 virtual ~Participant() = default;
47
48 // Plain getters (caller ensures threading)
49 const std::string& sid() const noexcept { return sid_; }
50 const std::string& name() const noexcept { return name_; }
51 const std::string& identity() const noexcept { return identity_; }
52 const std::string& metadata() const noexcept { return metadata_; }
53 const std::unordered_map<std::string, std::string>& attributes() const noexcept { return attributes_; }
54 ParticipantKind kind() const noexcept { return kind_; }
55 DisconnectReason disconnectReason() const noexcept { return reason_; }
56
57 uintptr_t ffiHandleId() const noexcept { return handle_.get(); }
58
59protected:
60 virtual std::shared_ptr<TrackPublication> findTrackPublication(const std::string& sid) const = 0;
61
64 friend class Room;
65
66private:
67 FfiHandle handle_;
68 std::string sid_, name_, identity_, metadata_;
69 std::unordered_map<std::string, std::string> attributes_;
70 ParticipantKind kind_;
71 DisconnectReason reason_;
72};
73
74} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
Base class for local and remote room participants.
Definition participant.h:34
Represents a LiveKit room session.
Definition room.h:98
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
ParticipantKind
Identifies the type of participant connected to a room.
Definition participant.h:31
DisconnectReason
Reason why a participant or room was disconnected.
Definition room_event_types.h:80