Skip to content

Commit

Permalink
Merge pull request #1 from navali-msft/2021-09-15-satyakon
Browse files Browse the repository at this point in the history
play audio and cancel media operation apis
  • Loading branch information
satyakonmsft committed Sep 14, 2021
2 parents 248d926 + b631d5e commit e27da7a
Show file tree
Hide file tree
Showing 9 changed files with 1,204 additions and 213 deletions.
5 changes: 5 additions & 0 deletions sdk/communication/azure-communication-callingserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
<version>1.3.5</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-callingserver</artifactId>
<version>1.0.0-beta.3</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.azure.communication.callingserver.models.CreateCallOptions;
import com.azure.communication.callingserver.models.JoinCallOptions;
import com.azure.communication.callingserver.models.ParallelDownloadOptions;
import com.azure.communication.callingserver.models.PlayAudioOptions;
import com.azure.communication.callingserver.models.PlayAudioResult;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand All @@ -20,7 +22,6 @@
import java.util.List;
import java.util.Objects;


/**
* Synchronous client that supports calling server operations.
*
Expand Down Expand Up @@ -76,7 +77,7 @@ public Response<CallConnection> createCallConnectionWithResponse(
CommunicationIdentifier source,
List<CommunicationIdentifier> targets,
CreateCallOptions createCallOptions,
final Context context) {
Context context) {
return callingServerAsyncClient
.createCallConnectionWithResponseInternal(source, targets, createCallOptions, context).block();
}
Expand Down Expand Up @@ -115,7 +116,7 @@ public Response<CallConnection> joinCallWithResponse(
String serverCallId,
CommunicationIdentifier source,
JoinCallOptions joinCallOptions,
final Context context) {
Context context) {
return callingServerAsyncClient.joinWithResponseInternal(serverCallId, source, joinCallOptions, context).block();
}

Expand Down Expand Up @@ -149,7 +150,7 @@ public ServerCall initializeServerCall(String serverCallId) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void downloadTo(String sourceEndpoint, OutputStream destinationStream, HttpRange httpRange) {
downloadToWithResponse(sourceEndpoint, destinationStream, httpRange, null);
downloadToWithResponse(sourceEndpoint, destinationStream, httpRange, Context.NONE);
}

/**
Expand All @@ -166,7 +167,7 @@ public void downloadTo(String sourceEndpoint, OutputStream destinationStream, Ht
public Response<Void> downloadToWithResponse(String sourceEndpoint,
OutputStream destinationStream,
HttpRange httpRange,
final Context context) {
Context context) {
Objects.requireNonNull(sourceEndpoint, "'sourceEndpoint' cannot be null");
Objects.requireNonNull(destinationStream, "'destinationStream' cannot be null");
return callingServerAsyncClient
Expand All @@ -188,7 +189,7 @@ public void downloadTo(String sourceEndpoint,
Path destinationPath,
ParallelDownloadOptions parallelDownloadOptions,
boolean overwrite) {
downloadToWithResponse(sourceEndpoint, destinationPath, parallelDownloadOptions, overwrite, null);
downloadToWithResponse(sourceEndpoint, destinationPath, parallelDownloadOptions, overwrite, Context.NONE);
}

/**
Expand All @@ -207,12 +208,136 @@ public Response<Void> downloadToWithResponse(String sourceEndpoint,
Path destinationPath,
ParallelDownloadOptions parallelDownloadOptions,
boolean overwrite,
final Context context) {
Context context) {
Objects.requireNonNull(sourceEndpoint, "'sourceEndpoint' cannot be null");
Objects.requireNonNull(destinationPath, "'destinationPath' cannot be null");
return callingServerAsyncClient.downloadToWithResponse(sourceEndpoint, destinationPath,
parallelDownloadOptions, overwrite, context).block();
}

/**
* Play audio in the call.
*
* @param serverCallId The server call id.
* @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
* audio prompts are supported. More specifically, the audio content in the wave file must
* be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
* @param playAudioOptions Options for play audio.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response payload for play audio operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PlayAudioResult playAudio(String serverCallId, String audioFileUri, PlayAudioOptions playAudioOptions, Context context) {
return callingServerAsyncClient.playAudioInternal(serverCallId, audioFileUri, playAudioOptions, context).block();
}

/**
* Play audio in the call.
*
* @param serverCallId The server call id.
* @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
* audio prompts are supported. More specifically, the audio content in the wave file must
* be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
* @param playAudioOptions Options for play audio.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response payload for play audio operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PlayAudioResult> playAudioWithResponse(
String serverCallId,
String audioFileUri,
PlayAudioOptions playAudioOptions,
Context context) {
return callingServerAsyncClient
.playAudioWithResponseInternal(serverCallId, audioFileUri, playAudioOptions, context)
.block();
}

/**
* Cancel Participant Media Operation.
*
* @param serverCallId The server call id.
* @param participantId The participant id.
* @param mediaOperationId The Id of the media operation to Cancel.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response containing the http response information
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void cancelParticipantMediaOperation(String serverCallId, String participantId, String mediaOperationId, Context context) {
cancelParticipantMediaOperationWithResponse(serverCallId, participantId, mediaOperationId, context);
}

/**
* Cancel Participant Media Operation.
*
* @param serverCallId The server call id.
* @param participantId The participant id.
* @param mediaOperationId The Id of the media operation to Cancel.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response containing the http response information
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> cancelParticipantMediaOperationWithResponse(
String serverCallId,
String participantId,
String mediaOperationId,
Context context) {
return callingServerAsyncClient
.cancelParticipantMediaOperationWithResponseInternal(serverCallId, participantId, mediaOperationId, context).block();
}

/**
* Play audio to a participant.
*
* @param serverCallId The server call id.
* @param participantId The participant id.
* @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
* audio prompts are supported. More specifically, the audio content in the wave file must
* be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
* @param playAudioOptions Options for play audio.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response payload for play audio to participant operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PlayAudioResult playAudioToParticipant(String serverCallId, String participantId, String audioFileUri, PlayAudioOptions playAudioOptions, Context context) {
return callingServerAsyncClient.playAudioToParticipantInternal(serverCallId, participantId, audioFileUri, playAudioOptions, context).block();
}

/**
* Play audio to a participant.
*
* @param serverCallId The server call id.
* @param participantId The participant id.
* @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
* audio prompts are supported. More specifically, the audio content in the wave file must
* be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
* @param playAudioOptions Options for play audio.
* @param context A {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response payload for play audio to participant operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PlayAudioResult> playAudioToParticipantWithResponse(
String serverCallId,
String participantId,
String audioFileUri,
PlayAudioOptions playAudioOptions,
Context context) {
return callingServerAsyncClient
.playAudioToParticipantWithResponseInternal(serverCallId, participantId, audioFileUri, playAudioOptions, context)
.block();
}
}


Loading

0 comments on commit e27da7a

Please sign in to comment.