Skip to content

Commit 79eb436

Browse files
authored
Update audio-streaming-quickstart-java.md
code snippets updated for GA
1 parent d73e2f9 commit 79eb436

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

articles/communication-services/how-tos/call-automation/includes/audio-streaming-quickstart-java.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,25 @@ When Azure Communication Services receives the URL for your WebSocket server, it
4646
To start media streaming during the call, you can use the API. To do so, set the `startMediaStreaming` parameter to `false` (which is the default), and later in the call, you can use the start API to enable media streaming.
4747

4848
``` Java
49-
MediaStreamingOptions mediaStreamingOptions = new MediaStreamingOptions(appConfig.getTransportUrl(), MediaStreamingTransport.WEBSOCKET, MediaStreamingContent.AUDIO, MediaStreamingAudioChannel.MIXED, false)
50-
.setEnableBidirectional(true)
51-
.setAudioFormat(AudioFormat.PCM_24K_MONO);
49+
MediaStreamingOptions mediaStreamingOptions = new MediaStreamingOptions(MediaStreamingAudioChannel.UNMIXED);
50+
mediaStreamingOptions.setTransportUrl(appConfig.getTransportUrl());
51+
mediaStreamingOptions.setStartMediaStreaming(true);
52+
mediaStreamingOptions.setEnableDtmfTones(true); // Allow receiving DTMF tones
53+
mediaStreamingOptions.setEnableBidirectional(true);
54+
mediaStreamingOptions.setAudioFormat(AudioFormat.PCM_24K_MONO);
5255

5356
options = new AnswerCallOptions(data.getString(INCOMING_CALL_CONTEXT), callbackUri)
5457
.setCallIntelligenceOptions(callIntelligenceOptions)
5558
.setMediaStreamingOptions(mediaStreamingOptions);
5659

5760
Response answerCallResponse = client.answerCallWithResponse(options, Context.NONE);
5861

59-
StartMediaStreamingOptions startMediaStreamingOptions = new StartMediaStreamingOptions()
60-
.setOperationContext("startMediaStreamingContext");
62+
StartMediaStreamingOptions mediaStreamingOptions = new StartMediaStreamingOptions();
63+
mediaStreamingOptions.setOperationContext("StartMediaStreamingContext");
6164

62-
callConnection.getCallMedia().startMediaStreamingWithResponse(startMediaStreamingOptions, Context.NONE);    
65+
client.getCallConnection(callConnectionId)
66+
.getCallMedia()
67+
.startMediaStreamingWithResponse(mediaStreamingOptions, Context.NONE);   
6368
```
6469

6570
## Stop audio streaming
@@ -68,9 +73,12 @@ To stop receiving audio streams during a call, you can use the **Stop streaming
6873
- **Automatic stop on call disconnect:** Audio streaming automatically stops when the call is disconnected.
6974

7075
``` Java
71-
StopMediaStreamingOptions stopMediaStreamingOptions = new StopMediaStreamingOptions()
72-
.setOperationContext("stopMediaStreamingContext");
73-
callConnection.getCallMedia().stopMediaStreamingWithResponse(stopMediaStreamingOptions, Context.NONE);
76+
StopMediaStreamingOptions stopOptions = new StopMediaStreamingOptions();
77+
stopOptions.setOperationContext("StopMediaStreamingContext");
78+
79+
client.getCallConnection(callConnectionId)
80+
.getCallMedia()
81+
.stopMediaStreamingWithResponse(stopOptions, Context.NONE);
7482
```
7583

7684
## Handling audio streams in your websocket server

0 commit comments

Comments
 (0)