From de1dceae9bc687107f79e62d77d45d7106090b13 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 21 Apr 2020 18:04:01 +0200 Subject: [PATCH] Simplify code --- lib/ui/screens/call_screen.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 8e32979..f285d8f 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -47,6 +47,9 @@ class _CallScreenState extends SafeState { final _renderers = Map(); MediaStream _localStream; + bool get _canMakeVideoCall => + _conversation.callCapabilities == CallCapabilities.VIDEO; + bool get isStreamingAudio => _localStream != null && _localStream.getAudioTracks().length > 0; @@ -217,7 +220,7 @@ class _CallScreenState extends SafeState { /// Toggle local video streaming Future _toggleStreaming(bool isVideo) async { - if (isVideo && _conversation.callCapabilities != CallCapabilities.VIDEO) { + if (isVideo && !_canMakeVideoCall) { print("Attempting to switch video call on a non-capable video stream!"); return; } @@ -250,8 +253,7 @@ class _CallScreenState extends SafeState { final peerConnection = await createPeerConnection(_conf.pluginConfig, { "mandatory": { "OfferToReceiveAudio": true, - "OfferToReceiveVideo": - _conversation.callCapabilities == CallCapabilities.VIDEO, + "OfferToReceiveVideo": _canMakeVideoCall, }, "optional": [], }); @@ -401,6 +403,7 @@ class _CallScreenState extends SafeState { // Remove peers videos Column( children: _membersList.readyPeers + .where((f) => _renderers.containsKey(f.userID)) .map((f) => _buildMemberVideo(f.userID)) .toList(), ),