2222import com .yanzhenjie .permission .AndPermission ;
2323import com .yanzhenjie .permission .runtime .Permission ;
2424
25+ import org .json .JSONException ;
26+
2527import io .agora .api .example .MainApplication ;
2628import io .agora .api .example .R ;
2729import io .agora .api .example .annotation .Example ;
3234import io .agora .rtc .RtcEngineConfig ;
3335import io .agora .rtc .models .ChannelMediaOptions ;
3436import io .agora .rtc .video .BeautyOptions ;
37+ import io .agora .rtc .video .ColorEnhanceOptions ;
38+ import io .agora .rtc .video .LowLightEnhanceOptions ;
3539import io .agora .rtc .video .VideoCanvas ;
40+ import io .agora .rtc .video .VideoDenoiserOptions ;
3641import io .agora .rtc .video .VideoEncoderConfiguration ;
42+ import io .agora .rtc .video .VirtualBackgroundSource ;
3743
3844import static io .agora .api .example .common .model .Examples .ADVANCED ;
3945import static io .agora .rtc .Constants .CHANNEL_PROFILE_LIVE_BROADCASTING ;
@@ -56,13 +62,19 @@ public class FaceBeauty extends BaseFragment implements View.OnClickListener, Co
5662 private FrameLayout fl_local , fl_remote ;
5763 private LinearLayout controlPanel ;
5864 private Button join ;
59- private Switch beauty ;
60- private SeekBar seek_lightness , seek_redness , seek_sharpness , seek_smoothness ;
65+ private Switch beauty , lightness , colorful , noiseReduce , virtualBackground ;
66+ private SeekBar seek_lightness , seek_redness , seek_sharpness , seek_smoothness , seek_strength , seek_skin ;
6167 private EditText et_channel ;
6268 private RtcEngine engine ;
6369 private int myUid ;
6470 private boolean joined = false ;
6571 private BeautyOptions beautyOptions = new BeautyOptions ();
72+ private LowLightEnhanceOptions lowLightEnhanceOptions = new LowLightEnhanceOptions ();
73+ private ColorEnhanceOptions colorEnhanceOptions = new ColorEnhanceOptions ();
74+ private VideoDenoiserOptions videoDenoiserOptions = new VideoDenoiserOptions ();
75+ private VirtualBackgroundSource virtualBackgroundSource = new VirtualBackgroundSource ();
76+ private float skinProtect = 1.0f ;
77+ private float strength = 0.5f ;
6678
6779 @ Nullable
6880 @ Override
@@ -84,6 +96,14 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
8496 controlPanel = view .findViewById (R .id .controlPanel );
8597 beauty = view .findViewById (R .id .switch_face_beautify );
8698 beauty .setOnCheckedChangeListener (this );
99+ lightness = view .findViewById (R .id .switch_lightness );
100+ lightness .setOnCheckedChangeListener (this );
101+ colorful = view .findViewById (R .id .switch_color );
102+ colorful .setOnCheckedChangeListener (this );
103+ virtualBackground = view .findViewById (R .id .switch_virtual_background );
104+ virtualBackground .setOnCheckedChangeListener (this );
105+ noiseReduce = view .findViewById (R .id .switch_video_noise_reduce );
106+ noiseReduce .setOnCheckedChangeListener (this );
87107 seek_lightness = view .findViewById (R .id .lightening );
88108 seek_lightness .setOnSeekBarChangeListener (this );
89109 seek_redness = view .findViewById (R .id .redness );
@@ -92,6 +112,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
92112 seek_sharpness .setOnSeekBarChangeListener (this );
93113 seek_smoothness = view .findViewById (R .id .smoothness );
94114 seek_smoothness .setOnSeekBarChangeListener (this );
115+ seek_strength = view .findViewById (R .id .strength );
116+ seek_strength .setOnSeekBarChangeListener (this );
117+ seek_skin = view .findViewById (R .id .skinProtect );
118+ seek_skin .setOnSeekBarChangeListener (this );
119+
120+ virtualBackgroundSource .blur_degree = 2 ;
95121 }
96122
97123 @ Override
@@ -274,9 +300,22 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
274300 if (buttonView .getId () == beauty .getId ()){
275301 engine .setBeautyEffectOptions (isChecked , beautyOptions );
276302 }
303+ else if (buttonView .getId () == lightness .getId ()){
304+ engine .setLowlightEnhanceOptions (isChecked , lowLightEnhanceOptions );
305+ }
306+ else if (buttonView .getId () == colorful .getId ()){
307+ colorEnhanceOptions .skinProtectLevel = skinProtect ;
308+ colorEnhanceOptions .strengthLevel = strength ;
309+ engine .setColorEnhanceOptions (isChecked , colorEnhanceOptions );
310+ }
311+ else if (buttonView .getId () == noiseReduce .getId ()){
312+ engine .setVideoDenoiserOptions (isChecked , videoDenoiserOptions );
313+ }
314+ else if (buttonView .getId () == virtualBackground .getId ()){
315+ engine .enableVirtualBackground (isChecked , virtualBackgroundSource );
316+ }
277317 }
278318
279-
280319 @ Override
281320 public void onProgressChanged (SeekBar seekBar , int progress , boolean fromUser ) {
282321 float value = ((float ) progress ) / 10 ;
@@ -296,6 +335,14 @@ else if(seekBar.getId() == seek_smoothness.getId()){
296335 beautyOptions .smoothnessLevel = value ;
297336 engine .setBeautyEffectOptions (beauty .isChecked (), beautyOptions );
298337 }
338+ else if (seekBar .getId () == seek_strength .getId ()) {
339+ colorEnhanceOptions .strengthLevel = value ;
340+ engine .setColorEnhanceOptions (colorful .isChecked (), colorEnhanceOptions );
341+ }
342+ else if (seekBar .getId () == seek_skin .getId ()) {
343+ colorEnhanceOptions .skinProtectLevel = value ;
344+ engine .setColorEnhanceOptions (colorful .isChecked (), colorEnhanceOptions );
345+ }
299346 }
300347
301348 @ Override
0 commit comments