Mute sharing and control
Mute refers to disabling the transmission of audio captured by the microphone. You can mute or unmute local audio and share your application's mute status with peers. You can also request a specific peer or all peers to mute or unmute their audio.
Prior to PlanetKit 6.0, muting did not directly affect the operation of microphone. Starting with PlanetKit 6.0, however, the microphone is controlled by muting as follows:
- When you mute the local audio, PlanetKit turns off the microphone and disables audio transmission, making the microphone indicator turned off.
- When you unmute the local audio, PlanetKit turns on the microphone and enables audio transmission, making the microphone indicator turned on.
Control and share local audio mute
This section explains how to mute or unmute local audio by call type.
1-to-1 call
To mute or unmute local audio in 1-to-1 calls, use muteMyAudio(). The changes in the mute status of local audio are sent to peers through peerMicDidMute or peerMicDidUnmute.
The following diagram shows the flow of muting and unmuting local audio in a 1-to-1 call.
Related sample code is as follows.
Muting or unmuting local audio
// mute: true for mute, false for unmute
func muteMyAudioExample(call: PlanetKitCall, mute: Bool) {
call.muteMyAudio(mute) { success in
print("muteMyAudio(mute=\(mute)) result: \(success)")
}
}
Handling related events on the peer side
extension CallDelegateExample : PlanetKitCallDelegate {
...
func peerMicDidMute(_ call: PlanetKitCall) {
// This is called when the peer changed their microphone status to be muted.
// Write your own code here.
}
func peerMicDidUnmute(_ call: PlanetKitCall) {
// This is called when the peer changed their microphone status to be unmuted.
// Write your own code here.
}
}
Group call
To mute or unmute local audio in group calls, use muteMyAudio(). The changes in the mute status of local audio are sent to peers through peersMicDidMute or peersMicDidUnmute.
The following diagram shows the flow of muting and unmuting local audio in a group call.
Related sample code is as follows.
Muting or unmuting local audio
// mute: true for mute, false for unmute
func muteMyAudioExample(conference: PlanetKitConference, mute: Bool) {
conference.muteMyAudio(mute) { success in
print("muteMyAudio(mute=\(mute)) result: \(success)")
}
}
Handling related events on the peer side
extension ConferenceDelegateExample : PlanetKitConferenceDelegate {
...
func peersMicDidMute(_ conference: PlanetKitConference, peers: [PlanetKitConferencePeer]) {
// This is called when one or more peers changed their microphone status to be muted.
// Write your own code here.
}
func peersMicDidUnmute(_ conference: PlanetKitConference, peers: [PlanetKitConferencePeer]) {
// This is called when one or more peers changed their microphone status to be unmuted.
// Write your own code here.
}
}
Request remote audio mute
This section explains how to request muting or unmuting of remote audio by call type.
Whether the peers need to mute or unmute their audio when they get a request is implementation-dependent.
The following examples assume that the peers will mute or unmute their audio according to the request.
1-to-1 call
To request a peer to mute or unmute in 1-to-1 calls, use requestPeerMute(). This request is sent to the peer through myMuteRequestedByPeer, and changes in the mute status of remote audio are sent to the local user through peerMicDidMute or peerMicDidUnmute.
The following diagram shows the flow of requesting to mute and unmute remote audio in a 1-to-1 call.
Related sample code is as follows.
Requesting to mute or unmute remote audio
// mute: true for mute, false for unmute
func requestPeerMuteExample(call: PlanetKitCall, mute: Bool) {
call.requestPeerMute(mute) { success in
print("requestPeerMute(mute=\(mute)) result: \(success)")
}
}
Handling related events on the peer side
extension CallDelegateExample : PlanetKitCallDelegate {
...
func myMuteRequestedByPeer(_ call: PlanetKitCall, mute: Bool) {
// This is called when the peer requests the local user to mute or unmute the microphone.
call.muteMyAudio(mute) { success in
print("muteMyAudio(mute=\(mute)) result: \(success)")
}
}
}
Group call
In group calls, you can request a specific peer or all peers to mute or unmute their audio.
- To request a specific peer to mute or unmute one's own audio, use
requestPeerMute(). - To request all peers to mute or unmute their audio, use
requestPeersMute().
These requests are sent to peers through myMuteRequestedByPeer and the changes in the mute status of remote audio are sent to the local user through peersMicDidMute or peersMicDidUnmute.
The following diagram shows the flow of requesting to mute and unmute remote audio in a group call.
Related sample code is as follows.
Requesting to mute or unmute remote audio
// Request mute for single peer
// mute: true for mute, false for unmute
func requestPeerMuteExample(conference: PlanetKitConference, mute: Bool, peerId: PlanetKitUserId) {
conference.requestPeerMute(mute, peerId: peerId) { success in
print("requestPeerMute(mute=\(mute), peerId=\(peerId)) result: \(success)")
}
}
// Request mute for all peers
// mute: true for mute, false for unmute
func requestPeersMuteExample(conference: PlanetKitConference, mute: Bool) {
conference.requestPeersMute(mute) { success in
print("requestPeersMute(mute=\(mute)) result: \(success)")
}
}
Handling related events on the peer side
extension ConferenceDelegateExample : PlanetKitConferenceDelegate {
...
func myMuteRequestedByPeer(_ conference: PlanetKitConference, peer: PlanetKitConferencePeer, mute: Bool) {
// This is called when a peer requests the local user to mute or unmute the microphone.
conference.muteMyAudio(mute) { success in
print("muteMyAudio(mute=\(mute)) result: \(success)")
}
}
}
Related API
APIs related to mute sharing and control are as follows.
1-to-1 call
Methods
Events
-
peerMicDidMuteofPlanetKitCallDelegate -
peerMicDidUnmuteofPlanetKitCallDelegate -
myMuteRequestedByPeerofPlanetKitCallDelegate
Group call
Methods
-
muteMyAudio()ofPlanetKitConference -
requestPeerMute()ofPlanetKitConference -
requestPeersMute()ofPlanetKitConference