LiveKit C++ SDK
Real-time audio/video 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 "livekit/data_track_error.h"
20#include "livekit/data_track_frame.h"
21#include "livekit/data_track_info.h"
22#include "livekit/ffi_handle.h"
23#include "livekit/result.h"
24
25#include <cstddef>
26#include <memory>
27#include <optional>
28#include <string>
29#include <vector>
30
31namespace livekit {
32
33namespace proto {
34class OwnedLocalDataTrack;
35}
36
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
75
83 tryPush(std::vector<std::uint8_t> &&payload,
84 std::optional<std::uint64_t> user_timestamp = std::nullopt);
85
87 bool isPublished() const;
88
95
96private:
97 friend class LocalParticipant;
98
99 explicit LocalDataTrack(const proto::OwnedLocalDataTrack &owned);
100
101 uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
102
104 FfiHandle handle_;
105
107 DataTrackInfo info_;
108};
109
110} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
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)
Result< void, LocalDataTrackTryPushError > tryPush(const DataTrackFrame &frame)
Definition local_participant.h:57
Definition result.h:42
Definition data_track_frame.h:36
Definition data_track_info.h:29