Skip to content

Commit

Permalink
Fmorales/hold (Azure#36858)
Browse files Browse the repository at this point in the history
* Hold draft

* Adding Hold/Unhold

* updating swagger location

* Using latest swagger
  • Loading branch information
cochi2 authored Sep 21, 2023
1 parent 0fbfd34 commit f05cf65
Show file tree
Hide file tree
Showing 33 changed files with 2,904 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,56 @@ public void stopContinuousDtmfRecognition(CommunicationIdentifier targetParticip
public Response<Void> stopContinuousDtmfRecognitionWithResponse(CommunicationIdentifier targetParticipant, String operationContext, String callbackUrl, Context context) {
return callMediaAsync.stopContinuousDtmfRecognitionWithResponseInternal(targetParticipant, operationContext, callbackUrl, context).block();
}

/**
* Holds participant in call.
* @param targetParticipant the target.
* @param playSourceInfo audio to play.
* @param loop to repeat.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void startHoldMusic(CommunicationIdentifier targetParticipant,
PlaySource playSourceInfo,
boolean loop) {
return callMediaAsync.startHoldMusicAsync(targetParticipant, playSourceInfo, loop).block();
}

/**
* Holds participant in call.
* @param targetParticipant the target.
* @param playSourceInfo audio to play.
* @param loop to repeat.
* @param context Context
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> startHoldMusicWithResponse(CommunicationIdentifier targetParticipant,
PlaySource playSourceInfo,
boolean loop,
Context context) {
return callMediaAsync.startHoldMusicWithResponseInternal(targetParticipant, playSourceInfo, loop, context).block();
}

/**
* Removes hold from participant in call.
* @param targetParticipant the target.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void stopHoldMusic(CommunicationIdentifier targetParticipant) {
return callMediaAsync.stopHoldMusicAsync(targetParticipant).block();
}

/**
* Removes hold from participant in call.
* @param targetParticipant the target.
* @param context Context.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> stopHoldMusicWithResponse(CommunicationIdentifier targetParticipant,
Context context) {
return callMediaAsync.stopHoldMusicWithResponseInternal(targetParticipant, context).block();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.azure.communication.callautomation.implementation.models.DtmfToneInternal;
import com.azure.communication.callautomation.implementation.models.FileSourceInternal;
import com.azure.communication.callautomation.implementation.models.GenderTypeInternal;
import com.azure.communication.callautomation.implementation.models.HoldParticipantRequestInternal;
import com.azure.communication.callautomation.implementation.models.TextSourceInternal;
import com.azure.communication.callautomation.implementation.models.SsmlSourceInternal;
import com.azure.communication.callautomation.implementation.models.PlayOptionsInternal;
Expand All @@ -22,6 +23,7 @@
import com.azure.communication.callautomation.implementation.models.RecognizeOptionsInternal;
import com.azure.communication.callautomation.implementation.models.RecognizeRequest;
import com.azure.communication.callautomation.implementation.models.SendDtmfRequestInternal;
import com.azure.communication.callautomation.implementation.models.UnholdParticipantRequestInternal;
import com.azure.communication.callautomation.models.PlayToAllOptions;
import com.azure.communication.callautomation.models.CallMediaRecognizeChoiceOptions;
import com.azure.communication.callautomation.models.CallMediaRecognizeDtmfOptions;
Expand Down Expand Up @@ -249,14 +251,7 @@ Mono<Response<Void>> playToAllWithResponseInternal(PlayToAllOptions options, Con
}

PlayRequest getPlayRequest(PlayOptions options) {
PlaySourceInternal playSourceInternal = new PlaySourceInternal();
if (options.getPlaySource() instanceof FileSource) {
playSourceInternal = getPlaySourceInternalFromFileSource((FileSource) options.getPlaySource());
} else if (options.getPlaySource() instanceof TextSource) {
playSourceInternal = getPlaySourceInternalFromTextSource((TextSource) options.getPlaySource());
} else if (options.getPlaySource() instanceof SsmlSource) {
playSourceInternal = getPlaySourceInternalFromSsmlSource((SsmlSource) options.getPlaySource());
}
PlaySourceInternal playSourceInternal = convertPlaySourceToPlaySourceInternal(options.getPlaySource());

if (playSourceInternal.getSourceType() != null) {
PlayRequest request = new PlayRequest()
Expand Down Expand Up @@ -620,4 +615,84 @@ Mono<Response<Void>> stopContinuousDtmfRecognitionWithResponseInternal(Communica
}
}

/**
* Holds participant in call.
* @param targetParticipant the target.
* @param playSourceInfo audio to play.
* @param loop to repeat.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> startHoldMusicAsync(CommunicationIdentifier targetParticipant,
PlaySource playSourceInfo,
boolean loop) {
return startHoldMusicWithResponseAsync(targetParticipant, playSourceInfo, loop).then();
}

/**
* Holds participant in call.
* @param targetParticipant the target.
* @param playSourceInfo audio to play.
* @param loop to repeat.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> startHoldMusicWithResponseAsync(CommunicationIdentifier targetParticipant,
PlaySource playSourceInfo,
boolean loop) {
return withContext(context -> startHoldMusicWithResponseInternal(targetParticipant, playSourceInfo, loop, context));
}

Mono<Response<Void>> startHoldMusicWithResponseInternal(CommunicationIdentifier targetParticipant,
PlaySource playSourceInfo,
boolean loop,
Context context) {
try {
context = context == null ? Context.NONE : context;

HoldParticipantRequestInternal request = new HoldParticipantRequestInternal()
.setParticipantToHold(CommunicationIdentifierConverter.convert(targetParticipant))
.setPlaySourceInfo(convertPlaySourceToPlaySourceInternal(playSourceInfo))
.setLoop(loop);

return contentsInternal
.startHoldMusicWithResponseAsync(callConnectionId, request, context);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Removes hold from participant in call.
* @param targetParticipant the target.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> stopHoldMusicAsync(CommunicationIdentifier targetParticipant) {
return stopHoldMusicWithResponseAsync(targetParticipant).then();
}

/**
* Holds participant in call.
* @param targetParticipant the target.
* @return Response for successful operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> stopHoldMusicWithResponseAsync(CommunicationIdentifier targetParticipant) {
return withContext(context -> stopHoldMusicWithResponseInternal(targetParticipant, context));
}

Mono<Response<Void>> stopHoldMusicWithResponseInternal(CommunicationIdentifier targetParticipant,
Context context) {
try {
context = context == null ? Context.NONE : context;
UnholdParticipantRequestInternal request = new UnholdParticipantRequestInternal()
.setParticipantToUnhold(CommunicationIdentifierConverter.convert(targetParticipant));

return contentsInternal
.stopHoldMusicWithResponseAsync(callConnectionId, request, context);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}
}
Loading

0 comments on commit f05cf65

Please sign in to comment.