import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'liblinphone_flutter_platform_interface.dart'; import 'models/call_type.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) async { return (await methodChannel.invokeMethod( 'makeCall', {'callTo': callTo, 'isVideoEnabled': isVideoEnabled}, ))!; } @override Future answerCall() async { return (await methodChannel.invokeMethod('answerCall'))!; } @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'))!; } }