tencent cloud

Mobile Live Video Broadcasting

AtomicPusher

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-11-02 17:31:48
AI翻訳

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
ValueListenable<PusherConnectState>
Connection state.
statistics
ValueListenable<PusherStatistics>
Pusher runtime statistics.
pusherInfo
ValueListenable<PusherInfo>
Pusher live room info.
totalViewerCount
ValueListenable<int>
Total viewer count.

API List

Function
Description
shared
Get the global singleton.
Add pusher event callback listener.
Remove pusher event callback listener.
setView
Set the render view.
startPush
Start pushing (streaming).
stopPush
Stop pushing (streaming).
Update live room configuration.
release
Release pusher resources.
Enable advanced features by key-value pair.

Getting Instance

shared

Get the global singleton.

Observing State and Events

addListener

Add pusher event callback listener.
void addListener(PusherListener? listener);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
listener
Listener.

removeListener

Remove pusher event callback listener.
void removeListener(PusherListener? listener);
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.
void setView(AtomicLiveWidget view);
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.
void startPush(PusherInfo config);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
config
Live room configuration.

stopPush

Stop pushing (streaming).
void 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.
void updateConfig(PusherInfo config, List<PusherInfoModifyFlag> modifyFlagList);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
config
Updated configuration.
modifyFlagList
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.
void 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.
void enableAdvancedFeature(String key, Object value);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
key
String
Feature key.
value
Object
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.
errorInvalidParameter
-1
Invalid parameter.
errorInvalidState
-2
The operation is not allowed in the current state (e.g. startPush again while pushing, updateConfig before startPush).
errorStartPushRequestFailed
-3
The startPush request chain failed (server / signaling / TRTC). See message for details.
errorUpdateConfigRequestFailed
-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):
startPush
DISCONNECTED ─────────────▶ 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.

PusherInfoModifyFlag

Fields that can be updated via updateConfig. Each flag is a bit value aligned with the underlying engine's field flags, so the raw values are intentionally non-contiguous (bits used by unrelated fields are skipped).
Enum Value
Value
Description
liveName
1
Update the live name.
notice
2
Update the notice.
isPublicVisible
32
Update whether the live is publicly visible.
coverURL
128
Update the cover URL.
backgroundURL
256
Update the background URL.
categoryList
512
Update the category list.
metaData
4096
Update the custom metadata.

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.

PusherSummary

Statistics data of this live session, reported when the live ends. Used to display summarized data such as views, interactions, and gifts.
Property
Type
Description
totalViewers
int
Cumulative view count.
totalGiftsSent
int
Total number of gifts sent.
totalGiftCoins
int
Total gift amount.
totalUniqueGiftSenders
int
Number of gift senders.
totalLikesReceived
int
Total likes.
totalMessageCount
int
Total messages.
liveDuration
int
Live duration (seconds).

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
ValueListenable<PusherConnectState>
Connection state.
statistics
ValueListenable<PusherStatistics>
Pusher runtime statistics.
pusherInfo
ValueListenable<PusherInfo>
Pusher live room info.
totalViewerCount
ValueListenable<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
int
Create time.
categoryList
List<int>
Category list.
isPublicVisible
bool
Whether publicly visible.
metaData
Map<String, String>
Custom metadata.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック