Skip to content

Commit 8647582

Browse files
std::cout/cerr to LK_LOG
fix rebase issue
1 parent 848f7f1 commit 8647582

File tree

7 files changed

+60
-56
lines changed

7 files changed

+60
-56
lines changed

bridge/src/bridge_data_track.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "livekit/local_data_track.h"
2121
#include "livekit/local_participant.h"
2222

23-
#include <iostream>
24-
2523
namespace livekit_bridge {
2624

2725
BridgeDataTrack::BridgeDataTrack(std::string name,
@@ -46,7 +44,7 @@ bool BridgeDataTrack::pushFrame(const std::vector<std::uint8_t> &payload,
4644
try {
4745
return track_->tryPush(frame);
4846
} catch (const std::exception &e) {
49-
std::cerr << "[BridgeDataTrack] tryPush error: " << e.what() << "\n";
47+
LK_LOG_ERROR("[BridgeDataTrack] tryPush error: " << e.what());
5048
return false;
5149
}
5250
}
@@ -65,7 +63,7 @@ bool BridgeDataTrack::pushFrame(const std::uint8_t *data, std::size_t size,
6563
try {
6664
return track_->tryPush(frame);
6765
} catch (const std::exception &e) {
68-
std::cerr << "[BridgeDataTrack] tryPush error: " << e.what() << "\n";
66+
LK_LOG_ERROR("[BridgeDataTrack] tryPush error: " << e.what());
6967
return false;
7068
}
7169
}
@@ -94,8 +92,8 @@ void BridgeDataTrack::release() {
9492
try {
9593
participant_->unpublishDataTrack(track_);
9694
} catch (...) {
97-
std::cerr << "[BridgeDataTrack] unpublishDataTrack error, continuing "
98-
"with cleanup\n";
95+
LK_LOG_ERROR("[BridgeDataTrack] unpublishDataTrack error, continuing "
96+
"with cleanup");
9997
}
10098
}
10199

bridge/src/bridge_room_delegate.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ void BridgeRoomDelegate::onRemoteDataTrackPublished(
5757
livekit::Room & /*room*/,
5858
const livekit::RemoteDataTrackPublishedEvent &ev) {
5959
if (!ev.track) {
60-
std::cerr << "[BridgeRoomDelegate] onRemoteDataTrackPublished called "
61-
"with null track.\n";
60+
LK_LOG_ERROR("[BridgeRoomDelegate] onRemoteDataTrackPublished called "
61+
"with null track.");
6262
return;
6363
}
6464

65-
std::cout << "[BridgeRoomDelegate] onRemoteDataTrackPublished: \""
66-
<< ev.track->info().name << "\" from \""
67-
<< ev.track->publisherIdentity() << "\"\n";
65+
LK_LOG_INFO("[BridgeRoomDelegate] onRemoteDataTrackPublished: \""
66+
<< ev.track->info().name << "\" from \""
67+
<< ev.track->publisherIdentity() << "\"");
6868
bridge_.onRemoteDataTrackPublished(ev.track);
6969
}
7070

bridge/src/livekit_bridge.cpp

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,11 @@ LiveKitBridge::createDataTrack(const std::string &name) {
307307
"LiveKitBridge::createDataTrack: not connected to a room");
308308
}
309309

310-
std::cout << "[LiveKitBridge] Publishing data track \"" << name << "\"...\n";
310+
LK_LOG_INFO("[LiveKitBridge] Publishing data track \"" << name << "\"...");
311311
auto track = room_->localParticipant()->publishDataTrack(name);
312-
std::cout << "[LiveKitBridge] Data track \"" << name << "\" published "
313-
<< "(sid=" << track->info().sid << ").\n";
312+
LK_LOG_INFO("[LiveKitBridge] Data track \"" << name << "\" published "
313+
<< "(sid=" << track->info().sid
314+
<< ").");
314315

315316
auto bridge_track = std::shared_ptr<BridgeDataTrack>(
316317
new BridgeDataTrack(name, std::move(track), room_->localParticipant()));
@@ -357,8 +358,8 @@ void LiveKitBridge::setOnDataFrameCallback(
357358
std::thread old_thread;
358359
{
359360
std::lock_guard<std::mutex> lock(mutex_);
360-
std::cout << "[LiveKitBridge] Registered data callback for (\""
361-
<< participant_identity << "\", \"" << track_name << "\").\n";
361+
LK_LOG_INFO("[LiveKitBridge] Registered data callback for (\""
362+
<< participant_identity << "\", \"" << track_name << "\").");
362363
DataCallbackKey key{participant_identity, track_name};
363364
data_callbacks_[key] = std::move(callback);
364365

@@ -445,9 +446,9 @@ void LiveKitBridge::onTrackSubscribed(
445446
old_thread = startVideoReader(key, track, it->second);
446447
}
447448
} else {
448-
std::cout << "[LiveKitBridge] Track subscribed: \"" << track->name()
449-
<< "\" from \"" << participant_identity
450-
<< "\" (sid=" << track->sid() << ")\n";
449+
LK_LOG_INFO("[LiveKitBridge] Track subscribed: \""
450+
<< track->name() << "\" from \"" << participant_identity
451+
<< "\" (sid=" << track->sid() << ")");
451452
}
452453
}
453454
// If this key already had a reader (e.g. track was re-subscribed), the old
@@ -474,9 +475,10 @@ void LiveKitBridge::onTrackUnsubscribed(const std::string &participant_identity,
474475

475476
void LiveKitBridge::onRemoteDataTrackPublished(
476477
std::shared_ptr<livekit::RemoteDataTrack> track) {
477-
std::cout << "[LiveKitBridge] Remote data track published: \""
478-
<< track->info().name << "\" from \"" << track->publisherIdentity()
479-
<< "\" (sid=" << track->info().sid << ")\n";
478+
LK_LOG_INFO("[LiveKitBridge] Remote data track published: \""
479+
<< track->info().name << "\" from \""
480+
<< track->publisherIdentity() << "\" (sid=" << track->info().sid
481+
<< ")");
480482

481483
std::thread old_thread;
482484
std::string identity;
@@ -491,14 +493,15 @@ void LiveKitBridge::onRemoteDataTrackPublished(
491493

492494
auto it = data_callbacks_.find(key);
493495
if (it != data_callbacks_.end()) {
494-
std::cout << "[LiveKitBridge] Found matching callback for ("
495-
<< key.identity << ", " << key.track_name
496-
<< "), starting data reader.\n";
496+
LK_LOG_INFO("[LiveKitBridge] Found matching callback for ("
497+
<< key.identity << ", " << key.track_name
498+
<< "), starting data reader.");
497499
old_thread = startDataReader(key, track, it->second);
498500
} else {
499-
std::cout << "[LiveKitBridge] No callback registered yet for ("
500-
<< key.identity << ", " << key.track_name
501-
<< "); storing as pending (will start when callback is set).\n";
501+
LK_LOG_INFO(
502+
"[LiveKitBridge] No callback registered yet for ("
503+
<< key.identity << ", " << key.track_name
504+
<< "); storing as pending (will start when callback is set).");
502505
pending_remote_data_tracks_[key] = track;
503506
}
504507
}
@@ -569,9 +572,8 @@ LiveKitBridge::startAudioReader(const CallbackKey &key,
569572

570573
active_av_readers_[key] = std::move(reader);
571574
if (active_av_readers_.size() > kMaxActiveReaders) {
572-
std::cerr << "[LiveKitBridge] More than expected active readers. Need to "
573-
"evaluate how much to expect/support.";
574-
"solution";
575+
LK_LOG_ERROR("[LiveKitBridge] More than expected active readers. Need to "
576+
"evaluate how much to expect/support.");
575577
}
576578
return old_thread;
577579
}
@@ -611,8 +613,8 @@ LiveKitBridge::startVideoReader(const CallbackKey &key,
611613

612614
active_av_readers_[key] = std::move(reader);
613615
if (active_av_readers_.size() > kMaxActiveReaders) {
614-
std::cerr << "[LiveKitBridge] More than expected active readers. Need to "
615-
"evaluate how much to expect/support.";
616+
LK_LOG_ERROR("[LiveKitBridge] More than expected active readers. Need to "
617+
"evaluate how much to expect/support.");
616618
}
617619
return old_thread;
618620
}
@@ -623,21 +625,21 @@ std::thread LiveKitBridge::startDataReader(
623625
DataFrameCallback cb) {
624626
auto old_thread = extractDataReaderThread(key);
625627

626-
std::cout << "[LiveKitBridge] Subscribing to data track \"" << key.track_name
627-
<< "\" from \"" << key.identity << "\"...\n";
628+
LK_LOG_INFO("[LiveKitBridge] Subscribing to data track \""
629+
<< key.track_name << "\" from \"" << key.identity << "\"...");
628630

629631
std::shared_ptr<livekit::DataTrackSubscription> subscription;
630632
try {
631633
subscription = track->subscribe();
632634
} catch (const std::exception &e) {
633-
std::cerr << "[LiveKitBridge] Failed to subscribe to data track \""
634-
<< key.track_name << "\" from \"" << key.identity
635-
<< "\": " << e.what() << "\n";
635+
LK_LOG_ERROR("[LiveKitBridge] Failed to subscribe to data track \""
636+
<< key.track_name << "\" from \"" << key.identity
637+
<< "\": " << e.what());
636638
return old_thread;
637639
}
638640

639-
std::cout << "[LiveKitBridge] Subscribed to data track \"" << key.track_name
640-
<< "\"; starting reader thread.\n";
641+
LK_LOG_INFO("[LiveKitBridge] Subscribed to data track \""
642+
<< key.track_name << "\"; starting reader thread.");
641643

642644
auto sub_copy = subscription;
643645
auto track_name = key.track_name;
@@ -647,19 +649,19 @@ std::thread LiveKitBridge::startDataReader(
647649
reader.remote_track = track;
648650
reader.subscription = std::move(subscription);
649651
reader.thread = std::thread([sub_copy, cb, track_name, identity]() {
650-
std::cout << "[LiveKitBridge] Data reader thread running for \""
651-
<< track_name << "\" from \"" << identity << "\".\n";
652+
LK_LOG_INFO("[LiveKitBridge] Data reader thread running for \""
653+
<< track_name << "\" from \"" << identity << "\".");
652654
livekit::DataFrame frame;
653655
while (sub_copy->read(frame)) {
654656
try {
655657
cb(frame.payload, frame.user_timestamp);
656658
} catch (const std::exception &e) {
657-
std::cerr << "[LiveKitBridge] Data callback exception: " << e.what()
658-
<< "\n";
659+
LK_LOG_ERROR("[LiveKitBridge] Data callback exception: " << e.what()
660+
<< ");
659661
}
660662
}
661-
std::cout << "[LiveKitBridge] Data reader thread exiting for \""
662-
<< track_name << "\" from \"" << identity << "\".\n";
663+
LK_LOG_INFO("[LiveKitBridge] Data reader thread exiting for \""
664+
<< track_name << "\" from \"" << identity << "\".");
663665
});
664666

665667
active_data_readers_[key] = std::move(reader);

examples/bridge_human_robot/human.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
#include <atomic>
5858
#include <chrono>
59-
#include <cstdint>
6059
#include <csignal>
60+
#include <cstdint>
6161
#include <cstdlib>
6262
#include <cstring>
6363
#include <iostream>

include/livekit/room_delegate.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,8 @@ class RoomDelegate {
297297
* Data tracks are independent of the audio/video track hierarchy and
298298
* require an explicit subscribe() call to start receiving frames.
299299
*/
300-
virtual void onRemoteDataTrackPublished(Room &,
301-
const RemoteDataTrackPublishedEvent &) {
302-
}
300+
virtual void
301+
onRemoteDataTrackPublished(Room &, const RemoteDataTrackPublishedEvent &) {}
303302

304303
// ------------------------------------------------------------------
305304
// Participants snapshot

src/ffi_client.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ FfiClient::connectAsync(const std::string &url, const std::string &token,
324324
auto *opts = connect->mutable_options();
325325
opts->set_auto_subscribe(options.auto_subscribe);
326326
opts->set_dynacast(options.dynacast);
327+
opts->set_single_peer_connection(options.single_peer_connection);
328+
LK_LOG_INFO("[FfiClient] connectAsync: auto_subscribe={}, dynacast={}, "
329+
"single_peer_connection={}",
330+
options.auto_subscribe, options.dynacast,
331+
options.single_peer_connection);
327332

328333
// --- E2EE / encryption (optional) ---
329334
if (options.encryption.has_value()) {

src/room.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,17 +604,17 @@ void Room::OnEvent(const FfiEvent &event) {
604604
const auto &rdtp = re.remote_data_track_published();
605605
auto remote_track =
606606
std::shared_ptr<RemoteDataTrack>(new RemoteDataTrack(rdtp.track()));
607-
std::cout << "[Room] RoomEvent::kRemoteDataTrackPublished: \""
608-
<< remote_track->info().name << "\" from \""
609-
<< remote_track->publisherIdentity()
610-
<< "\" (sid=" << remote_track->info().sid << ")\n";
607+
LK_LOG_INFO("[Room] RoomEvent::kRemoteDataTrackPublished: \""
608+
<< remote_track->info().name << "\" from \""
609+
<< remote_track->publisherIdentity()
610+
<< "\" (sid=" << remote_track->info().sid << ")");
611611
RemoteDataTrackPublishedEvent ev;
612612
ev.track = remote_track;
613613
if (delegate_snapshot) {
614614
delegate_snapshot->onRemoteDataTrackPublished(*this, ev);
615615
} else {
616-
std::cerr << "[Room] No delegate set; RemoteDataTrackPublished "
617-
"event dropped.\n";
616+
LK_LOG_ERROR("[Room] No delegate set; RemoteDataTrackPublished "
617+
"event dropped.");
618618
}
619619
break;
620620
}

0 commit comments

Comments
 (0)