-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add cluster metadata publish and subscribe options: peer and track info #260
Conversation
WalkthroughWalkthroughThe recent updates focus on enhancing room and peer interaction functionalities within the media core system. Key changes include the introduction of new enums and parameters like Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Files skipped from review as they are similar to previous changes (1)
Additional Context UsedGitHub Check Runs (2)
Additional comments not posted (9)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
if self.peers_map_subscribers.remove(&owner).is_some() { | ||
if self.peers_map_subscribers.is_empty() { | ||
log::info!("[ClusterRoom {}] last peer unsub peers map => unsubscribe", self.room); | ||
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.peers_map, MapControl::Unsub))); | ||
} | ||
} |
Check warning
Code scanning / clippy
this if statement can be collapsed Warning
if self.tracks_map_subscribers.remove(&owner).is_some() { | ||
if self.tracks_map_subscribers.is_empty() { | ||
log::info!("[ClusterRoom {}] last peer unsub tracks map => unsubscribe", self.room); | ||
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.tracks_map, MapControl::Unsub))); | ||
} | ||
} |
Check warning
Code scanning / clippy
this if statement can be collapsed Warning
@@ -215,7 +235,7 @@ | |||
None | |||
} | |||
|
|||
fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId) -> Option<InternalOutput> { | |||
fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> { |
Check warning
Code scanning / clippy
this lifetime isn't used in the function definition Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Out of diff range and nitpick comments (3)
packages/transport_webrtc/src/transport/whip.rs (1)
98-99
: Consider implementing logic for handlingPeerJoined
andPeerLeaved
events or document why they are intentionally ignored.packages/transport_webrtc/src/transport/whep.rs (1)
104-105
: Consider implementing logic for handlingPeerJoined
andPeerLeaved
events or document why they are intentionally ignored.packages/media_core/src/cluster/room/metadata.rs (1)
26-31
: Define thePeerContainer
struct more clearly.Consider adding documentation comments to the
PeerContainer
struct to explain the purpose and usage of each field. This will improve code readability and maintainability.
if self.peers_map_subscribers.remove(&owner).is_some() { | ||
if self.peers_map_subscribers.is_empty() { | ||
log::info!("[ClusterRoom {}] last peer unsub peers map => unsubscribe", self.room); | ||
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.peers_map, MapControl::Unsub))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify the if
statement.
- if self.peers_map_subscribers.remove(&owner).is_some() {
- if self.peers_map_subscribers.is_empty() {
+ if self.peers_map_subscribers.remove(&owner).is_some() && self.peers_map_subscribers.is_empty() {
This change collapses nested if
statements into a single statement, improving readability.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if self.peers_map_subscribers.remove(&owner).is_some() { | |
if self.peers_map_subscribers.is_empty() { | |
log::info!("[ClusterRoom {}] last peer unsub peers map => unsubscribe", self.room); | |
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.peers_map, MapControl::Unsub))); | |
} | |
} | |
if self.peers_map_subscribers.remove(&owner).is_some() && self.peers_map_subscribers.is_empty() { | |
log::info!("[ClusterRoom {}] last peer unsub peers map => unsubscribe", self.room); | |
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.peers_map, MapControl::Unsub))); | |
} |
if self.tracks_map_subscribers.remove(&owner).is_some() { | ||
if self.tracks_map_subscribers.is_empty() { | ||
log::info!("[ClusterRoom {}] last peer unsub tracks map => unsubscribe", self.room); | ||
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.tracks_map, MapControl::Unsub))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify the if
statement.
- if self.tracks_map_subscribers.remove(&owner).is_some() {
- if self.tracks_map_subscribers.is_empty() {
+ if self.tracks_map_subscribers.remove(&owner).is_some() && self.tracks_map_subscribers.is_empty() {
This change collapses nested if
statements into a single statement, improving readability.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if self.tracks_map_subscribers.remove(&owner).is_some() { | |
if self.tracks_map_subscribers.is_empty() { | |
log::info!("[ClusterRoom {}] last peer unsub tracks map => unsubscribe", self.room); | |
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.tracks_map, MapControl::Unsub))); | |
} | |
} | |
if self.tracks_map_subscribers.remove(&owner).is_some() && self.tracks_map_subscribers.is_empty() { | |
log::info!("[ClusterRoom {}] last peer unsub tracks map => unsubscribe", self.room); | |
self.queue.push_back(Output::Kv(dht_kv::Control::MapCmd(self.tracks_map, MapControl::Unsub))); | |
} |
self.queue | ||
.push_back(Output::Endpoint(vec![owner.clone()], ClusterEndpointEvent::TrackStarted(peer.clone(), name.clone(), meta.clone()))); | ||
.push_back(Output::Endpoint(vec![owner.clone()], ClusterEndpointEvent::PeerJoined(info.peer.clone(), info.meta.clone()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid unnecessary cloning.
- .push_back(Output::Endpoint(vec![owner.clone()], ClusterEndpointEvent::PeerJoined(info.peer.clone(), info.meta.clone())));
+ .push_back(Output::Endpoint(vec![owner], ClusterEndpointEvent::PeerJoined(info.peer.clone(), info.meta.clone())));
Since Owner
implements the Copy
trait, there's no need to use clone()
here. This change avoids unnecessary cloning and improves performance.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
.push_back(Output::Endpoint(vec![owner.clone()], ClusterEndpointEvent::PeerJoined(info.peer.clone(), info.meta.clone()))); | |
.push_back(Output::Endpoint(vec![owner], ClusterEndpointEvent::PeerJoined(info.peer.clone(), info.meta.clone()))); |
for (_track_key, info) in self.cluster_tracks.iter() { | ||
//TODO avoiding duplicate same peer | ||
self.queue.push_back(Output::Endpoint( | ||
vec![owner.clone()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid unnecessary cloning.
- vec![owner.clone()],
+ vec![owner],
Since Owner
implements the Copy
trait, there's no need to use clone()
here. This change avoids unnecessary cloning and improves performance.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
vec![owner.clone()], | |
vec![owner], |
@@ -215,7 +235,7 @@ | |||
None | |||
} | |||
|
|||
fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId) -> Option<InternalOutput> { | |||
fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the unused lifetime warning in the join_room
function definition.
- fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> {
+ fn join_room(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
fn join_room<'a>(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> { | |
fn join_room(&mut self, now: Instant, room: RoomId, peer: PeerId, meta: PeerMeta, publish: RoomInfoPublish, subscribe: RoomInfoSubscribe) -> Option<InternalOutput> { |
…ack info (8xFF#260) * feat: add cluster metadata publish and subscribe options: peer and track info * fixed: wrong sending media mid in whep * test: cluster metadata tests
Pull Request
Description
This PR implement cluster metadata feature
Related Issue
If this pull request is related to any issue, please mention it here.
Checklist
Screenshots
If applicable, add screenshots to help explain the changes made.
Additional Notes
Add any additional notes or context about the pull request here.
Summary by CodeRabbit
New Features
Refactor