@tencent-rtc/mcp 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/resource/doc/native_live/android/V2TXLiveCode_api_android.md +312 -0
- package/resource/doc/native_live/android/V2TXLiveDef_api_android.md +430 -0
- package/resource/doc/native_live/android/V2TXLivePlayerObserver_api_android.md +679 -0
- package/resource/doc/native_live/android/V2TXLivePlayer_api_android.md +671 -0
- package/resource/doc/native_live/android/V2TXLivePremier_api_android.md +271 -0
- package/resource/doc/native_live/android/V2TXLivePusherObserver_api_android.md +849 -0
- package/resource/doc/native_live/android/V2TXLivePusher_api_android.md +1046 -0
- package/resource/doc/native_live/flutter/V2TXLiveCode_api_flutter.md +460 -0
- package/resource/doc/native_live/flutter/V2TXLiveDef_api_flutter.md +558 -0
- package/resource/doc/native_live/flutter/V2TXLivePlayerObserver_api_flutter.md +865 -0
- package/resource/doc/native_live/flutter/V2TXLivePlayer_api_flutter.md +657 -0
- package/resource/doc/native_live/flutter/V2TXLivePremier_api_flutter.md +437 -0
- package/resource/doc/native_live/flutter/V2TXLivePusherObserver_api_flutter.md +335 -0
- package/resource/doc/native_live/flutter/V2TXLivePusher_api_flutter.md +748 -0
- package/resource/doc/native_live/iOS/V2TXLiveCode_api_iOS.md +327 -0
- package/resource/doc/native_live/iOS/V2TXLiveDef_api_iOS.md +507 -0
- package/resource/doc/native_live/iOS/V2TXLivePlayerObserver_api_iOS.md +507 -0
- package/resource/doc/native_live/iOS/V2TXLivePlayer_api_iOS.md +659 -0
- package/resource/doc/native_live/iOS/V2TXLivePremier_api_iOS.md +284 -0
- package/resource/doc/native_live/iOS/V2TXLivePusherObserver_api_iOS.md +814 -0
- package/resource/doc/native_live/iOS/V2TXLivePusher_api_iOS.md +1000 -0
- package/tools/common/get-faq.js +1 -1
- package/tools/common/get-faq.js.map +1 -1
- package/tools/definitions/get_native_live_api_def.js +23 -0
- package/tools/definitions/get_native_live_api_def.js.map +1 -0
- package/tools/index.js +4 -0
- package/tools/index.js.map +1 -1
- package/tools/native_live/get-native-live-api.js +31 -0
- package/tools/native_live/get-native-live-api.js.map +1 -0
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
# Tencent Cloud Live Streaming SDK V2TXLivePlayerObserver Live Player Callback Interface
|
|
2
|
+
|
|
3
|
+
## Feature Overview
|
|
4
|
+
|
|
5
|
+
`V2TXLivePlayerObserver` is the callback interface for the Tencent Cloud Live Streaming SDK player. Implement this interface to receive real-time status updates and event notifications from the player. By handling these callbacks, you can monitor player status, respond to playback events, collect statistics, and more.
|
|
6
|
+
|
|
7
|
+
**File Path**: `com/tencent/live2/V2TXLivePlayerObserver.java`
|
|
8
|
+
|
|
9
|
+
**Core Features**:
|
|
10
|
+
- Player status monitoring (errors, warnings, connection events)
|
|
11
|
+
- Audio and video playback event callbacks
|
|
12
|
+
- Playback statistics and performance metrics
|
|
13
|
+
- Custom video rendering and audio processing
|
|
14
|
+
- Local recording management
|
|
15
|
+
- SEI message reception and handling
|
|
16
|
+
|
|
17
|
+
## Callback Method Details
|
|
18
|
+
|
|
19
|
+
### 1. Error and Warning Callbacks
|
|
20
|
+
|
|
21
|
+
#### onError() - Player Error Callback
|
|
22
|
+
```java
|
|
23
|
+
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Description**: Triggered when a player error occurs.
|
|
27
|
+
|
|
28
|
+
**Parameters**:
|
|
29
|
+
- `player`: The player instance reporting the error
|
|
30
|
+
- `code`: Error code (see `V2TXLiveCode` enum)
|
|
31
|
+
- `msg`: Error message
|
|
32
|
+
- `extraInfo`: Additional error details
|
|
33
|
+
|
|
34
|
+
**Common Scenarios**:
|
|
35
|
+
- Invalid RTC stream pull parameters
|
|
36
|
+
- RTC stream pull timeout
|
|
37
|
+
- RTC stream pull server processing failure
|
|
38
|
+
- No available HEVC decoder
|
|
39
|
+
|
|
40
|
+
**Example**:
|
|
41
|
+
```java
|
|
42
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
43
|
+
@Override
|
|
44
|
+
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
|
45
|
+
switch (code) {
|
|
46
|
+
case V2TXLIVE_ERROR_INVALID_PARAMETER:
|
|
47
|
+
Log.e(TAG, "Invalid RTC stream pull parameters, " + msg);
|
|
48
|
+
break;
|
|
49
|
+
case V2TXLIVE_ERROR_REQUEST_TIMEOUT:
|
|
50
|
+
Log.e(TAG, "RTC stream pull timeout, " + msg);
|
|
51
|
+
break;
|
|
52
|
+
case V2TXLIVE_ERROR_SERVER_PROCESS_FAILED:
|
|
53
|
+
Log.e(TAG, "RTC stream pull server processing failed, please check stream pull parameters, " + msg);
|
|
54
|
+
break;
|
|
55
|
+
case V2TXLIVE_ERROR_DISCONNECTED:
|
|
56
|
+
Log.e(TAG, "Stream pull disconnected, " + msg);
|
|
57
|
+
break;
|
|
58
|
+
case V2TXLIVE_ERROR_NO_AVAILABLE_HEVC_DECODERS:
|
|
59
|
+
Log.e(TAG, "No available HEVC decoder, you can switch to AVC stream for playback, " + msg);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
Log.e(TAG, "Other error, " + msg);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### onWarning() - Player Warning Callback
|
|
70
|
+
```java
|
|
71
|
+
public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Description**: Triggered when a player warning occurs.
|
|
75
|
+
|
|
76
|
+
**Parameters**:
|
|
77
|
+
- `player`: The player instance reporting the warning
|
|
78
|
+
- `code`: Warning code (see `V2TXLiveCode` enum)
|
|
79
|
+
- `msg`: Warning message
|
|
80
|
+
- `extraInfo`: Additional warning details
|
|
81
|
+
|
|
82
|
+
**Common Scenarios**:
|
|
83
|
+
- Video rendering stutter
|
|
84
|
+
- Decoder type change
|
|
85
|
+
|
|
86
|
+
**Example**:
|
|
87
|
+
```java
|
|
88
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
89
|
+
@Override
|
|
90
|
+
public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
|
91
|
+
switch (code) {
|
|
92
|
+
case V2TXLIVE_WARNING_VIDEO_BLOCK:
|
|
93
|
+
Log.w(TAG, "Video rendering stutter detected");
|
|
94
|
+
break;
|
|
95
|
+
case V2TXLIVE_WARNING_CURRENT_DECODE_TYPE_CHANGED:
|
|
96
|
+
int codec_type = extraInfo.getInt("codec_type");
|
|
97
|
+
if (codec_type == 0) {
|
|
98
|
+
Log.w(TAG, "Decoder type changed to h.264, " + msg);
|
|
99
|
+
} else if (codec_type == 1) {
|
|
100
|
+
Log.w(TAG, "Decoder type changed to h.265, " + msg);
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
Log.w(TAG, "Other warning, " + msg);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 2. Connection and Status Callbacks
|
|
112
|
+
|
|
113
|
+
#### onConnected() - Connection Success Callback
|
|
114
|
+
```java
|
|
115
|
+
public void onConnected(V2TXLivePlayer player, Bundle extraInfo)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Description**: Triggered when the player successfully connects to the server.
|
|
119
|
+
|
|
120
|
+
**Parameters**:
|
|
121
|
+
- `player`: The player instance that connected
|
|
122
|
+
- `extraInfo`: Connection details
|
|
123
|
+
|
|
124
|
+
**Use Cases**:
|
|
125
|
+
- Monitor network connection status
|
|
126
|
+
|
|
127
|
+
**Example**:
|
|
128
|
+
```java
|
|
129
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
130
|
+
@Override
|
|
131
|
+
public void onConnected(V2TXLivePlayer player, Bundle extraInfo) {
|
|
132
|
+
Log.i(TAG, "Successfully connected to server");
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### onVideoResolutionChanged() - Video Resolution Change Callback
|
|
138
|
+
```java
|
|
139
|
+
public void onVideoResolutionChanged(V2TXLivePlayer player, int width, int height)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Description**: Triggered when the video resolution changes.
|
|
143
|
+
|
|
144
|
+
**Parameters**:
|
|
145
|
+
- `player`: The player instance
|
|
146
|
+
- `width`: New video width
|
|
147
|
+
- `height`: New video height
|
|
148
|
+
|
|
149
|
+
**Use Cases**:
|
|
150
|
+
- Adapt video rendering view
|
|
151
|
+
- Dynamically adjust player layout
|
|
152
|
+
|
|
153
|
+
**Example**:
|
|
154
|
+
```java
|
|
155
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
156
|
+
@Override
|
|
157
|
+
public void onVideoResolutionChanged(V2TXLivePlayer player, int width, int height) {
|
|
158
|
+
Log.i(TAG, "Video stream resolution changed: width-" + width + ", height-" + height);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 3. Playback Event Callbacks
|
|
164
|
+
|
|
165
|
+
#### onVideoPlaying() - Video Playback Start Callback
|
|
166
|
+
```java
|
|
167
|
+
public void onVideoPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Description**: Triggered when video playback starts. For subsequent plays, this callback is paired with `onVideoLoading`.
|
|
171
|
+
|
|
172
|
+
**Parameters**:
|
|
173
|
+
- `player`: The player instance
|
|
174
|
+
- `firstPlay`: `true` if this is the first playback, otherwise `false`
|
|
175
|
+
- `extraInfo`: Playback details
|
|
176
|
+
|
|
177
|
+
**Use Cases**:
|
|
178
|
+
- Update playback status UI
|
|
179
|
+
- Start playback timer
|
|
180
|
+
- Log playback events
|
|
181
|
+
- Calculate time-to-first-frame
|
|
182
|
+
|
|
183
|
+
**Example**:
|
|
184
|
+
```java
|
|
185
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
186
|
+
@Override
|
|
187
|
+
public void onVideoPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo) {
|
|
188
|
+
if (firstPlay) {
|
|
189
|
+
// First time video starts playing
|
|
190
|
+
Log.i(TAG, "First playback started");
|
|
191
|
+
} else {
|
|
192
|
+
// Subsequent playback, hide loading UI
|
|
193
|
+
Log.i(TAG, "Playback started");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### onVideoLoading() - Video Loading Callback
|
|
200
|
+
```java
|
|
201
|
+
public void onVideoLoading(V2TXLivePlayer player, Bundle extraInfo)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Description**: Triggered when video data is loading.
|
|
205
|
+
|
|
206
|
+
**Parameters**:
|
|
207
|
+
- `player`: The player instance
|
|
208
|
+
- `extraInfo`: Loading status details
|
|
209
|
+
|
|
210
|
+
**Use Cases**:
|
|
211
|
+
- Show loading animation
|
|
212
|
+
- Display buffering status
|
|
213
|
+
|
|
214
|
+
**Example**:
|
|
215
|
+
```java
|
|
216
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
217
|
+
@Override
|
|
218
|
+
public void onVideoLoading(V2TXLivePlayer player, Bundle extraInfo) {
|
|
219
|
+
// Video playback is loading, show loading UI
|
|
220
|
+
Log.i(TAG, "Video playback loading started");
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### onAudioPlaying() - Audio Playback Start Callback
|
|
226
|
+
```java
|
|
227
|
+
public void onAudioPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Description**: Triggered when audio playback starts.
|
|
231
|
+
|
|
232
|
+
**Parameters**:
|
|
233
|
+
- `player`: The player instance
|
|
234
|
+
- `firstPlay`: `true` if this is the first playback, otherwise `false`
|
|
235
|
+
- `extraInfo`: Playback details
|
|
236
|
+
|
|
237
|
+
**Use Cases**:
|
|
238
|
+
- Monitor audio playback status
|
|
239
|
+
- Handle pure audio stream playback
|
|
240
|
+
|
|
241
|
+
**Example**:
|
|
242
|
+
```java
|
|
243
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
244
|
+
@Override
|
|
245
|
+
public void onAudioPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo) {
|
|
246
|
+
if (firstPlay) {
|
|
247
|
+
Log.i(TAG, "First audio playback started");
|
|
248
|
+
} else {
|
|
249
|
+
Log.i(TAG, "Audio playback started");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### onAudioLoading() - Audio Loading Callback
|
|
256
|
+
```java
|
|
257
|
+
public void onAudioLoading(V2TXLivePlayer player, Bundle extraInfo)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Description**: Triggered when audio data is loading.
|
|
261
|
+
|
|
262
|
+
**Parameters**:
|
|
263
|
+
- `player`: The player instance
|
|
264
|
+
- `extraInfo`: Loading status details
|
|
265
|
+
|
|
266
|
+
**Use Cases**:
|
|
267
|
+
- Show loading animation
|
|
268
|
+
- Display buffering status
|
|
269
|
+
|
|
270
|
+
**Example**:
|
|
271
|
+
```java
|
|
272
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
273
|
+
@Override
|
|
274
|
+
public void onAudioLoading(V2TXLivePlayer player, Bundle extraInfo) {
|
|
275
|
+
// Audio playback is loading
|
|
276
|
+
Log.i(TAG, "Audio playback loading started");
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### 4. Audio/Video Data Processing Callbacks
|
|
282
|
+
|
|
283
|
+
#### onPlayoutVolumeUpdate() - Volume Update Callback
|
|
284
|
+
```java
|
|
285
|
+
public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Description**: Provides real-time updates on playback volume.
|
|
289
|
+
|
|
290
|
+
**Parameters**:
|
|
291
|
+
- `player`: The player instance
|
|
292
|
+
- `volume`: Current playback volume (0-100)
|
|
293
|
+
|
|
294
|
+
**Prerequisite**: Call `enableVolumeEvaluation()` to enable volume evaluation.
|
|
295
|
+
|
|
296
|
+
**Use Cases**:
|
|
297
|
+
- Display real-time volume levels
|
|
298
|
+
- Animate audio waveform
|
|
299
|
+
- Detect mute status
|
|
300
|
+
|
|
301
|
+
**Example**:
|
|
302
|
+
```java
|
|
303
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
304
|
+
@Override
|
|
305
|
+
public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume) {
|
|
306
|
+
// Update audio playback volume UI
|
|
307
|
+
Log.i(TAG, "Audio playback volume: " + volume);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
player.enableVolumeEvaluation(300);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### onRenderVideoFrame() - Custom Video Rendering Callback
|
|
314
|
+
```java
|
|
315
|
+
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveVideoFrame videoFrame)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Description**: Delivers video frame data for custom rendering.
|
|
319
|
+
|
|
320
|
+
**Parameters**:
|
|
321
|
+
- `player`: The player instance
|
|
322
|
+
- `videoFrame`: Video frame data (`V2TXLiveVideoFrame`)
|
|
323
|
+
|
|
324
|
+
**Prerequisite**: Call `enableObserveVideoFrame()` to enable video frame callbacks.
|
|
325
|
+
|
|
326
|
+
**Use Cases**:
|
|
327
|
+
- Implement custom video rendering
|
|
328
|
+
|
|
329
|
+
**Example**:
|
|
330
|
+
```java
|
|
331
|
+
// Enable custom rendering
|
|
332
|
+
player.enableObserveVideoFrame(true, V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatTexture2D, V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeTexture);
|
|
333
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
334
|
+
@Override
|
|
335
|
+
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveVideoFrame videoFrame) {
|
|
336
|
+
// Custom rendering logic
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### onPlayoutAudioFrame() - Audio Frame Callback
|
|
342
|
+
```java
|
|
343
|
+
public void onPlayoutAudioFrame(V2TXLivePlayer player, V2TXLiveAudioFrame audioFrame)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Description**: Delivers audio frame data for custom processing.
|
|
347
|
+
|
|
348
|
+
**Parameters**:
|
|
349
|
+
- `player`: The player instance
|
|
350
|
+
- `audioFrame`: Audio frame data (`V2TXLiveAudioFrame`)
|
|
351
|
+
|
|
352
|
+
**Prerequisite**: Call `enableObserveAudioFrame()` to enable audio frame callbacks.
|
|
353
|
+
|
|
354
|
+
**Use Cases**:
|
|
355
|
+
- Implement custom audio processing
|
|
356
|
+
|
|
357
|
+
**Example**:
|
|
358
|
+
```java
|
|
359
|
+
// Enable audio frame monitoring
|
|
360
|
+
player.enableObserveAudioFrame(true);
|
|
361
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
362
|
+
@Override
|
|
363
|
+
public void onPlayoutAudioFrame(V2TXLivePlayer player, V2TXLiveAudioFrame audioFrame) {
|
|
364
|
+
// Custom audio processing
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### 5. Statistics and Monitoring Callbacks
|
|
370
|
+
|
|
371
|
+
#### onStatisticsUpdate() - Playback Statistics Callback
|
|
372
|
+
```java
|
|
373
|
+
public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLivePlayerStatistics statistics)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Description**: Provides real-time playback statistics every 2 seconds.
|
|
377
|
+
|
|
378
|
+
**Parameters**:
|
|
379
|
+
- `player`: The player instance
|
|
380
|
+
- `statistics`: Playback statistics (`V2TXLivePlayerStatistics`)
|
|
381
|
+
|
|
382
|
+
**Statistics Include**:
|
|
383
|
+
- Video width and height
|
|
384
|
+
- Frame rate and bitrate
|
|
385
|
+
- Network status
|
|
386
|
+
- Buffer size
|
|
387
|
+
- Playback latency
|
|
388
|
+
|
|
389
|
+
**Use Cases**:
|
|
390
|
+
- Monitor playback quality
|
|
391
|
+
- Analyze performance
|
|
392
|
+
- Collect user experience metrics
|
|
393
|
+
|
|
394
|
+
**Example**:
|
|
395
|
+
```java
|
|
396
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
397
|
+
@Override
|
|
398
|
+
public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLivePlayerStatistics statistics) {
|
|
399
|
+
// Handle playback statistics
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### 6. Advanced Feature Callbacks
|
|
405
|
+
|
|
406
|
+
#### onSnapshotComplete() - Snapshot Completion Callback
|
|
407
|
+
```java
|
|
408
|
+
public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image)
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Description**: Triggered when a snapshot operation completes.
|
|
412
|
+
|
|
413
|
+
**Parameters**:
|
|
414
|
+
- `player`: The player instance
|
|
415
|
+
- `image`: Captured video frame as a Bitmap
|
|
416
|
+
|
|
417
|
+
**Use Cases**:
|
|
418
|
+
- Save video snapshots
|
|
419
|
+
- Implement frame sharing
|
|
420
|
+
|
|
421
|
+
**Example**:
|
|
422
|
+
```java
|
|
423
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
424
|
+
@Override
|
|
425
|
+
public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image) {
|
|
426
|
+
// Handle snapshot result
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
player.snapshot();
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
#### onReceiveSeiMessage() - SEI Message Callback
|
|
433
|
+
```java
|
|
434
|
+
public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data)
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**Description**: Receives SEI (Supplemental Enhancement Information) messages.
|
|
438
|
+
|
|
439
|
+
**Parameters**:
|
|
440
|
+
- `player`: The player instance
|
|
441
|
+
- `payloadType`: SEI message type
|
|
442
|
+
- `data`: SEI message data
|
|
443
|
+
|
|
444
|
+
**Prerequisite**: Call `enableReceiveSeiMessage()` to enable SEI message reception.
|
|
445
|
+
|
|
446
|
+
**Use Cases**:
|
|
447
|
+
- Transmit scene information
|
|
448
|
+
- Deliver interactive messages
|
|
449
|
+
|
|
450
|
+
**Example**:
|
|
451
|
+
```java
|
|
452
|
+
// Enable SEI message reception
|
|
453
|
+
player.enableReceiveSeiMessage(true, 5);
|
|
454
|
+
player.enableReceiveSeiMessage(true, 242);
|
|
455
|
+
player.enableReceiveSeiMessage(true, 243);
|
|
456
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
457
|
+
@Override
|
|
458
|
+
public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) {
|
|
459
|
+
// Handle SEI message
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
#### onStreamSwitched() - Stream Switch Callback
|
|
465
|
+
```java
|
|
466
|
+
public void onStreamSwitched(V2TXLivePlayer player, String url, int code)
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Description**: Triggered after a stream resolution switch completes via `switchStream()`.
|
|
470
|
+
|
|
471
|
+
**Parameters**:
|
|
472
|
+
- `player`: The player instance
|
|
473
|
+
- `url`: Playback URL after switching
|
|
474
|
+
- `code`: Switch status code (`0`: success, `-1`: timeout, `-2`: server error, `-3`: client error)
|
|
475
|
+
|
|
476
|
+
**Use Cases**:
|
|
477
|
+
- Monitor stream quality switching
|
|
478
|
+
|
|
479
|
+
**Example**:
|
|
480
|
+
```java
|
|
481
|
+
player.startLivePlayer("http://example.com/live/stream_1080p.flv");
|
|
482
|
+
|
|
483
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
484
|
+
@Override
|
|
485
|
+
public void onStreamSwitched(V2TXLivePlayer player, String url, int code) {
|
|
486
|
+
if (code == 0) {
|
|
487
|
+
Log.i(TAG, "Switch successful");
|
|
488
|
+
} else if (code == -1) {
|
|
489
|
+
Log.i(TAG, "Switch timeout");
|
|
490
|
+
} else if (code == -2) {
|
|
491
|
+
Log.i(TAG, "Switch failed, server error");
|
|
492
|
+
} else if (code == -3) {
|
|
493
|
+
Log.i(TAG, "Switch failed, client error");
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
player.switchStream("http://example.com/live/stream_720p.flv");
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### 7. Local Recording Callbacks
|
|
501
|
+
|
|
502
|
+
#### onLocalRecordBegin() - Recording Start Callback
|
|
503
|
+
```java
|
|
504
|
+
public void onLocalRecordBegin(V2TXLivePlayer player, int code, String storagePath)
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**Description**: Triggered when a local recording task starts, after calling `startLocalRecording()`.
|
|
508
|
+
|
|
509
|
+
**Parameters**:
|
|
510
|
+
- `player`: The player instance
|
|
511
|
+
- `code`: Recording status code
|
|
512
|
+
- `storagePath`: Path to the recording file
|
|
513
|
+
|
|
514
|
+
**Status Codes**:
|
|
515
|
+
- `0`: Recording started successfully
|
|
516
|
+
- `-1`: Internal error
|
|
517
|
+
- `-2`: Invalid file extension
|
|
518
|
+
- `-6`: Recording already started
|
|
519
|
+
- `-7`: Recording file already exists
|
|
520
|
+
- `-8`: No write permission in recording directory
|
|
521
|
+
|
|
522
|
+
#### onLocalRecording() - Recording Progress Callback
|
|
523
|
+
```java
|
|
524
|
+
public void onLocalRecording(V2TXLivePlayer player, long durationMs, String storagePath)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
**Description**: Reports recording progress at intervals specified by `V2TXLiveDef.V2TXLiveLocalRecordingParams.interval` in `startLocalRecording`.
|
|
528
|
+
|
|
529
|
+
**Parameters**:
|
|
530
|
+
- `player`: The player instance
|
|
531
|
+
- `durationMs`: Recorded duration in milliseconds
|
|
532
|
+
- `storagePath`: Path to the recording file
|
|
533
|
+
|
|
534
|
+
**Use Cases**:
|
|
535
|
+
- Display recording progress
|
|
536
|
+
- Enforce recording duration limits
|
|
537
|
+
- Monitor recording status
|
|
538
|
+
|
|
539
|
+
#### onLocalRecordComplete() - Recording Completion Callback
|
|
540
|
+
```java
|
|
541
|
+
public void onLocalRecordComplete(V2TXLivePlayer player, int code, String storagePath)
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**Description**: Triggered when a recording task ends, after calling `stopLocalRecording()`.
|
|
545
|
+
|
|
546
|
+
**Parameters**:
|
|
547
|
+
- `player`: The player instance
|
|
548
|
+
- `code`: Completion status code
|
|
549
|
+
- `storagePath`: Path to the recording file
|
|
550
|
+
|
|
551
|
+
**Status Codes**:
|
|
552
|
+
- `0`: Recording completed successfully
|
|
553
|
+
- `-1`: Recording failed
|
|
554
|
+
- `-2`: Recording ended due to resolution or orientation change
|
|
555
|
+
- `-3`: Recording duration too short or no data captured
|
|
556
|
+
|
|
557
|
+
**Example**:
|
|
558
|
+
```java
|
|
559
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
560
|
+
@Override
|
|
561
|
+
public void onLocalRecordBegin(V2TXLivePlayer player, int code, String storagePath) {
|
|
562
|
+
Log.i(TAG, "Recording started");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
@Override
|
|
566
|
+
public void onLocalRecording(V2TXLivePlayer player, long durationMs, String storagePath) {
|
|
567
|
+
Log.i(TAG, "Recording in progress..., durationMs: " + durationMs);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
@Override
|
|
571
|
+
public void onLocalRecordComplete(V2TXLivePlayer player, int code, String storagePath) {
|
|
572
|
+
Log.i(TAG, "Recording completed");
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
V2TXLiveDef.V2TXLiveLocalRecordingParams params = new V2TXLiveDef.V2TXLiveLocalRecordingParams();
|
|
577
|
+
params.filePath = "filepath";
|
|
578
|
+
params.interval = 2000;
|
|
579
|
+
int code = player.startLocalRecording(params);
|
|
580
|
+
if (code == V2TXLIVE_OK) {
|
|
581
|
+
Log.i(TAG, "Recording started successfully");
|
|
582
|
+
} else if (code == V2TXLIVE_ERROR_INVALID_PARAMETER) {
|
|
583
|
+
Log.i(TAG, "Invalid recording parameters");
|
|
584
|
+
} else if (code == V2TXLIVE_ERROR_REFUSED) {
|
|
585
|
+
Log.i(TAG, "Recording request refused");
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Basic Player Callback Implementation
|
|
590
|
+
```java
|
|
591
|
+
public class MyPlayerObserver extends V2TXLivePlayerObserver {
|
|
592
|
+
@Override
|
|
593
|
+
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
|
594
|
+
// Handle playback error
|
|
595
|
+
Log.e("PlayerError", "Error code: " + code + ", Error message: " + msg);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
@Override
|
|
599
|
+
public void onConnected(V2TXLivePlayer player, Bundle extraInfo) {
|
|
600
|
+
// Handle connection success
|
|
601
|
+
Log.i("Player", "Successfully connected to server");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
@Override
|
|
605
|
+
public void onVideoPlaying(V2TXLivePlayer player, boolean firstPlay, Bundle extraInfo) {
|
|
606
|
+
// Video playback started
|
|
607
|
+
if (firstPlay) {
|
|
608
|
+
Log.i("Player", "First playback started");
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
@Override
|
|
613
|
+
public void onStatisticsUpdate(V2TXLivePlayer player, V2TXLivePlayerStatistics statistics) {
|
|
614
|
+
// Update playback statistics
|
|
615
|
+
Log.d("PlayerStats", "Frame rate: " + statistics.fps + ", Bitrate: " + statistics.bitrate);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// Set the observer
|
|
620
|
+
V2TXLivePlayer player = new V2TXLivePlayerImpl(context);
|
|
621
|
+
player.setObserver(new MyPlayerObserver());
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Custom Video Processing Example
|
|
625
|
+
```java
|
|
626
|
+
public class VideoProcessorObserver extends V2TXLivePlayerObserver {
|
|
627
|
+
@Override
|
|
628
|
+
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveVideoFrame videoFrame) {
|
|
629
|
+
// Custom video frame processing
|
|
630
|
+
// Add filters, watermarks, etc.
|
|
631
|
+
processVideoFrame(videoFrame);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
private void processVideoFrame(V2TXLiveVideoFrame frame) {
|
|
635
|
+
// Video frame processing logic
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// Enable custom video frame callback
|
|
640
|
+
player.enableObserveVideoFrame(true);
|
|
641
|
+
player.setObserver(new VideoProcessorObserver());
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
### Local Recording Monitoring Example
|
|
645
|
+
```java
|
|
646
|
+
public class RecordingObserver extends V2TXLivePlayerObserver {
|
|
647
|
+
@Override
|
|
648
|
+
public void onLocalRecordBegin(V2TXLivePlayer player, int code, String storagePath) {
|
|
649
|
+
if (code == 0) {
|
|
650
|
+
Log.i("Recording", "Recording started, file path: " + storagePath);
|
|
651
|
+
} else {
|
|
652
|
+
Log.e("Recording", "Recording failed, error code: " + code);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@Override
|
|
657
|
+
public void onLocalRecording(V2TXLivePlayer player, long durationMs, String storagePath) {
|
|
658
|
+
// Update recording progress
|
|
659
|
+
updateRecordingProgress(durationMs);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
@Override
|
|
663
|
+
public void onLocalRecordComplete(V2TXLivePlayer player, int code, String storagePath) {
|
|
664
|
+
if (code == 0) {
|
|
665
|
+
Log.i("Recording", "Recording completed, file path: " + storagePath);
|
|
666
|
+
} else {
|
|
667
|
+
Log.w("Recording", "Recording ended abnormally, status code: " + code);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
## Notes
|
|
674
|
+
|
|
675
|
+
1. **Callback Thread**: All callbacks except custom rendering are executed on the UI main thread.
|
|
676
|
+
2. **Performance Impact**: Custom rendering and audio processing callbacks may impact playback performance.
|
|
677
|
+
3. **Memory Management**: Release unused observer objects promptly to prevent memory leaks.
|
|
678
|
+
4. **Error Handling**: Handle error codes appropriately and provide user-friendly messages.
|
|
679
|
+
5. **Permission Check**: Local recording requires storage permissions and sufficient available space.
|