Skip to content

Commit 638e8ac

Browse files
authored
Merge pull request #233639 from lucianopa-msft/lucianopa/ufd-samples
[Native] [AzureCommunicationCalling] UFD samples fro native
2 parents 98e5a0c + 1b14440 commit 638e8ac

File tree

5 files changed

+482
-109
lines changed

5 files changed

+482
-109
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: Azure Communication Services User Facing Diagnostics (Android)
3+
titleSuffix: An Azure Communication Services concept document
4+
description: Provides usage samples of the User Facing Diagnostics feature Android Native.
5+
author: lucianopa-msft
6+
ms.author: lucianopa
7+
8+
services: azure-communication-services
9+
ms.date: 04/06/2023
10+
ms.topic: include
11+
ms.service: azure-communication-services
12+
ms.subservice: calling
13+
---
14+
15+
## Accessing diagnostics
16+
17+
User-facing diagnostics is an extended feature of the core `Call` API and allows you to diagnose an active call.
18+
19+
```java
20+
DiagnosticsCallFeature diagnosticsCallFeature = call.feature(Features.DIAGNOSTICS_CALL);
21+
```
22+
23+
## User Facing Diagnostic events
24+
25+
- Get feature object and add listeners to the diagnostics events.
26+
27+
```java
28+
DiagnosticsCallFeature diagnosticsCallFeature = call.feature(Features.DIAGNOSTICS_CALL);
29+
30+
/* NetworkDiagnostic */
31+
FlagDiagnosticChangedListener listener = (FlagDiagnosticChangedEvent args) -> {
32+
Boolean mediaValue = args.getValue();
33+
// Handle new value for no network diagnostic.
34+
};
35+
36+
NetworkDiagnostics networkDiagnostics = diagnosticsCallFeature.getNetworkDiagnostics();
37+
networkDiagnostics.addOnNoNetworkChangedListener(listener);
38+
39+
// To remove listener for network quality event
40+
networkDiagnostics.removeOnNoNetworkChangedListener(listener);
41+
42+
// Quality Diagnostics
43+
DiagnosticsCallFeature diagnosticsCallFeature = call.feature(Features.DIAGNOSTICS_CALL);
44+
QualityDiagnosticChangedListener listener = (QualityDiagnosticChangedEvent args) -> {
45+
DiagnosticQuality diagnosticQuality = args.getValue();
46+
// Handle new value for network reconnect diagnostic.
47+
};
48+
49+
NetworkDiagnostics networkDiagnostics = diagnosticsCallFeature.getNetworkDiagnostics();
50+
networkDiagnostics.addOnNetworkReconnectChangedListener(listener);
51+
52+
// To remove listener for media flag event
53+
networkDiagnostics.removeOnNetworkReconnectChangedListener(listener);
54+
55+
/* MediaDiagnostic */
56+
DiagnosticsCallFeature diagnosticsCallFeature = call.feature(Features.DIAGNOSTICS_CALL);
57+
FlagDiagnosticChangedListener listener = (FlagDiagnosticChangedEvent args) -> {
58+
Boolean mediaValue = args.getValue();
59+
// Handle new value for speaker not functioning diagnostic.
60+
};
61+
62+
MediaDiagnostics mediaDiagnostics = diagnosticsCallFeature.getMedia();
63+
mediaDiagnostics.addOnSpeakerNotFunctioningChangedListener(listener);
64+
65+
// To remove listener for media flag event
66+
mediaDiagnostics.removeOnSpeakerNotFunctioningChangedListener(listener);
67+
68+
```
69+
70+
## Get the latest User Facing Diagnostics
71+
72+
- Get the latest diagnostic values that were raised in current call. If we still didn't receive a value for the diagnostic, an exception is thrown.
73+
74+
```java
75+
DiagnosticsCallFeature diagnosticsCallFeature = call.feature(Features.DIAGNOSTICS_CALL);
76+
NetworkDiagnostics networkDiagnostics = diagnosticsCallFeature.getNetwork();
77+
MediaDiagnostics mediaDiagnostics = diagnosticsCallFeature.getMedia();
78+
79+
NetworkDiagnosticValues latestNetwork = networkDiagnostics.getLatest();
80+
Boolean lastNetworkValue = latestNetwork.isNoNetwork(); // null if there isn't a value for this diagnostic.
81+
DiagnosticQuality lastReceiveQualityValue = latestNetwork.getNetworkReceiveQuality(); // UNKNOWN if there isn't a value for this diagnostic.
82+
83+
MediaDiagnosticValues latestMedia = networkDiagnostics.getLatest();
84+
Boolean lastSpeakerNotFunctionValue = latestMedia.isSpeakerNotFunctioning(); // null if there isn't a value for this diagnostic.
85+
86+
// Use the last values ...
87+
88+
```
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: Azure Communication Services User Facing Diagnostics (iOS)
3+
titleSuffix: An Azure Communication Services concept document
4+
description: Provides usage samples of the User Facing Diagnostics feature iOS Native.
5+
author: lucianopa-msft
6+
ms.author: lucianopa
7+
8+
services: azure-communication-services
9+
ms.date: 04/06/2023
10+
ms.topic: include
11+
ms.service: azure-communication-services
12+
ms.subservice: calling
13+
---
14+
15+
## Accessing diagnostics
16+
17+
User-facing diagnostics is an extended feature of the core `Call` API and allows you to diagnose an active call.
18+
19+
```swift
20+
let userFacingDiagnostics = self.call?.feature(Features.diagnostics)
21+
```
22+
23+
## User Facing Diagnostic events
24+
25+
- Implement the delegates for `media` and `network` diagnostic sources. `MediaDiagnosticsDelegate` and `NetworkDiagnosticsDelegate` respectively.
26+
27+
```swift
28+
extension CallObserver: MediaDiagnosticsDelegate {
29+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
30+
didChangeCameraFreezeValue args: FlagDiagnosticChangedEventArgs) {
31+
let newValue = args.value
32+
// Handle the diagnostic event value changed...
33+
}
34+
35+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
36+
didChangeSpeakerMutedValue args: FlagDiagnosticChangedEventArgs) {
37+
let newValue = args.value
38+
// Handle the diagnostic event value changed...
39+
}
40+
41+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
42+
didChangeCameraStartFailedValue args: FlagDiagnosticChangedEventArgs) {
43+
let newValue = args.value
44+
// Handle the diagnostic event value changed...
45+
}
46+
47+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
48+
didChangeSpeakerNotFunctioningValue args: FlagDiagnosticChangedEventArgs) {
49+
let newValue = args.value
50+
// Handle the diagnostic event value changed...
51+
}
52+
53+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
54+
didChangeCameraPermissionDeniedValue args: FlagDiagnosticChangedEventArgs) {
55+
let newValue = args.value
56+
// Handle the diagnostic event value changed...
57+
}
58+
59+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
60+
didChangeMicrophoneNotFunctioningValue args: FlagDiagnosticChangedEventArgs) {
61+
let newValue = args.value
62+
// Handle the diagnostic event value changed...
63+
}
64+
65+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
66+
didChangeMicrophoneMuteUnexpectedlyValue args: FlagDiagnosticChangedEventArgs) {
67+
let newValue = args.value
68+
// Handle the diagnostic event value changed...
69+
}
70+
71+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
72+
didChangeCameraStartTimedOutValue args: FlagDiagnosticChangedEventArgs) {
73+
let newValue = args.value
74+
// Handle the diagnostic event value changed...
75+
}
76+
77+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
78+
didChangeSpeakerVolumeIsZeroValue args: FlagDiagnosticChangedEventArgs) {
79+
let newValue = args.value
80+
// Handle the diagnostic event value changed...
81+
}
82+
83+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
84+
didChangeNoSpeakerDevicesEnumeratedValue args: FlagDiagnosticChangedEventArgs) {
85+
let newValue = args.value
86+
// Handle the diagnostic event value changed...
87+
}
88+
89+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
90+
didChangeNoMicrophoneDevicesEnumeratedValue args: FlagDiagnosticChangedEventArgs) {
91+
let newValue = args.value
92+
// Handle the diagnostic event value changed...
93+
}
94+
95+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
96+
didChangeSpeakingWhileMicrophoneIsMutedValue args: FlagDiagnosticChangedEventArgs) {
97+
let newValue = args.value
98+
// Handle the diagnostic event value changed...
99+
}
100+
101+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
102+
didChangeSpeakerNotFunctioningDeviceInUseValue args: FlagDiagnosticChangedEventArgs) {
103+
let newValue = args.value
104+
// Handle the diagnostic event value changed...
105+
}
106+
107+
func mediaDiagnostics(_ mediaDiagnostics: MediaDiagnostics,
108+
didChangeMicrophoneNotFunctioningDeviceInUseValue args: FlagDiagnosticChangedEventArgs) {
109+
let newValue = args.value
110+
// Handle the diagnostic event value changed...
111+
}
112+
}
113+
114+
extension CallObserver: NetworkDiagnosticsDelegate {
115+
func networkDiagnostics(_ networkDiagnostics: NetworkDiagnostics,
116+
didChangeNoNetworkValue args: FlagDiagnosticChangedEventArgs) {
117+
let newValue = args.value
118+
// Handle the diagnostic event value changed...
119+
}
120+
121+
func networkDiagnostics(_ networkDiagnostics: NetworkDiagnostics,
122+
didChangeNetworkReconnectValue args: QualityDiagnosticChangedEventArgs) {
123+
let newValue = args.value
124+
// Handle the diagnostic event value changed...
125+
}
126+
127+
func networkDiagnostics(_ networkDiagnostics: NetworkDiagnostics,
128+
didChangeNetworkSendQualityValue args: QualityDiagnosticChangedEventArgs) {
129+
let newValue = args.value
130+
// Handle the diagnostic event value changed...
131+
}
132+
133+
func networkDiagnostics(_ networkDiagnostics: NetworkDiagnostics,
134+
didChangeNetworkReceiveQualityValue args: QualityDiagnosticChangedEventArgs) {
135+
let newValue = args.value
136+
// Handle the diagnostic event value changed...
137+
}
138+
139+
func networkDiagnostics(_ networkDiagnostics: NetworkDiagnostics,
140+
didChangeNetworkRelaysNotReachableValue args: FlagDiagnosticChangedEventArgs) {
141+
let newValue = args.value
142+
// Handle the diagnostic event value changed...
143+
}
144+
}
145+
```
146+
147+
- Hold a reference to `media` and `network` diagnostics and set delegate object for listening to events.
148+
149+
```swift
150+
self.mediaDiagnostics = userFacingDiagnostics?.media
151+
self.networkDiagnostics = userFacingDiagnostics?.network
152+
self.mediaDiagnostics?.delegate = self.callObserver
153+
self.networkDiagnostics?.delegate = self.callObserver
154+
```
155+
156+
## Get the latest User Facing Diagnostics
157+
158+
- Get the latest diagnostic values that were raised. If we still didn't receive a value for the diagnostic, `nil` or `.unknown` is returned.
159+
160+
```swift
161+
let lastSpeakerNotFunctionValue = self.mediaDiagnostics.latest.speakerNotFunctioning // Boolean?
162+
let lastNetworkRelayNotReachableValue = self.networkDiagnostics.latest.networkRelaysNotReachable // Boolean?
163+
let lastReceiveQualityValue = self.networkDiagnostics.latest.networkReceiveQuality // DiagnosticQuality (.good, .poor, .bad)
164+
// or .unknown if there isn't a diagnostic for this.
165+
```
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Azure Communication Services User Facing Diagnostics (Web)
3+
titleSuffix: An Azure Communication Services concept document
4+
description: Provides usage samples of the User Facing Diagnostics feature for Web.
5+
author: lucianopa-msft
6+
ms.author: lucianopa
7+
8+
services: azure-communication-services
9+
ms.date: 04/06/2023
10+
ms.topic: include
11+
ms.service: azure-communication-services
12+
ms.subservice: calling
13+
---
14+
15+
## Accessing diagnostics
16+
17+
User-facing diagnostics is an extended feature of the core `Call` API and allows you to diagnose an active call.
18+
19+
```js
20+
const userFacingDiagnostics = call.feature(Features.UserFacingDiagnostics);
21+
```
22+
23+
## User Facing Diagnostic events
24+
25+
- Subscribe to the `diagnosticChanged` event to monitor when any user-facing diagnostic changes.
26+
27+
```js
28+
/**
29+
* Each diagnostic has the following data:
30+
* - diagnostic is the type of diagnostic, e.g. NetworkSendQuality, DeviceSpeakWhileMuted, etc...
31+
* - value is DiagnosticQuality or DiagnosticFlag:
32+
* - DiagnosticQuality = enum { Good = 1, Poor = 2, Bad = 3 }.
33+
* - DiagnosticFlag = true | false.
34+
* - valueType = 'DiagnosticQuality' | 'DiagnosticFlag'
35+
*/
36+
const diagnosticChangedListener = (diagnosticInfo: NetworkDiagnosticChangedEventArgs | MediaDiagnosticChangedEventArgs) => {
37+
console.log(`Diagnostic changed: ` +
38+
`Diagnostic: ${diagnosticInfo.diagnostic}` +
39+
`Value: ${diagnosticInfo.value}` +
40+
`Value type: ${diagnosticInfo.valueType}`);
41+
42+
if (diagnosticInfo.valueType === 'DiagnosticQuality') {
43+
if (diagnosticInfo.value === DiagnosticQuality.Bad) {
44+
console.error(`${diagnosticInfo.diagnostic} is bad quality`);
45+
46+
} else if (diagnosticInfo.value === DiagnosticQuality.Poor) {
47+
console.error(`${diagnosticInfo.diagnostic} is poor quality`);
48+
}
49+
50+
} else if (diagnosticInfo.valueType === 'DiagnosticFlag') {
51+
if (diagnosticInfo.value === true) {
52+
console.error(`${diagnosticInfo.diagnostic}`);
53+
}
54+
}
55+
};
56+
57+
userFacingDiagnostics.network.on('diagnosticChanged', diagnosticChangedListener);
58+
userFacingDiagnostics.media.on('diagnosticChanged', diagnosticChangedListener);
59+
```
60+
61+
## Get the latest User Facing Diagnostics
62+
63+
- Get the latest diagnostic values that were raised. If a diagnostic is undefined, that is because it was never raised.
64+
65+
```js
66+
const latestNetworkDiagnostics = userFacingDiagnostics.network.getLatest();
67+
68+
console.log(
69+
`noNetwork: ${latestNetworkDiagnostics.noNetwork.value}, ` +
70+
`value type = ${latestNetworkDiagnostics.noNetwork.valueType}`
71+
);
72+
73+
console.log(
74+
`networkReconnect: ${latestNetworkDiagnostics.networkReconnect.value}, ` +
75+
`value type = ${latestNetworkDiagnostics.networkReconnect.valueType}`
76+
);
77+
78+
console.log(
79+
`networkReceiveQuality: ${latestNetworkDiagnostics.networkReceiveQuality.value}, ` +
80+
`value type = ${latestNetworkDiagnostics.networkReceiveQuality.valueType}`
81+
);
82+
83+
const latestMediaDiagnostics = userFacingDiagnostics.media.getLatest();
84+
85+
console.log(
86+
`speakingWhileMicrophoneIsMuted: ${latestMediaDiagnostics.speakingWhileMicrophoneIsMuted.value}, ` +
87+
`value type = ${latestMediaDiagnostics.speakingWhileMicrophoneIsMuted.valueType}`
88+
);
89+
90+
console.log(
91+
`cameraStartFailed: ${latestMediaDiagnostics.cameraStartFailed.value}, ` +
92+
`value type = ${latestMediaDiagnostics.cameraStartFailed.valueType}`
93+
);
94+
95+
console.log(
96+
`microphoneNotFunctioning: ${latestMediaDiagnostics.microphoneNotFunctioning.value}, ` +
97+
`value type = ${latestMediaDiagnostics.microphoneNotFunctioning.valueType}`
98+
);
99+
```

0 commit comments

Comments
 (0)