Azure communication service - Audio control

Payal Tiwari 0 Reputation points
2024-11-06T06:02:50.19+00:00

Hi, I have a use case where I want to block incoming and outgoing audio for Specific remote Participant

How can this be achieved through the ACS Javascript SDK and iOS SDK ?

For blocking incoming audio, I have tried to mute remote participant , but it will mute for all , I dont want this , I want that audio mute for only specific participant not for all
I m following this join room call Example
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/rooms/join-rooms-call?pivots=platform-ios

functionality for this i need :

I have 2 participant with 1 host
host can hear both participants audio but both participant can not able to hear each other they can audible to only host

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
941 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 16,926 Reputation points Microsoft Employee
    2024-12-19T07:02:37.87+00:00

    @Payal Tiwari I want to be clear that there is not an officially supported method to block certain users incoming or outgoing audio.

    There might be a few workarounds but keep in mind, I have put these together more so in theory and they may not work for your setup or future updates could break it.

    Mute Specific Remote Participant for Others:

    While ACS does not natively support muting a participant's audio for specific others directly, you can handle this on the receiving end.

    const callAgent = await callClient.createCallAgent(tokenCredential);
    const call = await callAgent.join({ groupId: '<group-id>' }, { videoOptions: { localVideoStreams: [] } });
    
    call.on('remoteParticipantsUpdated', (e) => {
        e.added.forEach(remoteParticipant => {
            remoteParticipant.on('videoStreamsUpdated', (streamEvent) => {
                streamEvent.added.forEach(remoteVideoStream => {
                    const renderer = new VideoStreamRenderer(remoteVideoStream);
                    const view = await renderer.createView();
                    document.getElementById('remoteVideoContainer').appendChild(view.target);
                });
            });
    
            // Listen to audio streams
            remoteParticipant.on('stateChanged', () => {
                if (remoteParticipant.state === 'Connected') {
                    remoteParticipant.audioStreams.forEach(remoteAudioStream => {
                        // Disable the audio stream for other participants, keeping it active only for the host
                        if (remoteParticipant.identifier !== hostIdentifier) {
                            remoteAudioStream.stop();
                        }
                    });
                }
            });
        });
    });
    
    
    

    For iOS, you’ll have to manage the audio streams similarly by controlling which streams are played back on each participant’s device. Here’s a conceptual approach:

    1. Configure Audio for Participants: When a participant connects, you can decide which remote audio streams to subscribe to. If a participant should not hear another participant, you do not subscribe to their audio stream.
    2. Host Audio Management: The host subscribes to all audio streams to hear everyone, while each participant only subscribes to the host's audio stream.
         call.remoteParticipants.forEach { remoteParticipant in
             remoteParticipant.delegate = self
         }
         // Delegate method to handle remote participant's audio stream state
         func remoteParticipant(_ remoteParticipant: RemoteParticipant, didUpdate audioStreams: [RemoteAudioStream]) {
             for audioStream in audioStreams {
                 if remoteParticipant.identifier != hostIdentifier {
                     // Stop or do not subscribe to the audio stream
                     audioStream.stop()
                 }
             }
         }
         
         
      
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.