Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Hold/Unhold capabilities to ACS. #38858

Merged
merged 13 commits into from
Sep 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,14 @@ protected CallMedia() { }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CallAutomation.SendDtmfResult>> SendDtmfAsync(System.Collections.Generic.IEnumerable<Azure.Communication.CallAutomation.DtmfTone> tones, Azure.Communication.CommunicationIdentifier targetParticipant, string operationContext = null, System.Uri callbackUri = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response StartContinuousDtmfRecognition(Azure.Communication.CommunicationIdentifier targetParticipant, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> StartContinuousDtmfRecognitionAsync(Azure.Communication.CommunicationIdentifier targetParticipant, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response StartHoldMusic(Azure.Communication.CallAutomation.StartHoldMusicOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> StartHoldMusicAsync(Azure.Communication.CallAutomation.StartHoldMusicOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Communication.CallAutomation.StartRecognizingCallMediaResult> StartRecognizing(Azure.Communication.CallAutomation.CallMediaRecognizeOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CallAutomation.StartRecognizingCallMediaResult>> StartRecognizingAsync(Azure.Communication.CallAutomation.CallMediaRecognizeOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response StopContinuousDtmfRecognition(Azure.Communication.CommunicationIdentifier targetParticipant, string operationContext = null, System.Uri callbackUri = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> StopContinuousDtmfRecognitionAsync(Azure.Communication.CommunicationIdentifier targetParticipant, string operationContext = null, System.Uri callbackUri = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response StopHoldMusic(Azure.Communication.CallAutomation.StopHoldMusicOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> StopHoldMusicAsync(Azure.Communication.CallAutomation.StopHoldMusicOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct CallMediaRecognitionType : System.IEquatable<Azure.Communication.CallAutomation.CallMediaRecognitionType>
Expand Down Expand Up @@ -633,6 +637,7 @@ internal DialogHangup() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public DialogInputType(string value) { throw null; }
public static Azure.Communication.CallAutomation.DialogInputType AzureOpenAI { get { throw null; } }
public static Azure.Communication.CallAutomation.DialogInputType PowerVirtualAgents { get { throw null; } }
public bool Equals(Azure.Communication.CallAutomation.DialogInputType other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -1270,6 +1275,14 @@ public StartDialogOptions(string dialogId, Azure.Communication.CallAutomation.Di
public Azure.Communication.CallAutomation.DialogInputType DialogInputType { get { throw null; } }
public string OperationContext { get { throw null; } set { } }
}
public partial class StartHoldMusicOptions
{
public StartHoldMusicOptions(Azure.Communication.CommunicationIdentifier targetParticipant, Azure.Communication.CallAutomation.PlaySource playSourceInfo) { }
public bool Loop { get { throw null; } set { } }
public string OperationContext { get { throw null; } set { } }
public Azure.Communication.CallAutomation.PlaySource PlaySourceInfo { get { throw null; } set { } }
public Azure.Communication.CommunicationIdentifier TargetParticipant { get { throw null; } }
}
public partial class StartRecognizingCallMediaResult
{
internal StartRecognizingCallMediaResult() { }
Expand All @@ -1294,6 +1307,23 @@ public StartRecordingOptions(Azure.Communication.CallAutomation.CallLocator call
public Azure.Communication.CallAutomation.RecordingFormat RecordingFormat { get { throw null; } set { } }
public System.Uri RecordingStateCallbackUri { get { throw null; } set { } }
}
public partial class StartTranscriptionRequest
{
public StartTranscriptionRequest() { }
public string Locale { get { throw null; } set { } }
public string OperationContext { get { throw null; } set { } }
}
public partial class StopHoldMusicOptions
{
public StopHoldMusicOptions(Azure.Communication.CommunicationIdentifier targetParticipant) { }
public string OperationContext { get { throw null; } set { } }
public Azure.Communication.CommunicationIdentifier TargetParticipant { get { throw null; } }
}
public partial class StopTranscriptionRequest
{
public StopTranscriptionRequest() { }
public string OperationContext { get { throw null; } set { } }
}
public partial class TextSource : Azure.Communication.CallAutomation.PlaySource
{
public TextSource(string text) { }
Expand Down Expand Up @@ -1372,6 +1402,11 @@ public partial class UnmuteParticipantsResult
internal UnmuteParticipantsResult() { }
public string OperationContext { get { throw null; } }
}
public partial class UpdateTranscriptionDataRequest
{
public UpdateTranscriptionDataRequest(string locale) { }
public string Locale { get { throw null; } }
}
public partial class UserConsent
{
internal UserConsent() { }
Expand Down
104 changes: 104 additions & 0 deletions sdk/communication/Azure.Communication.CallAutomation/src/CallMedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,110 @@ public virtual Response<StartRecognizingCallMediaResult> StartRecognizing(CallMe
}
}

/// <summary>
/// Hold participant from the call.
/// </summary>
/// <param name="options">The options.</param>
/// <param name="cancellationToken"></param>
cochi2 marked this conversation as resolved.
Show resolved Hide resolved
/// <returns></returns>
public virtual Response StartHoldMusic(StartHoldMusicOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(StartHoldMusic)}");
scope.Start();
try
{
var request = new StartHoldMusicRequestInternal(
CommunicationIdentifierSerializer.Serialize(options.TargetParticipant),
TranslatePlaySourceToInternal(options.PlaySourceInfo))
{
Loop = options.Loop,
OperationContext = options.OperationContext,
};

return CallMediaRestClient.StartHoldMusic(CallConnectionId, request, cancellationToken: cancellationToken);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

/// <summary>
/// Hold participant from the call.
/// </summary>
/// <param name="options">The options.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual async Task<Response> StartHoldMusicAsync(StartHoldMusicOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(StartHoldMusicAsync)}");
scope.Start();
try
{
var request = new StartHoldMusicRequestInternal(
CommunicationIdentifierSerializer.Serialize(options.TargetParticipant),
TranslatePlaySourceToInternal(options.PlaySourceInfo))
{
Loop = options.Loop,
OperationContext = options.OperationContext,
};

return await CallMediaRestClient.StartHoldMusicAsync(CallConnectionId, request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

/// <summary>
/// Remove hold from participant.
/// </summary>
/// <param name="options">The options.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual async Task<Response> StopHoldMusicAsync(StopHoldMusicOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(StopHoldMusicAsync)}");
scope.Start();
try
{
StopHoldMusicRequestInternal request = new StopHoldMusicRequestInternal(CommunicationIdentifierSerializer.Serialize(options.TargetParticipant));

return await CallMediaRestClient.StopHoldMusicAsync(CallConnectionId, request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

/// <summary>
/// Remove hold from participant.
/// </summary>
/// <param name="options">The options.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual Response StopHoldMusic(StopHoldMusicOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallMedia)}.{nameof(StopHoldMusicAsync)}");
scope.Start();
try
{
StopHoldMusicRequestInternal request = new StopHoldMusicRequestInternal(CommunicationIdentifierSerializer.Serialize(options.TargetParticipant));

return CallMediaRestClient.StopHoldMusic(CallConnectionId, request, cancellationToken: cancellationToken);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

private static RecognizeRequestInternal CreateRecognizeRequest(CallMediaRecognizeOptions recognizeOptions)
{
if (recognizeOptions == null)
Expand Down
Loading