import 'package:flutter/foundation.dart'; 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 { /// The method channel used to interact with the native platform. @visibleForTesting final methodChannel = const MethodChannel('liblinphone_flutter'); @override Future checkPermissions() async { return (await methodChannel.invokeMethod('checkPermissions'))!; } @override Future initialize() async { return (await methodChannel.invokeMethod('initialize'))!; } @override Future register( String username, String password, String serverIp, int serverPort, ) async { return (await methodChannel .invokeMethod('register', { 'username': username, 'password': password, 'serverIp': serverIp, 'serverPort': serverPort, }))!; } @override Future unregister() async { return (await methodChannel.invokeMethod('unregister'))!; } @override Future makeCall( String callTo, bool isVideoEnabled, String notificationTitle, String notificationMessage, ) async { return (await methodChannel .invokeMethod('makeCall', { 'callTo': callTo, 'isVideoEnabled': isVideoEnabled, 'notificationTitle': notificationTitle, 'notificationMessage': notificationMessage, }))!; } @override Future answerCall( String notificationTitle, String notificationMessage, ) async { return (await methodChannel .invokeMethod('answerCall', { 'notificationTitle': notificationTitle, 'notificationMessage': notificationMessage, }))!; } @override Future hangupCall() async { return (await methodChannel.invokeMethod('hangupCall'))!; } @override Future inCall() async { return (await methodChannel.invokeMethod('inCall'))!; } @override Future callType() async { final callTypeOrdinal = await methodChannel.invokeMethod('callType'); return CallType.fromOrdinal(callTypeOrdinal!); } @override Future toggleVideo() async { return (await methodChannel.invokeMethod('toggleVideo'))!; } @override Future toggleMicrophone() async { return (await methodChannel.invokeMethod('toggleMicrophone'))!; } @override Future stop() async { return (await methodChannel.invokeMethod('stop'))!; } @override Future syncCurrentState() async { return (await methodChannel.invokeMethod('syncCurrentState'))!; } @override Future sendDtmf(String tone) async { return (await methodChannel.invokeMethod( 'sendDtmf', {'tone': tone}, ))!; } @override Future stopCallService() async { return (await methodChannel.invokeMethod('stopCallService'))!; } @override Future setMicGain(double level) async { return (await methodChannel.invokeMethod( 'setMicGain', {'level': level}, ))!; } @override Future getMicGain() async { return (await methodChannel.invokeMethod('getMicGain'))!; } @override Future setPlaybackGain(double level) async { return (await methodChannel.invokeMethod( 'setPlaybackGain', {'level': level}, ))!; } @override Future getPlaybackGain() async { return (await methodChannel.invokeMethod('getPlaybackGain'))!; } @override Future setDscp(int sipDscp, int audioDscp, int videoDscp) async { return (await methodChannel.invokeMethod('setDscp', { 'sipDscp': sipDscp, 'audioDscp': audioDscp, 'videoDscp': videoDscp, }))!; } @override Future getDscp() async { final data = (await methodChannel.invokeMethod>( 'getDscp', ))!; final values = DscpValues.fromJson(data); return values; } }