From cb9f225f5962d399f48b65d5f855e11f146cbbcb Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 22 Feb 2017 15:19:42 -0800 Subject: [PATCH] Don't start VideoCapturer until video enabled. Should help with battery consumption on audio-only calls Fixes #6259 // FREEBIE --- .../securesms/webrtc/PeerConnectionWrapper.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java b/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java index 8bf5741c90..42a297965d 100644 --- a/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java +++ b/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java @@ -79,7 +79,6 @@ public class PeerConnectionWrapper { if (videoCapturer != null) { this.videoSource = factory.createVideoSource(videoCapturer); - this.videoCapturer.startCapture(1280, 720, 30); this.videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource); this.videoTrack.addRenderer(new VideoRenderer(localRenderer)); @@ -97,6 +96,15 @@ public class PeerConnectionWrapper { if (this.videoTrack != null) { this.videoTrack.setEnabled(enabled); } + + if (this.videoCapturer != null) { + try { + if (enabled) this.videoCapturer.startCapture(1280, 720, 30); + else this.videoCapturer.stopCapture(); + } catch (InterruptedException e) { + Log.w(TAG, e); + } + } } public void setAudioEnabled(boolean enabled) {