From 28e64ef4ce8e8acfc5717b42e2fe17e83aee0a80 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 3 Dec 2024 23:51:11 -0800 Subject: [PATCH] Support mute/unmute for local tracks --- livekit-rtc/livekit/rtc/track.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/livekit-rtc/livekit/rtc/track.py b/livekit-rtc/livekit/rtc/track.py index de870481..6231da9e 100644 --- a/livekit-rtc/livekit/rtc/track.py +++ b/livekit-rtc/livekit/rtc/track.py @@ -80,6 +80,18 @@ def create_audio_track(name: str, source: "AudioSource") -> "LocalAudioTrack": resp = FfiClient.instance.request(req) return LocalAudioTrack(resp.create_audio_track.track) + def mute(self): + req = proto_ffi.FfiRequest() + req.local_track_mute.track_handle = self._ffi_handle.handle + req.local_track_mute.mute = True + FfiClient.instance.request(req) + + def unmute(self): + req = proto_ffi.FfiRequest() + req.local_track_mute.track_handle = self._ffi_handle.handle + req.local_track_mute.mute = False + FfiClient.instance.request(req) + def __repr__(self) -> str: return f"rtc.LocalAudioTrack(sid={self.sid}, name={self.name})" @@ -97,6 +109,18 @@ def create_video_track(name: str, source: "VideoSource") -> "LocalVideoTrack": resp = FfiClient.instance.request(req) return LocalVideoTrack(resp.create_video_track.track) + def mute(self): + req = proto_ffi.FfiRequest() + req.local_track_mute.track_handle = self._ffi_handle.handle + req.local_track_mute.mute = True + FfiClient.instance.request(req) + + def unmute(self): + req = proto_ffi.FfiRequest() + req.local_track_mute.track_handle = self._ffi_handle.handle + req.local_track_mute.mute = False + FfiClient.instance.request(req) + def __repr__(self) -> str: return f"rtc.LocalVideoTrack(sid={self.sid}, name={self.name})"