@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,814 @@
|
|
|
1
|
+
Tencent Cloud Live Streaming SDK V2TXLivePusherObserver Callback Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`V2TXLivePusherObserver.h` defines the callback protocol for Tencent Cloud Live Streaming SDK on iOS and macOS. Use this interface to receive real-time status updates, streaming statistics, error notifications, and event callbacks during the live broadcast lifecycle.
|
|
6
|
+
|
|
7
|
+
**Supported Platforms**: iOS, macOS
|
|
8
|
+
**Protocol Type**: Objective-C Protocol
|
|
9
|
+
**Callback Methods**: 15 core callbacks
|
|
10
|
+
|
|
11
|
+
## ๐ Table of Contents
|
|
12
|
+
|
|
13
|
+
### 1. [Core Feature Highlights](#ๆ ธๅฟๅ่ฝ็นๆง)
|
|
14
|
+
### 2. [Error and Warning Callbacks](#้่ฏฏไธ่ญฆๅๅ่ฐ)
|
|
15
|
+
### 3. [First Frame Capture Callbacks](#้ฆๅธง้้ๅ่ฐ)
|
|
16
|
+
### 4. [Push Status Callbacks](#ๆจๆต็ถๆๅ่ฐ)
|
|
17
|
+
### 5. [Statistics Callbacks](#็ป่ฎกๆฐๆฎๅ่ฐ)
|
|
18
|
+
### 6. [Audio & Video Processing Callbacks](#้ณ่ง้ขๅค็ๅ่ฐ)
|
|
19
|
+
### 7. [Screen Sharing Callbacks](#ๅฑๅนๅไบซๅ่ฐ)
|
|
20
|
+
### 8. [Local Recording Callbacks](#ๆฌๅฐๅฝๅถๅ่ฐ)
|
|
21
|
+
### 9. [Advanced Feature Callbacks](#้ซ็บงๅ่ฝๅ่ฐ)
|
|
22
|
+
### 10. [Usage Examples](#ไฝฟ็จ็คบไพ)
|
|
23
|
+
|
|
24
|
+
## 1. Core Feature Highlights
|
|
25
|
+
|
|
26
|
+
### ๐ฏ Callback Categories
|
|
27
|
+
|
|
28
|
+
| Category | Callback Count | Description |
|
|
29
|
+
|-----------------|---------------|-----------------------------------------------|
|
|
30
|
+
| Error & Warning | 2 | Error and warning notifications for live push |
|
|
31
|
+
| First Frame | 2 | First audio/video frame capture notifications |
|
|
32
|
+
| Push Status | 1 | Connection status updates |
|
|
33
|
+
| Statistics | 1 | Real-time streaming statistics |
|
|
34
|
+
| Audio/Video Proc| 3 | Custom audio/video processing |
|
|
35
|
+
| Screen Sharing | 2 | Screen capture start/stop notifications |
|
|
36
|
+
| Local Recording | 3 | Local recording status updates |
|
|
37
|
+
| Advanced | 1 | Voice activity detection status |
|
|
38
|
+
|
|
39
|
+
### ๐ง Technical Highlights
|
|
40
|
+
|
|
41
|
+
- **Real-time**: All callbacks are dispatched on the main thread
|
|
42
|
+
- **Comprehensive**: Covers all major live stream events
|
|
43
|
+
- **Extensible**: Supports custom audio and video processing
|
|
44
|
+
- **Debug-Friendly**: Provides detailed error and statistics reporting
|
|
45
|
+
|
|
46
|
+
## 2. Error and Warning Callbacks
|
|
47
|
+
|
|
48
|
+
### โ ๏ธ onError - Error Notification
|
|
49
|
+
|
|
50
|
+
```objc
|
|
51
|
+
- (void)onError:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Description**: Notifies when the live pusher encounters an error.
|
|
55
|
+
|
|
56
|
+
**Parameters**:
|
|
57
|
+
- `code`: Error code, see `V2TXLiveCode`
|
|
58
|
+
- `msg`: Error message
|
|
59
|
+
- `extraInfo`: Additional details
|
|
60
|
+
|
|
61
|
+
**Typical Scenarios**:
|
|
62
|
+
- Network connection failure
|
|
63
|
+
- Invalid stream URL
|
|
64
|
+
- Hardware device error
|
|
65
|
+
- Encoder initialization failure
|
|
66
|
+
|
|
67
|
+
**Recommended Handling**:
|
|
68
|
+
```objc
|
|
69
|
+
- (void)onError:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
70
|
+
NSLog(@"Live push error: %ld - %@", (long)code, msg);
|
|
71
|
+
|
|
72
|
+
switch (code) {
|
|
73
|
+
case V2TXLIVE_ERROR_NET_DISCONNECT:
|
|
74
|
+
// Network disconnected, attempt reconnection
|
|
75
|
+
[self reconnect];
|
|
76
|
+
break;
|
|
77
|
+
case V2TXLIVE_ERROR_INVALID_LICENSE:
|
|
78
|
+
// Invalid license, verify configuration
|
|
79
|
+
[self checkLicense];
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
// Handle other errors
|
|
83
|
+
[self handleError:code];
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### โ ๏ธ onWarning - Warning Notification
|
|
90
|
+
|
|
91
|
+
```objc
|
|
92
|
+
- (void)onWarning:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Description**: Notifies when the live pusher encounters a warning.
|
|
96
|
+
|
|
97
|
+
**Parameters**:
|
|
98
|
+
- `code`: Warning code, see `V2TXLiveCode`
|
|
99
|
+
- `msg`: Warning message
|
|
100
|
+
- `extraInfo`: Additional details
|
|
101
|
+
|
|
102
|
+
**Common Scenarios**:
|
|
103
|
+
- Poor network conditions
|
|
104
|
+
- Encoding parameter mismatch
|
|
105
|
+
- Device resource constraints
|
|
106
|
+
- Audio/video capture issues
|
|
107
|
+
|
|
108
|
+
**Recommended Handling**:
|
|
109
|
+
```objc
|
|
110
|
+
- (void)onWarning:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
111
|
+
NSLog(@"Live push warning: %ld - %@", (long)code, msg);
|
|
112
|
+
|
|
113
|
+
// Respond to specific warnings
|
|
114
|
+
if (code == V2TXLIVE_WARNING_NETWORK_BUSY) {
|
|
115
|
+
// Network congestion, notify user or reduce bitrate
|
|
116
|
+
[self adjustBitrate];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 3. First Frame Capture Callbacks
|
|
122
|
+
|
|
123
|
+
### ๐ต onCaptureFirstAudioFrame - First Audio Frame
|
|
124
|
+
|
|
125
|
+
```objc
|
|
126
|
+
- (void)onCaptureFirstAudioFrame;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Description**: Triggered when the microphone captures the first audio frame.
|
|
130
|
+
|
|
131
|
+
**Typical Use Cases**:
|
|
132
|
+
- Monitor audio capture status
|
|
133
|
+
- Measure stream startup latency
|
|
134
|
+
- Detect audio device readiness
|
|
135
|
+
|
|
136
|
+
**Sample Implementation**:
|
|
137
|
+
```objc
|
|
138
|
+
- (void)onCaptureFirstAudioFrame {
|
|
139
|
+
NSLog(@"First audio frame captured");
|
|
140
|
+
[self updateUIWithAudioStatus:YES];
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### ๐ฅ onCaptureFirstVideoFrame - First Video Frame
|
|
145
|
+
|
|
146
|
+
```objc
|
|
147
|
+
- (void)onCaptureFirstVideoFrame;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Description**: Triggered when the camera captures the first video frame.
|
|
151
|
+
|
|
152
|
+
**Typical Use Cases**:
|
|
153
|
+
- Monitor video capture status
|
|
154
|
+
- Control preview display timing
|
|
155
|
+
- Detect camera device readiness
|
|
156
|
+
|
|
157
|
+
**Sample Implementation**:
|
|
158
|
+
```objc
|
|
159
|
+
- (void)onCaptureFirstVideoFrame {
|
|
160
|
+
NSLog(@"First video frame captured");
|
|
161
|
+
[self updateUIWithVideoStatus:YES];
|
|
162
|
+
|
|
163
|
+
// Start preview animation
|
|
164
|
+
[self showPreviewAnimation];
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 4. Push Status Callbacks
|
|
169
|
+
|
|
170
|
+
### ๐ onPushStatusUpdate - Connection Status Update
|
|
171
|
+
|
|
172
|
+
```objc
|
|
173
|
+
- (void)onPushStatusUpdate:(V2TXLivePushStatus)status message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Description**: Notifies when the live pusher connection status changes.
|
|
177
|
+
|
|
178
|
+
**Parameters**:
|
|
179
|
+
- `status`: Push status, see `V2TXLivePushStatus`
|
|
180
|
+
- `msg`: Status message
|
|
181
|
+
- `extraInfo`: Additional details
|
|
182
|
+
|
|
183
|
+
**Status Enum Reference**:
|
|
184
|
+
```objc
|
|
185
|
+
typedef NS_ENUM(NSInteger, V2TXLivePushStatus) {
|
|
186
|
+
V2TXLivePushStatusDisconnected = 0, // Disconnected
|
|
187
|
+
V2TXLivePushStatusConnecting, // Connecting
|
|
188
|
+
V2TXLivePushStatusConnectSuccess, // Connected
|
|
189
|
+
V2TXLivePushStatusReconnecting, // Reconnecting
|
|
190
|
+
};
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Status Transition Example**:
|
|
194
|
+
```objc
|
|
195
|
+
- (void)onPushStatusUpdate:(V2TXLivePushStatus)status message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
196
|
+
switch (status) {
|
|
197
|
+
case V2TXLivePushStatusConnecting:
|
|
198
|
+
NSLog(@"Connecting to live streaming server...");
|
|
199
|
+
[self updateStatus:@"Connecting"];
|
|
200
|
+
break;
|
|
201
|
+
|
|
202
|
+
case V2TXLivePushStatusConnectSuccess:
|
|
203
|
+
NSLog(@"Live stream connected successfully");
|
|
204
|
+
[self updateStatus:@"Streaming"];
|
|
205
|
+
[self startPushTimer];
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case V2TXLivePushStatusReconnecting:
|
|
209
|
+
NSLog(@"Network issue, reconnecting...");
|
|
210
|
+
[self updateStatus:@"Reconnecting"];
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
case V2TXLivePushStatusDisconnected:
|
|
214
|
+
NSLog(@"Live stream connection disconnected");
|
|
215
|
+
[self updateStatus:@"Disconnected"];
|
|
216
|
+
[self stopPushTimer];
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 5. Statistics Callback
|
|
223
|
+
|
|
224
|
+
### ๐ onStatisticsUpdate - Streaming Statistics
|
|
225
|
+
|
|
226
|
+
```objc
|
|
227
|
+
- (void)onStatisticsUpdate:(V2TXLivePusherStatistics *)statistics;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Description**: Provides real-time streaming performance metrics.
|
|
231
|
+
|
|
232
|
+
**Parameters**:
|
|
233
|
+
- `statistics`: Streaming statistics object with detailed metrics
|
|
234
|
+
|
|
235
|
+
**Statistics Structure**:
|
|
236
|
+
```objc
|
|
237
|
+
@interface V2TXLivePusherStatistics : NSObject
|
|
238
|
+
|
|
239
|
+
/** App CPU usage (%) */
|
|
240
|
+
@property (nonatomic, assign) int appCpu;
|
|
241
|
+
|
|
242
|
+
/** System CPU usage (%) */
|
|
243
|
+
@property (nonatomic, assign) int systemCpu;
|
|
244
|
+
|
|
245
|
+
/** Video width */
|
|
246
|
+
@property (nonatomic, assign) int width;
|
|
247
|
+
|
|
248
|
+
/** Video height */
|
|
249
|
+
@property (nonatomic, assign) int height;
|
|
250
|
+
|
|
251
|
+
/** Frame rate (fps) */
|
|
252
|
+
@property (nonatomic, assign) int fps;
|
|
253
|
+
|
|
254
|
+
/** Video bitrate (kbps) */
|
|
255
|
+
@property (nonatomic, assign) int videoBitrate;
|
|
256
|
+
|
|
257
|
+
/** Audio bitrate (kbps) */
|
|
258
|
+
@property (nonatomic, assign) int audioBitrate;
|
|
259
|
+
|
|
260
|
+
/** Network latency (ms) */
|
|
261
|
+
@property (nonatomic, assign) int delay;
|
|
262
|
+
|
|
263
|
+
/** Network jitter (ms) */
|
|
264
|
+
@property (nonatomic, assign) int jitter;
|
|
265
|
+
|
|
266
|
+
/** Audio sample rate (Hz) */
|
|
267
|
+
@property (nonatomic, assign) int audioSampleRate;
|
|
268
|
+
|
|
269
|
+
/** Number of audio channels */
|
|
270
|
+
@property (nonatomic, assign) int audioChannels;
|
|
271
|
+
|
|
272
|
+
@end
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Sample Implementation**:
|
|
276
|
+
```objc
|
|
277
|
+
- (void)onStatisticsUpdate:(V2TXLivePusherStatistics *)statistics {
|
|
278
|
+
// Update UI with latest stats
|
|
279
|
+
self.statsLabel.text = [NSString stringWithFormat:@"FPS:%dfps Bitrate:%dkbps Latency:%dms",
|
|
280
|
+
statistics.fps, statistics.videoBitrate, statistics.delay];
|
|
281
|
+
|
|
282
|
+
// Monitor performance
|
|
283
|
+
if (statistics.appCpu > 80) {
|
|
284
|
+
[self adjustPerformance];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Monitor network quality
|
|
288
|
+
if (statistics.delay > 1000) {
|
|
289
|
+
[self adjustBitrateForNetwork];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 6. Audio & Video Processing Callbacks
|
|
295
|
+
|
|
296
|
+
### ๐ onMicrophoneVolumeUpdate - Capture Volume Update
|
|
297
|
+
|
|
298
|
+
```objc
|
|
299
|
+
- (void)onMicrophoneVolumeUpdate:(NSInteger)volume;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Description**: Reports microphone capture volume.
|
|
303
|
+
|
|
304
|
+
**Prerequisite**: Enable volume evaluation via `enableVolumeEvaluation`.
|
|
305
|
+
|
|
306
|
+
**Parameters**:
|
|
307
|
+
- `volume`: Volume level (0-100)
|
|
308
|
+
|
|
309
|
+
**Typical Use Cases**:
|
|
310
|
+
- Display real-time volume
|
|
311
|
+
- Detect mute state
|
|
312
|
+
- Monitor audio quality
|
|
313
|
+
|
|
314
|
+
**Sample Implementation**:
|
|
315
|
+
```objc
|
|
316
|
+
- (void)onMicrophoneVolumeUpdate:(NSInteger)volume {
|
|
317
|
+
// Update volume bar
|
|
318
|
+
[self.volumeView setVolume:volume];
|
|
319
|
+
|
|
320
|
+
// Mute detection
|
|
321
|
+
if (volume < 5) {
|
|
322
|
+
[self showMuteIndicator];
|
|
323
|
+
} else {
|
|
324
|
+
[self hideMuteIndicator];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### ๐ต onProcessAudioFrame - Custom Audio Processing
|
|
330
|
+
|
|
331
|
+
```objc
|
|
332
|
+
- (void)onProcessAudioFrame:(V2TXLiveAudioFrame *)frame;
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Description**: Provides locally captured audio frames after preprocessing, effects, and BGM mixing.
|
|
336
|
+
|
|
337
|
+
**Technical Details**:
|
|
338
|
+
- **Frame Duration**: 0.02 seconds
|
|
339
|
+
- **Format**: PCM
|
|
340
|
+
- **Byte Calculation**: `Sample rate ร Frame duration ร Channel count ร Sample bit width`
|
|
341
|
+
|
|
342
|
+
**Default Example**:
|
|
343
|
+
```
|
|
344
|
+
48000Hz ร 0.02s ร 1 channel ร 16bit = 15360bit = 1920 bytes
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Notes**:
|
|
348
|
+
1. Avoid time-consuming operations in this callback
|
|
349
|
+
2. Processing must complete within 20ms
|
|
350
|
+
3. Audio data is readable and writable for synchronous modification
|
|
351
|
+
|
|
352
|
+
**Sample Implementation**:
|
|
353
|
+
```objc
|
|
354
|
+
- (void)onProcessAudioFrame:(V2TXLiveAudioFrame *)frame {
|
|
355
|
+
// Real-time audio processing
|
|
356
|
+
|
|
357
|
+
// 1. Simple volume boost
|
|
358
|
+
[self enhanceAudioVolume:frame];
|
|
359
|
+
|
|
360
|
+
// 2. Audio spectrum analysis
|
|
361
|
+
[self analyzeAudioSpectrum:frame];
|
|
362
|
+
|
|
363
|
+
// 3. Apply custom effects
|
|
364
|
+
[self applyCustomAudioEffect:frame];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
- (void)enhanceAudioVolume:(V2TXLiveAudioFrame *)frame {
|
|
368
|
+
// Volume boost algorithm
|
|
369
|
+
int16_t *audioData = (int16_t *)frame.data;
|
|
370
|
+
NSUInteger sampleCount = frame.data.length / sizeof(int16_t);
|
|
371
|
+
|
|
372
|
+
for (NSUInteger i = 0; i < sampleCount; i++) {
|
|
373
|
+
audioData[i] = (int16_t)(audioData[i] * 1.2); // Boost volume by 20%
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### ๐ฅ onProcessVideoFrame - Custom Video Processing
|
|
379
|
+
|
|
380
|
+
```objc
|
|
381
|
+
- (void)onProcessVideoFrame:(V2TXLiveVideoFrame *_Nonnull)srcFrame dstFrame:(V2TXLiveVideoFrame *_Nonnull)dstFrame;
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Description**: Enables custom video processing, including beauty filters and effects.
|
|
385
|
+
|
|
386
|
+
**Prerequisite**: Enable via `enableCustomVideoProcess`.
|
|
387
|
+
|
|
388
|
+
**Parameters**:
|
|
389
|
+
- `srcFrame`: Original video frame (read-only)
|
|
390
|
+
- `dstFrame`: Processed video frame (writable)
|
|
391
|
+
|
|
392
|
+
**Use Cases**:
|
|
393
|
+
|
|
394
|
+
#### Beauty Component Generates New Texture
|
|
395
|
+
```objc
|
|
396
|
+
- (void)onProcessVideoFrame:(V2TXLiveVideoFrame *)srcFrame dstFrame:(V2TXLiveVideoFrame *)dstFrame {
|
|
397
|
+
// Beauty filter generates new texture
|
|
398
|
+
GLuint dstTextureId = [self.beautyProcessor processTexture:srcFrame.textureId
|
|
399
|
+
width:srcFrame.width
|
|
400
|
+
height:srcFrame.height];
|
|
401
|
+
|
|
402
|
+
// Assign processed texture
|
|
403
|
+
dstFrame.textureId = dstTextureId;
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
#### Beauty Component Uses Existing Texture
|
|
408
|
+
```objc
|
|
409
|
+
- (void)onProcessVideoFrame:(V2TXLiveVideoFrame *)srcFrame dstFrame:(V2TXLiveVideoFrame *)dstFrame {
|
|
410
|
+
// Third-party beauty filter uses input/output textures
|
|
411
|
+
[self.thirdPartyBeauty processInputTexture:srcFrame.textureId
|
|
412
|
+
outputTexture:dstFrame.textureId
|
|
413
|
+
width:srcFrame.width
|
|
414
|
+
height:srcFrame.height];
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### ๐ง onGLContextDestroyed - OpenGL Context Cleanup
|
|
419
|
+
|
|
420
|
+
```objc
|
|
421
|
+
- (void)onGLContextDestroyed;
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Description**: Notifies when the SDK's internal OpenGL context is destroyed.
|
|
425
|
+
|
|
426
|
+
**Trigger Scenarios**:
|
|
427
|
+
- App enters background
|
|
428
|
+
- Live pusher is released
|
|
429
|
+
- OpenGL context lost
|
|
430
|
+
|
|
431
|
+
**Recommended Handling**:
|
|
432
|
+
```objc
|
|
433
|
+
- (void)onGLContextDestroyed {
|
|
434
|
+
NSLog(@"OpenGL context destroyed");
|
|
435
|
+
|
|
436
|
+
// Release custom OpenGL resources
|
|
437
|
+
[self cleanupGLResources];
|
|
438
|
+
|
|
439
|
+
// Reinitialize OpenGL components as needed
|
|
440
|
+
[self reinitializeGLComponents];
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## 7. Screen Sharing Callbacks
|
|
445
|
+
|
|
446
|
+
### ๐ฅ๏ธ onScreenCaptureStarted - Screen Sharing Started
|
|
447
|
+
|
|
448
|
+
```objc
|
|
449
|
+
- (void)onScreenCaptureStarted;
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**Description**: Indicates that screen sharing has started successfully.
|
|
453
|
+
|
|
454
|
+
**Sample Implementation**:
|
|
455
|
+
```objc
|
|
456
|
+
- (void)onScreenCaptureStarted {
|
|
457
|
+
NSLog(@"Screen sharing started");
|
|
458
|
+
|
|
459
|
+
// Update UI state
|
|
460
|
+
[self updateScreenShareStatus:YES];
|
|
461
|
+
|
|
462
|
+
// Show screen sharing indicator
|
|
463
|
+
[self showScreenShareIndicator];
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### ๐ฅ๏ธ onScreenCaptureStopped - Screen Sharing Stopped
|
|
468
|
+
|
|
469
|
+
```objc
|
|
470
|
+
- (void)onScreenCaptureStopped:(int)reason;
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
**Description**: Indicates that screen sharing has stopped.
|
|
474
|
+
|
|
475
|
+
**Parameters**:
|
|
476
|
+
- `reason`: Stop reason
|
|
477
|
+
- `0`: Stopped manually by user
|
|
478
|
+
- `1`: iOS - interrupted by system; Mac/Windows - window closed
|
|
479
|
+
- `2`: Windows - display device status changed (not triggered on other platforms)
|
|
480
|
+
|
|
481
|
+
**Sample Implementation**:
|
|
482
|
+
```objc
|
|
483
|
+
- (void)onScreenCaptureStopped:(int)reason {
|
|
484
|
+
NSLog(@"Screen sharing stopped, reason: %d", reason);
|
|
485
|
+
|
|
486
|
+
switch (reason) {
|
|
487
|
+
case 0: // User stopped manually
|
|
488
|
+
[self showToast:@"Screen sharing ended"];
|
|
489
|
+
break;
|
|
490
|
+
|
|
491
|
+
case 1: // Interrupted by system
|
|
492
|
+
[self showToast:@"Screen sharing interrupted by system"];
|
|
493
|
+
break;
|
|
494
|
+
|
|
495
|
+
case 2: // Device status changed (Windows only)
|
|
496
|
+
[self showToast:@"Display device status changed"];
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
[self updateScreenShareStatus:NO];
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
## 8. Local Recording Callbacks
|
|
505
|
+
|
|
506
|
+
### ๐น onLocalRecordBegin - Recording Started
|
|
507
|
+
|
|
508
|
+
```objc
|
|
509
|
+
- (void)onLocalRecordBegin:(NSInteger)errCode storagePath:(NSString *)storagePath;
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Description**: Notifies when local recording starts.
|
|
513
|
+
|
|
514
|
+
**Parameters**:
|
|
515
|
+
- `errCode`: Status code
|
|
516
|
+
- `0`: Recording started successfully
|
|
517
|
+
- `-1`: Internal error
|
|
518
|
+
- `-2`: Invalid file extension (unsupported format)
|
|
519
|
+
- `-6`: Recording already started, must stop first
|
|
520
|
+
- `-7`: File exists, must delete first
|
|
521
|
+
- `-8`: No write permission
|
|
522
|
+
- `storagePath`: Recording file path
|
|
523
|
+
|
|
524
|
+
**Sample Implementation**:
|
|
525
|
+
```objc
|
|
526
|
+
- (void)onLocalRecordBegin:(NSInteger)errCode storagePath:(NSString *)storagePath {
|
|
527
|
+
if (errCode == 0) {
|
|
528
|
+
NSLog(@"Local recording started successfully, file path: %@", storagePath);
|
|
529
|
+
[self updateRecordStatus:YES];
|
|
530
|
+
} else {
|
|
531
|
+
NSLog(@"Local recording failed to start, error code: %ld", (long)errCode);
|
|
532
|
+
[self handleRecordError:errCode];
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### ๐น onLocalRecording - Recording Progress
|
|
538
|
+
|
|
539
|
+
```objc
|
|
540
|
+
- (void)onLocalRecording:(NSInteger)durationMs storagePath:(NSString *)storagePath;
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
**Description**: Reports recording progress.
|
|
544
|
+
|
|
545
|
+
**Parameters**:
|
|
546
|
+
- `durationMs`: Duration in milliseconds
|
|
547
|
+
- `storagePath`: Recording file path
|
|
548
|
+
|
|
549
|
+
**Notes**:
|
|
550
|
+
- This callback is disabled by default
|
|
551
|
+
- Set the interval parameter when calling `startLocalRecording`
|
|
552
|
+
|
|
553
|
+
**Sample Implementation**:
|
|
554
|
+
```objc
|
|
555
|
+
- (void)onLocalRecording:(NSInteger)durationMs storagePath:(NSString *)storagePath {
|
|
556
|
+
// Update recording duration display
|
|
557
|
+
NSInteger seconds = durationMs / 1000;
|
|
558
|
+
self.recordTimeLabel.text = [NSString stringWithFormat:@"Recording: %02ld:%02ld",
|
|
559
|
+
seconds / 60, seconds % 60];
|
|
560
|
+
|
|
561
|
+
// Monitor long recording sessions
|
|
562
|
+
if (seconds > 3600) { // Over 1 hour
|
|
563
|
+
[self showLongRecordingWarning];
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### ๐น onLocalRecordComplete - Recording Completed
|
|
569
|
+
|
|
570
|
+
```objc
|
|
571
|
+
- (void)onLocalRecordComplete:(NSInteger)errCode storagePath:(NSString *)storagePath;
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
**Description**: Notifies when local recording ends.
|
|
575
|
+
|
|
576
|
+
**Parameters**:
|
|
577
|
+
- `errCode`: Status code
|
|
578
|
+
- `0`: Recording ended successfully
|
|
579
|
+
- `-1`: Recording failed
|
|
580
|
+
- `-2`: Resolution/orientation change ended recording
|
|
581
|
+
- `-3`: Duration too short or no audio/video captured
|
|
582
|
+
- `storagePath`: Recording file path
|
|
583
|
+
|
|
584
|
+
**Sample Implementation**:
|
|
585
|
+
```objc
|
|
586
|
+
- (void)onLocalRecordComplete:(NSInteger)errCode storagePath:(NSString *)storagePath {
|
|
587
|
+
if (errCode == 0) {
|
|
588
|
+
NSLog(@"Local recording completed, file path: %@", storagePath);
|
|
589
|
+
[self showRecordSuccessAlert:storagePath];
|
|
590
|
+
} else {
|
|
591
|
+
NSLog(@"Local recording failed, error code: %ld", (long)errCode);
|
|
592
|
+
[self handleRecordCompleteError:errCode];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
[self updateRecordStatus:NO];
|
|
596
|
+
}
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## 9. Advanced Feature Callbacks
|
|
600
|
+
|
|
601
|
+
### ๐ onSetMixTranscodingConfig - Cloud Stream Mixing Status
|
|
602
|
+
|
|
603
|
+
```objc
|
|
604
|
+
- (void)onSetMixTranscodingConfig:(V2TXLiveCode)code message:(NSString *)msg;
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
**Description**: Reports the result of setting cloud stream mixing transcoding parameters.
|
|
608
|
+
|
|
609
|
+
**Parameters**:
|
|
610
|
+
- `code`: Result code
|
|
611
|
+
- `msg`: Error message (if any)
|
|
612
|
+
|
|
613
|
+
**Sample Implementation**:
|
|
614
|
+
```objc
|
|
615
|
+
- (void)onSetMixTranscodingConfig:(V2TXLiveCode)code message:(NSString *)msg {
|
|
616
|
+
if (code == V2TXLIVE_OK) {
|
|
617
|
+
NSLog(@"Cloud stream mixing configuration succeeded");
|
|
618
|
+
} else {
|
|
619
|
+
NSLog(@"Cloud stream mixing configuration failed: %@", msg);
|
|
620
|
+
[self retryMixTranscodingConfig];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### ๐ธ onSnapshotComplete - Snapshot Result
|
|
626
|
+
|
|
627
|
+
```objc
|
|
628
|
+
- (void)onSnapshotComplete:(nullable TXImage *)image;
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**Description**: Notifies when a snapshot operation completes.
|
|
632
|
+
|
|
633
|
+
**Prerequisite**: Triggered after calling `snapshot`.
|
|
634
|
+
|
|
635
|
+
**Parameters**:
|
|
636
|
+
- `image`: Captured video frame (may be nil)
|
|
637
|
+
|
|
638
|
+
**Sample Implementation**:
|
|
639
|
+
```objc
|
|
640
|
+
- (void)onSnapshotComplete:(TXImage *)image {
|
|
641
|
+
if (image) {
|
|
642
|
+
// Save snapshot to photo album
|
|
643
|
+
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
|
|
644
|
+
|
|
645
|
+
// Display snapshot preview
|
|
646
|
+
[self showSnapshotPreview:image];
|
|
647
|
+
} else {
|
|
648
|
+
NSLog(@"Snapshot failed");
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### ๐๏ธ onVoiceActivityDetectionUpdate - Voice Activity Detection
|
|
654
|
+
|
|
655
|
+
```objc
|
|
656
|
+
- (void)onVoiceActivityDetectionUpdate:(BOOL)active;
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
**Description**: Reports voice activity detection status.
|
|
660
|
+
|
|
661
|
+
**Prerequisite**: Enable via `enableVoiceActivityDetection`.
|
|
662
|
+
|
|
663
|
+
**Parameters**:
|
|
664
|
+
- `active`: YES if speaking detected, NO otherwise
|
|
665
|
+
|
|
666
|
+
**Sample Implementation**:
|
|
667
|
+
```objc
|
|
668
|
+
- (void)onVoiceActivityDetectionUpdate:(BOOL)active {
|
|
669
|
+
if (active) {
|
|
670
|
+
NSLog(@"Host started speaking detected");
|
|
671
|
+
[self showSpeakingIndicator];
|
|
672
|
+
} else {
|
|
673
|
+
NSLog(@"Host stopped speaking detected");
|
|
674
|
+
[self hideSpeakingIndicator];
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
## 10. Usage Examples
|
|
680
|
+
|
|
681
|
+
### ๐ง Complete Live Pusher Callback Implementation
|
|
682
|
+
|
|
683
|
+
```objc
|
|
684
|
+
#import "V2TXLivePusherObserver.h"
|
|
685
|
+
|
|
686
|
+
@interface MyPusherObserver () <V2TXLivePusherObserver>
|
|
687
|
+
@end
|
|
688
|
+
|
|
689
|
+
@implementation MyPusherObserver
|
|
690
|
+
|
|
691
|
+
#pragma mark - Error and Warning Handling
|
|
692
|
+
|
|
693
|
+
- (void)onError:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
694
|
+
NSLog(@"Live push error: %ld - %@", (long)code, msg);
|
|
695
|
+
|
|
696
|
+
// Handle error based on code
|
|
697
|
+
[self handlePushError:code message:msg];
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
- (void)onWarning:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
701
|
+
NSLog(@"Live push warning: %ld - %@", (long)code, msg);
|
|
702
|
+
|
|
703
|
+
// Display warning toast
|
|
704
|
+
[self showWarningToast:msg];
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
#pragma mark - Push Status Monitoring
|
|
708
|
+
|
|
709
|
+
- (void)onPushStatusUpdate:(V2TXLivePushStatus)status message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
710
|
+
// Update UI status
|
|
711
|
+
[self updatePushStatus:status];
|
|
712
|
+
|
|
713
|
+
// Log status change
|
|
714
|
+
[self logPushStatus:status message:msg];
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
- (void)onStatisticsUpdate:(V2TXLivePusherStatistics *)statistics {
|
|
718
|
+
// Update statistics in UI
|
|
719
|
+
[self updateStatsDisplay:statistics];
|
|
720
|
+
|
|
721
|
+
// Auto-adjust performance
|
|
722
|
+
[self autoAdjustBasedOnStats:statistics];
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
#pragma mark - Audio & Video Processing
|
|
726
|
+
|
|
727
|
+
- (void)onProcessAudioFrame:(V2TXLiveAudioFrame *)frame {
|
|
728
|
+
// Real-time audio processing
|
|
729
|
+
[self.audioProcessor processFrame:frame];
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
- (void)onProcessVideoFrame:(V2TXLiveVideoFrame *)srcFrame dstFrame:(V2TXLiveVideoFrame *)dstFrame {
|
|
733
|
+
// Real-time beauty processing
|
|
734
|
+
[self.beautyProcessor processFrame:srcFrame to:dstFrame];
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
#pragma mark - Recording Features
|
|
738
|
+
|
|
739
|
+
- (void)onLocalRecordBegin:(NSInteger)errCode storagePath:(NSString *)storagePath {
|
|
740
|
+
if (errCode == 0) {
|
|
741
|
+
self.currentRecordPath = storagePath;
|
|
742
|
+
[self startRecordTimer];
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
- (void)onLocalRecording:(NSInteger)durationMs storagePath:(NSString *)storagePath {
|
|
747
|
+
[self updateRecordTime:durationMs];
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
- (void)onLocalRecordComplete:(NSInteger)errCode storagePath:(NSString *)storagePath {
|
|
751
|
+
[self stopRecordTimer];
|
|
752
|
+
[self handleRecordCompletion:errCode path:storagePath];
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
@end
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### ๐ฏ Best Practice Recommendations
|
|
759
|
+
|
|
760
|
+
**Thread Safety**
|
|
761
|
+
```objc
|
|
762
|
+
- (void)onStatisticsUpdate:(V2TXLivePusherStatistics *)statistics {
|
|
763
|
+
// Always update UI on the main thread
|
|
764
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
765
|
+
[self updateStatsUI:statistics];
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
**Performance Optimization**
|
|
771
|
+
```objc
|
|
772
|
+
- (void)onProcessAudioFrame:(V2TXLiveAudioFrame *)frame {
|
|
773
|
+
// Keep callback logic lightweight
|
|
774
|
+
@autoreleasepool {
|
|
775
|
+
[self.lightweightProcessor process:frame];
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
**Error Recovery**
|
|
781
|
+
```objc
|
|
782
|
+
- (void)onError:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
783
|
+
if ([self isRecoverableError:code]) {
|
|
784
|
+
[self scheduleReconnect];
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
## 11. Callback Sequence Diagram
|
|
790
|
+
|
|
791
|
+
### ๐ Live Stream Lifecycle Callback Sequence
|
|
792
|
+
|
|
793
|
+
```
|
|
794
|
+
Live stream start:
|
|
795
|
+
1. onPushStatusUpdate(V2TXLivePushStatusConnecting)
|
|
796
|
+
2. onCaptureFirstVideoFrame (if video enabled)
|
|
797
|
+
3. onCaptureFirstAudioFrame (if audio enabled)
|
|
798
|
+
4. onPushStatusUpdate(V2TXLivePushStatusConnectSuccess)
|
|
799
|
+
5. onStatisticsUpdate (periodic)
|
|
800
|
+
|
|
801
|
+
Live stream stop:
|
|
802
|
+
1. onPushStatusUpdate(V2TXLivePushStatusDisconnected)
|
|
803
|
+
2. onGLContextDestroyed (if using OpenGL)
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
### ๐ Status Transition Diagram
|
|
807
|
+
|
|
808
|
+
```
|
|
809
|
+
Initialize โ Connecting โ Connected โ Streaming
|
|
810
|
+
โ
|
|
811
|
+
Reconnecting โ Connected
|
|
812
|
+
โ
|
|
813
|
+
Disconnected
|
|
814
|
+
```
|