@tencent-rtc/mcp 1.2.8 → 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 (30) 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/definitions/get_native_live_api_def.js +23 -0
  24. package/tools/definitions/get_native_live_api_def.js.map +1 -0
  25. package/tools/index.js +4 -0
  26. package/tools/index.js.map +1 -1
  27. package/tools/native_live/get-native-live-api.js +31 -0
  28. package/tools/native_live/get-native-live-api.js.map +1 -0
  29. package/utils/report-cls-client.js +1 -1
  30. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,437 @@
1
+ # Tencent Cloud Live Streaming SDK V2TXLivePremier API Documentation
2
+
3
+ ## Feature Overview
4
+
5
+ `V2TXLivePremier` is the advanced interface for the Tencent Cloud Live Streaming (CSS) SDK. It provides global configuration and management for the SDK.
6
+
7
+ **File Path**: `v2_tx_live_premier.dart`
8
+ **Platform Support**: Flutter
9
+ **Feature Scope**: SDK initialization, license management, environment configuration
10
+
11
+ ## 📋 Table of Contents
12
+
13
+ ### 1. [V2TXLivePremier API](#v2txlivepremier接口)
14
+ ### 2. [V2TXLivePremierObserver Callback Interface](#v2txlivepremierobserver回调接口)
15
+
16
+ ## 1. V2TXLivePremier API
17
+
18
+ ### Get SDK Version
19
+ ```dart
20
+ static Future<String> getSDKVersionStr() async
21
+ ```
22
+
23
+ **Return Value**: SDK version string, e.g., "10.7.0.12345"
24
+
25
+ **When to Use**: No restrictions
26
+
27
+ **Typical Use Cases**:
28
+ - Checking version compatibility
29
+ - Providing version details for troubleshooting
30
+ - Reporting and monitoring
31
+
32
+ **Example**:
33
+ ```dart
34
+ String version = await V2TXLivePremier.getSDKVersionStr();
35
+ print('Current SDK version: $version');
36
+ ```
37
+
38
+ ### Set Observer Callback
39
+ ```dart
40
+ static Future<void> setObserver(V2TXLivePremierObserver? observer) async
41
+ ```
42
+
43
+ **Parameter**:
44
+ - `observer`: An object that implements the V2TXLivePremierObserver protocol
45
+
46
+ **When to Use**: Set at app startup for global effect
47
+
48
+ **Notes**:
49
+ - Set the observer once during app startup
50
+ - The observer object must remain valid for the entire app lifecycle
51
+
52
+ **Example**:
53
+ ```dart
54
+ await V2TXLivePremier.setObserver((type, params) {
55
+ switch (type) {
56
+ case V2TXLivePremierObserverType.onLog:
57
+ print('Log output: ${params['log']}');
58
+ break;
59
+ case V2TXLivePremierObserverType.onLicenceLoaded:
60
+ print('Licence load result: ${params['result']}');
61
+ break;
62
+ }
63
+ });
64
+ ```
65
+
66
+ ### Configure SDK Environment
67
+ ```dart
68
+ static Future<V2TXLiveCode> setEnvironment(String env) async
69
+ ```
70
+
71
+ **Parameter**:
72
+ - `env`: Environment identifier. Options:
73
+ - `"default"`: Default environment; SDK automatically selects the optimal access point
74
+ - `"GDPR"`: GDPR-compliant environment; audio/video data does not pass through Mainland China servers
75
+
76
+ **Note**: Only call this API if you have specific requirements.
77
+
78
+ **Example**:
79
+ ```dart
80
+ // Call only if GDPR compliance is required
81
+ await V2TXLivePremier.setEnvironment("GDPR");
82
+ ```
83
+
84
+ ### Set License Authorization
85
+ ```dart
86
+ static Future<void> setLicence(String url, String key) async
87
+ ```
88
+
89
+ **Parameters**:
90
+ - `url`: License URL
91
+ - `key`: License key
92
+
93
+ **When to Use**: Call at app startup, before any streaming or playback
94
+
95
+ **Documentation**: https://cloud.tencent.com/document/product/454/34750
96
+
97
+ **Example**:
98
+ ```dart
99
+ class MyApplication extends StatelessWidget {
100
+ @override
101
+ Widget build(BuildContext context) {
102
+ // Set license during app startup
103
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
104
+ await V2TXLivePremier.setObserver((type, params) {
105
+ if (type == V2TXLivePremierObserverType.onLicenceLoaded) {
106
+ int result = params?['result'] ?? -1;
107
+ String reason = params?['reason'] ?? '';
108
+
109
+ if (result == 0) {
110
+ print('Licence loaded successfully, $reason');
111
+ } else if (result == -4) {
112
+ print('Licence package name mismatch, $reason');
113
+ } else if (result == -11) {
114
+ print('Licence expired, $reason');
115
+ } else {
116
+ print('Licence other error, $reason');
117
+ }
118
+ }
119
+ });
120
+ await V2TXLivePremier.setLicence("your_licence_url", "your_licence_key");
121
+ });
122
+
123
+ return MaterialApp(
124
+ home: MyHomePage(),
125
+ );
126
+ }
127
+ }
128
+ ```
129
+
130
+ ### Call Experimental API
131
+ ```dart
132
+ static Future<V2TXLiveCode> callExperimentalAPI(String jsonStr) async
133
+ ```
134
+
135
+ **Parameter**:
136
+ - `jsonStr`: JSON string describing the API and its parameters
137
+
138
+ **Return Value**:
139
+ - `V2TXLIVE_OK`: Success
140
+ - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Invalid parameter
141
+
142
+ **Example**:
143
+ ```dart
144
+ String jsonParams = '{"api": "test", "param": "value"}';
145
+ V2TXLiveCode result = await V2TXLivePremier.callExperimentalAPI(jsonParams);
146
+ if (result == V2TXLiveCode.V2TXLIVE_OK) {
147
+ print('Experimental API call succeeded');
148
+ }
149
+ ```
150
+
151
+ ## 2. V2TXLivePremierObserver Callback Interface
152
+
153
+ ### Log Output Callback
154
+ ```dart
155
+ void Function(V2TXLivePremierObserverType type, Map<String, dynamic>? params)
156
+ ```
157
+
158
+ **Parameters**:
159
+ - `type`: Callback type, should be `V2TXLivePremierObserverType.onLog`
160
+ - `params`: Contains `level` and `log`
161
+
162
+ **Use Cases**:
163
+ - Custom log processing
164
+ - Redirect logs to external systems
165
+ - Log filtering and formatting
166
+
167
+ **Example**:
168
+ ```dart
169
+ V2TXLivePremier.setObserver((type, params) {
170
+ if (type == V2TXLivePremierObserverType.onLog) {
171
+ int level = params?['level'] ?? 0;
172
+ String log = params?['log'] ?? '';
173
+
174
+ // Custom log handling
175
+ if (level >= V2TXLiveLogLevel.V2TXLiveLogLevelWarning) {
176
+ print('Warning log: $log');
177
+ } else {
178
+ print('Normal log: $log');
179
+ }
180
+ }
181
+ });
182
+ ```
183
+
184
+ ### License Load Callback
185
+ ```dart
186
+ void Function(V2TXLivePremierObserverType type, Map<String, dynamic>? params)
187
+ ```
188
+
189
+ **Parameters**:
190
+ - `type`: Callback type, should be `V2TXLivePremierObserverType.onLicenceLoaded`
191
+ - `params`: Contains `result` and `reason`
192
+
193
+ **Example**:
194
+ ```dart
195
+ V2TXLivePremier.setObserver((type, params) {
196
+ if (type == V2TXLivePremierObserverType.onLicenceLoaded) {
197
+ int result = params?['result'] ?? -1;
198
+ String reason = params?['reason'] ?? '';
199
+
200
+ if (result == 0) {
201
+ print('Licence loaded successfully: $reason');
202
+ } else {
203
+ print('Licence load failed ($result): $reason');
204
+ }
205
+ }
206
+ });
207
+ ```
208
+
209
+ ## Code Examples
210
+
211
+ ### SDK Initialization Example
212
+ ```dart
213
+ import 'package:flutter/material.dart';
214
+ import 'package:tencent_trtc/v2_tx_live_premier.dart';
215
+ import 'package:tencent_trtc/v2_tx_live_def.dart';
216
+
217
+ class MyApplication extends StatelessWidget {
218
+ @override
219
+ Widget build(BuildContext context) {
220
+ // Initialize SDK at app startup
221
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
222
+ await SDKManager.initializeSDK();
223
+ });
224
+
225
+ return MaterialApp(
226
+ title: 'Tencent Cloud Live Streaming SDK Example',
227
+ home: MyHomePage(),
228
+ );
229
+ }
230
+ }
231
+
232
+ class SDKManager {
233
+ static Future<void> initializeSDK() async {
234
+ try {
235
+ // 1. Register observer callback
236
+ await V2TXLivePremier.setObserver((type, params) {
237
+ switch (type) {
238
+ case V2TXLivePremierObserverType.onLog:
239
+ int level = params?['level'] ?? 0;
240
+ String log = params?['log'] ?? '';
241
+
242
+ // Handle logs by level
243
+ if (level >= V2TXLiveLogLevel.V2TXLiveLogLevelWarning) {
244
+ print('⚠️ Warning log: $log');
245
+ } else if (level >= V2TXLiveLogLevel.V2TXLiveLogLevelInfo) {
246
+ print('ℹ️ Info log: $log');
247
+ } else {
248
+ print('🔍 Debug log: $log');
249
+ }
250
+ break;
251
+
252
+ case V2TXLivePremierObserverType.onLicenceLoaded:
253
+ int result = params?['result'] ?? -1;
254
+ String reason = params?['reason'] ?? '';
255
+
256
+ if (result == 0) {
257
+ print('✅ Licence loaded successfully: $reason');
258
+ } else if (result == -4) {
259
+ print('❌ Licence package name mismatch: $reason');
260
+ } else if (result == -11) {
261
+ print('❌ Licence expired: $reason');
262
+ } else {
263
+ print('❌ Licence load failed ($result): $reason');
264
+ }
265
+ break;
266
+ }
267
+ });
268
+
269
+ // 2. Set license (required)
270
+ await V2TXLivePremier.setLicence("your_licence_url", "your_licence_key");
271
+
272
+ // 3. Get SDK version
273
+ String version = await V2TXLivePremier.getSDKVersionStr();
274
+ print('📦 SDK version: $version');
275
+
276
+ print('🎉 SDK initialization complete');
277
+
278
+ } catch (e) {
279
+ print('❌ SDK initialization exception: $e');
280
+ }
281
+ }
282
+ }
283
+ ```
284
+
285
+ #### Experimental API Example
286
+ ```dart
287
+ class ExperimentalAPI {
288
+ static Future<void> testExperimentalAPI() async {
289
+ try {
290
+ // Call experimental API
291
+ String jsonParams = '''
292
+ {
293
+ "api": "testFeature",
294
+ "params": {
295
+ "enable": true,
296
+ "threshold": 0.5,
297
+ "mode": "auto"
298
+ }
299
+ }
300
+ ''';
301
+
302
+ V2TXLiveCode result = await V2TXLivePremier.callExperimentalAPI(jsonParams);
303
+
304
+ if (result == V2TXLiveCode.V2TXLIVE_OK) {
305
+ print('✅ Experimental API call succeeded');
306
+ } else if (result == V2TXLiveCode.V2TXLIVE_ERROR_INVALID_PARAMETER) {
307
+ print('❌ Experimental API parameter error');
308
+ } else {
309
+ print('❌ Experimental API call failed: $result');
310
+ }
311
+
312
+ } catch (e) {
313
+ print('❌ Experimental API call exception: $e');
314
+ }
315
+ }
316
+ }
317
+ ```
318
+
319
+ ## Notes
320
+
321
+ ### License Authorization Management
322
+ - **Required**: Call `setLicence()` before using the SDK; otherwise, features will be restricted
323
+ - **Timing**: Set during app startup, before any streaming or playback
324
+ - **Error Handling**: Monitor authorization status with the `onLicenceLoaded` callback
325
+
326
+ ### Callback Registration Timing
327
+ - **Early Registration**: Register observer callbacks before SDK initialization
328
+ - **Single Registration**: Set only once at app startup
329
+ - **Lifecycle**: The observer object must remain valid throughout the app lifecycle
330
+
331
+ ### Thread Safety
332
+ - **Main Thread Execution**: All callbacks in Flutter run on the UI main thread
333
+ - **No Thread Handling Required**: No extra thread synchronization needed
334
+ - **Async Safety**: Ensure asynchronous operations are handled correctly
335
+
336
+ ### Memory Management
337
+ - **Timely Removal**: Remove observers when no longer needed
338
+ - **Avoid Cyclic References**: Do not hold strong references to the SDK in callbacks
339
+ - **Resource Release**: Release all resources when the app exits
340
+
341
+ ### Log Configuration
342
+ - **Debug Phase**: Enable detailed logs for troubleshooting
343
+ - **Production Environment**: Reduce log output for better performance
344
+ - **Custom Handling**: Use the `onLog` callback for custom log processing
345
+
346
+ ### Environment Configuration
347
+ - **Default Environment**: Use unless you have special requirements
348
+ - **GDPR Environment**: Use only if GDPR compliance is required
349
+ - **Proxy Settings**: Configure only if proxy access is needed
350
+
351
+ ## Best Practices
352
+
353
+ ### License Setup Best Practices
354
+ ```dart
355
+ class LicenceManager {
356
+ static Future<bool> setupLicence() async {
357
+ try {
358
+ // Register license callback
359
+ await V2TXLivePremier.setObserver((type, params) {
360
+ if (type == V2TXLivePremierObserverType.onLicenceLoaded) {
361
+ int result = params?['result'] ?? -1;
362
+ String reason = params?['reason'] ?? '';
363
+
364
+ if (result == 0) {
365
+ print('✅ License authorized successfully');
366
+ } else {
367
+ print('❌ License authorization failed ($result): $reason');
368
+ // Show user-friendly error messages based on error code
369
+ showLicenceErrorDialog(result, reason);
370
+ }
371
+ }
372
+ });
373
+
374
+ // Set license
375
+ await V2TXLivePremier.setLicence("your_licence_url", "your_licence_key");
376
+ return true;
377
+
378
+ } catch (e) {
379
+ print('❌ License setup exception: $e');
380
+ return false;
381
+ }
382
+ }
383
+
384
+ static void showLicenceErrorDialog(int result, String reason) {
385
+ // Show error message based on error code
386
+ String message = '';
387
+ switch (result) {
388
+ case -4:
389
+ message = 'App package name mismatch. Please check your license configuration.';
390
+ break;
391
+ case -11:
392
+ message = 'License expired. Please renew your license.';
393
+ break;
394
+ default:
395
+ message = 'License configuration error: $reason';
396
+ break;
397
+ }
398
+
399
+ // Display error dialog
400
+ showDialog(
401
+ context: context,
402
+ builder: (context) => AlertDialog(
403
+ title: Text('License Error'),
404
+ content: Text(message),
405
+ actions: [
406
+ TextButton(
407
+ onPressed: () => Navigator.pop(context),
408
+ child: Text('OK'),
409
+ ),
410
+ ],
411
+ ),
412
+ );
413
+ }
414
+ }
415
+ ```
416
+
417
+ ## FAQs
418
+
419
+ ### Q: How do I troubleshoot license setup failures?
420
+ A: Check the following:
421
+ 1. Is the license URL and key correct?
422
+ 2. Does the app package name match the license configuration?
423
+ 3. Is the license still valid?
424
+ 4. Is the network connection working?
425
+
426
+ ### Q: What if the log file becomes too large?
427
+ A: Recommendations:
428
+ 1. Use a higher log level in production
429
+ 2. Clean up log files regularly
430
+ 3. Use custom log callbacks to filter logs
431
+
432
+ ### Q: How do I test experimental APIs?
433
+ A: Recommendations:
434
+ 1. Use in a test environment
435
+ 2. Review API documentation carefully
436
+ 3. Handle exceptions appropriately
437
+ 4. Provide feedback on your experience