StatefulCallClient interface

Defines the methods that allow CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> to be used statefully. The interface provides access to proxied state and also allows registering a handler for state change events. For state definition see CallClientState.

State change events are driven by:

  • Returned data from <xref:%40azure%2Fcommunication-calling%23DeviceManager> APIs.
  • Returned data from <xref:%40azure%2Fcommunication-calling%23CallAgent> APIs.
  • Listeners automatically attached to various azure communication-calling objects:
    • CallAgent 'incomingCall'
    • CallAgent 'callsUpdated'
    • DeviceManager 'videoDevicesUpdated'
    • DeviceManager 'audioDevicesUpdated
    • DeviceManager 'selectedMicrophoneChanged'
    • DeviceManager 'selectedSpeakerChanged'
    • Call 'stateChanged'
    • Call 'idChanged'
    • Call 'isMutedChanged'
    • Call 'isScreenSharingOnChanged'
    • Call 'remoteParticipantsUpdated'
    • Call 'localVideoStreamsUpdated'
    • IncomingCall 'callEnded'
    • RemoteParticipant 'stateChanged'
    • RemoteParticipant 'isMutedChanged'
    • RemoteParticipant 'displayNameChanged'
    • RemoteParticipant 'isSpeakingChanged'
    • RemoteParticipant 'videoStreamsUpdated'
    • RemoteVideoStream 'isAvailableChanged'
    • TranscriptionCallFeature 'isTranscriptionActiveChanged'
    • RecordingCallFeature 'isRecordingActiveChanged'
Extends

Methods

createView(undefined | string, undefined | CommunicationIdentifier, LocalVideoStreamState | RemoteVideoStreamState, CreateViewOptions)

Renders a RemoteVideoStreamState or LocalVideoStreamState and stores the resulting VideoStreamRendererViewState under the relevant RemoteVideoStreamState or LocalVideoStreamState or as unparented view in the state. Under the hood calls <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.createView>.

Scenario 1: Render RemoteVideoStreamState

Scenario 2: Render LocalVideoStreamState for a call

  • CallId is required, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • The <xref:%40azure%2Fcommunication-calling%23Call.localVideoStreams> must already be started using <xref:%40azure%2Fcommunication-calling%23Call.startVideo>.

  • Resulting VideoStreamRendererViewState is stored in the given callId localVideoStreams in CallClientState.

  • Scenario 2: Render LocalVideoStreamState not part of a call (example rendering camera for local preview)

  • CallId must be undefined, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • Resulting VideoStreamRendererViewState is stored in under the given LocalVideoStreamState in <xref:CallClientState.deviceManager.unparentedViews>

disposeView(undefined | string, undefined | CommunicationIdentifier, LocalVideoStreamState | RemoteVideoStreamState)

Stops rendering a RemoteVideoStreamState or LocalVideoStreamState and removes the <xref:VideoStreamRendererView> from the relevant RemoteVideoStreamState in CallClientState or <xref:LocalVideoStream> in CallClientState or appropriate <xref:CallClientState.deviceManager.unparentedViews> Under the hood calls <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.dispose>.

Its important to disposeView to clean up resources properly.

Scenario 1: Dispose RemoteVideoStreamState

  • CallId is required, participantId is required, and stream of type RemoteVideoStreamState is required

Scenario 2: Dispose LocalVideoStreamState for a call

  • CallId is required, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • Scenario 2: Dispose LocalVideoStreamState not part of a call

  • CallId must be undefined, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • LocalVideoStreamState must be the original one passed to createView.

getState()

Holds all the state that we could proxy from CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> as CallClientState CallClientState.

offStateChange((state: CallClientState) => void)

Allows unregistering for 'stateChanged' events.

onStateChange((state: CallClientState) => void)

Allows a handler to be registered for 'stateChanged' events.

Inherited Methods

createCallAgent(CommunicationTokenCredential, CallAgentOptions)

