@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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/resource/doc/native_live/android/V2TXLiveCode_api_android.md +312 -0
  3. package/resource/doc/native_live/android/V2TXLiveDef_api_android.md +430 -0
  4. package/resource/doc/native_live/android/V2TXLivePlayerObserver_api_android.md +679 -0
  5. package/resource/doc/native_live/android/V2TXLivePlayer_api_android.md +671 -0
  6. package/resource/doc/native_live/android/V2TXLivePremier_api_android.md +271 -0
  7. package/resource/doc/native_live/android/V2TXLivePusherObserver_api_android.md +849 -0
  8. package/resource/doc/native_live/android/V2TXLivePusher_api_android.md +1046 -0
  9. package/resource/doc/native_live/flutter/V2TXLiveCode_api_flutter.md +460 -0
  10. package/resource/doc/native_live/flutter/V2TXLiveDef_api_flutter.md +558 -0
  11. package/resource/doc/native_live/flutter/V2TXLivePlayerObserver_api_flutter.md +865 -0
  12. package/resource/doc/native_live/flutter/V2TXLivePlayer_api_flutter.md +657 -0
  13. package/resource/doc/native_live/flutter/V2TXLivePremier_api_flutter.md +437 -0
  14. package/resource/doc/native_live/flutter/V2TXLivePusherObserver_api_flutter.md +335 -0
  15. package/resource/doc/native_live/flutter/V2TXLivePusher_api_flutter.md +748 -0
  16. package/resource/doc/native_live/iOS/V2TXLiveCode_api_iOS.md +327 -0
  17. package/resource/doc/native_live/iOS/V2TXLiveDef_api_iOS.md +507 -0
  18. package/resource/doc/native_live/iOS/V2TXLivePlayerObserver_api_iOS.md +507 -0
  19. package/resource/doc/native_live/iOS/V2TXLivePlayer_api_iOS.md +659 -0
  20. package/resource/doc/native_live/iOS/V2TXLivePremier_api_iOS.md +284 -0
  21. package/resource/doc/native_live/iOS/V2TXLivePusherObserver_api_iOS.md +814 -0
  22. package/resource/doc/native_live/iOS/V2TXLivePusher_api_iOS.md +1000 -0
  23. package/tools/common/get-faq.js +1 -1
  24. package/tools/common/get-faq.js.map +1 -1
  25. package/tools/definitions/get_native_live_api_def.js +23 -0
  26. package/tools/definitions/get_native_live_api_def.js.map +1 -0
  27. package/tools/index.js +4 -0
  28. package/tools/index.js.map +1 -1
  29. package/tools/native_live/get-native-live-api.js +31 -0
  30. package/tools/native_live/get-native-live-api.js.map +1 -0
  31. package/utils/report-cls-client.js +1 -1
  32. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,1046 @@
