LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
local_audio_track.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 <memory>
20#include <string>
21
22#include "livekit/audio_frame.h"
23#include "livekit/local_track_publication.h"
24#include "livekit/track.h"
25#include "livekit/visibility.h"
26
27namespace livekit {
28
29namespace proto {
30class OwnedTrack;
31}
32
33class AudioSource;
34class PlatformAudioSource;
35
58class LIVEKIT_API LocalAudioTrack : public Track {
59public:
71 static std::shared_ptr<LocalAudioTrack> createLocalAudioTrack(const std::string& name,
72 const std::shared_ptr<AudioSource>& source);
73
86 static std::shared_ptr<LocalAudioTrack> createLocalAudioTrack(const std::string& name,
87 const std::shared_ptr<PlatformAudioSource>& source);
88
95 void mute();
96
102 void unmute();
103
107 std::string toString() const;
108
111 std::shared_ptr<LocalTrackPublication> publication() const noexcept { return local_publication_; }
112
117 void setPublication(const std::shared_ptr<LocalTrackPublication>& publication) noexcept override {
118 local_publication_ = publication;
119 }
120
121private:
122 explicit LocalAudioTrack(FfiHandle handle, const proto::OwnedTrack& track);
123
126 std::shared_ptr<LocalTrackPublication> local_publication_;
127};
128
129} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
Represents a user-provided audio track sourced from the local device.
Definition local_audio_track.h:58
std::string toString() const
Return a human-readable string representation of the track.
void mute()
Mutes the audio track.
static std::shared_ptr< LocalAudioTrack > createLocalAudioTrack(const std::string &name, const std::shared_ptr< AudioSource > &source)
Creates a new local audio track backed by the given AudioSource.
void unmute()
Unmute the audio track.
std::shared_ptr< LocalTrackPublication > publication() const noexcept
Returns the publication that owns this track, or nullptr if the track is not published.
Definition local_audio_track.h:111
void setPublication(const std::shared_ptr< LocalTrackPublication > &publication) noexcept override
Set the publication that owns this track.
Definition local_audio_track.h:117
static std::shared_ptr< LocalAudioTrack > createLocalAudioTrack(const std::string &name, const std::shared_ptr< PlatformAudioSource > &source)
Creates a new local audio track backed by the given PlatformAudioSource.
Base class for local and remote media tracks.
Definition track.h:77
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25