The CallAgent is used to handle calls. To create the CallAgent, pass a CommunicationTokenCredential object provided from SDK.

  • The CallClient can only have one active CallAgent instance at a time.
  • You can create a new CallClient instance to create a new CallAgent.
  • You can dispose of a CallClient's current active CallAgent, and call the CallClient's createCallAgent() method again to create a new CallAgent.
createTeamsCallAgent(CommunicationTokenCredential, TeamsCallAgentOptions)

The TeamsCallAgent is used to handle Teams calls. To create the TeamsCallAgent, pass a CommunicationTokenCredential object provided from SDK.

  • The CallClient can only have one active TeamsCallAgent instance at a time.
  • You can create a new CallClient instance to create a new TeamsCallAgent.
  • You can dispose of a CallClient's current active TeamsCallAgent, and call the CallClient's createTeamsCallAgent() method again to create a new TeamsCallAgent.
feature<TFeature>(CallClientFeatureFactory<TFeature>)

Retrieves an initialized and memoized Feature object with extended API. Check the object Features.* for all available extended call client features in this package.

getDeviceManager()

The DeviceManager is used to handle media devices such as cameras, microphones, and speakers.

Method Details

createView(undefined | string, undefined | CommunicationIdentifier, LocalVideoStreamState | RemoteVideoStreamState, CreateViewOptions)

Renders a RemoteVideoStreamState or LocalVideoStreamState and stores the resulting VideoStreamRendererViewState under the relevant RemoteVideoStreamState or LocalVideoStreamState or as unparented view in the state. Under the hood calls <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.createView>.

Scenario 1: Render RemoteVideoStreamState

Scenario 2: Render LocalVideoStreamState for a call

  • CallId is required, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • The <xref:%40azure%2Fcommunication-calling%23Call.localVideoStreams> must already be started using <xref:%40azure%2Fcommunication-calling%23Call.startVideo>.

  • Resulting VideoStreamRendererViewState is stored in the given callId localVideoStreams in CallClientState.

  • Scenario 2: Render LocalVideoStreamState not part of a call (example rendering camera for local preview)

  • CallId must be undefined, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • Resulting VideoStreamRendererViewState is stored in under the given LocalVideoStreamState in <xref:CallClientState.deviceManager.unparentedViews>

function createView(callId: undefined | string, participantId: undefined | CommunicationIdentifier, stream: LocalVideoStreamState | RemoteVideoStreamState, options?: CreateViewOptions): Promise<undefined | CreateViewResult>

Parameters

callId

undefined | string

CallId for the given stream. Can be undefined if the stream is not part of any call.

participantId

undefined | CommunicationIdentifier

<xref:RemoteParticipant.identifier> associated with the given RemoteVideoStreamState. Could be undefined if rendering LocalVideoStreamState.

stream

LocalVideoStreamState | RemoteVideoStreamState

The LocalVideoStreamState or RemoteVideoStreamState to start rendering.

options
CreateViewOptions

Options that are passed to the <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer>.

Returns

Promise<undefined | CreateViewResult>

disposeView(undefined | string, undefined | CommunicationIdentifier, LocalVideoStreamState | RemoteVideoStreamState)

Stops rendering a RemoteVideoStreamState or LocalVideoStreamState and removes the <xref:VideoStreamRendererView> from the relevant RemoteVideoStreamState in CallClientState or <xref:LocalVideoStream> in CallClientState or appropriate <xref:CallClientState.deviceManager.unparentedViews> Under the hood calls <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.dispose>.

Its important to disposeView to clean up resources properly.

Scenario 1: Dispose RemoteVideoStreamState

  • CallId is required, participantId is required, and stream of type RemoteVideoStreamState is required

Scenario 2: Dispose LocalVideoStreamState for a call

  • CallId is required, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • Scenario 2: Dispose LocalVideoStreamState not part of a call

  • CallId must be undefined, participantId must be undefined, and stream of type LocalVideoStreamState is required.

  • LocalVideoStreamState must be the original one passed to createView.