1
+ # Tencent Cloud Live Streaming SDK V2TXLivePusher Streaming API Documentation
2
+
3
+ ## Feature Overview
4
+
5
+ `V2TXLivePusher` is the primary streaming interface in the Tencent Cloud Live Streaming SDK. It handles encoding local audio and video and pushes the stream to a specified URL, supporting any streaming server.
6
+
7
+ **File Path**: `com/tencent/live2/V2TXLivePusher.java`
8
+ **Platform Support**: Android
9
+
10
+ ## Core Features
11
+
12
+ ### 🎯 Main Capabilities
13
+ - ✅ **Capture Sources**: Camera, microphone, screen, image, custom capture
14
+ - ✅ **Video Controls**: Rotation, fill mode, mirroring, watermark
15
+ - ✅ **Streaming Controls**: Start/stop, pause/resume, audio/video separation
16
+ - ✅ **Effects**: Beauty, filters, stickers, audio effects
17
+ - ✅ **Cloud Stream Mixing**: Multi-channel audio/video stream mix transcoding
18
+ - ✅ **Local Recording**: Record audio/video streams locally
19
+ - ✅ **Custom Capture**: Support for external devices and special formats
20
+
21
+ ### 🔧 Technical Highlights
22
+ - **Low Latency**: Optimized encoding and adaptive networking
23
+ - **High Compatibility**: Supports multiple video encoding formats and resolutions
24
+ - **Easy Integration**: Simple APIs and robust callback system
25
+ - **High Performance**: Hardware encoding acceleration and efficient capture pipeline
26
+
27
+ ### Creating a Pusher Instance
28
+ ```java
29
+ // Create an RTMP protocol pusher instance; startPush must use an RTMP URL
30
+ V2TXLivePusher pusher = new V2TXLivePusherImpl(context, V2TXLiveDef.V2TXLiveMode.TXLiveMode_RTMP);
31
+
32
+ // Create an RTC protocol pusher instance; startPush must use an RTC URL
33
+ V2TXLivePusher pusher = new V2TXLivePusherImpl(context, V2TXLiveDef.V2TXLiveMode.TXLiveMode_RTC);
34
+ ```
35
+
36
+ **Protocol Selection Guidelines**:
37
+ - **RTMP Protocol**: Best for CDN live streaming; latency is typically 2–3 seconds.
38
+ - **RTC Protocol**: Ideal for real-time interactive scenarios; latency is typically under 400ms.
39
+
40
+ ## API Details
41
+
42
+ ### 1. Basic Setup Interfaces
43
+
44
+ #### setObserver() - Set Pusher Callback
45
+ ```java
46
+ public abstract void setObserver(V2TXLivePusherObserver observer);
47
+ ```
48
+
49
+ **Parameters**:
50
+ - `observer`: Callback object implementing `V2TXLivePusherObserver`
51
+
52
+ **When to Use**: Set immediately after initializing the pusher.
53
+
54
+ **Description**: Register a callback to receive pusher status updates, volume changes, statistics, warnings, and errors.
55
+
56
+ **Example**:
57
+ ```java
58
+ pusher.setObserver(new V2TXLivePusherObserver(){
59
+ // ...
60
+ });
61
+ ```
62
+
63
+ #### setRenderView() - Set Local Camera Preview View
64
+ ```java
65
+ public abstract int setRenderView(TXCloudVideoView view);
66
+ public abstract int setRenderView(TextureView view);
67
+ public abstract int setRenderView(SurfaceView view);
68
+ ```
69
+
70
+ **Parameters**:
71
+ - `view`: Preview view; supports three types
72
+
73
+ **Return Value**: `V2TXLiveCode`
74
+ - `V2TXLIVE_OK`: Success
75
+
76
+ **When to Use**: Set the preview view before starting the stream.
77
+
78
+ **Description**: The camera feed, after applying beauty, face shape adjustment, filters, and other effects, will display on the specified view.
79
+
80
+ **Example**:
81
+ ```java
82
+ pusher.setRenderView(videoView);
83
+ ```
84
+
85
+ #### setRenderMirror() - Set Local Camera Preview Mirroring
86
+ ```java
87
+ public abstract int setRenderMirror(V2TXLiveMirrorType mirrorType);
88
+ ```
89
+
90
+ **Parameters**:
91
+ - `mirrorType`: Camera mirror type (`V2TXLiveDef#V2TXLiveMirrorType`)
92
+ - `V2TXLiveMirrorTypeAuto` [default]: Front camera mirrored, rear camera not mirrored
93
+ - `V2TXLiveMirrorTypeEnable`: Both front and rear cameras mirrored
94
+ - `V2TXLiveMirrorTypeDisable`: Both front and rear cameras not mirrored
95
+
96
+ **Return Value**: `V2TXLiveCode`
97
+ - `V2TXLIVE_OK`: Success
98
+
99
+ **When to Use**: No restrictions
100
+
101
+ **Example**:
102
+ ```java
103
+ // Front camera mirrored, rear camera not mirrored
104
+ pusher.setRenderMirror(V2TXLiveDef.V2TXLiveMirrorType.V2TXLiveMirrorTypeAuto);
105
+ // All cameras mirrored
106
+ pusher.setRenderMirror(V2TXLiveDef.V2TXLiveMirrorType.V2TXLiveMirrorTypeEnable);
107
+ // All cameras not mirrored
108
+ pusher.setRenderMirror(V2TXLiveDef.V2TXLiveMirrorType.V2TXLiveMirrorTypeDisable);
109
+ ```
110
+
111
+ #### setEncoderMirror() - Set Video Encoding Mirroring
112
+ ```java
113
+ public abstract int setEncoderMirror(boolean mirror);
114
+ ```
115
+
116
+ **Parameters**:
117
+ - `mirror`: Whether to mirror [default: false]
118
+
119
+ **Return Value**: `V2TXLiveCode`
120
+ - `V2TXLIVE_OK`: Success
121
+
122
+ **Description**: Encoding mirroring only affects the video displayed to the audience.
123
+
124
+ **When to Use**: No restrictions
125
+
126
+ **Example**:
127
+ ```java
128
+ // Audience sees mirrored video
129
+ pusher.setEncoderMirror(true);
130
+ // Audience sees non-mirrored video
131
+ pusher.setEncoderMirror(false);
132
+ ```
133
+
134
+ #### setRenderRotation() - Set Local Camera Preview Rotation
135
+ ```java
136
+ public abstract int setRenderRotation(V2TXLiveRotation rotation);
137
+ ```
138
+
139
+ **Parameters**:
140
+ - `rotation`: Preview rotation angle (`V2TXLiveDef#V2TXLiveRotation`)
141
+ - `V2TXLiveRotation0` [default]: 0°, no rotation
142
+ - `V2TXLiveRotation90`: 90° clockwise
143
+ - `V2TXLiveRotation180`: 180° clockwise
144
+ - `V2TXLiveRotation270`: 270° clockwise
145
+
146
+ **Return Value**: `V2TXLiveCode`
147
+ - `V2TXLIVE_OK`: Success
148
+
149
+ **Description**: Rotates only the local preview; does not affect the streamed video.
150
+
151
+ **When to Use**: No restrictions
152
+
153
+ **Example**:
154
+ ```java
155
+ // Set preview rotation to 0°
156
+ pusher.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
157
+ // Set preview rotation to 90°
158
+ pusher.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation90);
159
+ // Set preview rotation to 180°
160
+ pusher.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation180);
161
+ // Set preview rotation to 270°
162
+ pusher.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
163
+ ```
164
+
165
+ #### setRenderFillMode() - Set Local Camera Preview Fill Mode
166
+ ```java
167
+ public abstract int setRenderFillMode(V2TXLiveFillMode mode);
168
+ ```
169
+
170
+ **Parameters**:
171
+ - `mode`: Fill mode (`V2TXLiveDef#V2TXLiveFillMode`)
172
+ - `V2TXLiveFillModeFill` [default]: Image fills the screen, no black borders, some cropping
173
+ - `V2TXLiveFillModeFit`: Image fits the screen, no cropping, may have black borders
174
+ - `V2TXLiveFillModeScaleFill`: Image stretched to fill; aspect ratio may not be preserved
175
+
176
+ **Return Value**: `V2TXLiveCode`
177
+ - `V2TXLIVE_OK`: Success
178
+
179
+ **When to Use**: No restrictions
180
+
181
+ **Example**:
182
+ ```java
183
+ // Image fills the screen
184
+ pusher.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFill);
185
+ // Image fits the screen
186
+ pusher.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit);
187
+ // Image stretched to fill
188
+ pusher.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeScaleFill);
189
+ ```
190
+
191
+ ### 2. Capture Control Interfaces
192
+
193
+ #### startCamera() / stopCamera() - Enable/Disable Camera Capture
194
+ ```java
195
+ public abstract int startCamera(boolean frontCamera);
196
+ public abstract int stopCamera();
197
+ ```
198
+
199
+ **Parameters**:
200
+ - `frontCamera`: true for front camera [default: true]
201
+
202
+ **Return Value**: `V2TXLiveCode`
203
+ - `V2TXLIVE_OK`: Success
204
+
205
+ **Important**:
206
+ - **Enable at least one capture source before streaming**; otherwise, streaming will fail.
207
+ - Only one capture source can be active per pusher instance: `startVirtualCamera`, `startCamera`, or `startScreenCapture`.
208
+ - To switch sources, stop the current source before starting another.
209
+
210
+ **When to Use**: Call before starting the stream.
211
+
212
+ **Example**:
213
+ ```java
214
+ // Enable front camera
215
+ pusher.startCamera(true);
216
+ // Enable rear camera
217
+ pusher.startCamera(false);
218
+ // Stop camera capture
219
+ pusher.stopCamera();
220
+ ```
221
+
222
+ #### startMicrophone() / stopMicrophone() - Enable/Disable Microphone Capture
223
+ ```java
224
+ public abstract int startMicrophone();
225
+ public abstract int stopMicrophone();
226
+ ```
227
+
228
+ **Return Value**: `V2TXLiveCode`
229
+ - `V2TXLIVE_OK`: Success
230
+
231
+ **Use Cases**:
232
+ - **Audio/Video Streaming**: Capture audio with camera
233
+ - **Audio-only Streaming**: Use microphone alone
234
+ - **Screen Sharing**: Combine with screen capture for system and microphone audio
235
+
236
+ **Notes**:
237
+ - **Enable microphone capture before streaming**; otherwise, only video will be streamed.
238
+ - For audio-only streaming, use microphone capture alone.
239
+ - Microphone capture can be toggled during streaming.
240
+
241
+ **When to Use**: Call before starting the stream.
242
+
243
+ **Example**:
244
+ ```java
245
+ // Enable microphone capture
246
+ pusher.startMicrophone();
247
+ // Stop microphone capture
248
+ pusher.stopMicrophone();
249
+ ```
250
+
251
+ #### startVirtualCamera() / stopVirtualCamera() - Enable/Disable Image Streaming
252
+ ```java
253
+ public abstract int startVirtualCamera(Bitmap image);
254
+ public abstract int stopVirtualCamera();
255
+ ```
256
+
257
+ **Parameters**:
258
+ - `image`: Image to stream
259
+
260
+ **Return Value**: `V2TXLiveCode`
261
+ - `V2TXLIVE_OK`: Success
262
+
263
+ **Use Cases**:
264
+ - **Image Streaming**: Use a static image as the video source
265
+ - **Maintenance Page**: Display maintenance info during downtime
266
+ - **Ad Display**: Show advertisement images
267
+
268
+ **Notes**:
269
+ - **Enable image streaming before streaming**; otherwise, streaming will fail.
270
+ - The image is encoded as video, consuming bandwidth.
271
+ - Typically used with microphone capture for audio.
272
+ - Image streaming and camera capture cannot be enabled simultaneously.
273
+
274
+ **When to Use**: Call before starting the stream.
275
+
276
+ **Example**:
277
+ ```java
278
+ // Enable image streaming
279
+ Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.live_image);
280
+ pusher.startVirtualCamera(image);
281
+ // Stop image streaming
282
+ pusher.stopVirtualCamera();
283
+ ```
284
+
285
+ #### startScreenCapture() / stopScreenCapture() - Enable/Disable Screen Capture
286
+ ```java
287
+ public abstract int startScreenCapture();
288
+ public abstract int stopScreenCapture();
289
+ ```
290
+
291
+ **Return Value**: `V2TXLiveCode`
292
+ - `V2TXLIVE_OK`: Success
293
+
294
+ **Use Cases**:
295
+ - **Screen Sharing**: Share device screen for live streaming
296
+ - **Remote Teaching**: Share screens for online classes
297
+ - **Game Streaming**: Stream gameplay
298
+ - **App Demo**: Demonstrate app workflows
299
+
300
+ **Notes**:
301
+ - **Enable screen capture before streaming**; otherwise, streaming will fail.
302
+ - Android requires screen recording permissions.
303
+ - Can be combined with `startSystemAudioLoopback()` to capture system audio.
304
+ - Screen capture and camera capture cannot be enabled simultaneously.
305
+
306
+ **When to Use**: Call before starting the stream.
307
+
308
+ **Example**:
309
+ ```java
310
+ // Enable screen capture
311
+ pusher.startScreenCapture();
312
+ // Stop screen capture
313
+ pusher.stopScreenCapture();
314
+ ```
315
+
316
+ ### 3. Streaming Control Interfaces
317
+
318
+ #### startPush() - Start Streaming
319
+ ```java
320
+ public abstract int startPush(String url);
321
+ ```
322
+
323
+ **Parameters**:
324
+ - `url`: Target streaming address; supports any streaming server
325
+
326
+ **Return Value**: `V2TXLiveCode`
327
+ - `V2TXLIVE_OK`: Operation successful, connecting to target
328
+ - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Invalid URL
329
+ - `V2TXLIVE_ERROR_INVALID_LICENSE`: Invalid license, authentication failed
330
+ - `V2TXLIVE_ERROR_REFUSED`: RTC does not support simultaneous push/pull of the same StreamId on one device
331
+
332
+ **Important**:
333
+ - **Enable at least one capture source before calling startPush()**; otherwise, streaming will fail.
334
+ - Supported sources: camera, microphone, screen, image streaming, custom capture.
335
+ - You can switch sources during streaming, but must stop the current source before starting another.
336
+
337
+ **When to Use**: After enabling a capture source.
338
+
339
+ **Example**:
340
+ ```java
341
+ int result = pusher.startPush("rtmp://example.com/live/stream");
342
+ if (result == V2TXLiveCode.V2TXLIVE_OK) {
343
+ Log.i(TAG, "Streaming started successfully");
344
+ } else if (result == V2TXLiveCode.V2TXLIVE_ERROR_INVALID_PARAMETER) {
345
+ Log.w(TAG, "Invalid streaming URL");
346
+ } else if (result == V2TXLiveCode.V2TXLIVE_ERROR_INVALID_LICENSE) {
347
+ Log.w(TAG, "Invalid license, please check your license");
348
+ } else if (result == V2TXLiveCode.V2TXLIVE_ERROR_REFUSED) {
349
+ Log.w(TAG, "Operation refused");
350
+ }
351
+ ```
352
+
353
+ #### stopPush() - Stop Streaming
354
+ ```java
355
+ public abstract int stopPush();
356
+ ```
357
+
358
+ **Return Value**: `V2TXLiveCode`
359
+ - `V2TXLIVE_OK`: Success
360
+
361
+ **When to Use**: After streaming has started.
362
+
363
+ **Example**:
364
+ ```java
365
+ pusher.stopPush();
366
+ ```
367
+
368
+ #### isPushing() - Check Streaming Status
369
+ ```java
370
+ public abstract int isPushing();
371
+ ```
372
+
373
+ **Return Value**:
374
+ - `1`: Currently streaming
375
+ - `0`: Streaming stopped
376
+
377
+ **When to Use**: No restrictions
378
+
379
+ **Example**:
380
+ ```java
381
+ int isPushing = pusher.isPushing();
382
+ if (isPushing == 1) {
383
+ Log.i(TAG, "Streaming in progress");
384
+ } else {
385
+ Log.i(TAG, "Streaming stopped");
386
+ }
387
+ ```
388
+
389
+ ### 4. Audio/Video Control Interfaces
390
+
391
+ #### pauseAudio() / resumeAudio() - Pause/Resume Audio
392
+ ```java
393
+ public abstract int pauseAudio();
394
+ public abstract int resumeAudio();
395
+ ```
396
+
397
+ **Return Value**: `V2TXLiveCode`
398
+ - `V2TXLIVE_OK`: Success
399
+
400
+ **When to Use**: No restrictions
401
+
402
+ **Example**:
403
+ ```java
404
+ // Pause audio
405
+ pusher.pauseAudio();
406
+ // Resume audio
407
+ pusher.resumeAudio();
408
+ ```
409
+
410
+ #### pauseVideo() / resumeVideo() - Pause/Resume Video
411
+ ```java
412
+ public abstract int pauseVideo();
413
+ public abstract int resumeVideo();
414
+ ```
415
+
416
+ **Return Value**: `V2TXLiveCode`
417
+ - `V2TXLIVE_OK`: Success
418
+
419
+ **When to Use**: No restrictions
420
+
421
+ **Example**:
422
+ ```java
423
+ // Pause video
424
+ pusher.pauseVideo();
425
+ // Resume video
426
+ pusher.resumeVideo();
427
+ ```
428
+
429
+ #### setAudioQuality() - Set Audio Quality
430
+ ```java
431
+ public abstract int setAudioQuality(V2TXLiveAudioQuality quality);
432
+ ```
433
+
434
+ **Parameters**:
435
+ - `quality`: Audio quality (`V2TXLiveDef#V2TXLiveAudioQuality`)
436
+ - `V2TXLiveAudioQualityDefault` [default]: General quality
437
+ - `V2TXLiveAudioQualitySpeech`: Speech quality
438
+ - `V2TXLiveAudioQualityMusic`: Music quality
439
+
440
+ **Return Value**: `V2TXLiveCode`
441
+ - `V2TXLIVE_OK`: Success
442
+ - `V2TXLIVE_ERROR_REFUSED`: Cannot change audio quality during streaming
443
+
444
+ **When to Use**: Before streaming starts
445
+
446
+ **Example**:
447
+ ```java
448
+ // Set general audio quality
449
+ pusher.setAudioQuality(V2TXLiveDef.V2TXLiveAudioQuality.V2TXLiveAudioQualityDefault);
450
+ // Set speech quality
451
+ pusher.setAudioQuality(V2TXLiveDef.V2TXLiveAudioQuality.V2TXLiveAudioQualitySpeech);
452
+ // Set music quality
453
+ pusher.setAudioQuality(V2TXLiveDef.V2TXLiveAudioQuality.V2TXLiveAudioQualityMusic);
454
+ ```
455
+
456
+ #### setVideoQuality() - Set Video Encoding Parameters
457
+ ```java
458
+ public abstract int setVideoQuality(V2TXLiveVideoEncoderParam param);
459
+ ```
460
+
461
+ **Parameters**:
462
+ - `param`: Video encoding parameters
463
+
464
+ **Return Value**: `V2TXLiveCode`
465
+ - `V2TXLIVE_OK`: Success
466
+
467
+ **When to Use**: Before streaming starts
468
+
469
+ **Example**:
470
+ ```java
471
+ V2TXLiveVideoEncoderParam param = new V2TXLiveVideoEncoderParam();
472
+ param.videoResolution = V2TXLiveVideoResolution.V2TXLiveVideoResolution1280x720;
473
+ param.videoFps = 15;
474
+ param.videoBitrate = 1200;
475
+ pusher.setVideoQuality(param);
476
+ ```
477
+
478
+ ### 5. Effects Management Interfaces
479
+
480
+ #### getAudioEffectManager() - Get Audio Effect Manager
481
+ ```java
482
+ public abstract TXAudioEffectManager getAudioEffectManager();
483
+ ```
484
+
485
+ **Description**:
486
+ - Adjust microphone volume
487
+ - Set reverb and voice effects
488
+ - Enable ear monitoring and adjust ear monitor volume
489
+ - Add background music and control playback
490
+
491
+ **Return Value**: `TXAudioEffectManager` object
492
+
493
+ **When to Use**: No restrictions
494
+
495
+ **Example**:
496
+ ```java
497
+ TXAudioEffectManager audioEffectManager = pusher.getAudioEffectManager();
498
+ // Set voice volume
499
+ audioEffectManager.setVoiceVolume(100);
500
+ // Set background music volume
501
+ audioEffectManager.setAllMusicVolume(50);
502
+ ```
503
+
504
+ #### getBeautyManager() - Get Beauty Manager
505
+ ```java
506
+ public abstract TXBeautyManager getBeautyManager();
507
+ ```
508
+
509
+ **Description**:
510
+ - Set beauty style, whitening, ruddy, big eyes, face slimming, and other beauty effects
511
+ - Adjust hairline, eye spacing, eye corners, mouth shape, and other facial features
512
+ - Add facial accessories and dynamic effects
513
+ - Apply makeup effects
514
+ - Perform gesture recognition
515
+
516
+ **Return Value**: `TXBeautyManager` object
517
+
518
+ **When to Use**: No restrictions
519
+
520
+ **Example**:
521
+ ```java
522
+ TXBeautyManager beautyManager = pusher.getBeautyManager();
523
+ // Set beauty style
524
+ beautyManager.setBeautyStyle(TXBeautyManager.TXBeautyStyleNature);
525
+ // Set whitening level
526
+ beautyManager.setWhitenessLevel(5);
527
+ // Set ruddy level
528
+ beautyManager.setRuddyLevel(5);
529
+ ```
530
+
531
+ #### getDeviceManager() - Get Device Manager
532
+ ```java
533
+ public abstract TXDeviceManager getDeviceManager();
534
+ ```
535
+
536
+ **Description**:
537
+ - Switch between front and rear cameras
538
+ - Enable auto focus
539
+ - Set camera zoom
540
+ - Toggle flashlight
541
+ - Switch between headset and speaker
542
+ - Change volume type (media or call)
543
+
544
+ **Return Value**: `TXDeviceManager` object
545
+
546
+ **When to Use**: No restrictions
547
+
548
+ **Example**:
549
+ ```java
550
+ TXDeviceManager deviceManager = pusher.getDeviceManager();
551
+ // Switch camera
552
+ deviceManager.switchCamera(true);
553
+ // Enable auto focus
554
+ deviceManager.setAutoFocusEnabled(true);
555
+ // Enable flashlight
556
+ deviceManager.enableTorch(true);
557
+ ```
558
+
559
+ ### 6. Advanced Feature Interfaces
560
+
561
+ #### snapshot() - Capture Local Frame
562
+ ```java
563
+ public abstract int snapshot();
564
+ ```
565
+
566
+ **Return Value**: `V2TXLiveCode`
567
+ - `V2TXLIVE_OK`: Success
568
+ - `V2TXLIVE_ERROR_REFUSED`: Streaming stopped; cannot snapshot
569
+
570
+ **When to Use**: After streaming has started
571
+
572
+ **Example**:
573
+ ```java
574
+ pusher.setObserver(new V2TXLivePusherObserver() {
575
+ @Override
576
+ public void onSnapshotComplete(Bitmap image) {
577
+ // Handle snapshot result
578
+ }
579
+ });
580
+ pusher.snapshot();
581
+ ```
582
+
583
+ #### setWatermark() - Set Watermark
584
+ ```java
585
+ public abstract int setWatermark(Bitmap image, float x, float y, float scale);
586
+ ```
587
+
588
+ **Parameters**:
589
+ - `image`: Watermark image; null disables watermark
590
+ - `x`: Horizontal position (0–1)
591
+ - `y`: Vertical position (0–1)
592
+ - `scale`: Scale (0–1)
593
+
594
+ **Return Value**: `V2TXLiveCode`
595
+ - `V2TXLIVE_OK`: Success
596
+
597
+ **When to Use**: No restrictions
598
+
599
+ **Example**:
600
+ ```java
601
+ Bitmap watermark = BitmapFactory.decodeResource(getResources(), R.drawable.watermark);
602
+ pusher.setWatermark(watermark, 0.1f, 0.1f, 0.2f);
603
+ // Disable watermark
604
+ pusher.setWatermark(null, 0, 0, 0);
605
+ ```
606
+
607
+ #### enableVolumeEvaluation() - Enable Capture Volume Evaluation
608
+ ```java
609
+ public abstract int enableVolumeEvaluation(int intervalMs);
610
+ ```
611
+
612
+ **Parameters**:
613
+ - `intervalMs`: Callback interval in ms; minimum 100ms. Set <=0 to disable [default: 0]
614
+
615
+ **Return Value**: `V2TXLiveCode`
616
+ - `V2TXLIVE_OK`: Success
617
+
618
+ **Description**: When enabled, the SDK reports volume via the `onMicrophoneVolumeUpdate` callback.
619
+
620
+ **When to Use**: No restrictions
621
+
622
+ **Example**:
623
+ ```java
624
+ pusher.setObserver(new V2TXLivePusherObserver() {
625
+ @Override
626
+ public void onMicrophoneVolumeUpdate(int volume) {
627
+ // Handle volume update
628
+ }
629
+ });
630
+ pusher.enableVolumeEvaluation(300);
631
+ ```
632
+
633
+ #### enableCustomVideoProcess() - Enable/Disable Custom Video Processing
634
+ ```java
635
+ public abstract int enableCustomVideoProcess(boolean enable, V2TXLivePixelFormat pixelFormat, V2TXLiveBufferType bufferType);
636
+ ```
637
+
638
+ **Parameters**:
639
+ - `enable`: true to enable, false to disable [default: false]
640
+ - `pixelFormat`: Pixel format (`V2TXLiveDef#V2TXLivePixelFormat`)
641
+ - `bufferType`: Buffer type (`V2TXLiveDef#V2TXLiveBufferType`)
642
+
643
+ **Return Value**: `V2TXLiveCode`
644
+ - `V2TXLIVE_OK`: Success
645
+ - `V2TXLIVE_ERROR_NOT_SUPPORTED`: Unsupported format
646
+
647
+ **Supported Format Combinations**:
648
+ - `V2TXLivePixelFormatTexture2D + V2TXLiveBufferTypeTexture`
649
+ - `V2TXLivePixelFormatI420 + V2TXLiveBufferTypeByteBuffer`
650
+
651
+ **When to Use**: Before streaming starts
652
+
653
+ **Example**:
654
+ ```java
655
+ pusher.enableCustomVideoProcess(true,
656
+ V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatTexture2D,
657
+ V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeTexture);
658
+ ```
659
+
660
+ #### enableCustomVideoCapture() - Enable/Disable Custom Video Capture
661
+ ```java
662
+ public abstract int enableCustomVideoCapture(boolean enable);
663
+ ```
664
+
665
+ **Parameters**:
666
+ - `enable`: true to enable, false to disable [default: false]
667
+
668
+ **Return Value**: `V2TXLiveCode`
669
+ - `V2TXLIVE_OK`: Success
670
+
671
+ **Use Cases**:
672
+ - **External Device Capture**: Use external cameras, capture cards, etc.
673
+ - **Video Processing**: Pre-process video before streaming
674
+ - **Multi-source Composition**: Combine multiple video sources
675
+ - **Special Formats**: Stream special video formats
676
+
677
+ **Notes**:
678
+ - **Enable custom capture before streaming**; otherwise, streaming will fail.
679
+ - Must be called before `startPush` to take effect.
680
+ - In custom capture mode, the SDK only encodes and sends; it does not capture.
681
+
682
+ **When to Use**: Before streaming starts
683
+
684
+ **Example**:
685
+ ```java
686
+ // Enable custom video capture
687
+ pusher.enableCustomVideoCapture(true);
688
+ pusher.startPush(url);
689
+
690
+ // Send custom video frame
691
+ V2TXLiveVideoFrame videoFrame = new V2TXLiveVideoFrame();
692
+ videoFrame.width = 1920;
693
+ videoFrame.height = 1080;
694
+ videoFrame.pixelFormat = V2TXLivePixelFormat.V2TXLivePixelFormatI420;
695
+ videoFrame.bufferType = V2TXLiveBufferType.V2TXLiveBufferTypeByteBuffer;
696
+ pusher.sendCustomVideoFrame(videoFrame);
697
+ ```
698
+
699
+ #### enableCustomAudioCapture() - Enable/Disable Custom Audio Capture
700
+ ```java
701
+ public abstract int enableCustomAudioCapture(boolean enable);
702
+ ```
703
+
704
+ **Parameters**:
705
+ - `enable`: true to enable, false to disable [default: false]
706
+
707
+ **Return Value**: `V2TXLiveCode`
708
+ - `V2TXLIVE_OK`: Success
709
+
710
+ **Use Cases**:
711
+ - **External Audio Devices**: Use external microphones, audio interfaces, etc.
712
+ - **Audio Processing**: Pre-process audio before streaming
713
+ - **Multi-channel Audio**: Combine multiple audio sources
714
+
715
+ **Notes**:
716
+ - **Enable custom capture before streaming**; otherwise, streaming will fail.
717
+ - Must be called before `startPush` to take effect.
718
+ - In custom capture mode, the SDK only encodes and sends; it does not capture.
719
+
720
+ **When to Use**: Before streaming starts
721
+
722
+ **Example**:
723
+ ```java
724
+ // Enable custom audio capture
725
+ pusher.enableCustomAudioCapture(true);
726
+ pusher.startPush(url);
727
+
728
+ // Send custom audio frame
729
+ V2TXLiveAudioFrame audioFrame = new V2TXLiveAudioFrame();
730
+ audioFrame.data = audioData; // PCM audio data
731
+ audioFrame.sampleRate = 44100; // Sample rate
732
+ audioFrame.channel = 1; // Audio channel count
733
+ pusher.sendCustomAudioFrame(audioFrame);
734
+ ```
735
+
736
+ #### sendSeiMessage() - Send SEI Message
737
+ ```java
738
+ public abstract int sendSeiMessage(int payloadType, byte[] data);
739
+ ```
740
+
741
+ **Parameters**:
742
+ - `payloadType`: Data type; supports 5 and 242 (recommend 242)
743
+ - `data`: Data to send
744
+
745
+ **Return Value**: `V2TXLiveCode`
746
+ - `V2TXLIVE_OK`: Success
747
+
748
+ **Description**: The player receives this message via the `onReceiveSeiMessage` callback.
749
+
750
+ **When to Use**: During streaming
751
+
752
+ **Example**:
753
+ ```java
754
+ byte[] seiData = "Hello SEI".getBytes();
755
+ pusher.sendSeiMessage(242, seiData);
756
+ ```
757
+
758
+ #### startSystemAudioLoopback() / stopSystemAudioLoopback() - Enable/Disable System Audio Capture
759
+ ```java
760
+ public abstract int startSystemAudioLoopback();
761
+ public abstract int stopSystemAudioLoopback();
762
+ ```
763
+
764
+ **Return Value**: `V2TXLiveCode`
765
+ - `V2TXLIVE_OK`: Success
766
+
767
+ **Description**:
768
+ - Captures all system audio playback and mixes with microphone audio for cloud streaming
769
+ - Only available on Android API 29+
770
+ - Must enable before starting screen sharing
771
+ - Requires a foreground service to avoid silent capture
772
+
773
+ **When to Use**: Before streaming starts
774
+
775
+ **Example**:
776
+ ```java
777
+ // Enable system audio capture
778
+ pusher.startSystemAudioLoopback();
779
+ // Disable system audio capture
780
+ pusher.stopSystemAudioLoopback();
781
+ ```
782
+
783
+ #### setMixTranscodingConfig() - Set Cloud Stream Mixing Parameters
784
+ ```java
785
+ public abstract int setMixTranscodingConfig(V2TXLiveTranscodingConfig config);
786
+ ```
787
+
788
+ **Parameters**:
789
+ - `config`: MixTranscoding configuration; pass null to cancel cloud stream mixing
790
+
791
+ **Return Value**: `V2TXLiveCode`
792
+ - `V2TXLIVE_OK`: Success
793
+ - `V2TXLIVE_ERROR_REFUSED`: Not allowed if streaming hasn't started
794
+
795
+ **Mixing Principle**:
796
+ ```
797
+ [Video 1] => Decoding ====> \
798
+ \
799
+ [Video 2] => Decoding => Video Mixing => Encoding => [Mixed Video]
800
+ /
801
+ [Video 3] => Decoding ====> /
802
+
803
+ [Audio 1] => Decoding ====> \
804
+ \
805
+ [Audio 2] => Decoding => Audio Mixing => Encoding => [Mixed Audio]
806
+ /
807
+ [Audio 3] => Decoding ====> /
808
+ ```
809
+
810
+ **Notes**:
811
+ - **RTC Protocol Only**: This API is only supported for RTC protocol; not available for RTMP or other protocols.
812
+ - Cloud transcoding adds 1–2 seconds of CDN viewing latency.
813
+ - Cancel mixing configuration promptly to avoid unnecessary charges.
814
+
815
+ **When to Use**: During streaming
816
+
817
+ **Example**:
818
+ ```java
819
+ V2TXLiveTranscodingConfig config = new V2TXLiveTranscodingConfig();
820
+ config.videoWidth = 1280;
821
+ config.videoHeight = 720;
822
+ config.videoBitrate = 1500;
823
+ config.videoFps = 15;
824
+ pusher.setMixTranscodingConfig(config);
825
+
826
+ // Cancel mixing
827
+ pusher.setMixTranscodingConfig(null);
828
+ ```
829
+
830
+ #### startLocalRecording() / stopLocalRecording() - Start/Stop Local Recording
831
+ ```java
832
+ public abstract int startLocalRecording(V2TXLiveLocalRecordingParams params);
833
+ public abstract void stopLocalRecording();
834
+ ```
835
+
836
+ **Parameters**:
837
+ - `params`: Local recording parameters
838
+
839
+ **Return Value**: `V2TXLiveCode`
840
+ - `V2TXLIVE_OK`: Success
841
+ - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Invalid parameters
842
+ - `V2TXLIVE_ERROR_REFUSED`: API refused; streaming not started
843
+
844
+ **Description**: Recording can only start after streaming is enabled; recording is invalid when not streaming.
845
+
846
+ **When to Use**: During streaming
847
+
848
+ **Example**:
849
+ ```java
850
+ pusher.setObserver(new V2TXLivePusherObserver() {
851
+ @Override
852
+ public void onLocalRecordBegin(int code, String storagePath) {
853
+ Log.i(TAG, "Recording started");
854
+ }
855
+
856
+ @Override
857
+ public void onLocalRecording(long durationMs, String storagePath) {
858
+ Log.i(TAG, "Recording..., durationMs: " + durationMs);
859
+ }
860
+
861
+ @Override
862
+ public void onLocalRecordComplete(int code, String storagePath) {
863
+ Log.i(TAG, "Recording completed");
864
+ }
865
+ });
866
+
867
+ V2TXLiveLocalRecordingParams params = new V2TXLiveLocalRecordingParams();
868
+ params.filePath = "filepath";
869
+ params.interval = 2000;
870
+ int code = pusher.startLocalRecording(params);
871
+ if (code == V2TXLIVE_OK) {
872
+ Log.i(TAG, "Recording started successfully");
873
+ } else if (code == V2TXLIVE_ERROR_INVALID_PARAMETER) {
874
+ Log.i(TAG, "Invalid recording parameters");
875
+ } else if (code == V2TXLIVE_ERROR_REFUSED) {
876
+ Log.i(TAG, "Recording call refused");
877
+ }
878
+ ```
879
+
880
+ #### showDebugView() - Show Debug Dashboard
881
+ ```java
882
+ public abstract void showDebugView(boolean isShow);
883
+ ```
884
+
885
+ **Parameters**:
886
+ - `isShow`: true to show, false to hide [default: false]
887
+
888
+ **When to Use**: No restrictions
889
+
890
+ **Example**:
891
+ ```java
892
+ // Show debug view
893
+ pusher.showDebugView(true);
894
+ // Hide debug view
895
+ pusher.showDebugView(false);
896
+ ```
897
+
898
+ #### setProperty() - Call Advanced V2TXLivePusher API
899
+ ```java
900
+ public abstract int setProperty(String key, Object value);
901
+ ```
902
+
903
+ **Parameters**:
904
+ - `key`: Advanced API key; see `V2TXLiveProperty` for details
905
+ - `value`: Parameter for the corresponding advanced API
906
+
907
+ **Return Value**: `V2TXLiveCode`
908
+ - `V2TXLIVE_OK`: Success
909
+ - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Key cannot be empty
910
+
911
+ **Description**: For advanced features. For special requirements, contact your business or solution architect.
912
+
913
+ **When to Use**: No restrictions
914
+
915
+ **Example**:
916
+ ```java
917
+ pusher.setProperty("key", "value");
918
+ ```
919
+
920
+ ## Code Examples
921
+
922
+ ### Basic Streaming (Camera + Microphone)
923
+ ```java
924
+ // Create pusher instance
925
+ V2TXLivePusher pusher = new V2TXLivePusherImpl(context);
926
+
927
+ // Set callback
928
+ pusher.setObserver(new V2TXLivePusherObserver() {
929
+ @Override
930
+ public void onPushStatusUpdate(V2TXLiveDef.V2TXLivePushStatus status, String msg, Bundle extraInfo) {
931
+ // Handle streaming status changes
932
+ }
933
+ });
934
+
935
+ // Set preview view
936
+ pusher.setRenderView(textureView);
937
+
938
+ // Important: Enable at least one capture source before streaming
939
+ // 1. Enable camera capture (front camera)
940
+ pusher.startCamera(true);
941
+
942
+ // 2. Enable microphone capture
943
+ pusher.startMicrophone();
944
+
945
+ // 3. Start streaming (after enabling a capture source)
946
+ pusher.startPush("rtmp://your-stream-url");
947
+ ```
948
+
949
+ ### Screen Sharing Streaming
950
+ ```java
951
+ // Create pusher instance
952
+ V2TXLivePusher pusher = new V2TXLivePusherImpl(context);
953
+
954
+ // Set callback
955
+ pusher.setObserver(new V2TXLivePusherObserver() {
956
+ @Override
957
+ public void onPushStatusUpdate(V2TXLiveDef.V2TXLivePushStatus status, String msg, Bundle extraInfo) {
958
+ // Handle streaming status changes
959
+ }
960
+ });
961
+
962
+ // Important: Enable at least one capture source before streaming
963
+ // 1. Enable screen capture
964
+ pusher.startScreenCapture();
965
+
966
+ // 2. Enable microphone capture (optional, if audio is needed)
967
+ pusher.startMicrophone();
968
+
969
+ // 3. Start streaming
970
+ pusher.startPush("rtmp://your-stream-url");
971
+ ```
972
+
973
+ ### Custom Capture
974
+ ```java
975
+ // Create pusher instance
976
+ V2TXLivePusher pusher = new V2TXLivePusherImpl(context);
977
+
978
+ // Set callback
979
+ pusher.setObserver(new V2TXLivePusherObserver() {
980
+ @Override
981
+ public void onPushStatusUpdate(V2TXLiveDef.V2TXLivePushStatus status, String msg, Bundle extraInfo) {
982
+ // Handle streaming status changes
983
+ }
984
+ });
985
+
986
+ // Important: Enable at least one capture source before streaming
987
+ // 1. Enable custom video capture (call before startPush)
988
+ pusher.enableCustomVideoCapture(true);
989
+
990
+ // 2. Enable custom audio capture (optional, if audio is needed)
991
+ pusher.enableCustomAudioCapture(true);
992
+
993
+ // 3. Start streaming
994
+ pusher.startPush("rtmp://your-stream-url");
995
+
996
+ // 4. Send video frames in custom capture mode
997
+ V2TXLiveVideoFrame videoFrame = new V2TXLiveVideoFrame();
998
+ videoFrame.width = 1920;
999
+ videoFrame.height = 1080;
1000
+ videoFrame.pixelFormat = V2TXLivePixelFormat.V2TXLivePixelFormatI420;
1001
+ videoFrame.bufferType = V2TXLiveBufferType.V2TXLiveBufferTypeByteBuffer;
1002
+ pusher.sendCustomVideoFrame(videoFrame);
1003
+ ```
1004
+
1005
+ ## Notes
1006
+
1007
+ ### 1. Capture Source Requirements
1008
+ **Enable at least one capture source before streaming**, or streaming will fail:
1009
+ - **Camera Capture**: `startCamera()` + `startMicrophone()`
1010
+ - **Screen Capture**: `startScreenCapture()` + `startMicrophone()`
1011
+ - **Image Streaming**: `startVirtualCamera()` + `startMicrophone()`
1012
+ - **Custom Capture**: `enableCustomVideoCapture()` + `enableCustomAudioCapture()`
1013
+ - **Audio-only Streaming**: `startMicrophone()`
1014
+
1015
+ ### 2. Capture Source Switching
1016
+ - Only one capture source can be active per pusher instance.
1017
+ - To switch sources, always stop the current source before starting another.
1018
+
1019
+ ### 3. Required Call Sequence
1020
+ 1. Create pusher instance
1021
+ 2. Set callback and preview view
1022
+ 3. Enable at least one capture source
1023
+ 4. Call `startPush()` to begin streaming
1024
+
1025
+ ### 4. Custom Capture
1026
+ - Call custom capture APIs before `startPush` to take effect.
1027
+ - In custom capture mode, the SDK only encodes and sends; it does not capture.
1028
+
1029
+ ### 5. Cloud Stream Mixing
1030
+ - **Protocol Limitation**: Cloud stream mixing is only supported for RTC protocol, not RTMP or other protocols.
1031
+ - Cancel mixing configuration promptly to avoid unnecessary charges.
1032
+ - Cloud transcoding adds 1–2 seconds of CDN viewing latency.
1033
+
1034
+ ### 6. Local Recording
1035
+ - Recording can only start after streaming is enabled.
1036
+ - Do not change resolution or switch hardware/software encoding during recording.
1037
+
1038
+ ### 7. System Audio Capture
1039
+ - Requires Android API 29 or above.
1040
+ - Requires a foreground service to avoid silent capture.
1041
+ - Only works during screen sharing.
1042
+
1043
+ ### 8. Performance Optimization
1044
+ - Select appropriate audio/video quality settings for your scenario.
1045
+ - Release unused pusher instances promptly.
1046
+ - Use pause/resume functions to save bandwidth.