Skip to content

Bridge: RPCManager#67

Open
stephen-derosa wants to merge 4 commits intolivekit:mainfrom
stephen-derosa:sderosa/bridge-rpc
Open

Bridge: RPCManager#67
stephen-derosa wants to merge 4 commits intolivekit:mainfrom
stephen-derosa:sderosa/bridge-rpc

Conversation

@stephen-derosa
Copy link
Contributor

@stephen-derosa stephen-derosa commented Feb 27, 2026

Overview

RPC Manager for handling built in RPC calls and user registered RPC calls.

Built in RPC calls

  • mute/unmute tracks on remote participants

Examples

examples/bridge_mute_unmute/
examples/bridge_rpc/

Testing

  • RPC application level integration tests
  • RPCManager unit tests
  • testing through examples

@stephen-derosa stephen-derosa self-assigned this Feb 27, 2026
@stephen-derosa stephen-derosa added the enhancement New feature or request label Feb 27, 2026
const std::string &method, const std::string &payload,
std::optional<double> response_timeout = std::nullopt);
std::string
performRpc(const std::string &destination_identity, const std::string &method,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you run clang format ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, not sure how the original unformatted got in to begin with. Maybe before linting was in the pipeline?

auto *opts = connect->mutable_options();
opts->set_auto_subscribe(options.auto_subscribe);
opts->set_dynacast(options.dynacast);
opts->set_single_peer_connection(options.single_peer_connection);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may I ask why we stop calling this set_single_peer_connection() ?

Copy link
Contributor Author

@stephen-derosa stephen-derosa Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored -- this was from a local branch that removed this due to SFUs not supporting single peer connection by default

/// @param destination_identity Identity of the remote participant.
/// @param track_name Name of the track to mute.
/// @throws if the LocalParticipant requestTrackMute fails.
void requestTrackMute(const std::string &destination_identity,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this TrackMute / TrackUnmute APIs belong to rpc_manager ? rather than the tracks ?

Copy link
Contributor Author

@stephen-derosa stephen-derosa Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to mute other tracks. Unclear naming, so i updated the function name to requestRemoteTrackMute/Unmute ? This was a feature asked for by Polymath.

const std::string &method, const std::string &payload,
const std::optional<double> &response_timeout) {
assert(lp_ != nullptr);
return lp_->performRpc(destination_identity, method, payload,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need such RpcManager ? it seems a wrapper to call local_participant APIs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great question. The motivation behind the RPCManager was to be a single object that holds all RPC "work". I also think that people will be asking for "out of the box" RPC calls. For example Polymath asked for the ability to mute remote tracks. This RPC manager is a clean single place to add these "built in" RPC calls.

/// Callback the bridge provides to execute a track action
/// (mute/unmute/release). Throws livekit::RpcError if the track is not found
/// or the action is invalid.
using TrackActionFn = std::function<void(const std::string &action,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it takes std::string as action ? rather than enum (assuming it only suuport mute / unmute/release) ?

btw, not sure why we need this TrackActionFn either, it is a callback ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice great point ill make it an enum (can always add more enums in the future) :)

and yeah its just a type for the callback function to make the callback setting a bit cleaner to read

RPCManager: bridge object for managing default and custom RPC calls

bridge_rpc examples

RPCManager tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants