LiveKit C++ Client SDK v1.9.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
data_track_schema.h
1/*
2 * Copyright 2026 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 <string>
20#include <utility>
21
22namespace livekit {
23
37public:
57
63 DataTrackSchemaEncoding(WellKnown well_known) : well_known_(well_known) {}
64
72 static DataTrackSchemaEncoding custom(std::string identifier) {
74 encoding.custom_ = std::move(identifier);
75 return encoding;
76 }
77
81 bool isCustom() const { return !custom_.empty(); }
82
86 WellKnown wellKnown() const { return well_known_; }
87
91 const std::string& customIdentifier() const { return custom_; }
92
93private:
94 DataTrackSchemaEncoding() = default;
95
96 WellKnown well_known_ = Other;
97 std::string custom_;
98};
99
100inline bool operator==(const DataTrackSchemaEncoding& a, const DataTrackSchemaEncoding& b) {
101 if (a.isCustom() || b.isCustom()) {
102 return a.customIdentifier() == b.customIdentifier();
103 }
104 return a.wellKnown() == b.wellKnown();
105}
106inline bool operator!=(const DataTrackSchemaEncoding& a, const DataTrackSchemaEncoding& b) { return !(a == b); }
107
121public:
141
147 DataTrackFrameEncoding(WellKnown well_known) : well_known_(well_known) {}
148
156 static DataTrackFrameEncoding custom(std::string identifier) {
157 DataTrackFrameEncoding encoding;
158 encoding.custom_ = std::move(identifier);
159 return encoding;
160 }
161
165 bool isCustom() const { return !custom_.empty(); }
166
170 WellKnown wellKnown() const { return well_known_; }
171
175 const std::string& customIdentifier() const { return custom_; }
176
177private:
178 DataTrackFrameEncoding() = default;
179
180 WellKnown well_known_ = Other;
181 std::string custom_;
182};
183
184inline bool operator==(const DataTrackFrameEncoding& a, const DataTrackFrameEncoding& b) {
185 if (a.isCustom() || b.isCustom()) {
186 return a.customIdentifier() == b.customIdentifier();
187 }
188 return a.wellKnown() == b.wellKnown();
189}
190inline bool operator!=(const DataTrackFrameEncoding& a, const DataTrackFrameEncoding& b) { return !(a == b); }
191
204
205inline bool operator==(const DataTrackSchemaId& a, const DataTrackSchemaId& b) {
206 return a.name == b.name && a.encoding == b.encoding;
207}
208inline bool operator!=(const DataTrackSchemaId& a, const DataTrackSchemaId& b) { return !(a == b); }
209
210} // namespace livekit
Encoding used for frames sent on a data track.
Definition data_track_schema.h:120
WellKnown wellKnown() const
Get the well-known encoding.
Definition data_track_schema.h:170
WellKnown
Well-known frame encodings.
Definition data_track_schema.h:123
@ Cdr
CDR, described by a Ros2Msg, Ros2Idl, or OmgIdl schema.
Definition data_track_schema.h:127
@ Other
Another well-known encoding not known to this client version.
Definition data_track_schema.h:139
@ Json
JSON, self-describing or described by a JsonSchema schema.
Definition data_track_schema.h:137
@ Cbor
CBOR, self-describing.
Definition data_track_schema.h:133
@ Ros1
ROS 1, described by a Ros1Msg schema.
Definition data_track_schema.h:125
@ Msgpack
MessagePack, self-describing.
Definition data_track_schema.h:135
@ Protobuf
Protocol Buffer, described by a Protobuf schema.
Definition data_track_schema.h:129
@ Flatbuffer
FlatBuffer, described by a Flatbuffer schema.
Definition data_track_schema.h:131
DataTrackFrameEncoding(WellKnown well_known)
Construct a well-known encoding.
Definition data_track_schema.h:147
const std::string & customIdentifier() const
Get the custom identifier.
Definition data_track_schema.h:175
bool isCustom() const
Check whether this is a custom encoding.
Definition data_track_schema.h:165
static DataTrackFrameEncoding custom(std::string identifier)
Construct a custom, application-defined encoding.
Definition data_track_schema.h:156
Encoding used to interpret a data track schema definition.
Definition data_track_schema.h:36
WellKnown
Well-known schema encodings.
Definition data_track_schema.h:39
@ Protobuf
Protocol Buffer IDL.
Definition data_track_schema.h:41
@ Other
Another well-known encoding not known to this client version.
Definition data_track_schema.h:55
@ Ros2Msg
ROS 2 Message.
Definition data_track_schema.h:47
@ OmgIdl
OMG IDL.
Definition data_track_schema.h:51
@ JsonSchema
JSON Schema.
Definition data_track_schema.h:53
@ Ros1Msg
ROS 1 Message.
Definition data_track_schema.h:45
@ Flatbuffer
FlatBuffer IDL.
Definition data_track_schema.h:43
@ Ros2Idl
ROS 2 IDL.
Definition data_track_schema.h:49
const std::string & customIdentifier() const
Get the custom identifier.
Definition data_track_schema.h:91
DataTrackSchemaEncoding(WellKnown well_known)
Construct a well-known encoding.
Definition data_track_schema.h:63
bool isCustom() const
Check whether this is a custom encoding.
Definition data_track_schema.h:81
WellKnown wellKnown() const
Get the well-known encoding.
Definition data_track_schema.h:86
static DataTrackSchemaEncoding custom(std::string identifier)
Construct a custom, application-defined encoding.
Definition data_track_schema.h:72
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
Uniquely identifies a data track schema.
Definition data_track_schema.h:197
DataTrackSchemaEncoding encoding
Encoding of the schema definition.
Definition data_track_schema.h:202
std::string name
Name component of the schema identifier.
Definition data_track_schema.h:199