feat: (for now android only!) dscp retrieval and configuration methods

This commit is contained in:
Andrew 2026-04-28 15:08:25 +07:00
parent 02cc6ad612
commit 26d72ec1af
6 changed files with 104 additions and 6 deletions

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -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.');
}
}

View 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"]);
}