LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
local_data_track.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 <cstddef>
20#include <memory>
21#include <optional>
22#include <string>
23#include <vector>
24
25#include "livekit/data_track_error.h"
26#include "livekit/data_track_frame.h"
27#include "livekit/data_track_info.h"
28#include "livekit/ffi_handle.h"
29#include "livekit/result.h"
30#include "livekit/visibility.h"
31
32namespace livekit {
33
34namespace proto {
35class OwnedLocalDataTrack;
36}
37
58class LIVEKIT_API LocalDataTrack {
59public:
60 ~LocalDataTrack() = default;
61
62 LocalDataTrack(const LocalDataTrack&) = delete;
63 LocalDataTrack& operator=(const LocalDataTrack&) = delete;
64
66 const DataTrackInfo& info() const noexcept { return info_; }
67
73
78 Result<void, LocalDataTrackTryPushError> tryPush(std::vector<std::uint8_t>&& payload,
79 std::optional<std::uint64_t> user_timestamp = std::nullopt);
80
82 bool isPublished() const;
83
88
89private:
90 friend class LocalParticipant;
91
92 explicit LocalDataTrack(const proto::OwnedLocalDataTrack& owned);
93
94 uintptr_t ffiHandleId() const noexcept { return handle_.get(); }
95
97 FfiHandle handle_;
98
100 DataTrackInfo info_;
101};
102
103} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
Represents a locally published data track.
Definition local_data_track.h:58
bool isPublished() const
Whether the track is still published in the room.
const DataTrackInfo & info() const noexcept
Metadata about this data track.
Definition local_data_track.h:66
Result< void, LocalDataTrackTryPushError > tryPush(std::vector< std::uint8_t > &&payload, std::optional< std::uint64_t > user_timestamp=std::nullopt)
Try to push a frame to all subscribers of this track.
void unpublishDataTrack()
Unpublish this data track from the room.
Result< void, LocalDataTrackTryPushError > tryPush(const DataTrackFrame &frame)
Try to push a frame to all subscribers of this track.
Represents the local participant in a room.
Definition local_participant.h:55
Lightweight success-or-error return type for non-exceptional API failures.
Definition result.h:40
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
A single frame of data published or received on a data track.
Definition data_track_frame.h:36
Metadata about a published data track.
Definition data_track_info.h:27