From 94cbb9d86396049b15092ce7f07eba6e771b9159 Mon Sep 17 00:00:00 2001 From: unclexiao Date: Tue, 6 Aug 2019 15:20:01 +0800 Subject: [PATCH] feat. support setLocalVoiceChanger --- android/build.gradle | 2 +- .../agorartcengine/AgoraRtcEnginePlugin.java | 6 ++ ios/Classes/AgoraRtcEnginePlugin.m | 4 ++ lib/agora_rtc_engine.dart | 56 ++++++++++++++++++- 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 609012f11..c7bcb0670 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -35,5 +35,5 @@ android { } dependencies { - implementation 'io.agora.rtc:full-sdk:2.8.0' + implementation 'io.agora.rtc:full-sdk:2.8.1' } diff --git a/android/src/main/java/io/agora/agorartcengine/AgoraRtcEnginePlugin.java b/android/src/main/java/io/agora/agorartcengine/AgoraRtcEnginePlugin.java index afb01fbb3..ee2ae0022 100644 --- a/android/src/main/java/io/agora/agorartcengine/AgoraRtcEnginePlugin.java +++ b/android/src/main/java/io/agora/agorartcengine/AgoraRtcEnginePlugin.java @@ -260,6 +260,12 @@ public void onMethodCall(MethodCall call , Result result) { result.success(null); } break; + case "setLocalVoiceChanger": { + int changer = call.argument("changer"); + mRtcEngine.setLocalVoiceChanger(changer); + result.success(null); + } + break; case "setRemoteRenderMode": { int uid = call.argument("uid"); int mode = call.argument("mode"); diff --git a/ios/Classes/AgoraRtcEnginePlugin.m b/ios/Classes/AgoraRtcEnginePlugin.m index 476ac32d7..8961697cd 100644 --- a/ios/Classes/AgoraRtcEnginePlugin.m +++ b/ios/Classes/AgoraRtcEnginePlugin.m @@ -227,6 +227,10 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { NSInteger mode = [self intFromArguments:arguments key:@"mode"]; [self.agoraRtcEngine setLocalRenderMode:mode]; result(nil); + } else if ([@"setLocalVoiceChanger" isEqualToString:method]) { + NSInteger changer = [self intFromArguments:arguments key:@"changer"]; + [self.agoraRtcEngine setLocalVoiceChanger:changer]; + result(nil); } else if ([@"setRemoteRenderMode" isEqualToString:method]) { NSInteger uid = [self intFromArguments:arguments key:@"uid"]; NSInteger mode = [self intFromArguments:arguments key:@"mode"]; diff --git a/lib/agora_rtc_engine.dart b/lib/agora_rtc_engine.dart index b01c97759..76a921f9a 100644 --- a/lib/agora_rtc_engine.dart +++ b/lib/agora_rtc_engine.dart @@ -236,7 +236,7 @@ class AgoraRtcEngine { /// Before calling this method to set a new channel profile, [destroy] the current RtcEngine and [create] a new RtcEngine first. /// Call this method before [joinChannel], you cannot configure the channel profile when the channel is in use. static Future setChannelProfile(ChannelProfile profile) async { - await _channel.invokeMethod('setChannelProfile', {'profile': profile.index}); + await _channel.invokeMethod('setChannelProfile', {'profile': profile.index}); } /// Sets the role of a user (Live Broadcast only). @@ -481,6 +481,12 @@ class AgoraRtcEngine { 'setLocalRenderMode', {'mode': _intFromVideoRenderMode(renderMode)}); } + /// Sets the local voice changer option. + static Future setLocalVoiceChanger(VoiceChanger changer) async { + await _channel.invokeMethod( + 'setLocalVoiceChanger', {'changer': _intLocalVoiceChangere(changer)}); + } + /// Sets the remote video display mode. /// /// This method can be invoked multiple times during a call to change the display mode. @@ -1004,6 +1010,31 @@ class AgoraRtcEngine { return 1; } } + + static int _intLocalVoiceChangere(VoiceChanger changer) { + switch (changer) { + case VoiceChanger.VOICE_CHANGER_OLDMAN: + return 1; + break; + case VoiceChanger.VOICE_CHANGER_BABYBOY: + return 2; + break; + case VoiceChanger.VOICE_CHANGER_BABYGILR: + return 3; + break; + case VoiceChanger.VOICE_CHANGER_ZHUBAJIE: + return 4; + break; + case VoiceChanger.VOICE_CHANGER_ETHEREAL: + return 5; + break; + case VoiceChanger.VOICE_CHANGER_HULK: + return 6; + break; + default: + return 0; + } + } } class AudioVolumeInfo { @@ -1204,6 +1235,29 @@ enum VideoRenderMode { Fit, } +enum VoiceChanger { + /// The original voice (no local voice change). + VOICE_CHANGER_OFF, + + /// An old man's voice. + VOICE_CHANGER_OLDMAN, + + /// A little boy's voice. + VOICE_CHANGER_BABYBOY, + + ///A little girl's voice. + VOICE_CHANGER_BABYGILR, + + /// Zhu Bajie's voice (Zhu Bajie is a character from Journey to the West who has a voice like a growling bear). + VOICE_CHANGER_ZHUBAJIE, + + /// Ethereal vocal effects. + VOICE_CHANGER_ETHEREAL, + + /// Hulk's voice. + VOICE_CHANGER_HULK +} + enum UserPriority { High, Normal,