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

Minor fix for ConvClient joinCall api. #21558

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,16 @@ public virtual Response<CancelAllMediaOperationsResponse> CancelAllMediaOperatio
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="audioFileUri"/> is null. </exception>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string callLegId, Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
=> await PlayAudioAsync(callLegId, new PlayAudioOptions { AudioFileUri = audioFileUri, Loop = loop, AudioFileId = audioFileId, CallbackUri = callbackUri, OperationContext = operationContext }, cancellationToken).ConfigureAwait(false);
=> await PlayAudioAsync(
callLegId,
new PlayAudioOptions {
AudioFileUri = audioFileUri,
Loop = loop,
AudioFileId = audioFileId,
CallbackUri = callbackUri,
OperationContext = operationContext
},
cancellationToken).ConfigureAwait(false);

/// <summary> Play audio in the call. </summary>
/// <param name="callLegId"> The call leg id. </param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private ConversationClient(Uri endpoint, CallClientOptions options, AzureKeyCred
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="conversationId"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
public virtual async Task<Response<JoinCallResponse>> JoinCallAsync(string conversationId, CommunicationIdentifier source, CreateCallOptions callOptions, CancellationToken cancellationToken = default)
public virtual async Task<Response<JoinCallResponse>> JoinCallAsync(string conversationId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(JoinCallAsync)}");
scope.Start();
Expand Down Expand Up @@ -140,7 +140,7 @@ public virtual async Task<Response<JoinCallResponse>> JoinCallAsync(string conve
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="conversationId"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
public virtual Response<JoinCallResponse> JoinCall(string conversationId, CommunicationIdentifier source, CreateCallOptions callOptions, CancellationToken cancellationToken = default)
public virtual Response<JoinCallResponse> JoinCall(string conversationId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(JoinCall)}");
scope.Start();
Expand Down Expand Up @@ -178,16 +178,36 @@ public virtual Response<JoinCallResponse> JoinCall(string conversationId, Commun
/// <param name="callbackUri">The callback Uri to receive PlayAudio status notifications. </param>
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string conversationId, Uri audioFileUri, string audioFileId = null, Uri callbackUri = null , string operationContext = null, CancellationToken cancellationToken = default)
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="audioFileUri"/> is null. </exception>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string conversationId, Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
=> await PlayAudioAsync(
conversationId,
new PlayAudioOptions
{
AudioFileUri = audioFileUri,
AudioFileId = audioFileId,
CallbackUri = callbackUri,
OperationContext = operationContext
},
cancellationToken).ConfigureAwait(false);

/// <summary> Play audio in the call. </summary>
/// <param name="conversationId"> The call leg id. </param>
/// <param name="options"> Play audio request. </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string conversationId, PlayAudioOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudioAsync)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudio)}");
scope.Start();
try
{
Argument.AssertNotNull(audioFileUri, nameof(audioFileUri));
Argument.AssertNotNull(options, nameof(options));

// Currently looping media is not supported for out-call scenarios, thus setting it to false.
return await RestClient.PlayAudioAsync(conversationId, audioFileUri.AbsoluteUri, false, operationContext, audioFileId, callbackUri?.AbsoluteUri, cancellationToken).ConfigureAwait(false);
return await RestClient.PlayAudioAsync(conversationId, options.AudioFileUri?.AbsoluteUri, false, options.OperationContext, options.AudioFileId, options.CallbackUri?.AbsoluteUri, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
Expand All @@ -204,16 +224,34 @@ public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string con
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <returns></returns>
public virtual Response<PlayAudioResponse> PlayAudio(string conversationId, Uri audioFileUri, string audioFileId = null , Uri callbackUri = null, string operationContext = null, CancellationToken cancellationToken = default)
public virtual Response<PlayAudioResponse> PlayAudio(string conversationId, Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
=> PlayAudio(
conversationId,
new PlayAudioOptions
{
AudioFileUri = audioFileUri,
AudioFileId = audioFileId,
CallbackUri = callbackUri,
OperationContext = operationContext
},
cancellationToken);

/// <summary> Play audio in the call. </summary>
/// <param name="conversationId"> The conversation id that can be a group id or a encoded conversation url retrieve from client. </param>
/// <param name="options"> Play audio request. </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
public virtual Response<PlayAudioResponse> PlayAudio(string conversationId, PlayAudioOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudio)}");
scope.Start();
try
{
Argument.AssertNotNull(audioFileUri, nameof(audioFileUri));
Argument.AssertNotNull(options, nameof(options));

// Currently looping media is not supported for out-call scenarios, thus setting it to false.
return RestClient.PlayAudio(conversationId, audioFileUri.AbsoluteUri, false, operationContext, audioFileId, callbackUri?.AbsoluteUri, cancellationToken);
return RestClient.PlayAudio(conversationId, options.AudioFileUri?.AbsoluteUri, false, options.OperationContext, options.AudioFileId, options.CallbackUri?.AbsoluteUri, cancellationToken);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CreateCallOptions
/// <summary> The requested call events to subscribe to. </summary>
public IList<EventSubscriptionType> RequestedCallEvents { get; }

/// <summary> Initializes a new instance of CreateCallRequest. </summary>
/// <summary> Initializes a new instance of CreateCallOptions. </summary>
/// <param name="callbackUri"> The callback URI. </param>
/// <param name="requestedModalities"> The requested modalities. </param>
/// <param name="requestedCallEvents"> The requested call events to subscribe to. </param>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;

namespace Azure.Communication.Calling.Server
{
/// <summary> The options for joining a call. </summary>
public class JoinCallOptions
{
/// <summary> The subject. </summary>
public string Subject { get; set; }

/// <summary> The callback URI. </summary>
public Uri CallbackUri { get; }

/// <summary> The requested modalities. </summary>
public IList<CallModality> RequestedModalities { get; }

/// <summary> The requested call events to subscribe to. </summary>
public IList<EventSubscriptionType> RequestedCallEvents { get; }

/// <summary> Initializes a new instance of JoinCallOptions. </summary>
/// <param name="callbackUri"> The callback URI. </param>
/// <param name="requestedModalities"> The requested modalities. </param>
/// <param name="requestedCallEvents"> The requested call events to subscribe to. </param>
/// <exception cref="ArgumentNullException"> <paramref name="callbackUri"/>, <paramref name="requestedModalities"/>, or <paramref name="requestedCallEvents"/> is null. </exception>
public JoinCallOptions(Uri callbackUri, IEnumerable<CallModality> requestedModalities, IEnumerable<EventSubscriptionType> requestedCallEvents)
{
if (callbackUri == null)
{
throw new ArgumentNullException(nameof(callbackUri));
}
if (requestedModalities == null)
{
throw new ArgumentNullException(nameof(requestedModalities));
}
if (requestedCallEvents == null)
{
throw new ArgumentNullException(nameof(requestedCallEvents));
}

CallbackUri = callbackUri;
RequestedModalities = requestedModalities.ToList();
RequestedCallEvents = requestedCallEvents.ToList();
}
}
}