Skip to content

Commit 67033da

Browse files
v-pivamshiVinothini Dharmaraj
andauthored
Added Interrupt audio and announce api (Azure#47533)
* Added Interrupt audio and announce api * pushed assets.json file * updating the live test * adding the events * updating the playoptions --------- Co-authored-by: Vinothini Dharmaraj <[email protected]>
1 parent 525faf2 commit 67033da

35 files changed

+2100
-208
lines changed

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

Lines changed: 76 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 76 additions & 0 deletions
Large diffs are not rendered by default.

sdk/communication/Azure.Communication.CallAutomation/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/communication/Azure.Communication.CallAutomation",
5-
"Tag": "net/communication/Azure.Communication.CallAutomation_42ef7c9c87"
5+
"Tag": "net/communication/Azure.Communication.CallAutomation_639a28e13e"
66
}

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,39 @@ public class HoldEventResult
1111
/// </summary>
1212
public bool IsSuccess { get; internal set; }
1313

14+
/// <summary>
15+
/// <see cref="HoldAudioCompleted"/> event will be returned once the hold audio is completed successfully.
16+
/// </summary>
17+
public HoldAudioCompleted SuccessResult { get; }
18+
19+
/// <summary>
20+
/// <see cref="HoldAudioStarted"/> event will be returned once the hold audio has started successfully.
21+
/// </summary>
22+
public HoldAudioStarted StartResult { get; }
23+
24+
/// <summary>
25+
/// <see cref="HoldAudioPaused"/> event will be returned once the hold audio is paused successfully.
26+
/// </summary>
27+
public HoldAudioPaused PauseResult { get; }
28+
29+
/// <summary>
30+
/// <see cref="HoldAudioResumed"/> event will be returned once the hold audio is resumed successfully.
31+
/// </summary>
32+
public HoldAudioResumed ResumeResult { get; }
33+
1434
/// <summary>
1535
/// <see cref="HoldFailed"/> event will be returned once the hold failed.
1636
/// </summary>
1737
public HoldFailed FailureResult { get; }
1838

19-
internal HoldEventResult(bool isSuccess, HoldFailed failureResult)
39+
internal HoldEventResult(bool isSuccess, HoldAudioCompleted successResult, HoldFailed failureResult, HoldAudioStarted startResult, HoldAudioPaused pauseResult, HoldAudioResumed resumeResult)
2040
{
2141
IsSuccess = isSuccess;
42+
SuccessResult = successResult;
2243
FailureResult = failureResult;
44+
StartResult = startResult;
45+
PauseResult = pauseResult;
46+
ResumeResult = resumeResult;
2347
}
2448
}
2549
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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="InterruptAudioAndAnnounceEventResult"/> is returned from WaitForEvent of <see cref="InterruptAudioAndAnnounceResult"/>.</summary>
7+
public class InterruptAudioAndAnnounceEventResult
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="PlayStarted"/> event will be returned once the play has started successfully.
16+
/// </summary>
17+
public PlayStarted StartResult { get; }
18+
19+
/// <summary>
20+
/// <see cref="PlayPaused"/> event will be returned once the play is paused successfully.
21+
/// </summary>
22+
public PlayPaused PauseResult { get; }
23+
24+
/// <summary>
25+
/// <see cref="PlayResumed"/> event will be returned once the play is resumed successfully.
26+
/// </summary>
27+
public PlayResumed ResumeResult { get; }
28+
29+
/// <summary>
30+
/// <see cref="PlayCompleted"/> event will be returned once the play is completed successfully.
31+
/// </summary>
32+
public PlayCompleted SuccessResult { get; }
33+
34+
/// <summary>
35+
/// <see cref="PlayFailed"/> event will be returned once the play failed.
36+
/// </summary>
37+
public PlayFailed FailureResult { get; }
38+
39+
internal InterruptAudioAndAnnounceEventResult(bool isSuccess, PlayCompleted successResult, PlayFailed failureResult, PlayStarted startResult, PlayPaused pauseResult, PlayResumed resumeResult)
40+
{
41+
IsSuccess = isSuccess;
42+
SuccessResult = successResult;
43+
FailureResult = failureResult;
44+
StartResult = startResult;
45+
PauseResult = pauseResult;
46+
ResumeResult = resumeResult;
47+
}
48+
}
49+
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ public class PlayEventResult
1111
/// </summary>
1212
public bool IsSuccess { get; internal set; }
1313

14+
/// <summary>
15+
/// <see cref="PlayStarted"/> event will be returned once the play has started successfully.
16+
/// </summary>
17+
public PlayStarted StartResult { get; }
18+
19+
/// <summary>
20+
/// <see cref="PlayPaused"/> event will be returned once the play is paused successfully.
21+
/// </summary>
22+
public PlayPaused PauseResult { get; }
23+
24+
/// <summary>
25+
/// <see cref="PlayResumed"/> event will be returned once the play is resumed successfully.
26+
/// </summary>
27+
public PlayResumed ResumeResult { get; }
28+
1429
/// <summary>
1530
/// <see cref="PlayCompleted"/> event will be returned once the play is completed successfully.
1631
/// </summary>
@@ -21,11 +36,14 @@ public class PlayEventResult
2136
/// </summary>
2237
public PlayFailed FailureResult { get; }
2338

