Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nanpa/track-muted-event-for-local-publications.kdl
Copy link
Contributor

@ladvoc ladvoc Dec 1, 2025

Choose a reason for hiding this comment

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

This repository no longer uses the nanpa release manager, so this file should be removed before merging.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="fixed" package="livekit" "Emit TrackMuted/TrackUnmuted events for local publications"
9 changes: 8 additions & 1 deletion livekit/src/room/participant/local_participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ impl LocalParticipant {
}

pub(crate) fn update_info(&self, info: proto::ParticipantInfo) {
super::update_info(&self.inner, &Participant::Local(self.clone()), info);
super::update_info(&self.inner, &Participant::Local(self.clone()), info.clone());

for track in info.tracks {
let track_sid = track.sid.clone().try_into().unwrap();
if let Some(publication) = self.get_track_publication(&track_sid) {
publication.update_info(track.clone());
}
}
}

pub(crate) fn set_speaking(&self, speaking: bool) {
Expand Down
1 change: 1 addition & 0 deletions livekit/src/room/participant/remote_participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl RemoteParticipant {
name: remote_publication.name(),
r#type: proto::TrackType::from(remote_publication.kind()) as i32,
source: proto::TrackSource::from(remote_publication.source()) as i32,
muted: remote_publication.is_muted(),
..Default::default()
});

Expand Down
20 changes: 17 additions & 3 deletions livekit/src/room/publication/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,23 @@ impl LocalTrackPublication {
self.inner.info.read().proto_info.clone()
}

#[allow(dead_code)]
pub(crate) fn update_info(&self, info: proto::TrackInfo) {
super::update_info(&self.inner, &TrackPublication::Local(self.clone()), info);
pub(crate) fn update_info(&self, new_info: proto::TrackInfo) {
super::update_info(&self.inner, &TrackPublication::Local(self.clone()), new_info.clone());

let mut info = self.inner.info.write();
if info.muted != new_info.muted {
info.muted = new_info.muted;

drop(info);

if new_info.muted {
if let Some(on_mute) = self.inner.events.muted.lock().as_ref() {
on_mute(TrackPublication::Local(self.clone()));
}
} else if let Some(on_unmute) = self.inner.events.unmuted.lock().as_ref() {
on_unmute(TrackPublication::Local(self.clone()));
}
}
}

pub(crate) fn update_publish_options(&self, opts: TrackPublishOptions) {
Expand Down