Skip to content

Commit 4b8d11e

Browse files
vivekmore-msftabhishesingh-msftatazimsft
authored
Beta 2 feedback changes(sdk specific only) (#37876)
* Beta 2 feedback changes(sdk specific only) * make remaining ABR updates * update media event reason codes * address pr comments * update tests --------- Co-authored-by: abhishesingh-msft <[email protected]> Co-authored-by: Adam Tazi <[email protected]>
1 parent 7caedab commit 4b8d11e

File tree

85 files changed

+2313
-1155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2313
-1155
lines changed

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs

Lines changed: 61 additions & 58 deletions
Large diffs are not rendered by default.

sdk/communication/Azure.Communication.CallAutomation/src/Azure.Communication.CallAutomation.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,4 @@
3333
<PackageReference Include="Azure.Communication.Common" />
3434
<PackageReference Include="System.Text.Json" />
3535
</ItemGroup>
36-
<ItemGroup>
37-
<Folder Include="Generated\" />
38-
</ItemGroup>
3936
</Project>

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions opti
210210
AnswerCallRequestInternal request = new AnswerCallRequestInternal(options.IncomingCallContext, options.CallbackUri.AbsoluteUri);
211211

212212
// Add custom cognitive service domain name
213-
if (options.AzureCognitiveServicesEndpointUri != null)
213+
if (options.CognitiveServicesEndpoint != null)
214214
{
215-
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
215+
request.CognitiveServicesEndpoint = options.CognitiveServicesEndpoint.AbsoluteUri;
216216
}
217217

218218
request.AnsweredBy = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);
@@ -622,9 +622,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
622622
};
623623

624624
// Add custom cognitive service domain name
625-
if (options.AzureCognitiveServicesEndpointUri != null)
625+
if (options.CognitiveServicesEndpoint != null)
626626
{
627-
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
627+
request.CognitiveServicesEndpoint = options.CognitiveServicesEndpoint.AbsoluteUri;
628628
}
629629

630630
request.OperationContext = options.OperationContext;
@@ -646,9 +646,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
646646
};
647647

648648
// Add custom cognitive service domain name
649-
if (options.AzureCognitiveServicesEndpointUri != null)
649+
if (options.CognitiveServicesEndpoint != null)
650650
{
651-
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUri.AbsoluteUri;
651+
request.CognitiveServicesEndpoint = options.CognitiveServicesEndpoint.AbsoluteUri;
652652
}
653653

654654
request.OperationContext = options.OperationContext;

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationEventProcessor/EventResult/SendDtmfEventResult.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Azure.Communication.CallAutomation
5+
{
6+
/// <summary><see cref="SendDtmfTonesEventResult"/> is returned from WaitForEvent of <see cref="SendDtmfTonesResult"/>.</summary>
7+
public class SendDtmfTonesEventResult
8+
{
9+
/// <summary>
10+
/// Indicates whether the returned event is considered successful or not.
11+
/// </summary>
12+
public bool IsSuccess { get; internal set; }
13+
14+
/// <summary>
15+
/// <see cref="SendDtmfTonesCompleted"/> event will be returned once the dtmf tones have been sent successfully.
16+
/// </summary>
17+
public SendDtmfTonesCompleted SuccessResult { get; }
18+
19+
/// <summary>
20+
/// <see cref="SendDtmfTonesFailed"/> event will be returned if send dtmf tones completed unsuccessfully.
21+
/// </summary>
22+
public SendDtmfTonesFailed FailureResult { get; }
23+
24+
internal SendDtmfTonesEventResult(bool isSuccess, SendDtmfTonesCompleted successResult, SendDtmfTonesFailed failureResult)
25+
{
26+
IsSuccess = isSuccess;
27+
SuccessResult = successResult;
28+
FailureResult = failureResult;
29+
}
30+
}
31+
}

