feat: (for now android only!) dscp retrieval and configuration methods
This commit is contained in:
parent
02cc6ad612
commit
82c1a3f96c
6 changed files with 104 additions and 6 deletions
|
|
@ -242,6 +242,23 @@ class LiblinphoneFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
|
|||
result.success(linphoneBridge.getPlaybackGain())
|
||||
}
|
||||
|
||||
"setDscp" -> {
|
||||
try {
|
||||
val sipDscp = call.argument<Int>("sipDscp")
|
||||
val audioDscp = call.argument<Int>("audioDscp")
|
||||
val videoDscp = call.argument<Int>("videoDscp")
|
||||
linphoneBridge.setDscp(sipDscp, audioDscp, videoDscp)
|
||||
result.success(true)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "setDscp: ${e.message}")
|
||||
result.error("error", e.message, e)
|
||||
}
|
||||
}
|
||||
|
||||
"getDscp" -> {
|
||||
result.success(linphoneBridge.getDscp().toMap())
|
||||
}
|
||||
|
||||
else -> {
|
||||
result.notImplemented()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,4 +393,24 @@ class LinphoneBridge(
|
|||
fun getPlaybackGain(): Float {
|
||||
return core.getPlaybackGainDb()
|
||||
}
|
||||
|
||||
data class DscpValues(val sipDscp: Int, val audioDscp: Int, val videoDscp: Int) {
|
||||
fun toMap(): Map<String, Any?> {
|
||||
return mapOf(
|
||||
"sipDscp" to sipDscp,
|
||||
"audioDscp" to audioDscp,
|
||||
"videoDscp" to videoDscp,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fun setDscp(sipDscp: Int?, audioDscp: Int?, videoDscp: Int?) {
|
||||
sipDscp?.let { core.sipDscp = it }
|
||||
audioDscp?.let { core.audioDscp = it }
|
||||
videoDscp?.let { core.videoDscp = it }
|
||||
}
|
||||
|
||||
fun getDscp(): DscpValues {
|
||||
return DscpValues(core.sipDscp, core.audioDscp, core.videoDscp)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/services.dart' show EventChannel;
|
|||
|
||||
import 'liblinphone_flutter_platform_interface.dart';
|
||||
import 'models/call_type.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
import 'models/registration_state.dart';
|
||||
import 'models/call_state.dart';
|
||||
|
||||
|
|
@ -102,4 +103,14 @@ class LiblinphoneFlutter {
|
|||
|
||||
Future<double> getPlaybackGain() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getPlaybackGain();
|
||||
|
||||
Future<bool> setDscp(int sipDscp, int audioDscp, int videoDscp) async =>
|
||||
LiblinphoneFlutterPlatform.instance.setDscp(
|
||||
sipDscp,
|
||||
audioDscp,
|
||||
videoDscp,
|
||||
);
|
||||
|
||||
Future<DscpValues> getDscp() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getDscp();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||
|
||||
import 'liblinphone_flutter_platform_interface.dart';
|
||||
import 'models/call_type.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
|
||||
/// An implementation of [LiblinphoneFlutterPlatform] that uses method channels.
|
||||
class MethodChannelLiblinphoneFlutter extends LiblinphoneFlutterPlatform {
|
||||
|
|
@ -143,4 +144,22 @@ class MethodChannelLiblinphoneFlutter extends LiblinphoneFlutterPlatform {
|
|||
Future<double> getPlaybackGain() async {
|
||||
return (await methodChannel.invokeMethod<double>('getPlaybackGain'))!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> setDscp(int sipDscp, int audioDscp, int videoDscp) async {
|
||||
return (await methodChannel.invokeMethod<bool>('setDscp', <String, dynamic>{
|
||||
'sipDscp': sipDscp,
|
||||
'audioDscp': audioDscp,
|
||||
'videoDscp': videoDscp,
|
||||
}))!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DscpValues> getDscp() async {
|
||||
final data = (await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
|
||||
'getDscp',
|
||||
))!;
|
||||
final values = DscpValues.fromJson(data);
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:liblinphone_flutter/models/call_type.dart';
|
|||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
|
||||
import 'liblinphone_flutter_method_channel.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
|
||||
abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
||||
/// Constructs a LiblinphoneFlutterPlatform.
|
||||
|
|
@ -39,7 +40,9 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
String serverIp,
|
||||
int serverPort,
|
||||
) {
|
||||
throw UnimplementedError('register() has not been implemented.');
|
||||
throw UnimplementedError(
|
||||
'register(String username, String password, String serverIp, int serverPort) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> unregister() {
|
||||
|
|
@ -52,14 +55,18 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
String notificationTitle,
|
||||
String notificationMessage,
|
||||
) {
|
||||
throw UnimplementedError('makeCall() has not been implemented.');
|
||||
throw UnimplementedError(
|
||||
'makeCall(String callTo, bool isVideoEnabled, String notificationTitle, String notificationMessage) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> answerCall(
|
||||
String notificationTitle,
|
||||
String notificationMessage,
|
||||
) {
|
||||
throw UnimplementedError('answerCall() has not been implemented.');
|
||||
throw UnimplementedError(
|
||||
'answerCall(String notificationTitle, String notificationMessage) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> hangupCall() {
|
||||
|
|
@ -91,7 +98,7 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
}
|
||||
|
||||
Future<bool> sendDtmf(String tone) {
|
||||
throw UnimplementedError('sendDtmf() has not been implemented.');
|
||||
throw UnimplementedError('sendDtmf(String tone) has not been implemented.');
|
||||
}
|
||||
|
||||
Future<bool> stopCallService() async {
|
||||
|
|
@ -99,7 +106,9 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
}
|
||||
|
||||
Future<bool> setMicGain(double level) async {
|
||||
throw UnimplementedError('setMicGain() has not been implemented.');
|
||||
throw UnimplementedError(
|
||||
'setMicGain(double level) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<double> getMicGain() async {
|
||||
|
|
@ -107,10 +116,22 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
}
|
||||
|
||||
Future<bool> setPlaybackGain(double level) async {
|
||||
throw UnimplementedError('setPlaybackGain() has not been implemented.');
|
||||
throw UnimplementedError(
|
||||
'setPlaybackGain(double level) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<double> getPlaybackGain() async {
|
||||
throw UnimplementedError('getPlaybackGain() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<bool> setDscp(int sipDscp, int audioDscp, int videoDscp) async {
|
||||
throw UnimplementedError(
|
||||
'setDscp(int sipDscp, int audioDscp, int videoDscp) has not been implemented.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<DscpValues> getDscp() async {
|
||||
throw UnimplementedError('getDscp() has not been implemented.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
lib/models/dscp_values.dart
Normal file
10
lib/models/dscp_values.dart
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
final class DscpValues {
|
||||
final int sipDscp;
|
||||
final int audioDscp;
|
||||
final int videoDscp;
|
||||
|
||||
const DscpValues(this.sipDscp, this.audioDscp, this.videoDscp);
|
||||
|
||||
factory DscpValues.fromJson(Map<dynamic, dynamic> json) =>
|
||||
DscpValues(json["sipDscp"], json["audioDscp"], json["videoDscp"]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue