CallStore

abstract class CallStore

Audio/video call management APIs for initiating, answering, rejecting, hanging up calls, group call management, and call history management.

Overview

CallStore Manages all audio/video call related operations, including initiating, answering, rejecting, hanging up, group call management, and call history management. Audio/video call functionality is implemented through CallStore for real-time audio/video interaction between users. CallStore provides a comprehensive set of APIs to manage the entire call lifecycle.

Key Features

  • Create Audio/Video Calls:Support initiating audio or video calls to one or multiple users, with configurable timeout, custom data, and other parameters

  • Answer/Reject Audio/Video Calls:When receiving an incoming call invitation, you can choose to answer or reject

  • Hang Up Audio/Video Calls:End the current ongoing audio/video call

  • Group Call Management:Support joining existing group calls or inviting other users to join during a call

  • Call History Management:Query recent call records (with pagination support), delete specified call records

  • Event-Driven Architecture:Provides event listeners for call started, call received, call ended, etc.

  • State Subscription:Real-time subscription to current call state, including participant list, volume information, network quality, etc.

Important: Ensure the SDK is initialized before accessing the CallStore.shared singleton. Do not instantiate it directly, as doing so will prevent you from receiving call state updates.

Tip: Call state updates are delivered through the callState publisher. Subscribe to it to receive real-time updates of call data.

Call Operations Overview

The following table shows the main call operations

FeatureMethodDescription
Create CallcallsCreate an audio or video call to specified users
Answer CallacceptAnswer an incoming call
Reject CallrejectReject an incoming call
Hang Up CallhangupHang up the current call
Join CalljoinActively join a group call
Invite UsersinviteInvite other users to join the current call

Call History Management

FeatureMethodDescription
Query RecordsqueryRecentCallsQuery recent call records (with pagination support)
Delete RecordsdeleteRecentCallsDelete specified call records

Usage Example

import io.trtc.tuikit.atomicxcore.api.call.*

// Create a video call
CallStore.shared.calls(
participantIds = listOf("mike"),
callMediaType = CallMediaType.VIDEO,
params = null
) { code, message ->
}

Warning: Please ensure proper handling of UI state after the call ends to avoid UI anomalies.

Topics

Get Instance

Observe State and Events

Call Operations

Call History

See Also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

CallStore singleton instance

Properties

Link copied to clipboard
abstract val observerState: CallState

Current call state, including active call, participant list, volume information, network quality, etc.

Functions

Link copied to clipboard
abstract fun accept(completion: CompletionHandler?)

Answer a call. Call this method to answer the call when receiving an incoming call invitation.

Link copied to clipboard
abstract fun addListener(listener: CallListener)

Add call event callback listener

Link copied to clipboard
abstract fun calls(userIdList: List<String>, mediaType: CallMediaType, params: CallParams?, completion: CompletionHandler?)

Create an audio or video call to specified users, supporting both one-on-one and group calls.

Link copied to clipboard
abstract fun deleteRecentCalls(callIdList: List<String>, completion: CompletionHandler?)

Delete specified call records.

Link copied to clipboard
abstract fun hangup(completion: CompletionHandler?)

Hang up and end the current ongoing call.

Link copied to clipboard
abstract fun invite(participantIds: List<String>, params: CallParams?, completion: CompletionHandler?)

Invite other users to join during an ongoing call.

Link copied to clipboard
abstract fun join(callId: String, completion: CompletionHandler?)

Join an ongoing group call using a specific call ID.

Link copied to clipboard
abstract fun queryRecentCalls(cursor: String, count: Int, completion: CompletionHandler?)

Query recent call records with pagination support. Pass an empty string as the initial cursor. For subsequent requests, use the cursor returned in the previous response to fetch the next page. Results are updated asynchronously in state.recentCalls.

Link copied to clipboard
abstract fun reject(completion: CompletionHandler?)

Reject a call. Call this method to reject the call when receiving an incoming call invitation.

Link copied to clipboard
abstract fun removeListener(listener: CallListener)

Remove call event callback listener