Fix video freeze when on different activity than videoCallActivity by sending nowebcam

This commit is contained in:
Sylvain Berfini 2012-05-25 15:18:47 +02:00
parent 053f4effbb
commit 333de6198f

View file

@ -82,7 +82,6 @@ public class VideoCallActivity extends Activity implements
AndroidVideoWindowImpl androidVideoWindowImpl; AndroidVideoWindowImpl androidVideoWindowImpl;
private Runnable mCallQualityUpdater, mControls; private Runnable mCallQualityUpdater, mControls;
private LinearLayout mControlsLayout; private LinearLayout mControlsLayout;
private boolean shouldRestartVideoOnResume = false;
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -145,8 +144,7 @@ public class VideoCallActivity extends Activity implements
videoCall = LinphoneManager.getLc().getCurrentCall(); videoCall = LinphoneManager.getLc().getCurrentCall();
if (videoCall != null) { if (videoCall != null) {
LinphoneManager lm = LinphoneManager.getInstance(); LinphoneManager lm = LinphoneManager.getInstance();
if (!lm.shareMyCamera() && !lm.isVideoInitiator() if (!lm.shareMyCamera() && videoCall.cameraEnabled()) {
&& videoCall.cameraEnabled()) {
lm.sendStaticImage(true); lm.sendStaticImage(true);
} }
@ -369,9 +367,9 @@ public class VideoCallActivity extends Activity implements
if (mControlsLayout != null) if (mControlsLayout != null)
mControlsLayout.setVisibility(View.GONE); mControlsLayout.setVisibility(View.GONE);
if (shouldRestartVideoOnResume && LinphoneManager.getLc().getCurrentCall() != null) { if (videoCall != null && LinphoneManager.getInstance().shareMyCamera()) {
LinphoneManager.getLc().getCurrentCall().enableCamera(true); videoCall.enableCamera(true);
shouldRestartVideoOnResume = false; updatePreview(videoCall.cameraEnabled());
} }
} }
@ -403,13 +401,14 @@ public class VideoCallActivity extends Activity implements
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(), Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(),
", inCall:", LinphoneManager.getLc().isIncall(), ")"); ", inCall:", LinphoneManager.getLc().isIncall(), ")");
LinphoneManager.removeListener(this); LinphoneManager.removeListener(this);
// Send NoWebcam since Android 4.0 can't get the video from the
// webcam if the activity is not in foreground
if (videoCall != null)
videoCall.enableCamera(false);
if (isFinishing()) { if (isFinishing()) {
videoCall = null; // release reference videoCall = null; // release reference
} else {
// Send NoWebcam since Android 4.0 can't get the video from the
// webcam if the activity is not in foreground
shouldRestartVideoOnResume = true;
LinphoneManager.getLc().getCurrentCall().enableCamera(false);
} }
launched = false; launched = false;
synchronized (androidVideoWindowImpl) { synchronized (androidVideoWindowImpl) {