sdk/communication/Azure.Communication.CallAutomation/src/CallConnection.cs

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -662,47 +662,30 @@ public virtual CallMedia GetCallMedia()
662662
/// Only Acs Users are currently supported.
663663
/// </summary>
664664
/// <param name="targetParticipant">Participant to mute.</param>
665+
/// <param name="operationContext"> The Operation Context. </param>
665666
/// <param name="cancellationToken">The cancellation token.</param>
666667
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
667668
/// <exception cref="ArgumentNullException"> <paramref name="targetParticipant"/> is null. </exception>
668669
/// <returns>A Response containing MuteParticipantsResponse.</returns>
669-
public virtual Response<MuteParticipantsResult> MuteParticipants(CommunicationIdentifier targetParticipant, CancellationToken cancellationToken = default)
670-
{
671-
var options = new MuteParticipantsOptions(new List<CommunicationIdentifier> { targetParticipant });
672-
673-
return MuteParticipants(options, cancellationToken);
674-
}
675-
676-
/// <summary>
677-
/// Mute participants from the call.
678-
/// Only Acs Users are currently supported.
679-
/// </summary>
680-
/// <param name="options">Options for the MuteParticipant operation.</param>
681-
/// <param name="cancellationToken">The cancellation token.</param>
682-
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
683-
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
684-
/// <returns>A Response containing MuteParticipantsResponse. </returns>
685-
public virtual Response<MuteParticipantsResult> MuteParticipants(MuteParticipantsOptions options, CancellationToken cancellationToken = default)
670+
public virtual Response<MuteParticipantResult> MuteParticipant(CommunicationIdentifier targetParticipant, string operationContext = default, CancellationToken cancellationToken = default)
686671
{
687-
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(MuteParticipants)}");
672+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(MuteParticipant)}");
688673
scope.Start();
689674
try
690675
{
691-
if (options == null)
692-
throw new ArgumentNullException(nameof(options));
693-
694-
MuteParticipantsRequestInternal request = new MuteParticipantsRequestInternal(
695-
options.TargetParticipants.Select(participant => CommunicationIdentifierSerializer.Serialize(participant)));
676+
MuteParticipantRequestInternal request = new(new List<CommunicationIdentifierModel>() { CommunicationIdentifierSerializer.Serialize(targetParticipant) });
696677
var repeatabilityHeaders = new RepeatabilityHeaders();
697678

698-
request.OperationContext = options.OperationContext;
679+
request.OperationContext = operationContext;
699680

700-
return RestClient.Mute(
681+
var response = RestClient.Mute(
701682
CallConnectionId,
702683
request,
703684
repeatabilityHeaders.RepeatabilityRequestId,
704685
repeatabilityHeaders.RepeatabilityFirstSent,
705686
cancellationToken);
687+
688+
return Response.FromValue(new MuteParticipantResult(response.Value), response.GetRawResponse());
706689
}
707690
catch (Exception ex)
708691
{
@@ -716,47 +699,30 @@ public virtual Response<MuteParticipantsResult> MuteParticipants(MuteParticipant
716699
/// Only Acs Users are currently supported.
717700
/// </summary>
718701
/// <param name="targetParticipant">Participants to mute.</param>
702+
/// <param name="operationContext"> The Operation Context. </param>
719703
/// <param name="cancellationToken">The cancellation token.</param>
720704
/// <exception cref="ArgumentNullException"> <paramref name="targetParticipant"/> is null. </exception>
721705
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
722706
/// <returns></returns>
723-
public async virtual Task<Response<MuteParticipantsResult>> MuteParticipantsAsync(CommunicationIdentifier targetParticipant, CancellationToken cancellationToken = default)
707+
public async virtual Task<Response<MuteParticipantResult>> MuteParticipantAsync(CommunicationIdentifier targetParticipant, string operationContext = default, CancellationToken cancellationToken = default)
724708
{
725-
var options = new MuteParticipantsOptions(new List<CommunicationIdentifier> { targetParticipant });
726-
727-
return await MuteParticipantsAsync(options, cancellationToken).ConfigureAwait(false);
728-
}
729-
730-
/// <summary>
731-
/// Mute participants on the call.
732-
/// </summary>
733-
/// <param name="options">Options for the MuteParticipant operation.</param>
734-
/// <param name="cancellationToken">The cancellation token.</param>
735-
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
736-
/// <exception cref="ArgumentException"> <paramref name="options"/> OperationContext is too long. </exception>
737-
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
738-
/// <returns></returns>
739-
public async virtual Task<Response<MuteParticipantsResult>> MuteParticipantsAsync(MuteParticipantsOptions options, CancellationToken cancellationToken = default)
740-
{
741-
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(MuteParticipants)}");
709+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(MuteParticipant)}");
742710
scope.Start();
743711
try
744712
{
745-
if (options == null)
746-
throw new ArgumentNullException(nameof(options));
747-
748-
MuteParticipantsRequestInternal request = new MuteParticipantsRequestInternal(
749-
options.TargetParticipants.Select(participant => CommunicationIdentifierSerializer.Serialize(participant)));
713+
MuteParticipantRequestInternal request = new(new List<CommunicationIdentifierModel>() { CommunicationIdentifierSerializer.Serialize(targetParticipant) });
750714
var repeatabilityHeaders = new RepeatabilityHeaders();
751715

752-
request.OperationContext = options.OperationContext;
716+
request.OperationContext = operationContext;
753717

754-
return await RestClient.MuteAsync(
718+
var response = await RestClient.MuteAsync(
755719
CallConnectionId,
756720
request,
757721
repeatabilityHeaders.RepeatabilityRequestId,
758722
repeatabilityHeaders.RepeatabilityFirstSent,
759723
cancellationToken).ConfigureAwait(false);
724+
725+
return Response.FromValue(new MuteParticipantResult(response.Value), response.GetRawResponse());
760726
}
761727
catch (Exception ex)
762728
{

sdk/communication/Azure.Communication.CallAutomation/src/CallMedia.cs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private static RecognizeRequestInternal CreateRecognizeRequest(CallMediaRecogniz
419419
InitialSilenceTimeoutInSeconds = (int)recognizeChoiceOptions.InitialSilenceTimeout.TotalSeconds
420420
};
421421

422-
recognizeChoiceOptions.RecognizeChoices
422+
recognizeChoiceOptions.Choices
423423
.ToList().ForEach(t => recognizeConfigurationsInternal.Choices.Add(t));
424424

425425
if (!String.IsNullOrEmpty(recognizeChoiceOptions.SpeechLanguage))
@@ -532,19 +532,19 @@ private static PlaySourceInternal TranslatePlaySourceToInternal(PlaySource playS
532532
else if (playSource != null && playSource is TextSource textSource)
533533
{
534534
sourceInternal = new PlaySourceInternal(PlaySourceTypeInternal.Text);
535-
sourceInternal.TextSource = new TextSourceInternal(textSource.Text);
536-
sourceInternal.TextSource.SourceLocale = textSource.SourceLocale ?? null;
537-
sourceInternal.TextSource.VoiceGender = textSource.VoiceGender ?? GenderType.Male;
538-
sourceInternal.TextSource.VoiceName = textSource.VoiceName ?? null;
539-
sourceInternal.TextSource.CustomVoiceEndpointId = textSource.CustomVoiceEndpointId ?? null;
535+
sourceInternal.Text = new TextSourceInternal(textSource.Text);
536+
sourceInternal.Text.SourceLocale = textSource.SourceLocale ?? null;
537+
sourceInternal.Text.VoiceKind = textSource.VoiceKind ?? VoiceKind.Male;
538+
sourceInternal.Text.VoiceName = textSource.VoiceName ?? null;
539+
sourceInternal.Text.CustomVoiceEndpointId = textSource.CustomVoiceEndpointId ?? null;
540540
sourceInternal.PlaySourceCacheId = textSource.PlaySourceCacheId;
541541
return sourceInternal;
542542
}
543543
else if (playSource != null && playSource is SsmlSource ssmlSource)
544544
{
545545
sourceInternal = new PlaySourceInternal(PlaySourceTypeInternal.Ssml);
546-
sourceInternal.SsmlSource = new SsmlSourceInternal(ssmlSource.SsmlText);
547-
sourceInternal.SsmlSource.CustomVoiceEndpointId = ssmlSource.CustomVoiceEndpointId ?? null;
546+
sourceInternal.Ssml = new SsmlSourceInternal(ssmlSource.SsmlText);
547+
sourceInternal.Ssml.CustomVoiceEndpointId = ssmlSource.CustomVoiceEndpointId ?? null;
548548
sourceInternal.PlaySourceCacheId = ssmlSource.PlaySourceCacheId;
549549
return sourceInternal;
550550
}
@@ -673,23 +673,24 @@ public virtual async Task<Response> StopContinuousDtmfRecognitionAsync(Communica
673673
/// <param name="operationContext">An optional context object containing information about the operation, such as a unique identifier or custom metadata.</param>
674674
/// <param name="cancellationToken">An optional CancellationToken to cancel the request.</param>
675675
/// <returns>Returns a Response containing a SendDtmfResult object indicating the result of the send operation.</returns>
676-
public virtual async Task<Response<SendDtmfResult>> SendDtmfAsync(IEnumerable<DtmfTone> tones, CommunicationIdentifier targetParticipant,
676+
public virtual async Task<Response<SendDtmfTonesResult>> SendDtmfTonesAsync(IEnumerable<DtmfTone> tones, CommunicationIdentifier targetParticipant,
677677
string operationContext = default, CancellationToken cancellationToken = default)
678678
{
679-
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(SendDtmf)}");
679+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(SendDtmfTones)}");
680680
scope.Start();
681681
try
682682
{
683-
SendDtmfRequestInternal request = request = new(tones, CommunicationIdentifierSerializer.Serialize(targetParticipant));
684-
685-
request.OperationContext = operationContext;
683+
SendDtmfTonesRequestInternal request = new(tones, CommunicationIdentifierSerializer.Serialize(targetParticipant))
684+
{
685+
OperationContext = operationContext
686+
};
686687

687688
var repeatabilityHeaders = new RepeatabilityHeaders();
688689

689-
var response = await CallMediaRestClient.SendDtmfAsync(CallConnectionId, request, repeatabilityHeaders.RepeatabilityRequestId,
690+
var response = await CallMediaRestClient.SendDtmfTonesAsync(CallConnectionId, request, repeatabilityHeaders.RepeatabilityRequestId,
690691
repeatabilityHeaders.RepeatabilityFirstSent, cancellationToken).ConfigureAwait(false);
691692

692-
var result = new SendDtmfResult();
693+
var result = new SendDtmfTonesResult(response.Value.OperationContext);
693694
result.SetEventProcessor(EventProcessor, CallConnectionId, response.Value.OperationContext);
694695

695696
return Response.FromValue(result, response.GetRawResponse());
@@ -709,23 +710,24 @@ public virtual async Task<Response<SendDtmfResult>> SendDtmfAsync(IEnumerable<Dt
709710
/// <param name="operationContext">An optional context object containing information about the operation, such as a unique identifier or custom metadata.</param>
710711
/// <param name="cancellationToken">An optional CancellationToken to cancel the request.</param>
711712
/// <returns>Returns a Response containing a SendDtmfResult object indicating the result of the send operation.</returns>
712-
public virtual Response<SendDtmfResult> SendDtmf(IEnumerable<DtmfTone> tones, CommunicationIdentifier targetParticipant,
713+
public virtual Response<SendDtmfTonesResult> SendDtmfTones(IEnumerable<DtmfTone> tones, CommunicationIdentifier targetParticipant,
713714
string operationContext = default, CancellationToken cancellationToken = default)
714715
{
715-
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(SendDtmf)}");
716+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(SendDtmfTones)}");
716717
scope.Start();
717718
try
718719
{
719-
SendDtmfRequestInternal request = new(tones, CommunicationIdentifierSerializer.Serialize(targetParticipant));
720-
721-
request.OperationContext = operationContext;
720+
SendDtmfTonesRequestInternal request = new(tones, CommunicationIdentifierSerializer.Serialize(targetParticipant))
721+
{
722+
OperationContext = operationContext
723+
};
722724

723725
var repeatabilityHeaders = new RepeatabilityHeaders();
724726

725-
var response = CallMediaRestClient.SendDtmf(CallConnectionId, request, repeatabilityHeaders.RepeatabilityRequestId,
727+
var response = CallMediaRestClient.SendDtmfTones(CallConnectionId, request, repeatabilityHeaders.RepeatabilityRequestId,
726728
repeatabilityHeaders.RepeatabilityFirstSent, cancellationToken);
727729

728-
var result = new SendDtmfResult();
730+
var result = new SendDtmfTonesResult(response.Value.OperationContext);
729731
result.SetEventProcessor(EventProcessor, CallConnectionId, response.Value.OperationContext);
730732

731733
return Response.FromValue(result, response.GetRawResponse());

0 commit comments

Comments
 (0)