From 0015b253ac46b70dea243e11e31b87328bc1e4ca Mon Sep 17 00:00:00 2001 From: Pilli Vamshi Date: Wed, 15 Jan 2025 19:14:22 +0530 Subject: [PATCH 1/3] Media streaming audio format default Pcm24kMono changed to null. --- .../CallAutomationAsyncClient.java | 5 +- .../CallMediaAsyncAutomatedLiveTests.java | 120 ++++++++++++++++++ 2 files changed, 121 insertions(+), 4 deletions(-) diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java index ab277b6c9987..81a4315c9a4b 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java @@ -34,7 +34,6 @@ import com.azure.communication.callautomation.implementation.models.TranscriptionTransportTypeInternal; import com.azure.communication.callautomation.models.AnswerCallOptions; import com.azure.communication.callautomation.models.AnswerCallResult; -import com.azure.communication.callautomation.models.AudioFormat; import com.azure.communication.callautomation.models.CallInvite; import com.azure.communication.callautomation.models.CallLocator; import com.azure.communication.callautomation.models.CallLocatorKind; @@ -325,9 +324,7 @@ private CreateCallRequestInternal getCreateCallRequestInternal(CreateGroupCallOp MediaStreamingTransportTypeInternal.fromString(mediaStreamingOptions.getTransportType().toString())) .setStartMediaStreaming(mediaStreamingOptions.isStartMediaStreamingEnabled()) .setEnableBidirectional(mediaStreamingOptions.isEnableBidirectional()) - .setAudioFormat(mediaStreamingOptions.getAudioFormat() != null - ? AudioFormatInternal.fromString(mediaStreamingOptions.getAudioFormat().toString()) - : AudioFormatInternal.fromString(AudioFormat.PCM_24K_MONO.toString())); + .setAudioFormat(AudioFormatInternal.fromString(mediaStreamingOptions.getAudioFormat() != null ? mediaStreamingOptions.getAudioFormat().toString() : null )); } private TranscriptionOptionsInternal getTranscriptionOptionsInternal(TranscriptionOptions transcriptionOptions) { diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java index e8ad1c76de3d..8fcd0fa1fae9 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java @@ -61,6 +61,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import com.azure.communication.callautomation.models.AudioFormat; + public class CallMediaAsyncAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase { @ParameterizedTest @@ -502,6 +504,124 @@ public void createVOIPCallAndMediaStreamingTest(HttpClient httpClient) { } } + @ParameterizedTest + @MethodSource("com.azure.core.test.TestBase#getHttpClients") + @DisabledIfEnvironmentVariable( + named = "SKIP_LIVE_TEST", + matches = "(?i)(true)", + disabledReason = "Requires environment to be set up") + public void createVOIPCallAndMediaStreamingWithAudioFormatPcm24KMonoTest(HttpClient httpClient) { + /* Test case: ACS to ACS call and Media Streaming + * 1. create a CallAutomationClient. + * 2. Start Media Streaming with 24K mono and Stop Media Streaming + * 3. See Media Streaming sterted and stoped in call + */ + + CommunicationIdentityAsyncClient identityAsyncClient + = getCommunicationIdentityClientUsingConnectionString(httpClient) + .addPolicy((context, next) -> logHeaders("createVOIPCallAndMediaStreamingTest", next)) + .buildAsyncClient(); + + List callDestructors = new ArrayList<>(); + + try { + // create caller and receiver + CommunicationUserIdentifier caller = identityAsyncClient.createUser().block(); + CommunicationIdentifier target = identityAsyncClient.createUser().block(); + + // Create call automation client and use source as the caller. + CallAutomationAsyncClient callerAsyncClient = getCallAutomationClientUsingConnectionString(httpClient) + .addPolicy((context, next) -> logHeaders("createVOIPCallAndRejectAutomatedTest", next)) + .sourceIdentity(caller) + .buildAsyncClient(); + // Create call automation client for receivers. + CallAutomationAsyncClient receiverAsyncClient = getCallAutomationClientUsingConnectionString(httpClient) + .addPolicy((context, next) -> logHeaders("createVOIPCallAndRejectAutomatedTest", next)) + .buildAsyncClient(); + + String uniqueId = serviceBusWithNewCall(caller, target); + + // create options + List targets = new ArrayList<>(Collections.singletonList(target)); + MediaStreamingOptions mediaStreamingOptions + = new MediaStreamingOptions(TRANSPORT_URL, MediaStreamingTransport.WEBSOCKET, + MediaStreamingContent.AUDIO, MediaStreamingAudioChannel.MIXED, false); + mediaStreamingOptions.setAudioFormat(AudioFormat.PCM_24K_MONO); + CreateGroupCallOptions createCallOptions + = new CreateGroupCallOptions(targets, DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); + + createCallOptions.setMediaStreamingOptions(mediaStreamingOptions); + + // create a call + Response createCallResultResponse + = callerAsyncClient.createGroupCallWithResponse(createCallOptions).block(); + assertNotNull(createCallResultResponse); + + // validate the call + CreateCallResult createCallResult = createCallResultResponse.getValue(); + assertNotNull(createCallResult); + assertNotNull(createCallResult.getCallConnectionProperties()); + + // get call connection id + String callerConnectionId = createCallResult.getCallConnectionProperties().getCallConnectionId(); + assertNotNull(callerConnectionId); + + // wait for the incomingCallContext + String incomingCallContext = waitForIncomingCallContext(uniqueId, Duration.ofSeconds(10)); + assertNotNull(incomingCallContext); + + // answer the call + AnswerCallOptions answerCallOptions + = new AnswerCallOptions(incomingCallContext, DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); + AnswerCallResult answerCallResult + = Objects.requireNonNull(receiverAsyncClient.answerCallWithResponse(answerCallOptions).block()) + .getValue(); + assertNotNull(answerCallResult); + assertNotNull(answerCallResult.getCallConnectionAsync()); + assertNotNull(answerCallResult.getCallConnectionProperties()); + callDestructors.add(answerCallResult.getCallConnectionAsync()); + + // wait for callConnected + CallConnected callConnected = waitForEvent(CallConnected.class, callerConnectionId, Duration.ofSeconds(10)); + assertNotNull(callConnected); + + // Start Media Streaming + StartMediaStreamingOptions startMediaStreamingOptions = new StartMediaStreamingOptions(); + // startMediaStreamingOptions.setOperationCallbackUrl(DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); + CallMediaAsync callMedia = callerAsyncClient.getCallConnectionAsync(callerConnectionId).getCallMediaAsync(); + + System.out.println("TRANSPORT_URL: " + TRANSPORT_URL); + callMedia.startMediaStreamingWithResponse(startMediaStreamingOptions).block(); + + MediaStreamingStarted mediaStreamingStarted + = waitForEvent(MediaStreamingStarted.class, callerConnectionId, Duration.ofSeconds(10)); + assertNotNull(mediaStreamingStarted); + + // Stop Media Streaming + StopMediaStreamingOptions stopMediaStreamingOptions = new StopMediaStreamingOptions(); + // stopMediaStreamingOptions.setOperationCallbackUrl(DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); + + callerAsyncClient.getCallConnectionAsync(callerConnectionId) + .getCallMediaAsync() + .stopMediaStreamingWithResponse(stopMediaStreamingOptions) + .block(); + MediaStreamingStopped mediaStreamingStopped + = waitForEvent(MediaStreamingStopped.class, callerConnectionId, Duration.ofSeconds(10)); + assertNotNull(mediaStreamingStopped); + } catch (Exception ex) { + fail("Unexpected exception received", ex); + } finally { + if (!callDestructors.isEmpty()) { + try { + callDestructors.forEach(callConnection -> callConnection.hangUpWithResponse(true).block()); + } catch (Exception ignored) { + // Some call might have been terminated during the test, and it will cause exceptions here. + // Do nothing and iterate to next call connection. + } + } + } + } + @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( From fc33f5f23435674ca7fc3de9e9d6ae7d15fab9a4 Mon Sep 17 00:00:00 2001 From: Vinothini Dharmaraj Date: Wed, 15 Jan 2025 11:12:03 -0800 Subject: [PATCH 2/3] removing the live test --- .../CallAutomationAsyncClient.java | 4 +- .../CallMediaAsyncAutomatedLiveTests.java | 118 ------------------ 2 files changed, 3 insertions(+), 119 deletions(-) diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java index 81a4315c9a4b..f2764d4f3da2 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallAutomationAsyncClient.java @@ -324,7 +324,9 @@ private CreateCallRequestInternal getCreateCallRequestInternal(CreateGroupCallOp MediaStreamingTransportTypeInternal.fromString(mediaStreamingOptions.getTransportType().toString())) .setStartMediaStreaming(mediaStreamingOptions.isStartMediaStreamingEnabled()) .setEnableBidirectional(mediaStreamingOptions.isEnableBidirectional()) - .setAudioFormat(AudioFormatInternal.fromString(mediaStreamingOptions.getAudioFormat() != null ? mediaStreamingOptions.getAudioFormat().toString() : null )); + .setAudioFormat(AudioFormatInternal.fromString(mediaStreamingOptions.getAudioFormat() != null + ? mediaStreamingOptions.getAudioFormat().toString() + : null)); } private TranscriptionOptionsInternal getTranscriptionOptionsInternal(TranscriptionOptions transcriptionOptions) { diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java index 8fcd0fa1fae9..1db5f3f1cf2b 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java @@ -504,124 +504,6 @@ public void createVOIPCallAndMediaStreamingTest(HttpClient httpClient) { } } - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - @DisabledIfEnvironmentVariable( - named = "SKIP_LIVE_TEST", - matches = "(?i)(true)", - disabledReason = "Requires environment to be set up") - public void createVOIPCallAndMediaStreamingWithAudioFormatPcm24KMonoTest(HttpClient httpClient) { - /* Test case: ACS to ACS call and Media Streaming - * 1. create a CallAutomationClient. - * 2. Start Media Streaming with 24K mono and Stop Media Streaming - * 3. See Media Streaming sterted and stoped in call - */ - - CommunicationIdentityAsyncClient identityAsyncClient - = getCommunicationIdentityClientUsingConnectionString(httpClient) - .addPolicy((context, next) -> logHeaders("createVOIPCallAndMediaStreamingTest", next)) - .buildAsyncClient(); - - List callDestructors = new ArrayList<>(); - - try { - // create caller and receiver - CommunicationUserIdentifier caller = identityAsyncClient.createUser().block(); - CommunicationIdentifier target = identityAsyncClient.createUser().block(); - - // Create call automation client and use source as the caller. - CallAutomationAsyncClient callerAsyncClient = getCallAutomationClientUsingConnectionString(httpClient) - .addPolicy((context, next) -> logHeaders("createVOIPCallAndRejectAutomatedTest", next)) - .sourceIdentity(caller) - .buildAsyncClient(); - // Create call automation client for receivers. - CallAutomationAsyncClient receiverAsyncClient = getCallAutomationClientUsingConnectionString(httpClient) - .addPolicy((context, next) -> logHeaders("createVOIPCallAndRejectAutomatedTest", next)) - .buildAsyncClient(); - - String uniqueId = serviceBusWithNewCall(caller, target); - - // create options - List targets = new ArrayList<>(Collections.singletonList(target)); - MediaStreamingOptions mediaStreamingOptions - = new MediaStreamingOptions(TRANSPORT_URL, MediaStreamingTransport.WEBSOCKET, - MediaStreamingContent.AUDIO, MediaStreamingAudioChannel.MIXED, false); - mediaStreamingOptions.setAudioFormat(AudioFormat.PCM_24K_MONO); - CreateGroupCallOptions createCallOptions - = new CreateGroupCallOptions(targets, DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); - - createCallOptions.setMediaStreamingOptions(mediaStreamingOptions); - - // create a call - Response createCallResultResponse - = callerAsyncClient.createGroupCallWithResponse(createCallOptions).block(); - assertNotNull(createCallResultResponse); - - // validate the call - CreateCallResult createCallResult = createCallResultResponse.getValue(); - assertNotNull(createCallResult); - assertNotNull(createCallResult.getCallConnectionProperties()); - - // get call connection id - String callerConnectionId = createCallResult.getCallConnectionProperties().getCallConnectionId(); - assertNotNull(callerConnectionId); - - // wait for the incomingCallContext - String incomingCallContext = waitForIncomingCallContext(uniqueId, Duration.ofSeconds(10)); - assertNotNull(incomingCallContext); - - // answer the call - AnswerCallOptions answerCallOptions - = new AnswerCallOptions(incomingCallContext, DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); - AnswerCallResult answerCallResult - = Objects.requireNonNull(receiverAsyncClient.answerCallWithResponse(answerCallOptions).block()) - .getValue(); - assertNotNull(answerCallResult); - assertNotNull(answerCallResult.getCallConnectionAsync()); - assertNotNull(answerCallResult.getCallConnectionProperties()); - callDestructors.add(answerCallResult.getCallConnectionAsync()); - - // wait for callConnected - CallConnected callConnected = waitForEvent(CallConnected.class, callerConnectionId, Duration.ofSeconds(10)); - assertNotNull(callConnected); - - // Start Media Streaming - StartMediaStreamingOptions startMediaStreamingOptions = new StartMediaStreamingOptions(); - // startMediaStreamingOptions.setOperationCallbackUrl(DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); - CallMediaAsync callMedia = callerAsyncClient.getCallConnectionAsync(callerConnectionId).getCallMediaAsync(); - - System.out.println("TRANSPORT_URL: " + TRANSPORT_URL); - callMedia.startMediaStreamingWithResponse(startMediaStreamingOptions).block(); - - MediaStreamingStarted mediaStreamingStarted - = waitForEvent(MediaStreamingStarted.class, callerConnectionId, Duration.ofSeconds(10)); - assertNotNull(mediaStreamingStarted); - - // Stop Media Streaming - StopMediaStreamingOptions stopMediaStreamingOptions = new StopMediaStreamingOptions(); - // stopMediaStreamingOptions.setOperationCallbackUrl(DISPATCHER_CALLBACK + String.format("?q=%s", uniqueId)); - - callerAsyncClient.getCallConnectionAsync(callerConnectionId) - .getCallMediaAsync() - .stopMediaStreamingWithResponse(stopMediaStreamingOptions) - .block(); - MediaStreamingStopped mediaStreamingStopped - = waitForEvent(MediaStreamingStopped.class, callerConnectionId, Duration.ofSeconds(10)); - assertNotNull(mediaStreamingStopped); - } catch (Exception ex) { - fail("Unexpected exception received", ex); - } finally { - if (!callDestructors.isEmpty()) { - try { - callDestructors.forEach(callConnection -> callConnection.hangUpWithResponse(true).block()); - } catch (Exception ignored) { - // Some call might have been terminated during the test, and it will cause exceptions here. - // Do nothing and iterate to next call connection. - } - } - } - } - @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( From c24475bf9ccad8622f96dfc8e73243879566b239 Mon Sep 17 00:00:00 2001 From: Vinothini Dharmaraj Date: Wed, 15 Jan 2025 11:13:53 -0800 Subject: [PATCH 3/3] removing unused import --- .../callautomation/CallMediaAsyncAutomatedLiveTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java index 1db5f3f1cf2b..e8ad1c76de3d 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java @@ -61,8 +61,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import com.azure.communication.callautomation.models.AudioFormat; - public class CallMediaAsyncAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase { @ParameterizedTest