forked from livekit/client-sdk-cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrack.h
More file actions
136 lines (115 loc) · 4.04 KB
/
Copy pathtrack.h
File metadata and controls
136 lines (115 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright 2025 LiveKit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an “AS IS” BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "livekit/ffi_handle.h"
#include "livekit/stats.h"
#include <cstdint>
#include <future>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace livekit {
class LocalTrackPublication;
enum class TrackKind {
KIND_UNKNOWN = 0,
KIND_AUDIO = 1,
KIND_VIDEO = 2,
};
enum class TrackSource {
SOURCE_UNKNOWN = 0,
SOURCE_CAMERA = 1,
SOURCE_MICROPHONE = 2,
SOURCE_SCREENSHARE = 3,
SOURCE_SCREENSHARE_AUDIO = 4,
};
enum class StreamState {
STATE_UNKNOWN = 0,
STATE_ACTIVE = 1,
STATE_PAUSED = 2,
};
enum class AudioTrackFeature {
TF_STEREO = 0,
TF_NO_DTX = 1,
TF_AUTO_GAIN_CONTROL = 2,
TF_ECHO_CANCELLATION = 3,
TF_NOISE_SUPPRESSION = 4,
TF_ENHANCED_NOISE_CANCELLATION = 5,
TF_PRECONNECT_BUFFER = 6,
};
struct ParticipantTrackPermission {
std::string participant_identity;
std::optional<bool> allow_all;
std::vector<std::string> allowed_track_sids;
};
// ============================================================
// Base Track
// ============================================================
class Track {
public:
virtual ~Track() = default;
// Read-only properties
const std::string &sid() const noexcept { return sid_; }
const std::string &name() const noexcept { return name_; }
TrackKind kind() const noexcept { return kind_; }
StreamState stream_state() const noexcept { return state_; }
bool muted() const noexcept { return muted_; }
bool remote() const noexcept { return remote_; }
// Optional publication info
std::optional<TrackSource> source() const noexcept { return source_; }
std::optional<bool> simulcasted() const noexcept { return simulcasted_; }
std::optional<uint32_t> width() const noexcept { return width_; }
std::optional<uint32_t> height() const noexcept { return height_; }
std::optional<std::string> mime_type() const noexcept { return mime_type_; }
// Handle access
bool has_handle() const noexcept { return handle_.valid(); }
uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
// Async get stats
std::future<std::vector<RtcStats>> getStats() const;
/// After publishing a local track, associates the \ref LocalTrackPublication
/// with this track. Default implementation is a no-op (e.g. remote tracks).
virtual void setPublication(
const std::shared_ptr<LocalTrackPublication> &publication) noexcept {
(void)publication;
}
// Internal updates (called by Room)
void setStreamState(StreamState s) noexcept { state_ = s; }
void setMuted(bool m) noexcept { muted_ = m; }
void setName(std::string n) noexcept { name_ = std::move(n); }
protected:
Track(FfiHandle handle, std::string sid, std::string name, TrackKind kind,
StreamState state, bool muted, bool remote);
void setPublicationFields(std::optional<TrackSource> source,
std::optional<bool> simulcasted,
std::optional<uint32_t> width,
std::optional<uint32_t> height,
std::optional<std::string> mime_type);
private:
FfiHandle handle_; // Owned
std::string sid_;
std::string name_;
TrackKind kind_{TrackKind::KIND_UNKNOWN};
StreamState state_{StreamState::STATE_UNKNOWN};
bool muted_{false};
bool remote_{false};
std::optional<TrackSource> source_;
std::optional<bool> simulcasted_;
std::optional<uint32_t> width_;
std::optional<uint32_t> height_;
std::optional<std::string> mime_type_;
};
} // namespace livekit