feat: add playback gain methods to all platforms
This commit is contained in:
parent
7608d79d64
commit
5a547958d5
7 changed files with 75 additions and 0 deletions
|
|
@ -227,6 +227,21 @@ class LiblinphoneFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
|
|||
result.success(linphoneBridge.getMicGain())
|
||||
}
|
||||
|
||||
"setPlaybackGain" -> {
|
||||
try {
|
||||
val level = call.argument<Float>("level")!!
|
||||
linphoneBridge.setPlaybackGain(level)
|
||||
result.success(true)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "setPlaybackGain: ${e.message}")
|
||||
result.error("error", e.message, e)
|
||||
}
|
||||
}
|
||||
|
||||
"getPlaybackGain" -> {
|
||||
result.success(linphoneBridge.getPlaybackGain())
|
||||
}
|
||||
|
||||
else -> {
|
||||
result.notImplemented()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,4 +384,12 @@ class LinphoneBridge(
|
|||
fun getMicGain(): Float {
|
||||
return core.getMicGainDb()
|
||||
}
|
||||
|
||||
fun setPlaybackGain(level: Float) {
|
||||
core.setPlaybackGainDb(level)
|
||||
}
|
||||
|
||||
fun getPlaybackGain(): Float {
|
||||
return core.getPlaybackGainDb()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,6 +244,23 @@ public class LiblinphoneFlutterPlugin: NSObject, FlutterPlugin {
|
|||
case "getMicGain":
|
||||
result(linphoneBridge.getMicGain())
|
||||
|
||||
case "setPlaybackGain":
|
||||
guard let args = call.arguments as? [String: Any],
|
||||
let level = args["level"] as? String else {
|
||||
result(FlutterError(
|
||||
code: "INVALID_ARGUMENTS",
|
||||
message: "Missing required arguments",
|
||||
details: nil
|
||||
))
|
||||
return
|
||||
}
|
||||
|
||||
linphoneBridge.setPlaybackGain(level: level)
|
||||
result(success)
|
||||
|
||||
case "getPlaybackGain":
|
||||
result(linphoneBridge.getPlaybackGain())
|
||||
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,6 +280,14 @@ class LinphoneBridge {
|
|||
func getMicGain() -> Float {
|
||||
return core.micGainDb
|
||||
}
|
||||
|
||||
func setPlaybackGain(level: Float) {
|
||||
core.playbackGainDb = level
|
||||
}
|
||||
|
||||
func getPlaybackGain() -> Float {
|
||||
return core.playbackGainDb
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CoreDelegate
|
||||
|
|
|
|||
|
|
@ -96,4 +96,10 @@ class LiblinphoneFlutter {
|
|||
|
||||
Future<double> getMicGain() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getMicGain();
|
||||
|
||||
Future<bool> setPlaybackGain(double level) async =>
|
||||
LiblinphoneFlutterPlatform.instance.setPlaybackGain(level);
|
||||
|
||||
Future<double> getPlaybackGain() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getPlaybackGain();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,4 +130,17 @@ class MethodChannelLiblinphoneFlutter extends LiblinphoneFlutterPlatform {
|
|||
Future<double> getMicGain() async {
|
||||
return (await methodChannel.invokeMethod<double>('getMicGain'))!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> setPlaybackGain(double level) async {
|
||||
return (await methodChannel.invokeMethod<bool>(
|
||||
'setPlaybackGain',
|
||||
<String, dynamic>{'level': level},
|
||||
))!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<double> getPlaybackGain() async {
|
||||
return (await methodChannel.invokeMethod<double>('getPlaybackGain'))!;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,4 +105,12 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
Future<double> getMicGain() async {
|
||||
throw UnimplementedError('getMicGain() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<bool> setPlaybackGain(double level) async {
|
||||
throw UnimplementedError('setPlaybackGain() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<double> getPlaybackGain() async {
|
||||
throw UnimplementedError('getPlaybackGain() has not been implemented.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue