Skip to content

Commit f293c30

Browse files
authored
Merge pull request #289358 from fuyan2024/fuyan/hard_mute_pr_fork
Media access feature quick start - web sdk
2 parents 86b158a + c9bef8b commit f293c30

File tree

4 files changed

+281
-2
lines changed

4 files changed

+281
-2
lines changed

articles/communication-services/how-tos/calling-sdk/includes/capabilities/capabilities-web.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,21 @@ capabilitiesFeature.on('capabilitiesChanged', (capabilitiesChangeInfo) => {
5959
(value.isPresent) ? this.setState({ canReact: true }) : this.setState({ canReact: false });
6060
continue;
6161
}
62+
if(key === 'forbidOthersAudio' && value.reason != 'FeatureNotSupported') {
63+
(value.isPresent) ? this.setState({ canForbidOthersAudio: true }) : this.setState({ canForbidOthersAudio: false });
64+
continue;
65+
}
66+
if(key === 'forbidOthersVideo' && value.reason != 'FeatureNotSupported') {
67+
(value.isPresent) ? this.setState({ canForbidOthersVideo: true }) : this.setState({ canForbidOthersVideo: false });
68+
continue;
69+
}
6270
}
6371
});
6472
```
6573

6674
**Capabilities Exposed**
67-
- *turnVideoOn*: Ability to turn video on
68-
- *unmuteMic*: Ability to turn mic on
75+
- *turnVideoOn*: Ability to turn on video
76+
- *unmuteMic*: Ability to send audio
6977
- *shareScreen*: Ability to share screen
7078
- *removeParticipant*: Ability to remove a participant
7179
- *hangUpForEveryOne*: Ability to hang up for everyone
@@ -81,3 +89,5 @@ capabilitiesFeature.on('capabilitiesChanged', (capabilitiesChangeInfo) => {
8189
- *muteOthers*: Ability to soft mute remote participant(s) in the meeting
8290
- *reaction*: Ability to react in the meeting (beta only)
8391
- *viewAttendeeNames*: Ability to view attendee names in the meeting
92+
- *forbidOthersAudio*: Ability to forbid attendees' audio in the meeting or group call
93+
- *forbidOthersVideo*: Ability to forbid attendees' video in the meeting or group call
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
author: fuyan
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 10/24/2024
6+
ms.author: fuyan
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-web.md)]
9+
10+
## Implement media access
11+
12+
`MediaAccess` is a `feature` of the class `Call`. You first need to import package `Features` from the Calling SDK:
13+
14+
```js
15+
import { Features} from "@azure/communication-calling";
16+
```
17+
18+
Then you can get the instance of `MediaAccess` API from the `call` instance:
19+
20+
```js
21+
const mediaAccessFeature = call.feature(Features.MediaAccess);
22+
```
23+
24+
### Control access to send audio or video of individual attendees
25+
26+
Use the `permitAudio()` method to enable selected attendees to unmute. Use the `permitVideo()` method to enable selected attendees to turn on video. These actions don't automatically unmute or turn on video. They only enable attendees to perform these actions.
27+
28+
Use the `forbidAudio()` method to enable organizers to mute selected attendees and deny them the ability to unmute. Use the `forbidVideo()` method to enable organizers to turn off video for selected attendees and deny them the ability to turn on video.
29+
30+
```js
31+
// Define list of attendees
32+
const acsUser = new CommunicationUserIdentifier('<USER_ID>');
33+
const teamsUser = new MicrosoftTeamsUserIdentifier('<USER_ID>');
34+
const participants = [acsUser, teamsUser];
35+
36+
// Allow selected attendees to unmute
37+
mediaAccessFeature.permitAudio(participants);
38+
39+
// Deny selected attendees to unmute
40+
mediaAccessFeature.forbidAudio(participants);
41+
42+
// Allow selected attendees to turn on video
43+
mediaAccessFeature.permitVideo(participants);
44+
45+
// Deny selected attendees to turn on video
46+
mediaAccessFeature.forbidVideo(participants);
47+
```
48+
49+
### List media access state for all remote participants
50+
51+
Use the `getAllOthersMediaAccess` API to get information about all remote participant media access states for current call.
52+
An example of how to use the `getAllOthersMediaAccess` API:
53+
```js
54+
let remoteParticipantsMediaAccess = mediaAccessHandFeature.getAllOthersMediaAccess()
55+
56+
remoteParticipantsMediaAccess.forEach((mediaAccess) => {
57+
console.log(`Identifier: ${mediaAccess.participant } can unmute: ${mediaAccess.isAudioPermitted } and can turn on video: ${mediaAccess.isVideoPermitted }`);
58+
})
59+
```
60+
61+
### Get notification that media access changed
62+
63+
Subscribe to the `mediaAccessChanged` events from `MediaAccess` API to receive array of `MediaAccess` instances. Use the array to see the media access state for all remote participants if they're currently enabled or denied the ability to send audio or video. By default, all participants other than the attendee role can send audio and video. The `mediaAccessChanged` events are triggered when a participant with an appropriate role changes media access for selected attendees or all attendees.
64+
65+
```js
66+
const mediaAccessChangedHandler = (event) => {
67+
console.log(`Attendees that changed media access states:`);
68+
event.mediaAccesses.forEach( (mediaAccess) => {
69+
console.log(`Identifier: ${mediaAccess.participant } can unmute: ${mediaAccess.isAudioPermitted } and can turn on video: ${mediaAccess.isVideoPermitted }`);
70+
}
71+
}
72+
mediaAccessFeature.on('mediaAccessChanged', mediaAccessChangedHandler )
73+
```
74+
75+
### Stop receiving media access events
76+
Use the following code to stop receiving media access events.
77+
```js
78+
mediaAccessFeature.off('mediaAccessChanged', mediaAccessChangedHandler)
79+
```
80+
81+
### Media Access properties
82+
Class `MediaAccess` has the following properties:
83+
84+
| Properties | Description |
85+
|--|--|
86+
| participant | Identifier of the participant whose media access changed. |
87+
| isAudioPermitted | Boolean value indicating whether ability to send audio is allowed for this participant. |
88+
| isVideoPermitted | Boolean value indicating whether ability to send video is allowed for this participant. |
89+
90+
### Control access to send audio or video for all attendees
91+
Microsoft Teams meetings support APIs that enable organizers, co-organizers, and presenters to change the meeting options **Allow mic for attendees** or **Allow camera for attendees**. You can use those APIs to change the value of the meeting options, which enable organizers to enable or denying all attendees sending audio or video.
92+
93+
You can use the `permitOthersAudio()` method to set meeting option **Allow mic for attendees** to `true` and enable all attendees to unmute. You can also use the `permitOthersVideo()` method to set meeting option **Allow camera for attendees** to `true` and enable all attendees to turn on video. These actions don't automatically unmute or turn on video. They only enable attendees to perform these actions.
94+
95+
Use the `forbidOthersAudio()` method to set meeting option **Allow mic for attendees** to `false`, which organizers can use to mute all attendees and deny them the ability to unmute. You can also use the `forbidOthersVideo()` method to set meeting option **Allow mic for attendees** to `false`, which organizers can use to turn of video for all attendees and deny them the ability to turn on video.
96+
97+
Participants with appropriate roles can override methods `permitOthersAudio` ,`permitOthersVideo`, `forbidOthersAudio` ,`forbidOthersVideo` with methods `forbidAudio` and `forbidVideo` or `permitAudio` and `permitVideo`. Change of media access for all attendees triggers `mediaAccessChanged` event for all participants that are impacted.
98+
99+
```js
100+
// Allow all attendees to unmute
101+
mediaAccessFeature.permitOthersAudio();
102+
103+
// Deny all attendees to unmute
104+
mediaAccessFeature.forbidOthersAudio();
105+
106+
// Allow all attendees to turn on video
107+
mediaAccessFeature.permitOthersVideo();
108+
109+
// Deny all attendees to turn on video
110+
mediaAccessFeature.forbidOthersVideo();
111+
```
112+
113+
### Get Teams meeting media access setting
114+
You can use the `getMeetingMediaAccess` API to get values of `Allow mic for attendees` or `Allow camera for attendees` Teams meeting options. The fact that meeting options are set to `true` or `false` don't guarantee that all attendees have permitted or forbid audio or video, because those calls can be overridden with methods `forbidAudio`, `forbidVideo`, `permitAudio` and `permitVideo`.
115+
Here's an example of how to use the `getMeetingMediaAccess` API:
116+
```js
117+
let meetingMediaAccess = mediaAccessHandFeature.getMeetingMediaAccess()
118+
console.log(`Teams meeting settings - Allow mic for attendees: ${meetingMediaAccess.isAudioPermitted}, Allow camera for attendees: ${meetingMediaAccess.isVideoPermitted}`);
119+
```
120+
121+
### Get notification that meeting media access changed
122+
You can subscribe to the `meetingMediaAccessChanged` events from `MediaAccess` API to receive a `MeetingMediaAccess` instance when Teams meeting options `Allow mic for attendees` or `Allow camera for attendees` are changed.
123+
```js
124+
const meetingMediaAccessChangedHandler = (event) => {
125+
console.log(`Teams meeting settings - Allow mic for attendees: ${event.meetingMediaAccess.isAudioPermitted}, Allow camera for attendees: ${event.meetingMediaAccess.isVideoPermitted}`);
126+
}
127+
mediaAccessFeature.on('meetingMediaAccessChanged', meetingMediaAccessChangedHandler )
128+
```
129+
130+
### Stop receiving meeting media access events
131+
Use the following code to stop receiving meeting media access events.
132+
```js
133+
mediaAccessFeature.off('meetingMediaAccessChanged', meetingMediaAccessChangedHandler)
134+
```
135+
136+
### Meeting media access properties
137+
Class `MeetingMediaAccess` has the following properties:
138+
139+
| Properties | Description |
140+
|--|--|
141+
| isAudioPermitted | Boolean value of Teams meeting option `Allow mic for attendees`. |
142+
| isVideoPermitted | Boolean value of Teams meeting option `Allow camera for attendees`. |
143+
144+
### Troubleshooting
145+
146+
|Error code| Subcode | Result Category | Reason | Resolution |
147+
|----------------------------------------------|--------|--------|---------|----------|
148+
|500 | 46500 | UnexpectedServerError | Internal error while updating the audio or video access. | Gather browser console logs and contact Azure Communication Services support. |
149+
|500 | 46501 | UnexpectedClientError | Couldn't initialize media access feature. | Gather browser console logs and contact Azure Communication Services support. |
150+
|403 | 46502 | ExpectedError | Change media access failed. User doesn't have an organizer, coorganizer, or presenter role. | Ensure that the user has one of mentioned roles and try again. If the issue persists, gather browser console logs and contact Azure Communication Services support. |
151+
|403| 46503 | UnexpectedServerError |Change media access failed. Change media access can only be done in meeting or group call scenarios. | Ensure that the feature is initialized only for Teams meeting or group call scenarios. You can check `Capability` feature to learn about the availability of the feature. If the issue persists, gather browser console logs and contact Azure Communication Services support. |
152+
|403 | 46504| ExpectedError | Change media access failed. Only able to change media access for attendees. | Ensure that the method is called only for participants with role attendees. You can check the property `role` of class `remoteParticipant` to understand the role of the participant.|
153+
|412 | 46505| ExpectedError | Failed to change media access. | Use media access APIs only when your instance of `Call` has property `state` set to `connected`. |
154+
|412| 46506 | UnexpectedClientError | Media access change failed as meeting capabilities are empty. | Gather browser console logs and contact Azure Communication Services support. |
155+
|412| 46507 | ExpectedError | Azure Communication Services currently disabled this feature. | Try the APIs in a couple of days. |
156+
157+
## SDK compatibility
158+
159+
The following table shows the minimum version of SDKs that support individual APIs.
160+
161+
| Operations | Web | Web UI | iOS | iOS UI | Android | Android UI | Windows |
162+
|-------------|-----|--------|-----|--------|---------|------------|---------|
163+
|Permit audio |1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
164+
|Forbid audio |1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
165+
|Permit others audio|1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
166+
|Forbid others audio|1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
167+
|Permit video |1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
168+
|Forbid video |1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
169+
|Permit others video|1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
170+
|Forbid others video|1.31.2,<br>1.32.1-beta.1|❌|❌|❌|❌|❌|❌|
171+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Control participant access to media
3+
titleSuffix: An Azure Communication Services how-to guide
4+
description: Use Azure Communication Services SDKs to control access to media for individual participants.
5+
author: fuyan
6+
ms.author: fuyan
7+
ms.service: azure-communication-services
8+
ms.subservice: calling
9+
ms.topic: how-to
10+
ms.date: 10/24/2024
11+
ms.custom: template-how-to
12+
zone_pivot_groups: acs-plat-web-ios-android-windows
13+
14+
#Customer intent: As a developer, I want to learn how to send and receive Media access state using SDK.
15+
---
16+
17+
# Control participant access to media
18+
::: zone pivot="platform-android"
19+
[!INCLUDE [Public Preview Disclaimer](../../includes/public-preview-include-document.md)]
20+
::: zone-end
21+
22+
::: zone pivot="platform-ios"
23+
[!INCLUDE [Public Preview Disclaimer](../../includes/public-preview-include-document.md)]
24+
::: zone-end
25+
26+
::: zone pivot="platform-windows"
27+
[!INCLUDE [Public Preview Disclaimer](../../includes/public-preview-include-document.md)]
28+
::: zone-end
29+
30+
This article describes how you can enable organizers, co-organizers, or presenters to prevent attendees from unmuting themselves or turning on their video during Microsoft Teams meetings or group calls. Implement this feature to enable selected roles to control the ability of other attendees to send audio and video. You can't control media access for other roles. This article also describes how to determine if your audio or video is enabled or disabled. This includes providing attendees with the ability to check the media access status of other participants.
31+
32+
## Prerequisites
33+
34+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
35+
- A deployed Communication Services resource. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md).
36+
- A user access token to enable the calling client. For more information, see [Create and manage access tokens](../../quickstarts/identity/access-tokens.md).
37+
- Optional: Complete the article [Add voice calling to your app](../../quickstarts/voice-video-calling/getting-started-with-calling.md).
38+
39+
## Support
40+
41+
The following tables define support for media access in Azure Communication Services.
42+
43+
### Identities and call types
44+
45+
The following table shows media access support for specific call types and identities.
46+
47+
|Identities | Teams meeting | Room | 1:1 call | Group call | 1:1 Teams interop call | Group Teams interop call |
48+
|-----------------------------|---------------|------|----------|------------|------------------------|--------------------------|
49+
|Communication Services user | ✔️ | | | | | ✔️ |
50+
|Microsoft 365 user | ✔️ | | | | | ✔️ |
51+
52+
### Operations
53+
54+
The following table shows support for individual APIs in the Calling SDK related to individual identity types. The media access feature only supports these operations in Teams meetings.
55+
56+
|Operations | Communication Services user | Microsoft 365 user | Equivalent Teams UI action|
57+
|-----------------------------|---------------|--------------------------|--------------------------|
58+
| Permit audio | ✔️ [1] | ✔️ [1] | Enable mic |
59+
| Forbid audio | ✔️ [1] | ✔️ [1] | Disable mic |
60+
| Permit video | ✔️ [1] | ✔️ [1] | Enable camera |
61+
| Forbid video | ✔️ [1] | ✔️ [1] | Disable camera |
62+
| Permit audio of all attendees | ✔️[1] [2] | ✔️[1] [2] | Meeting option: Enable mic for all attendees |
63+
| Forbid audio of all attendees | ✔️[1] [2] | ✔️ [1] [2] | Meeting option: Disable mic for all attendees |
64+
| Permit video of all attendees | ✔️[1] [2] | ✔️[1] [2] | Meeting option: Enable camera for all attendees |
65+
| Forbid video of all attendees | ✔️[1] [2] | ✔️[1] [2] | Meeting option: Disable camera for all attendees |
66+
| Get media access of other participants | ✔️ |✔️ ||
67+
| Get media access of Teams meeting | ✔️[2] |✔️[2] ||
68+
| Get notification that media access changed | ✔️ |✔️ ||
69+
| Get notification that Teams meeting's media access changed | ✔️[2] | ✔️[2] ||
70+
71+
[1] Only user with role organizer, co-organizer, or presenter.
72+
73+
[2] This operation is only supported in Microsoft Teams meetings.
74+
75+
### SDKs
76+
77+
The following tables show support for the media access feature in individual Azure Communication Services SDKs.
78+
79+
| Support status | Web | Web UI | iOS | iOS UI | Android | Android UI | Windows |
80+
|----------------|-----|--------|--------|--------|----------|--------|---------|
81+
| Is Supported | ✔️ | | | | | | |
82+
83+
::: zone pivot="platform-web"
84+
[!INCLUDE [Media Access Client-side JavaScript](./includes/media-access/media-access-web.md)]
85+
::: zone-end
86+
87+
88+
## Next steps
89+
- [Learn how to manage calls](./manage-calls.md)
90+
- [Learn how to manage video](./manage-video.md)
91+
- [Learn how to record calls](./record-calls.md)
92+
- [Learn how to transcribe calls](./call-transcription.md)
93+
94+
## Related articles
95+
96+
For more information about using the media access feature, see [Manage attendee audio and video permissions in Microsoft Teams meetings](https://support.microsoft.com/en-us/office/manage-attendee-audio-and-video-permissions-in-microsoft-teams-meetings-f9db15e1-f46f-46da-95c6-34f9f39e671a).

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ items:
509509
href: how-tos/calling-sdk/breakoutrooms.md
510510
- name: Together Mode
511511
href: how-tos/calling-sdk/together-mode.md
512+
- name: Media Access Control
513+
href: how-tos/calling-sdk/media-access.md
512514
- name: Configuring to proxy traffic
513515
items:
514516
- name: Proxy your calling traffic

0 commit comments

Comments
 (0)