@tencent-rtc/mcp 1.3.6 → 1.3.8

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.
@@ -0,0 +1,486 @@
1
+ `BaseBeautyStore` is the module in `AtomicXCore` for management of basic beauty effects for portraits. Through it, you can easily add natural beauty effects to your live stream or call applications.
2
+
3
+ ## Core Features
4
+ - **Skin smoothing adjustment**: Set the skin smoothing strength (0-9).
5
+
6
+ - **Brightening effect adjustment**: Set the brightening strength (0-9).
7
+
8
+ - **Rosy effect adjustment**: Set the rosy strength (0-9).
9
+
10
+ - **Effect reset**: One-click restore all beauty parameters to default value.
11
+
12
+ - **Listen for status**: Get currently effective beauty parameters in real time.
13
+
14
+
15
+ ## Core Concepts
16
+
17
+ Before starting integration, we first learn about the core concepts related to `BaseBeautyStore` in the following table:
18
+ <table>
19
+ <tr>
20
+ <td rowspan="1" colSpan="1" >**Core Concepts**</td>
21
+
22
+ <td rowspan="1" colSpan="1" >**Type**</td>
23
+
24
+ <td rowspan="1" colSpan="1" >**Core Responsibilities and Description**</td>
25
+ </tr>
26
+
27
+ <tr>
28
+ <td rowspan="1" colSpan="1" >[BaseBeautyState](https://tencent-rtc.github.io/TUIKit_Flutter/api_device_base_beauty_store/BaseBeautyState-class.html)</td>
29
+
30
+ <td rowspan="1" colSpan="1" >`class`</td>
31
+
32
+ <td rowspan="1" colSpan="1" >Represents the current status of the beauty module. It includes the intensity values of currently effective skin smoothing (`smoothLevel`), whitening (`whitenessLevel`), and rosy (`ruddyLevel`). All attributes are `ValueListenable<double>` data type and support subscription listening.</td>
33
+ </tr>
34
+
35
+ <tr>
36
+ <td rowspan="1" colSpan="1" >[BaseBeautyStore](https://tencent-rtc.github.io/TUIKit_Flutter/api_device_base_beauty_store/BaseBeautyStore-class.html)</td>
37
+
38
+ <td rowspan="1" colSpan="1" >`class`</td>
39
+
40
+ <td rowspan="1" colSpan="1" >This is the core management class for interacting with the basic beauty filter feature. It is a Global Singleton (`shared`), responsible for ALL basic beauty parameter settings, reset and state synchronization.</td>
41
+ </tr>
42
+ </table>
43
+
44
+
45
+ ## Implementation Steps
46
+
47
+ ### Step 1: Integrating the Component
48
+
49
+ Refer to [Quick Connection](https://write.woa.com/document/200455640177692672) for seamless integration with **AtomicXCore** and access completed.
50
+
51
+ ### Step 2: Getting the Instance and Listening to the Status
52
+
53
+ Get the Global Singleton of `BaseBeautyStore` and set a listener to get the current beauty effect parameter status in real time.
54
+
55
+ #### Implementation Method
56
+ 1. **Get the singleton**: Directly use `BaseBeautyStore.shared` to get the globally unique `BaseBeautyStore` instance.
57
+
58
+ 2. **Subscription status**: Listen for changes in the `baseBeautyState` properties via `addListener` to get beauty parameter updates in real time.
59
+
60
+
61
+ #### Sample Code
62
+ ``` java
63
+ import 'package:flutter/material.dart';
64
+ import 'package:atomic_x_core/atomicxcore.dart';
65
+
66
+ class BeautyManager {
67
+ // 1. Get a singleton
68
+ final _baseBeautyStore = BaseBeautyStore.shared;
69
+ late final VoidCallback _smoothLevelChangedListener = _onSmoothLevelChanged;
70
+ late final VoidCallback _whitenessLevelChangedListener = _onWhitenessLevelChanged;
71
+ late final VoidCallback _ruddyLevelChangedListener = _onRuddyLevelChanged;
72
+
73
+ // 2. Subscription status
74
+ void subscribeToBeautyState() {
75
+ _baseBeautyStore.baseBeautyState.smoothLevel.addListener(_smoothLevelChangedListener);
76
+ _baseBeautyStore.baseBeautyState.whitenessLevel.addListener(_whitenessLevelChangedListener);
77
+ _baseBeautyStore.baseBeautyState.ruddyLevel.addListener(_ruddyLevelChangedListener);
78
+ }
79
+
80
+ void _onSmoothLevelChanged() {
81
+ final level = _baseBeautyStore.baseBeautyState.smoothLevel.value;
82
+ debugPrint('Skin smoothing strength adjustment: $level');
83
+ }
84
+
85
+ void _onWhitenessLevelChanged() {
86
+ final level = _baseBeautyStore.baseBeautyState.whitenessLevel.value;
87
+ debugPrint('Whitening strength adjustment: $level');
88
+ }
89
+
90
+ void _onRuddyLevelChanged() {
91
+ final level = _baseBeautyStore.baseBeautyState.ruddyLevel.value;
92
+ debugPrint('Rosy strength adjustment: $level');
93
+ }
94
+
95
+ // Execute dispose before logging out of the App
96
+ void dispose() {
97
+ _baseBeautyStore.baseBeautyState.smoothLevel.removeListener(_smoothLevelChangedListener);
98
+ _baseBeautyStore.baseBeautyState.whitenessLevel.removeListener(_whitenessLevelChangedListener);
99
+ _baseBeautyStore.baseBeautyState.ruddyLevel.removeListener(_ruddyLevelChangedListener);
100
+ }
101
+ }
102
+ ```
103
+
104
+ ### Step 3: Set Beauty Parameter
105
+
106
+ When the user drags the beauty effect slider or clicks the preset button, call the appropriate API to set the intensity of beauty effects.
107
+
108
+ #### Implementation Method
109
+ 1. **Get intensity value**: Obtain the intensity value set by the user from the UI control (such as `Slider`). The parameter range accepted by the SDK API is `0-9`, where `0` means disabling the effect and `9` indicates the most obvious effect. You need to map the value of the UI control (for example, `0.0 - 1.0` of the Slider) to the range of `0 - 9`.
110
+
111
+ 2. **API call**: Call `setSmoothLevel()`, `setWhitenessLevel()`, and `setRuddyLevel()` to set the intensity of skin smoothing, whitening, and rosy effect.
112
+
113
+
114
+ #### Sample Code
115
+ ``` java
116
+ extension BeautyManagerExtension on BeautyManager {
117
+ /// Set the skin smoothing strength (input range 0.0 ~ 1.0, internal conversion to 0 ~ 9)
118
+ void updateSmoothLevel(double uiLevel) {
119
+ // Map the UI's 0.0 ~ 1.0 to the SDK's 0 ~ 9
120
+ final sdkLevel = uiLevel * 9.0;
121
+ _baseBeautyStore.setSmoothLevel(sdkLevel);
122
+ }
123
+
124
+ /// Set the whitening strength (input range 0.0 ~ 1.0, internal conversion to 0 ~ 9)
125
+ void updateWhitenessLevel(double uiLevel) {
126
+ final sdkLevel = uiLevel * 9.0;
127
+ _baseBeautyStore.setWhitenessLevel(sdkLevel);
128
+ }
129
+
130
+ /// Set the ruddy level (input range 0.0 ~ 1.0, internal conversion to 0 ~ 9)
131
+ void updateRuddyLevel(double uiLevel) {
132
+ final sdkLevel = uiLevel * 9.0;
133
+ _baseBeautyStore.setRuddyLevel(sdkLevel);
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### Step 4: Reset Beauty Effect
139
+
140
+ When the user clicks the "Reset" or "Disable Beauty Effects" button, restore all beauty parameters to the default value (usually 0).
141
+
142
+ #### Implementation Method
143
+
144
+ **Calling the API**: call directly the `baseBeautyStore.reset()` method.
145
+
146
+ #### Sample Code
147
+ ``` java
148
+ extension BeautyManagerReset on BeautyManager {
149
+ /// Reset ALL basic beauty effects
150
+ void resetBeautyEffects() {
151
+ _baseBeautyStore.reset();
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## Building a Beauty Effect UI
157
+
158
+ Flutter recommended using `ValueListenableBuilder` to build responsive UI, which auto-updates the interface when beauty effect parameters change:
159
+ ``` java
160
+ class BeautySliderWidget extends StatelessWidget {
161
+ final beautyStore = BaseBeautyStore.shared;
162
+
163
+ @override
164
+ Widget build(BuildContext context) {
165
+ return Column(
166
+ children: [
167
+ // Skin smoothing slider
168
+ ValueListenableBuilder<double>(
169
+ valueListenable: beautyStore.baseBeautyState.smoothLevel,
170
+ builder: (context, smoothLevel, child) {
171
+ return Row(
172
+ children: [
173
+ Text('Skin smoothing')
174
+ Expanded(
175
+ child: Slider(
176
+ value: smoothLevel,
177
+ min: 0,
178
+ max: 9,
179
+ divisions: 9,
180
+ onChanged: (value) {
181
+ beautyStore.setSmoothLevel(value);
182
+ },
183
+ ),
184
+ ),
185
+ Text('${smoothLevel.toInt()}'),
186
+ ],
187
+ );
188
+ },
189
+ ),
190
+ // Whitening slider
191
+ ValueListenableBuilder<double>(
192
+ valueListenable: beautyStore.baseBeautyState.whitenessLevel,
193
+ builder: (context, whitenessLevel, child) {
194
+ return Row(
195
+ children: [
196
+ Text('Whitening')
197
+ Expanded(
198
+ child: Slider(
199
+ value: whitenessLevel,
200
+ min: 0,
201
+ max: 9,
202
+ divisions: 9,
203
+ onChanged: (value) {
204
+ beautyStore.setWhitenessLevel(value);
205
+ },
206
+ ),
207
+ ),
208
+ Text('${whitenessLevel.toInt()}'),
209
+ ],
210
+ );
211
+ },
212
+ ),
213
+ // rosy slider
214
+ ValueListenableBuilder<double>(
215
+ valueListenable: beautyStore.baseBeautyState.ruddyLevel,
216
+ builder: (context, ruddyLevel, child) {
217
+ return Row(
218
+ children: [
219
+ Text('Rosy')
220
+ Expanded(
221
+ child: Slider(
222
+ value: ruddyLevel,
223
+ min: 0,
224
+ max: 9,
225
+ divisions: 9,
226
+ onChanged: (value) {
227
+ beautyStore.setRuddyLevel(value);
228
+ },
229
+ ),
230
+ ),
231
+ Text('${ruddyLevel.toInt()}'),
232
+ ],
233
+ );
234
+ },
235
+ ),
236
+ ],
237
+ );
238
+ }
239
+ }
240
+ ```
241
+
242
+ ## Complete Example
243
+ ``` java
244
+ import 'package:flutter/material.dart';
245
+ import 'package:atomic_x_core/atomicxcore.dart';
246
+
247
+ class BeautySettingsPage extends StatelessWidget {
248
+ final beautyStore = BaseBeautyStore.shared;
249
+
250
+ @override
251
+ Widget build(BuildContext context) {
252
+ return Scaffold(
253
+ appBar: AppBar(title: Text('Beauty settings')),
254
+ body: Padding(
255
+ padding: EdgeInsets.all(16),
256
+ child: Column(
257
+ children: [
258
+ // Skin smoothing
259
+ _buildBeautySlider(
260
+ title: 'Skin smoothing'
261
+ valueListenable: beautyStore.baseBeautyState.smoothLevel,
262
+ onChanged: (value) => beautyStore.setSmoothLevel(value),
263
+ ),
264
+ SizedBox(height: 20),
265
+ // Whitening
266
+ _buildBeautySlider(
267
+ title: 'Whitening',
268
+ valueListenable: beautyStore.baseBeautyState.whitenessLevel,
269
+ onChanged: (value) => beautyStore.setWhitenessLevel(value),
270
+ ),
271
+ SizedBox(height: 20),
272
+ // Rosy
273
+ _buildBeautySlider(
274
+ title: 'Rosy'
275
+ valueListenable: beautyStore.baseBeautyState.ruddyLevel,
276
+ onChanged: (value) => beautyStore.setRuddyLevel(value),
277
+ ),
278
+ SizedBox(height: 40),
279
+ // reset button
280
+ ElevatedButton(
281
+ onPressed: () {
282
+ beautyStore.reset();
283
+ },
284
+ child: Text('Reset beauty effect'),
285
+ ),
286
+ ],
287
+ ),
288
+ ),
289
+ );
290
+ }
291
+
292
+ Widget _buildBeautySlider({
293
+ required String title,
294
+ required ValueListenable<double> valueListenable,
295
+ required ValueChanged<double> onChanged,
296
+ }) {
297
+ return ValueListenableBuilder<double>(
298
+ valueListenable: valueListenable,
299
+ builder: (context, value, child) {
300
+ return Column(
301
+ crossAxisAlignment: CrossAxisAlignment.start,
302
+ children: [
303
+ Row(
304
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
305
+ children: [
306
+ Text(title, style: TextStyle(fontSize: 16)),
307
+ Text('${value.toInt()}', style: TextStyle(fontSize: 16)),
308
+ ],
309
+ ),
310
+ Slider(
311
+ value: value,
312
+ min: 0,
313
+ max: 9,
314
+ divisions: 9,
315
+ onChanged: onChanged,
316
+ ),
317
+ ],
318
+ );
319
+ },
320
+ );
321
+ }
322
+ }
323
+ ```
324
+
325
+ ## Advanced Features
326
+
327
+ ### Basic Beauty Filter Vs Advanced Beauty Effect
328
+
329
+ AtomicXCore also provided advanced beauty effect support to meet requirements of different scenes:
330
+ <table>
331
+ <tr>
332
+ <td rowspan="1" colSpan="1" >**Comparison Item**</td>
333
+
334
+ <td rowspan="1" colSpan="1" >**Basic Beauty Filter (BaseBeautyStore)**</td>
335
+
336
+ <td rowspan="1" colSpan="1" >**Advanced Beauty Effect (TencentEffect Requires Additional Integration)**</td>
337
+ </tr>
338
+
339
+ <tr>
340
+ <td rowspan="1" colSpan="1" >Core Features</td>
341
+
342
+ <td rowspan="1" colSpan="1" >Skin smoothing, whitening, rosy</td>
343
+
344
+ <td rowspan="1" colSpan="1" >Includes basic beauty filter, with various effects like V-face, eye distance adjustment, nose slimming, 3D stickers, filters, and makeup.</td>
345
+ </tr>
346
+
347
+ <tr>
348
+ <td rowspan="1" colSpan="1" >Billing</td>
349
+
350
+ <td rowspan="1" colSpan="1" >free (included in AtomicXCore license)</td>
351
+
352
+ <td rowspan="1" colSpan="1" >Payment (Tencent Effect SDK License must be bought extra).</td>
353
+ </tr>
354
+
355
+ <tr>
356
+ <td rowspan="1" colSpan="1" >integration method</td>
357
+
358
+ <td rowspan="1" colSpan="1" >default built-in, direct use `BaseBeautyStore.shared`</td>
359
+
360
+ <td rowspan="1" colSpan="1" >Additional integration of the `TencentEffect` component is required and authenticate.</td>
361
+ </tr>
362
+
363
+ <tr>
364
+ <td rowspan="1" colSpan="1" >Recommended scenarios</td>
365
+
366
+ <td rowspan="1" colSpan="1" >Scenarios with low beauty effect requirements that need quick implementation of basic beauty effect features</td>
367
+
368
+ <td rowspan="1" colSpan="1" >Scenarios with high beauty effect requirements that require various advanced functions such as beauty shaping, stickers, and filters.</td>
369
+ </tr>
370
+ </table>
371
+
372
+
373
+ ### Integrate Advanced Beauty Effect
374
+
375
+ If you need to use the advanced beauty function, refer to the [Advanced Beauty](https://trtc.io/document/73778?product=beautyar&menulabel=core%20sdk&platform=flutter) document for integration. After successful integration and authentication of `TencentEffect`, you can control ALL beauty effects through the API provided by `TencentEffect`.
376
+
377
+ ## API Reference
378
+
379
+ ### BaseBeautyStore
380
+ <table>
381
+ <tr>
382
+ <td rowspan="1" colSpan="1" >**Property/Method**</td>
383
+
384
+ <td rowspan="1" colSpan="1" >**Type**</td>
385
+
386
+ <td rowspan="1" colSpan="1" >**Note**</td>
387
+ </tr>
388
+
389
+ <tr>
390
+ <td rowspan="1" colSpan="1" >`shared`</td>
391
+
392
+ <td rowspan="1" colSpan="1" >`BaseBeautyStore`</td>
393
+
394
+ <td rowspan="1" colSpan="1" >Singleton instance</td>
395
+ </tr>
396
+
397
+ <tr>
398
+ <td rowspan="1" colSpan="1" >`baseBeautyState`</td>
399
+
400
+ <td rowspan="1" colSpan="1" >`BaseBeautyState`</td>
401
+
402
+ <td rowspan="1" colSpan="1" >Beauty effect status</td>
403
+ </tr>
404
+
405
+ <tr>
406
+ <td rowspan="1" colSpan="1" >`setSmoothLevel`</td>
407
+
408
+ <td rowspan="1" colSpan="1" >`void`</td>
409
+
410
+ <td rowspan="1" colSpan="1" >Set the skin smoothing strength (0-9).</td>
411
+ </tr>
412
+
413
+ <tr>
414
+ <td rowspan="1" colSpan="1" >`setWhitenessLevel`</td>
415
+
416
+ <td rowspan="1" colSpan="1" >`void`</td>
417
+
418
+ <td rowspan="1" colSpan="1" >Set the brightening strength (0-9).</td>
419
+ </tr>
420
+
421
+ <tr>
422
+ <td rowspan="1" colSpan="1" >`setRuddyLevel`</td>
423
+
424
+ <td rowspan="1" colSpan="1" >`void`</td>
425
+
426
+ <td rowspan="1" colSpan="1" >Set the rosy strength (0-9).</td>
427
+ </tr>
428
+
429
+ <tr>
430
+ <td rowspan="1" colSpan="1" >`reset`</td>
431
+
432
+ <td rowspan="1" colSpan="1" >`void`</td>
433
+
434
+ <td rowspan="1" colSpan="1" >Reset all beauty parameters to default value (0).</td>
435
+ </tr>
436
+ </table>
437
+
438
+
439
+ ### BaseBeautyState
440
+ <table>
441
+ <tr>
442
+ <td rowspan="1" colSpan="1" >**Attribute**</td>
443
+
444
+ <td rowspan="1" colSpan="1" >**Type**</td>
445
+
446
+ <td rowspan="1" colSpan="1" >**Note**</td>
447
+ </tr>
448
+
449
+ <tr>
450
+ <td rowspan="1" colSpan="1" >`smoothLevel`</td>
451
+
452
+ <td rowspan="1" colSpan="1" >`ValueListenable<double>`</td>
453
+
454
+ <td rowspan="1" colSpan="1" >Skin smoothing strength (0-9).</td>
455
+ </tr>
456
+
457
+ <tr>
458
+ <td rowspan="1" colSpan="1" >`whitenessLevel`</td>
459
+
460
+ <td rowspan="1" colSpan="1" >`ValueListenable<double>`</td>
461
+
462
+ <td rowspan="1" colSpan="1" >Brightening strength (0-9).</td>
463
+ </tr>
464
+
465
+ <tr>
466
+ <td rowspan="1" colSpan="1" >`ruddyLevel`</td>
467
+
468
+ <td rowspan="1" colSpan="1" >`ValueListenable<double>`</td>
469
+
470
+ <td rowspan="1" colSpan="1" >Rosy strength (0-9).</td>
471
+ </tr>
472
+ </table>
473
+
474
+
475
+ ## FAQs
476
+
477
+ ### I Set Up the Beauty Parameter, Why No Effect?
478
+
479
+ Please check the following points:
480
+ 1. **Is the camera enabled**: You must successfully turn on the camera (e.g. by `DeviceStore.shared.openLocalCamera()`) before the beauty effect can apply to the video stream.
481
+
482
+ 2. **Whether to use advanced beauty effect**: If you integrated `TencentEffect` (advanced beauty), ensure you use the API provided by `TencentEffect` to adjust the beauty effect.
483
+
484
+ 3. **Parameter range**: If you use basic beauty filter, confirm the strength value passed in is within the effective range (a double value between `0` and `9`).
485
+
486
+