1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Simplify code

This commit is contained in:
Pierre HUBERT 2020-04-21 18:04:01 +02:00
parent 2927f72674
commit de1dceae9b

View File

@ -47,6 +47,9 @@ class _CallScreenState extends SafeState<CallScreen> {
final _renderers = Map<int, RTCVideoRenderer>(); final _renderers = Map<int, RTCVideoRenderer>();
MediaStream _localStream; MediaStream _localStream;
bool get _canMakeVideoCall =>
_conversation.callCapabilities == CallCapabilities.VIDEO;
bool get isStreamingAudio => bool get isStreamingAudio =>
_localStream != null && _localStream.getAudioTracks().length > 0; _localStream != null && _localStream.getAudioTracks().length > 0;
@ -217,7 +220,7 @@ class _CallScreenState extends SafeState<CallScreen> {
/// Toggle local video streaming /// Toggle local video streaming
Future<void> _toggleStreaming(bool isVideo) async { Future<void> _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!"); print("Attempting to switch video call on a non-capable video stream!");
return; return;
} }
@ -250,8 +253,7 @@ class _CallScreenState extends SafeState<CallScreen> {
final peerConnection = await createPeerConnection(_conf.pluginConfig, { final peerConnection = await createPeerConnection(_conf.pluginConfig, {
"mandatory": { "mandatory": {
"OfferToReceiveAudio": true, "OfferToReceiveAudio": true,
"OfferToReceiveVideo": "OfferToReceiveVideo": _canMakeVideoCall,
_conversation.callCapabilities == CallCapabilities.VIDEO,
}, },
"optional": [], "optional": [],
}); });
@ -401,6 +403,7 @@ class _CallScreenState extends SafeState<CallScreen> {
// Remove peers videos // Remove peers videos
Column( Column(
children: _membersList.readyPeers children: _membersList.readyPeers
.where((f) => _renderers.containsKey(f.userID))
.map((f) => _buildMemberVideo(f.userID)) .map((f) => _buildMemberVideo(f.userID))
.toList(), .toList(),
), ),