Muokkaa

Jaa


Quickstart: Manage a room call

Introduction

During an Azure Communication Services (ACS) room call, you can manage the call using Calling SDKs or Call Automation SDKs or both. In a room call, you can control in-call actions using both the roles assigned to participants and properties configured in the room. The participant's roles control capabilities permitted per participant, while room properties apply to the room call as a whole.

Calling SDKs

Calling SDK is a client-side calling library enabling participants in a room call to perform several in-call operations, such as screen share, turn on/off video, mute/unmute, and so on. For the full list of capabilities, see Calling SDK Overview.

You control the capabilities based on roles assigned to participants in the call. For example, only the presenter can screen share. For participant roles and permissions, see Rooms concepts.

Call Automation SDKs

Call Automation SDK is a server-side library enabling administrators to manage an ongoing room call in a central and controlled environment. Unlike Calling SDK, Call Automation SDK operations are roles agnostic. Therefore, a call administrator can perform several in-call operations on behalf of the room call participants.

The following lists describe common in-call actions available in a room call.

Connect to a room call

Call Automation must connect to an existing room call before performing any in-call operations. The CallConnected or ConnectFailed events are raised using callback mechanisms to indicate if a connect operation was successful or failed respectively.

Uri callbackUri = new Uri("https://<myendpoint>/Events"); //the callback endpoint where you want to receive subsequent events
CallLocator roomCallLocator = new RoomCallLocator("<RoomId>");
ConnectCallResult response = await client.ConnectAsync(roomCallLocator, callbackUri);

Once successfully connected to a room call, a CallConnect event is notified via Callback URI. You can use callConnectionId to retrieve a call connection on the room call as needed. The following sample code snippets use the callConnectionId to demonstrate this function.

Add PSTN participant

Using Call Automation you can dial out to a PSTN number and add the participant into a room call. You must, however, set up a room to enable PSTN dial-out option (EnabledPSTNDialout set to true) and the Azure Communication Services resource must have a valid phone number provisioned.

For more information, see Rooms quickstart.

var callerIdNumber = new PhoneNumberIdentifier("+16044561234"); // This is the ACS-provisioned phone number for the caller  
var callThisPerson = new CallInvite(new PhoneNumberIdentifier("+16041234567"), callerIdNumber); // The target phone number to dial out to
CreateCallResult response = await client.GetCallConnection(callConnectionId).AddParticipantAsync(callThisPerson);

Remove PSTN participant


var removeThisUser = new PhoneNumberIdentifier("+16044561234");

// Remove a participant from the call with optional parameters
var removeParticipantOptions = new RemoveParticipantOptions(removeThisUser)
{
    OperationContext = "operationContext",
    OperationCallbackUri = new Uri("uri_endpoint"); // Sending event to a non-default endpoint
}

RemoveParticipantsResult result = await client.GetCallConnection(callConnectionId).RemoveParticipantAsync(removeParticipantOptions);

Send DTMF

Send a list of DTMF tones to an external participant.

var tones = new DtmfTone[] { DtmfTone.One, DtmfTone.Two, DtmfTone.Three, DtmfTone.Pound }; 
var sendDtmfTonesOptions = new SendDtmfTonesOptions(tones, new PhoneNumberIdentifier(calleePhonenumber))
{ 
	OperationContext = "dtmfs-to-ivr" 
}; 

var sendDtmfAsyncResult = await callAutomationClient.GetCallConnection(callConnectionId).GetCallMedia().SendDtmfTonesAsync(sendDtmfTonesOptions);

Call recording

Azure Communication Services rooms support recording capabilities including start, stop, pause, resume, and so on, provided by Call Automation. See the following code snippets to start/stop/pause/resume a recording in a room call. For a complete list of actions, see Call Automation recording.

// Start recording
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
   RecordingContent = RecordingContent.Audio,
   RecordingChannel = RecordingChannel.Unmixed,
   RecordingFormat = RecordingFormat.Wav,
   RecordingStateCallbackUri = new Uri("<CallbackUri>"),
   RecordingStorage = RecordingStorage.CreateAzureBlobContainerRecordingStorage(new Uri("<YOUR_STORAGE_CONTAINER_URL>"))
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording()
.StartAsync(recordingOptions);

// Pause recording using recordingId received in response of start recording.
var pauseRecording = await callAutomationClient.GetCallRecording ().PauseAsync(recordingId);

// Resume recording using recordingId received in response of start recording.
var resumeRecording = await callAutomationClient.GetCallRecording().ResumeAsync(recordingId);

// Stop recording using recordingId received in response of start recording.
var stopRecording = await callAutomationClient.GetCallRecording().StopAsync(recordingId);

Terminate a call

You can use the Call Automation SDK Hang Up action to terminate a call. When the Hang Up action completes, the SDK publishes a CallDisconnected event.

_ = await client.GetCallConnection(callConnectionId).HangUpAsync(forEveryone: true); 

Other actions

The following in-call actions are also supported in a room call.

  1. Add participant (ACS identifier)
  2. Remove participant (ACS identifier)
  3. Cancel add participant (ACS identifier and PSTN number)
  4. Hang up call
  5. Get participant (ACS identifier and PSTN number)
  6. Get multiple participants (ACS identifier and PSTN number)
  7. Get latest info about a call
  8. Play both audio files and text
  9. Play all both audio files and text
  10. Recognize both DTMF and speech
  11. Recognize continuous DTMF

For more information, see call actions and media actions.

Next steps

In this section you learned how to:

  • Join a room call from your application
  • Add in-call actions into a room call using calling SDKs
  • Add in-call actions into a room call using Call Automation SDKs

You may also want to: