AtomicPusher
Introduction
Typical usage flow: bind the preview view via
AtomicPusher.shared.setView(view), start pushing via startPush(config), monitor state for state changes, and release resources via release().Features
PusherState: Real-time pusher state, including connection state, statistics, and live room info.
PusherEvent: Pusher event callbacks, including error, live ended, kicked out, and other event types.
Subscribable Data
PusherState fields are described below:
Property | Type | Description |
networkState | Connection state. | |
statistics | Pusher runtime statistics. | |
pusherInfo | Pusher live room info. | |
totalViewerCount | StateFlow<Int> | Total viewer count. |
API List
Function | Description |
Get the global singleton. | |
Add pusher event callback listener. | |
Remove pusher event callback listener. | |
Set the render view. | |
Start pushing (streaming). | |
Stop pushing (streaming). | |
Update live room configuration. | |
Release pusher resources. | |
Enable advanced features by key-value pair. |
Getting Instance
AtomicPusher.shared
Get the global singleton.
Observing State and Events
addListener
Add pusher event callback listener.
abstract fun addListener(listener: PusherListener?)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
listener | Listener. |
removeListener
Remove pusher event callback listener.
abstract fun removeListener(listener: PusherListener?)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
listener | Listener. |
View Management
setView
Set the render view. The locally captured video frames will be rendered into the given
AtomicLiveView container.abstract fun setView(view: AtomicLiveView)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
view | The render view container. |
Push Control
startPush
Start pushing (streaming). Pass in the live room configuration; the SDK will create the push link accordingly.
abstract fun startPush(config: PusherInfo)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
config | Live room configuration. |
stopPush
Stop pushing (streaming).
abstract fun stopPush()
Version
Supported since version 3.5.
updateConfig
Update live room configuration. Call this after
startPush to update live room info such as name, cover, category etc.abstract fun updateConfig(config: PusherInfo,modifyFlagList: List<PusherInfo.ModifyFlag>,)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
config | Updated configuration. | |
modifyFlagList | List<PusherInfo.ModifyFlag> | Modify flags. |
release
Actively release the pusher. After calling, all APIs become no-ops, and internally held underlying resources, state, and event subscriptions will be cleaned up.
abstract fun release()
Version
Supported since version 3.5.
Advanced Features
enableAdvancedFeature
Advanced feature. Enable an advanced feature by key-value pair. Supported keys depend on the underlying native pusher capability and may evolve over versions.
abstract fun enableAdvancedFeature(key: String, value: Any)
Version
Supported since version 3.5.
Parameters
Parameter | Type | Description |
key | String | Feature key. |
value | Any | Feature value, type depends on the specific key. |
Data Structures
PusherCode
Atomic pusher error code enum, used to report push operation results and runtime errors.
Enum Value | Value | Description |
OK | 0 | No error, operation succeeded. |
ERROR_INVALID_PARAMETER | -1 | Invalid parameter. |
ERROR_INVALID_STATE | -2 | The operation is not allowed in the current state (e.g. startPush again while pushing, updateConfig before startPush). |
ERROR_START_PUSH_REQUEST_FAILED | -3 | The startPush request chain failed (server / signaling / TRTC). See message for details. |
ERROR_UPDATE_CONFIG_REQUEST_FAILED | -4 | The updateConfig request chain failed (server / signaling). See message for details. |
PusherConnectState
The connection state between the pusher and the push target. State machine (typical transitions):
startPushDISCONNECTED ─────────────▶ CONNECTING▲ ││ │ join/push succeeded│ ▼│ CONNECTED│ ││ network jitter / dropped, SDK auto-reconnects│ ▼│ CONNECTING│ ││ reconnect succeeded ─▶ CONNECTED└───── reconnect failed / stopPush / release
Note:
DISCONNECTED is the initial state; it is also returned to after calling stopPush / release. The auto-reconnect process reuses CONNECTING, without distinguishing "first connection" from "reconnecting".Enum Value | Value | Description |
DISCONNECTED | 0 | Not connected. Initial state, or after actively stopping the push / final reconnect failure. |
CONNECTING | 1 | Establishing connection. Used for both the first room-join handshake and auto-reconnect after a disconnection. |
CONNECTED | 2 | Connected, the push link is normal. |
PusherListener
Pusher event listener, used to receive one-shot events such as push errors, live ended, kicked out, etc. Register/remove listeners via
addListener / removeListener.PusherStatistics
Pusher runtime statistics.
Property | Type | Description |
videoWidth | Int | Video width (pixels). |
videoHeight | Int | Video height (pixels). |
videoFps | Int | Video frame rate (fps). |
videoBitrate | Int | Video bitrate (bps). |
audioBitrate | Int | Audio bitrate (bps). |
rtt | Int | Network round-trip time (milliseconds). |
packetLossRate | Int | Network packet loss rate (percentage). |
PusherState
Atomic pusher reactive state. Carries the state of AtomicPusher. You can read the current value or subscribe to changes via
state.Property | Type | Description |
networkState | Connection state. | |
statistics | Pusher runtime statistics. | |
pusherInfo | Pusher live room info. | |
totalViewerCount | StateFlow<Int> | Total viewer count. |
PusherInfo
Pusher live room info. Used both as the input parameter of
startPush / updateConfig, and carried in state.pusherInfo as the live room info returned from the engine.Property | Type | Description |
liveID | String | Live ID. |
liveName | String | Live name. |
coverURL | String | Cover URL. |
backgroundURL | String | Background URL. |
notice | String | Notice. |
createTime | Long | Create time. |
categoryList | List<Int> | Category list. |
isPublicVisible | Boolean | Whether publicly visible. |
metaData | Map<String, String> | Custom metadata. |
