From ae0b52859b3e2fb1ea67de61c71f7e08e2bbc384 Mon Sep 17 00:00:00 2001 From: hiroshihorie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:39:12 +0900 Subject: [PATCH] add/remove audio renderer for local tracks --- Sources/LiveKit/Track/AudioTrack.swift | 8 +++++++- Sources/LiveKit/Track/Local/LocalAudioTrack.swift | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/LiveKit/Track/AudioTrack.swift b/Sources/LiveKit/Track/AudioTrack.swift index 41417f4cf..003bb09e2 100644 --- a/Sources/LiveKit/Track/AudioTrack.swift +++ b/Sources/LiveKit/Track/AudioTrack.swift @@ -17,4 +17,10 @@ import Foundation @objc -public protocol AudioTrack where Self: Track {} +public protocol AudioTrack where Self: Track { + @objc(addAudioRenderer:) + func add(audioRenderer: AudioRenderer) + + @objc(removeAudioRenderer:) + func remove(audioRenderer: AudioRenderer) +} diff --git a/Sources/LiveKit/Track/Local/LocalAudioTrack.swift b/Sources/LiveKit/Track/Local/LocalAudioTrack.swift index 2255a4501..1f466e806 100644 --- a/Sources/LiveKit/Track/Local/LocalAudioTrack.swift +++ b/Sources/LiveKit/Track/Local/LocalAudioTrack.swift @@ -94,3 +94,13 @@ public extension LocalAudioTrack { var publishOptions: TrackPublishOptions? { super._state.lastPublishOptions } var publishState: Track.PublishState { super._state.publishState } } + +public extension LocalAudioTrack { + func add(audioRenderer: AudioRenderer) { + AudioManager.shared.add(localAudioRenderer: audioRenderer) + } + + func remove(audioRenderer: AudioRenderer) { + AudioManager.shared.remove(localAudioRenderer: audioRenderer) + } +}