Skip to content

Commit 26db63b

Browse files
authored
Add channelAffinity for call recording (Azure#34766)
* Add channelAffinity for call recording * remove json property annotation at channelaffinity
1 parent 1b3d57f commit 26db63b

File tree

7 files changed

+238
-10
lines changed

7 files changed

+238
-10
lines changed

sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallRecordingAsync.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.azure.communication.callautomation.implementation.models.BlobStorageInternal;
1010
import com.azure.communication.callautomation.implementation.models.CallLocatorInternal;
1111
import com.azure.communication.callautomation.implementation.models.CallLocatorKindInternal;
12+
import com.azure.communication.callautomation.implementation.models.ChannelAffinityInternal;
1213
import com.azure.communication.callautomation.implementation.models.CommunicationIdentifierModel;
1314
import com.azure.communication.callautomation.implementation.models.ExternalStorageInternal;
1415
import com.azure.communication.callautomation.implementation.models.RecordingContentInternal;
@@ -19,6 +20,7 @@
1920
import com.azure.communication.callautomation.models.BlobStorage;
2021
import com.azure.communication.callautomation.models.CallLocator;
2122
import com.azure.communication.callautomation.models.CallLocatorKind;
23+
import com.azure.communication.callautomation.models.ChannelAffinity;
2224
import com.azure.communication.callautomation.models.DownloadToFileOptions;
2325
import com.azure.communication.callautomation.models.GroupCallLocator;
2426
import com.azure.communication.callautomation.models.ParallelDownloadOptions;
@@ -162,6 +164,12 @@ private StartCallRecordingRequestInternal getStartCallRecordingRequest(StartReco
162164
.collect(Collectors.toList());
163165
request.setAudioChannelParticipantOrdering(audioChannelParticipantOrdering);
164166
}
167+
if (options.getChannelAffinity() != null) {
168+
List<ChannelAffinityInternal> channelAffinityInternals = options.getChannelAffinity()
169+
.stream().map(this::getChannelAffinityInternal)
170+
.collect(Collectors.toList());
171+
request.setChannelAffinity(channelAffinityInternals);
172+
}
165173
if (options.getExternalStorage() != null) {
166174
ExternalStorageInternal externalStorageInternal = new ExternalStorageInternal()
167175
.setStorageType(RecordingStorageTypeInternal.fromString(options.getExternalStorage().getStorageType().toString()));
@@ -565,4 +573,14 @@ private URL getUrlToSignRequestWith(String url) {
565573
private BlobStorageInternal getBlobStorageInternalFromBlobStorage(BlobStorage blobStorage) {
566574
return new BlobStorageInternal().setContainerUri(blobStorage.getContainerUrl());
567575
}
576+
577+
private ChannelAffinityInternal getChannelAffinityInternal(ChannelAffinity channelAffinity) {
578+
ChannelAffinityInternal channelAffinityInternal = new ChannelAffinityInternal();
579+
CommunicationIdentifierModel communicationIdentifierModel = CommunicationIdentifierConverter.convert(channelAffinity.getParticipant());
580+
channelAffinityInternal.setParticipant(communicationIdentifierModel);
581+
if (channelAffinity.getChannel() != null) {
582+
channelAffinityInternal.setChannel(channelAffinity.getChannel());
583+
}
584+
return channelAffinityInternal;
585+
}
568586
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
5+
package com.azure.communication.callautomation.implementation.models;
6+
7+
import com.azure.core.annotation.Fluent;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/** Channel affinity for a participant. */
11+
@Fluent
12+
public final class ChannelAffinityInternal {
13+
/*
14+
* Channel number to which bitstream from a particular participant will be
15+
* written.
16+
*/
17+
@JsonProperty(value = "channel")
18+
private Integer channel;
19+
20+
/*
21+
* The identifier for the participant whose bitstream will be written to
22+
* the channel
23+
* represented by the channel number.
24+
*/
25+
@JsonProperty(value = "participant", required = true)
26+
private CommunicationIdentifierModel participant;
27+
28+
/**
29+
* Get the channel property: Channel number to which bitstream from a particular participant will be written.
30+
*
31+
* @return the channel value.
32+
*/
33+
public Integer getChannel() {
34+
return this.channel;
35+
}
36+
37+
/**
38+
* Set the channel property: Channel number to which bitstream from a particular participant will be written.
39+
*
40+
* @param channel the channel value to set.
41+
* @return the ChannelAffinityInternal object itself.
42+
*/
43+
public ChannelAffinityInternal setChannel(Integer channel) {
44+
this.channel = channel;
45+
return this;
46+
}
47+
48+
/**
49+
* Get the participant property: The identifier for the participant whose bitstream will be written to the channel
50+
* represented by the channel number.
51+
*
52+
* @return the participant value.
53+
*/
54+
public CommunicationIdentifierModel getParticipant() {
55+
return this.participant;
56+
}
57+
58+
/**
59+
* Set the participant property: The identifier for the participant whose bitstream will be written to the channel
60+
* represented by the channel number.
61+
*
62+
* @param participant the participant value to set.
63+
* @return the ChannelAffinityInternal object itself.
64+
*/
65+
public ChannelAffinityInternal setParticipant(CommunicationIdentifierModel participant) {
66+
this.participant = participant;
67+
return this;
68+
}
69+
}

sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/implementation/models/StartCallRecordingRequestInternal.java

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,35 @@ public final class StartCallRecordingRequestInternal {
4242
private RecordingFormatInternal recordingFormatType;
4343

4444
/*
45-
* The sequential order in which audio channels are assigned to participants in the unmixed recording.
46-
* When 'recordingChannelType' is set to 'unmixed' and `audioChannelParticipantOrdering is not specified,
47-
* the audio channel to participant mapping will be automatically assigned based on the order in which participant
48-
* first audio was detected. Channel to participant mapping details can be found in the metadata of the recording.
45+
* The sequential order in which audio channels are assigned to
46+
* participants in the unmixed recording.
47+
* When 'recordingChannelType' is set to 'unmixed' and
48+
* `audioChannelParticipantOrdering is not specified,
49+
* the audio channel to participant mapping will be automatically assigned
50+
* based on the order in which participant
51+
* first audio was detected. Channel to participant mapping details can be
52+
* found in the metadata of the recording.
4953
*/
5054
@JsonProperty(value = "audioChannelParticipantOrdering")
5155
private List<CommunicationIdentifierModel> audioChannelParticipantOrdering;
5256

57+
/*
58+
* The channel affinity of call recording
59+
* When 'recordingChannelType' is set to 'unmixed', if channelAffinity is
60+
* not specified, 'channel' will be automatically assigned.
61+
* Channel-Participant mapping details can be found in the metadata of the
62+
* recording.
63+
* ///
64+
*/
65+
@JsonProperty(value = "channelAffinity")
66+
private List<ChannelAffinityInternal> channelAffinity;
67+
5368
/*
5469
* Optional property to specify location where recording will be stored
5570
*/
5671
@JsonProperty(value = "externalStorage")
5772
private ExternalStorageInternal externalStorage;
5873

59-
/** Creates an instance of StartCallRecordingRequestInternal class. */
60-
public StartCallRecordingRequestInternal() {}
61-
6274
/**
6375
* Get the callLocator property: The call locator.
6476
*
@@ -188,6 +200,30 @@ public StartCallRecordingRequestInternal setAudioChannelParticipantOrdering(
188200
return this;
189201
}
190202

203+
/**
204+
* Get the channelAffinity property: The channel affinity of call recording When 'recordingChannelType' is set to
205+
* 'unmixed', if channelAffinity is not specified, 'channel' will be automatically assigned. Channel-Participant
206+
* mapping details can be found in the metadata of the recording. ///.
207+
*
208+
* @return the channelAffinity value.
209+
*/
210+
public List<ChannelAffinityInternal> getChannelAffinity() {
211+
return this.channelAffinity;
212+
}
213+
214+
/**
215+
* Set the channelAffinity property: The channel affinity of call recording When 'recordingChannelType' is set to
216+
* 'unmixed', if channelAffinity is not specified, 'channel' will be automatically assigned. Channel-Participant
217+
* mapping details can be found in the metadata of the recording. ///.
218+
*
219+
* @param channelAffinity the channelAffinity value to set.
220+
* @return the StartCallRecordingRequestInternal object itself.
221+
*/
222+
public StartCallRecordingRequestInternal setChannelAffinity(List<ChannelAffinityInternal> channelAffinity) {
223+
this.channelAffinity = channelAffinity;
224+
return this;
225+
}
226+
191227
/**
192228
* Get the externalStorage property: Optional property to specify location where recording will be stored.
193229
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.communication.callautomation.models;
5+
6+
import com.azure.communication.common.CommunicationIdentifier;
7+
import com.azure.core.annotation.Fluent;
8+
9+
/** Channel affinity for a participant. */
10+
@Fluent
11+
public final class ChannelAffinity {
12+
/*
13+
* Channel number to which bitstream from a particular participant will be
14+
* written.
15+
*/
16+
private Integer channel;
17+
18+
/*
19+
* The identifier for the participant whose bitstream will be written to
20+
* the channel
21+
* represented by the channel number.
22+
*/
23+
private CommunicationIdentifier participant;
24+
25+
/**
26+
* Get the channel property: Channel number to which bitstream from a particular participant will be written.
27+
*
28+
* @return the channel value.
29+
*/
30+
public Integer getChannel() {
31+
return this.channel;
32+
}
33+
34+
/**
35+
* Set the channel property: Channel number to which bitstream from a particular participant will be written.
36+
*
37+
* @param channel the channel value to set.
38+
* @return the ChannelAffinityInternal object itself.
39+
*/
40+
public ChannelAffinity setChannel(Integer channel) {
41+
this.channel = channel;
42+
return this;
43+
}
44+
45+
/**
46+
* Get the participant property: The identifier for the participant whose bitstream will be written to the channel
47+
* represented by the channel number.
48+
*
49+
* @return the participant value.
50+
*/
51+
public CommunicationIdentifier getParticipant() {
52+
return this.participant;
53+
}
54+
55+
/**
56+
* Set the participant property: The identifier for the participant whose bitstream will be written to the channel
57+
* represented by the channel number.
58+
*
59+
* @param participant the participant value to set.
60+
* @return the ChannelAffinityInternal object itself.
61+
*/
62+
public ChannelAffinity setParticipant(CommunicationIdentifier participant) {
63+
this.participant = participant;
64+
return this;
65+
}
66+
}

sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/StartRecordingOptions.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public final class StartRecordingOptions {
2929

3030
private List<CommunicationIdentifier> audioChannelParticipantOrdering;
3131

32+
private List<ChannelAffinity> channelAffinity;
33+
3234
private ExternalStorage externalStorage;
3335

3436
/**
@@ -177,4 +179,28 @@ public StartRecordingOptions setExternalStorage(ExternalStorage externalStorage)
177179
this.externalStorage = externalStorage;
178180
return this;
179181
}
182+
183+
/**
184+
* Get the channelAffinity property: The channel affinity of call recording When 'recordingChannelType' is set to
185+
* 'unmixed', if channelAffinity is not specified, 'channel' will be automatically assigned. Channel-Participant
186+
* mapping details can be found in the metadata of the recording. ///.
187+
*
188+
* @return the channelAffinity value.
189+
*/
190+
public List<ChannelAffinity> getChannelAffinity() {
191+
return this.channelAffinity;
192+
}
193+
194+
/**
195+
* Set the channelAffinity property: The channel affinity of call recording When 'recordingChannelType' is set to
196+
* 'unmixed', if channelAffinity is not specified, 'channel' will be automatically assigned. Channel-Participant
197+
* mapping details can be found in the metadata of the recording. ///.
198+
*
199+
* @param channelAffinity the channelAffinity value to set.
200+
* @return the StartRecordingOptions object itself.
201+
*/
202+
public StartRecordingOptions setChannelAffinity(List<ChannelAffinity> channelAffinity) {
203+
this.channelAffinity = channelAffinity;
204+
return this;
205+
}
180206
}

sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallRecordingUnitTests.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33

44
package com.azure.communication.callautomation;
55

6+
import com.azure.communication.callautomation.models.ChannelAffinity;
67
import com.azure.communication.callautomation.models.RecordingState;
78
import com.azure.communication.callautomation.models.RecordingStateResult;
89
import com.azure.communication.callautomation.models.ServerCallLocator;
910
import com.azure.communication.callautomation.models.StartRecordingOptions;
11+
import com.azure.communication.common.PhoneNumberIdentifier;
12+
1013
import org.junit.jupiter.api.BeforeEach;
1114
import org.junit.jupiter.api.Test;
1215
import com.azure.core.exception.HttpResponseException;
1316

1417
import java.util.ArrayList;
18+
import java.util.Arrays;
19+
import java.util.List;
1520

1621
import static org.junit.jupiter.api.Assertions.assertEquals;
1722
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -32,10 +37,18 @@ public void recordingOperationsTest() {
3237
recordingOperationsResponses
3338
);
3439
callRecording = callAutomationClient.getCallRecording();
40+
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
41+
.setRecordingStateCallbackUrl("https://localhost/");
42+
43+
ChannelAffinity channelAffinity = new ChannelAffinity()
44+
.setParticipant(new PhoneNumberIdentifier("RECORDING_ID"))
45+
.setChannel(0);
46+
47+
List<ChannelAffinity> channelAffinities = Arrays.asList(channelAffinity);
48+
startRecordingOptions.setChannelAffinity(channelAffinities);
3549

3650
validateRecording(
37-
callRecording.start(new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
38-
.setRecordingStateCallbackUrl("https://localhost/")),
51+
callRecording.start(startRecordingOptions),
3952
RecordingState.ACTIVE
4053
);
4154

sdk/communication/azure-communication-callautomation/swagger/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To update generated files for call automation, run the following command
3333
``` yaml
3434
tag: package-2023-01-15-preview
3535
require:
36-
- https://github.com/williamzhao87/azure-rest-api-specs/blob/33883b827facd6567cbe03e3853634d59633b970/specification/communication/data-plane/CallAutomation/readme.md
36+
- https://github.com/williamzhao87/azure-rest-api-specs/blob/a37e7e55b3aa6174e83e425b31015bda6d65de06/specification/communication/data-plane/CallAutomation/readme.md
3737
java: true
3838
output-folder: ../
3939
license-header: MICROSOFT_MIT_SMALL

0 commit comments

Comments
 (0)