Skip to content

Commit 60e111a

Browse files
authored
Merge pull request #210112 from dbasantes/main
[Private Preview] Unmixed Audio Recording
2 parents 1451c7b + b428999 commit 60e111a

File tree

4 files changed

+495
-0
lines changed

4 files changed

+495
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Azure Communication Services Unmixed Audio Recording API quickstart
3+
titleSuffix: An Azure Communication Services quickstart document
4+
description: Private Preview quickstart for Unmixed Audio Call Recording APIs.
5+
author: dbasantes
6+
services: azure-communication-services
7+
ms.author: bharat
8+
ms.date: 09/07/2022
9+
ms.topic: quickstart
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
zone_pivot_groups: acs-csharp-java
13+
ms.custom: mode-api
14+
---
15+
# Unmixed Audio Call Recording Quickstart
16+
17+
[!INCLUDE [Private Preview](../../includes/private-preview-include-section.md)]
18+
19+
This quickstart gets you started recording voice and video calls. This quickstart assumes you've already used the [Calling client SDK](get-started-with-video-calling.md) to build the end-user calling experience. Using the **Calling Server APIs and SDKs** you can enable and manage recordings.
20+
21+
::: zone pivot="programming-language-csharp"
22+
[!INCLUDE [Test Unmixed Audio Recording with C#](./includes/call-recording-samples/private-preview-unmixed-audio-recording-server-csharp.md)]
23+
::: zone-end
24+
25+
::: zone pivot="programming-language-java"
26+
[!INCLUDE [Test Unmixed Audio Recording with Java](./includes/call-recording-samples/private-preview-unmixed-audio-recording-server-java.md)]
27+
::: zone-end
28+
29+
## Clean up resources
30+
31+
If you want to clean up and remove a Communication Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it. Learn more about [cleaning up resources](../create-communication-resource.md#clean-up-resources).
32+
33+
## Next steps
34+
35+
For more information, see the following articles:
36+
37+
- Learn more about [Call Recording](../../concepts/voice-video-calling/call-recording.md)
38+
- Check out our [calling hero sample](../../samples/calling-hero-sample.md)
39+
- Learn about [Calling SDK capabilities](./getting-started-with-calling.md)
40+
- Learn more about [how calling works](../../concepts/voice-video-calling/about-call-types.md)
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
---
2+
author: dbasantes
3+
ms.service: azure-communication-services
4+
ms.date: 09/07/2022
5+
ms.topic: include
6+
ms.custom: private_preview
7+
ms.author: bharat
8+
---
9+
10+
> [!NOTE]
11+
> Call Recording Unmixed audio is available in US only and may change based on feedback we receive during Private Preview.
12+
13+
14+
## Prerequisites
15+
16+
Before you start testing Unmixed Audio recording, please make sure you complete the following steps:
17+
18+
- Create an Azure account with an active subscription. For details, see [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
19+
- Create an Azure Communication Services resource. For details, see [Create an Azure Communication Services resource](../../../create-communication-resource.md). You'll need to record your resource **connection string** for this quickstart.
20+
- Create an Azure storage account and container, for details, see [Create a storage account](../../../../../storage/common/storage-account-create.md?tabs=azure-portal). You'll need to record your storage **connection string** and **container name** for this quickstart.
21+
- Subscribe to events via an [Azure Event Grid](../../../../../event-grid/overview.md) Web hook.
22+
- Download the [.NET SDK](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Communication.CallingServer/overview/1.0.0-alpha.20220829.1)
23+
- This Quickstart assumes you have some experience using the [Calling CLient SDK](https://docs.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/get-started-with-video-calling?pivots=platform-web). **Important**: To fetch serverCallId from Calling SDK, refer to the JavaScript example in the **Appendix** at the end of this document.
24+
- Make sure to provide the Azure Communication Services Call Recording team with your **immutable azure resource ID** to be whitelisted during the private preview tests.
25+
26+
27+
## 1. Create a Call Automation client
28+
29+
To create a call automation client, you'll use your Communication Services connection string and pass it to `CallAutomationClient` object.
30+
31+
```csharp
32+
CallAutomationClient callAutomationClient = new CallAutomationClient("<ACSConnectionString>");
33+
```
34+
35+
## 2. Start recording session with StartRecordingOptions using 'StartRecordingAsync' server API
36+
37+
Use the server call ID received during initiation of the call.
38+
• RecordingContent is used to pass the recording content type. Use audio
39+
• RecordingChannel is used to pass the recording channel type. Use unmixed.
40+
• RecordingFormat is used to pass the format of the recording. Use wav.
41+
42+
```csharp
43+
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
44+
{
45+
RecordingContent = RecordingContent.Audio,
46+
RecordingChannel = RecordingChannel.Unmixed,
47+
RecordingFormat = RecordingFormat.Wav,
48+
RecordingStateCallbackEndpoint = new Uri("<CallbackUri>");
49+
};
50+
Response<RecordingStateResult> response = await callAutomationClient.getCallRecording()
51+
.StartRecordingAsync(recordingOptions);
52+
```
53+
54+
### 2.1. Specify a user on a channel 0 for unmixed audio recording
55+
56+
```csharp
57+
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
58+
{
59+
RecordingContent = RecordingContent.Audio,
60+
RecordingChannel = RecordingChannel.Unmixed,
61+
RecordingFormat = RecordingFormat.Wav,
62+
RecordingStateCallbackEndpoint = new Uri("<CallbackUri>"),
63+
ChannelAffinity = new List<ChannelAffinity>
64+
{
65+
new ChannelAffinity {
66+
Channel = 0,
67+
Participant = new CommunicationUserIdentifier("<ACS_USER_MRI>")
68+
}
69+
}
70+
};
71+
Response<RecordingStateResult> response = await callAutomationClient.getCallRecording()
72+
.StartRecordingAsync(recordingOptions);
73+
```
74+
The `StartRecordingAsync` API response contains the recording ID of the recording session.
75+
76+
## 3. Stop recording session using 'StopRecordingAsync' server API
77+
78+
Use the recording ID received in response of `startRecordingWithResponse`.
79+
80+
```csharp
81+
var stopRecording = await callAutomationClient.GetCallRecording().StopRecordingAsync(recording.Value.RecordingId);
82+
```
83+
84+
## 4. Pause recording session using 'PauseRecordingAsync' server API
85+
86+
Use the recording ID received in response of `startRecordingWithResponse`.
87+
88+
```csharp
89+
var pauseRecording = await callAutomationClient.GetCallRecording ().PauseRecordingAsync(recording.Value.RecordingId);
90+
```
91+
92+
## 5. Resume recording session using 'ResumeRecordingAsync' server API
93+
94+
Use the recording ID received in response of `startRecordingWithResponse`.
95+
96+
```csharp
97+
var resumeRecording = await callAutomationClient.GetCallRecording().ResumeRecordingAsync(recording.Value.RecordingId);
98+
```
99+
100+
## 6. Download recording File using 'DownloadToAsync' server API
101+
102+
Use an [Azure Event Grid](../../../../../event-grid/overview.md) web hook or other triggered action should be used to notify your services when the recorded media is ready for download.
103+
104+
Below is an example of the event schema.
105+
106+
```
107+
{
108+
"id": string, // Unique guid for event
109+
"topic": string, // Azure Communication Services resource id
110+
"subject": string, // /recording/call/{call-id}
111+
"data": {
112+
"recordingStorageInfo": {
113+
"recordingChunks": [
114+
{
115+
"documentId": string, // Document id for retrieving from AMS storage
116+
"contentLocation": string, //Azure Communication Services URL where the content is located
117+
"metadataLocation": string, // Azure Communication Services URL where the metadata for this chunk is located
118+
"deleteLocation": string, // Azure Communication Services URL to use to delete all content, including recording and metadata.
119+
"index": int, // Index providing ordering for this chunk in the entire recording
120+
"endReason": string, // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
121+
}
122+
]
123+
},
124+
"recordingStartTime": string, // ISO 8601 date time for the start of the recording
125+
"recordingDurationMs": int, // Duration of recording in milliseconds
126+
"sessionEndReason": string // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
127+
},
128+
"eventType": string, // "Microsoft.Communication.RecordingFileStatusUpdated"
129+
"dataVersion": string, // "1.0"
130+
"metadataVersion": string, // "1"
131+
"eventTime": string // ISO 8601 date time for when the event was created
132+
}
133+
```
134+
135+
Use `DownloadStreamingAsync` API for downloading the recorded media.
136+
137+
```csharp
138+
var recordingDownloadUri = new Uri(downloadLocation);
139+
var response = await callAutomationClient.GetCallRecording().DownloadStreamingAsync(recordingDownloadUri);
140+
```
141+
The `downloadLocation` for the recording can be fetched from the `contentLocation` attribute of the `recordingChunk`. `DownloadStreamingAsync` method returns response of type `Response<Stream>`, which contains the downloaded content.
142+
143+
## 7. Delete recording content using 'DeleteRecordingAsync' server API
144+
145+
Use `DeleteRecordingAsync` API for deleting the recording content (e.g. recorded media, metadata)
146+
147+
```csharp
148+
var recordingDeleteUri = new Uri(deleteLocation);
149+
var response = await callAutomationClient.GetCallRecording().DeleteRecordingAsync(recordingDeleteUri);
150+
```
151+
152+
## Appendix
153+
154+
### A - Getting serverCallId as a requirement for call recording server APIs from JavaScript application
155+
156+
Call recording is an extended feature of the core Call API. You first need to import calling Features from the Calling SDK.
157+
158+
```JavaScript
159+
import { Features} from "@azure/communication-calling";
160+
```
161+
Then you can get the recording feature API object from the call instance:
162+
163+
```JavaScript
164+
const callRecordingApi = call.feature(Features.Recording);
165+
```
166+
Subscribe to recording changes:
167+
168+
```JavaScript
169+
const recordingStateChanged = () => {
170+
let recordings = callRecordingApi.recordings;
171+
172+
let state = SDK.RecordingState.None;
173+
if (recordings.length > 0) {
174+
state = recordings.some(r => r.state == SDK.RecordingState.Started)
175+
? SDK.RecordingState.Started
176+
: SDK.RecordingState.Paused;
177+
}
178+
179+
console.log(`RecordingState: ${state}`);
180+
}
181+
182+
const recordingsChangedHandler = (args: { added: SDK.RecordingInfo[], removed: SDK.RecordingInfo[]}) => {
183+
args.added?.forEach(a => {
184+
a.on('recordingStateChanged', recordingStateChanged);
185+
});
186+
187+
args.removed?.forEach(r => {
188+
r.off('recordingStateChanged', recordingStateChanged);
189+
});
190+
191+
recordingStateChanged();
192+
};
193+
194+
callRecordingApi.on('recordingsUpdated', recordingsChangedHandler);
195+
```
196+
Get server call ID which can be used to start/stop/pause/resume recording sessions.
197+
Once the call is connected, use the `getServerCallId` method to get the server call ID.
198+
199+
```JavaScript
200+
callAgent.on('callsUpdated', (e: { added: Call[]; removed: Call[] }): void => {
201+
e.added.forEach((addedCall) => {
202+
addedCall.on('stateChanged', (): void => {
203+
if (addedCall.state === 'Connected') {
204+
addedCall.info.getServerCallId().then(result => {
205+
dispatch(setServerCallId(result));
206+
}).catch(err => {
207+
console.log(err);
208+
});
209+
}
210+
});
211+
});
212+
});
213+
```
214+
215+
### B - How to find the Azure Resource ID
216+
217+
In order to get your Resource ID whitelisted, please send your Immutable Azure Resource ID to the Call Recording Team. For reference see the image below.
218+
219+
![Call recording how to get resource ID](../../media/call-recording/immutable resource id.md)
220+
221+
222+

0 commit comments

Comments
 (0)