From 565f351d1eb403480a66089d6b1bcd27f4fc8385 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 22 Apr 2020 18:35:19 +0200 Subject: [PATCH] Notify when we stop streaming --- lib/helpers/calls_helper.dart | 11 +++++++++++ lib/ui/screens/call_screen.dart | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/helpers/calls_helper.dart b/lib/helpers/calls_helper.dart index d98a670..3ab87e4 100644 --- a/lib/helpers/calls_helper.dart +++ b/lib/helpers/calls_helper.dart @@ -66,4 +66,15 @@ class CallsHelper { /// Mark ourselves as ready to stream to other peers static Future markPeerReady(int callID) async => await ws("calls/mark_ready", {"callID": callID}); + + /// Notify other peers that we stopped streaming + /// + /// This method never throw + static Future notifyStoppedStreaming(int callID) async { + try { + await ws("calls/stop_streaming", {"callID": callID}); + } catch (e, stack) { + print("$e\n$stack"); + } + } } diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 33ff9be..0571e8d 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -226,7 +226,7 @@ class _CallScreenState extends SafeState { final offer = await peerConnection.createOffer({ "mandatory": { "OfferToReceiveAudio": true, - "OfferToReceiveVideo": true, + "OfferToReceiveVideo": includeVideo, }, "optional": [], }); @@ -245,6 +245,8 @@ class _CallScreenState extends SafeState { if (_peersConnections.containsKey(userID())) { _peersConnections[userID()].close(); _peersConnections.remove(userID()); + + await CallsHelper.notifyStoppedStreaming(convID); } // Stop local stream @@ -313,6 +315,8 @@ class _CallScreenState extends SafeState { // Request an offer to establish a peer connection await CallsHelper.requestOffer(convID, memberID); + + setState(() {}); } catch (e, stack) { print("Could not connect to remote peer $e\n$stack!"); showSimpleSnack(context, tr("Could not connect to a remote peer!"));