2020#include " livekit_bridge/livekit_bridge.h"
2121#include " bridge_room_delegate.h"
2222#include " livekit_bridge/rpc_constants.h"
23- #include " rpc_manager .h"
23+ #include " rpc_controller .h"
2424
2525#include " livekit/audio_frame.h"
2626#include " livekit/audio_source.h"
@@ -64,7 +64,7 @@ LiveKitBridge::CallbackKeyHash::operator()(const CallbackKey &k) const {
6464
6565LiveKitBridge::LiveKitBridge ()
6666 : connected_(false ), connecting_(false ), sdk_initialized_(false ),
67- rpc_manager_ (std::make_unique<RpcManager >(
67+ rpc_controller_ (std::make_unique<RpcController >(
6868 [this ](const rpc::track_control::Action &action,
6969 const std::string &track_name) {
7070 executeTrackAction (action, track_name);
@@ -133,15 +133,15 @@ bool LiveKitBridge::connect(const std::string &url, const std::string &token,
133133 assert (lp != nullptr );
134134 }
135135
136- rpc_manager_ ->enable (lp);
136+ rpc_controller_ ->enable (lp);
137137 return true ;
138138}
139139
140140void LiveKitBridge::disconnect () {
141- // Disable the RPC manager before tearing down the room. This unregisters
141+ // Disable the RPC controller before tearing down the room. This unregisters
142142 // built-in handlers while the LocalParticipant is still alive.
143- if (rpc_manager_ ->isEnabled ()) {
144- rpc_manager_ ->disable ();
143+ if (rpc_controller_ && rpc_controller_ ->isEnabled ()) {
144+ rpc_controller_ ->disable ();
145145 }
146146
147147 // Collect threads to join outside the lock to avoid deadlock.
@@ -228,7 +228,10 @@ LiveKitBridge::createAudioTrack(const std::string &name, int sample_rate,
228228 int num_channels, livekit::TrackSource source) {
229229 std::lock_guard<std::mutex> lock (mutex_);
230230
231- assert (connected_ && room_);
231+ if (!connected_ || !room_) {
232+ throw std::runtime_error (
233+ " createAudioTrack requires an active connection; call connect() first" );
234+ }
232235
233236 // 1. Create audio source (real-time mode, queue_size_ms=0)
234237 auto audio_source =
@@ -260,7 +263,10 @@ LiveKitBridge::createVideoTrack(const std::string &name, int width, int height,
260263 livekit::TrackSource source) {
261264 std::lock_guard<std::mutex> lock (mutex_);
262265
263- assert (connected_ && room_);
266+ if (!connected_ || !room_) {
267+ throw std::runtime_error (
268+ " createVideoTrack requires an active connection; call connect() first" );
269+ }
264270
265271 // 1. Create video source
266272 auto video_source = std::make_shared<livekit::VideoSource>(width, height);
@@ -348,7 +354,7 @@ void LiveKitBridge::clearOnVideoFrameCallback(
348354}
349355
350356// ---------------------------------------------------------------
351- // RPC (delegates to RpcManager )
357+ // RPC (delegates to RpcController )
352358// ---------------------------------------------------------------
353359
354360std::optional<std::string>
@@ -361,8 +367,8 @@ LiveKitBridge::performRpc(const std::string &destination_identity,
361367 }
362368
363369 try {
364- return rpc_manager_ ->performRpc (destination_identity, method, payload,
365- response_timeout);
370+ return rpc_controller_ ->performRpc (destination_identity, method, payload,
371+ response_timeout);
366372 } catch (const std::exception &e) {
367373 std::cerr << " [LiveKitBridge] Exception: " << e.what () << " \n " ;
368374 return std::nullopt ;
@@ -383,7 +389,7 @@ bool LiveKitBridge::registerRpcMethod(
383389 return false ;
384390 }
385391 try {
386- rpc_manager_ ->registerRpcMethod (method_name, std::move (handler));
392+ rpc_controller_ ->registerRpcMethod (method_name, std::move (handler));
387393 return true ;
388394 } catch (const std::exception &e) {
389395 std::cerr << " [LiveKitBridge] Exception: " << e.what () << " \n " ;
@@ -402,7 +408,7 @@ bool LiveKitBridge::unregisterRpcMethod(const std::string &method_name) {
402408 return false ;
403409 }
404410 try {
405- rpc_manager_ ->unregisterRpcMethod (method_name);
411+ rpc_controller_ ->unregisterRpcMethod (method_name);
406412 return true ;
407413 } catch (const std::exception &e) {
408414 std::cerr << " [LiveKitBridge] Exception: " << e.what () << " \n " ;
@@ -422,7 +428,7 @@ bool LiveKitBridge::requestRemoteTrackMute(
422428 return false ;
423429 }
424430 try {
425- rpc_manager_ ->requestRemoteTrackMute (destination_identity, track_name);
431+ rpc_controller_ ->requestRemoteTrackMute (destination_identity, track_name);
426432 return true ;
427433 } catch (const std::exception &e) {
428434 std::cerr << " [LiveKitBridge] Exception: " << e.what () << " \n " ;
@@ -442,7 +448,7 @@ bool LiveKitBridge::requestRemoteTrackUnmute(
442448 return false ;
443449 }
444450 try {
445- rpc_manager_ ->requestRemoteTrackUnmute (destination_identity, track_name);
451+ rpc_controller_ ->requestRemoteTrackUnmute (destination_identity, track_name);
446452 return true ;
447453 } catch (const std::exception &e) {
448454 std::cerr << " [LiveKitBridge] Exception: " << e.what () << " \n " ;
@@ -457,7 +463,7 @@ bool LiveKitBridge::requestRemoteTrackUnmute(
457463}
458464
459465// ---------------------------------------------------------------
460- // Track action callback for RpcManager
466+ // Track action callback for RpcController
461467// ---------------------------------------------------------------
462468
463469void LiveKitBridge::executeTrackAction (const rpc::track_control::Action &action,
0 commit comments