1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 06:49:22 +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>();
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<CallScreen> {
/// Toggle local video streaming
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!");
return;
}
@ -250,8 +253,7 @@ class _CallScreenState extends SafeState<CallScreen> {
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<CallScreen> {
// Remove peers videos
Column(
children: _membersList.readyPeers
.where((f) => _renderers.containsKey(f.userID))
.map((f) => _buildMemberVideo(f.userID))
.toList(),
),