Skip to content

Commit 9be3a1c

Browse files
[Native] Pivot platform samples
1 parent a5914fa commit 9be3a1c

File tree

5 files changed

+451
-374
lines changed

5 files changed

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

0 commit comments

Comments
 (0)