|
|
|
@ -3,7 +3,6 @@ import 'dart:core';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
|
|
|
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
|
|
|
|
import 'package:flutter_webrtc/flutter_webrtc.dart' as webrtc_impl;
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
@ -22,14 +21,6 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
|
|
|
|
|
Client get client => matrix.client;
|
|
|
|
|
VoipPlugin(this.matrix) {
|
|
|
|
|
voip = VoIP(client, this);
|
|
|
|
|
Connectivity()
|
|
|
|
|
.onConnectivityChanged
|
|
|
|
|
.listen(_handleNetworkChanged)
|
|
|
|
|
.onError((e) => _currentConnectivity = ConnectivityResult.none);
|
|
|
|
|
Connectivity()
|
|
|
|
|
.checkConnectivity()
|
|
|
|
|
.then((result) => _currentConnectivity = result)
|
|
|
|
|
.catchError((e) => _currentConnectivity = ConnectivityResult.none);
|
|
|
|
|
if (!kIsWeb) {
|
|
|
|
|
final wb = WidgetsBinding.instance;
|
|
|
|
|
wb.addObserver(this);
|
|
|
|
@ -39,20 +30,9 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
|
|
|
|
|
bool background = false;
|
|
|
|
|
bool speakerOn = false;
|
|
|
|
|
late VoIP voip;
|
|
|
|
|
ConnectivityResult? _currentConnectivity;
|
|
|
|
|
OverlayEntry? overlayEntry;
|
|
|
|
|
BuildContext get context => matrix.context;
|
|
|
|
|
|
|
|
|
|
void _handleNetworkChanged(ConnectivityResult result) async {
|
|
|
|
|
/// Got a new connectivity status!
|
|
|
|
|
if (_currentConnectivity != result) {
|
|
|
|
|
voip.calls.forEach((_, sess) {
|
|
|
|
|
sess.restartIce();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
_currentConnectivity = result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void didChangeAppLifecycleState(AppLifecycleState? state) {
|
|
|
|
|
Logs().v('AppLifecycleState = $state');
|
|
|
|
|