function disposeView(callId: undefined | string, participantId: undefined | CommunicationIdentifier, stream: LocalVideoStreamState | RemoteVideoStreamState)

Parameters

callId

undefined | string

CallId for the given stream. Can be undefined if the stream is not part of any call.

participantId

undefined | CommunicationIdentifier

<xref:RemoteParticipant.identifier> associated with the given RemoteVideoStreamState. Could be undefined if disposing LocalVideoStreamState.

stream

LocalVideoStreamState | RemoteVideoStreamState

The LocalVideoStreamState or RemoteVideoStreamState to dispose.

getState()

Holds all the state that we could proxy from CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> as CallClientState CallClientState.

function getState(): CallClientState

Returns

offStateChange((state: CallClientState) => void)

Allows unregistering for 'stateChanged' events.

function offStateChange(handler: (state: CallClientState) => void)

Parameters

handler

(state: CallClientState) => void

Original callback to be unsubscribed.

onStateChange((state: CallClientState) => void)

Allows a handler to be registered for 'stateChanged' events.

function onStateChange(handler: (state: CallClientState) => void)

Parameters

handler

(state: CallClientState) => void

Callback to receive the state.

Inherited Method Details

createCallAgent(CommunicationTokenCredential, CallAgentOptions)

The CallAgent is used to handle calls. To create the CallAgent, pass a CommunicationTokenCredential object provided from SDK.

  • The CallClient can only have one active CallAgent instance at a time.
  • You can create a new CallClient instance to create a new CallAgent.
  • You can dispose of a CallClient's current active CallAgent, and call the CallClient's createCallAgent() method again to create a new CallAgent.
function createCallAgent(tokenCredential: CommunicationTokenCredential, options?: CallAgentOptions): Promise<CallAgent>

Parameters

tokenCredential
CommunicationTokenCredential

The token credential. Use AzureCommunicationTokenCredential from @azure/communication-common to create a credential.

options
CallAgentOptions

The CallAgentOptions for additional options like display name.

Returns

Promise<CallAgent>

Inherited From CallClient.createCallAgent

createTeamsCallAgent(CommunicationTokenCredential, TeamsCallAgentOptions)

The TeamsCallAgent is used to handle Teams calls. To create the TeamsCallAgent, pass a CommunicationTokenCredential object provided from SDK.

  • The CallClient can only have one active TeamsCallAgent instance at a time.
  • You can create a new CallClient instance to create a new TeamsCallAgent.
  • You can dispose of a CallClient's current active TeamsCallAgent, and call the CallClient's createTeamsCallAgent() method again to create a new TeamsCallAgent.
function createTeamsCallAgent(tokenCredential: CommunicationTokenCredential, options?: TeamsCallAgentOptions): Promise<TeamsCallAgent>

Parameters

tokenCredential
CommunicationTokenCredential

The token credential. Use AzureCommunicationTokenCredential from @azure/communication-common to create a credential.

options
TeamsCallAgentOptions

The CallAgentOptions for additional options like display name.

Returns

Promise<TeamsCallAgent>

Inherited From CallClient.createTeamsCallAgent

feature<TFeature>(CallClientFeatureFactory<TFeature>)

Retrieves an initialized and memoized Feature object with extended API. Check the object Features.* for all available extended call client features in this package.

function feature<TFeature>(factory: CallClientFeatureFactory<TFeature>): TFeature

Parameters

factory

CallClientFeatureFactory<TFeature>

The factory for the call client feature constructor that provides an extended API.

Returns

TFeature

Inherited From CallClient.feature

getDeviceManager()

The DeviceManager is used to handle media devices such as cameras, microphones, and speakers.

function getDeviceManager(): Promise<DeviceManager>

Returns

Promise<DeviceManager>

Inherited From CallClient.getDeviceManager