24-
internal PlayEventResult(bool isSuccess, PlayCompleted successResult, PlayFailed failureResult)
39+
internal PlayEventResult(bool isSuccess, PlayCompleted successResult, PlayFailed failureResult, PlayStarted startResult, PlayPaused pauseResult, PlayResumed resumeResult)
2540
{
2641
IsSuccess = isSuccess;
2742
SuccessResult = successResult;
2843
FailureResult = failureResult;
44+
StartResult = startResult;
45+
PauseResult = pauseResult;
46+
ResumeResult = resumeResult;
2947
}
3048
}
3149
}

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

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Linq;
77
using System.Threading;
88
using System.Threading.Tasks;
9-
using Azure.Core;
109
using Azure.Core.Pipeline;
1110

1211
namespace Azure.Communication.CallAutomation
@@ -1270,7 +1269,7 @@ public virtual Response StartTranscription(StartTranscriptionOptions options = d
12701269
{
12711270
var request = options == default
12721271
? new StartTranscriptionRequestInternal()
1273-
: new StartTranscriptionRequestInternal() { Locale = options.Locale, OperationContext = options.OperationContext, OperationCallbackUri=options.OperationCallbackUri, SpeechRecognitionModelEndpointId=options.SpeechRecognitionModelEndpointId };
1272+
: new StartTranscriptionRequestInternal() { Locale = options.Locale, OperationContext = options.OperationContext, OperationCallbackUri = options.OperationCallbackUri, SpeechRecognitionModelEndpointId = options.SpeechRecognitionModelEndpointId };
12741273

12751274
return CallMediaRestClient.StartTranscription(CallConnectionId, request, cancellationToken);
12761275
}
@@ -1545,5 +1544,64 @@ public virtual async Task<Response> StopMediaStreamingAsync(StopMediaStreamingOp
15451544
throw;
15461545
}
15471546
}
1547+
1548+
/// <summary>
1549+
/// Interrupts current hold audio and plays the announcement passed as a parameter. Resumes the hold audio after announcement completes.
1550+
/// </summary>
1551+
/// <param name="announcementOptions"></param>
1552+
/// <param name="cancellationToken"></param>
1553+
/// <returns>Returns <see cref="InterruptAudioAndAnnounceResult"/>, which can be used to wait for Play's related events.</returns>
1554+
public virtual Response<InterruptAudioAndAnnounceResult> InterruptAudioAndAnnounce(InterruptAudioAndAnnounceOptions announcementOptions, CancellationToken cancellationToken = default)
1555+
{
1556+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(InterruptAudioAndAnnounce)}");
1557+
scope.Start();
1558+
try
1559+
{
1560+
InterruptAudioAndAnnounceRequestInternal request = new InterruptAudioAndAnnounceRequestInternal(
1561+
announcementOptions.Announcement.Select(t => TranslatePlaySourceToInternal(t)).ToList(),
1562+
CommunicationIdentifierSerializer.Serialize(announcementOptions.PlayTo),
1563+
announcementOptions.OperationContext);
1564+
1565+
var response = CallMediaRestClient.InterruptAudioAndAnnounce(CallConnectionId, request, cancellationToken);
1566+
var result = new InterruptAudioAndAnnounceResult();
1567+
1568+
result.SetEventProcessor(EventProcessor, CallConnectionId, request.OperationContext);
1569+
return Response.FromValue(result, response);
1570+
}
1571+
catch (Exception ex)
1572+
{
1573+
scope.Failed(ex);
1574+
throw;
1575+
}
1576+
}
1577+
1578+
/// <summary>
1579+
/// Plays a file.
1580+
/// </summary>
1581+
/// <param name="announcementOptions"></param>
1582+
/// <param name="cancellationToken"></param>
1583+
/// <returns>Returns <see cref="InterruptAudioAndAnnounceResult"/>, which can be used to wait for Play's related events.</returns>
1584+
public async virtual Task<Response<InterruptAudioAndAnnounceResult>> InterruptAudioAndAnnounceAsync(InterruptAudioAndAnnounceOptions announcementOptions, CancellationToken cancellationToken = default)
1585+
{
1586+
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(InterruptAudioAndAnnounce)}");
1587+
scope.Start();
1588+
try
1589+
{
1590+
InterruptAudioAndAnnounceRequestInternal request = new InterruptAudioAndAnnounceRequestInternal(
1591+
announcementOptions.Announcement.Select(t => TranslatePlaySourceToInternal(t)).ToList(),
1592+
CommunicationIdentifierSerializer.Serialize(announcementOptions.PlayTo));
1593+
1594+
var response = await CallMediaRestClient.InterruptAudioAndAnnounceAsync(CallConnectionId, request, cancellationToken).ConfigureAwait(false);
1595+
var result = new InterruptAudioAndAnnounceResult();
1596+
1597+
result.SetEventProcessor(EventProcessor, CallConnectionId, request.OperationContext);
1598+
return Response.FromValue(result, response);
1599+
}
1600+
catch (Exception ex)
1601+
{
1602+
scope.Failed(ex);
1603+
throw;
1604+
}
1605+
}
15481606
}
15491607
}

sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/HoldAudioCompleted.Serialization.cs

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/HoldAudioCompleted.cs

Lines changed: 1 addition & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/HoldAudioPaused.Serialization.cs

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)