Skip to content

Commit e701750

Browse files
LIVEKIT_LOCAL_SDK_DIR
1 parent a74ca36 commit e701750

3 files changed

Lines changed: 34 additions & 22 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
88

99
set(LIVEKIT_SDK_VERSION "latest" CACHE STRING "LiveKit C++ SDK version (e.g. 0.2.0 or latest)")
10+
set(LIVEKIT_LOCAL_SDK_DIR "" CACHE PATH "Path to a local LiveKit SDK install prefix (skips download)")
1011

11-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
12-
include(LiveKitSDK)
13-
14-
livekit_sdk_setup(
15-
VERSION "${LIVEKIT_SDK_VERSION}"
16-
SDK_DIR "${CMAKE_BINARY_DIR}/_deps/livekit-sdk"
17-
GITHUB_TOKEN "$ENV{GITHUB_TOKEN}"
18-
)
19-
12+
if(LIVEKIT_LOCAL_SDK_DIR)
13+
message(STATUS "Using local LiveKit SDK: ${LIVEKIT_LOCAL_SDK_DIR}")
14+
list(PREPEND CMAKE_PREFIX_PATH "${LIVEKIT_LOCAL_SDK_DIR}")
15+
else()
16+
include(LiveKitSDK)
17+
livekit_sdk_setup(
18+
VERSION "${LIVEKIT_SDK_VERSION}"
19+
SDK_DIR "${CMAKE_BINARY_DIR}/_deps/livekit-sdk"
20+
GITHUB_TOKEN "$ENV{GITHUB_TOKEN}"
21+
)
22+
endif()
2023
find_package(LiveKit CONFIG REQUIRED)
2124
add_subdirectory(basic_room)
25+
add_subdirectory(all-cpp-examples)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ rm -rf build
3535
cmake -S . -B build -DLIVEKIT_SDK_VERSION=0.3.1
3636
```
3737

38+
Build against a local SDK:
39+
```bash
40+
rm -rf build
41+
# install the SDK into $HOME/livekit-sdk-install (or any other directory)
42+
cmake --install <sdk-build-dir> --prefix $HOME/livekit-sdk-install
43+
44+
# build the examples against the local SDK
45+
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=$HOME/livekit-sdk-install
46+
```
47+
3848

3949
### Building the examples
4050
#### macOS / Linux

basic_room/main.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ void printUsage(const char *prog) {
4141
<< " LIVEKIT_URL, LIVEKIT_TOKEN\n";
4242
}
4343

44-
bool parseArgs(int argc, char *argv[], std::string &url, std::string &token, bool &self_test) {
44+
bool parseArgs(int argc, char *argv[], std::string &url, std::string &token,
45+
bool &self_test) {
4546
for (int i = 1; i < argc; ++i) {
4647
const std::string a = argv[i];
4748
if (a == "-h" || a == "--help")
@@ -85,14 +86,9 @@ bool parseArgs(int argc, char *argv[], std::string &url, std::string &token, boo
8586
}
8687

8788
void print_livekit_version() {
88-
std::cout
89-
<< "LiveKit version: "
90-
<< LIVEKIT_BUILD_VERSION_FULL
91-
<< " (" << LIVEKIT_BUILD_FLAVOR
92-
<< ", commit " << LIVEKIT_BUILD_COMMIT
93-
<< ", built " << LIVEKIT_BUILD_DATE
94-
<< ")"
95-
<< std::endl;
89+
std::cout << "LiveKit version: " << LIVEKIT_BUILD_VERSION_FULL << " ("
90+
<< LIVEKIT_BUILD_FLAVOR << ", commit " << LIVEKIT_BUILD_COMMIT
91+
<< ", built " << LIVEKIT_BUILD_DATE << ")" << std::endl;
9692
}
9793

9894
} // namespace
@@ -106,7 +102,7 @@ int main(int argc, char *argv[]) {
106102
return 1;
107103
}
108104
if (self_test) {
109-
livekit::initialize(livekit::LogSink::kConsole);
105+
livekit::initialize(livekit::LogLevel::Info, livekit::LogSink::kConsole);
110106
livekit::shutdown();
111107
std::cout << "self-test ok" << std::endl;
112108
return 0;
@@ -115,7 +111,7 @@ int main(int argc, char *argv[]) {
115111
std::signal(SIGINT, handleSignal);
116112

117113
// Init LiveKit
118-
livekit::initialize(livekit::LogSink::kConsole);
114+
livekit::initialize(livekit::LogLevel::Info, livekit::LogSink::kConsole);
119115

120116
auto room = std::make_unique<Room>();
121117

@@ -145,7 +141,8 @@ int main(int argc, char *argv[]) {
145141

146142
std::shared_ptr<LocalTrackPublication> audioPub;
147143
try {
148-
audioPub = room->localParticipant()->publishTrack(audioTrack, audioOpts);
144+
room->localParticipant()->publishTrack(audioTrack, audioOpts);
145+
audioPub = audioTrack->publication();
149146
std::cout << "Published audio: sid=" << audioPub->sid() << "\n";
150147
} catch (const std::exception &e) {
151148
std::cerr << "Failed to publish audio: " << e.what() << "\n";
@@ -163,7 +160,8 @@ int main(int argc, char *argv[]) {
163160

164161
std::shared_ptr<LocalTrackPublication> videoPub;
165162
try {
166-
videoPub = room->localParticipant()->publishTrack(videoTrack, videoOpts);
163+
room->localParticipant()->publishTrack(videoTrack, videoOpts);
164+
videoPub = videoTrack->publication();
167165
std::cout << "Published video: sid=" << videoPub->sid() << "\n";
168166
} catch (const std::exception &e) {
169167
std::cerr << "Failed to publish video: " << e.what() << "\n";

0 commit comments

Comments
 (0)