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(), ),