diff --git a/src/org/linphone/ConferenceActivity.java b/src/org/linphone/ConferenceActivity.java index c607e1e87..206acefbc 100644 --- a/src/org/linphone/ConferenceActivity.java +++ b/src/org/linphone/ConferenceActivity.java @@ -30,7 +30,6 @@ import org.linphone.LinphoneManagerWaitHelper.LinphoneManagerReadyListener; import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; -import org.linphone.LinphoneSimpleListener.LinphoneOnVideoCallReadyListener; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCore; @@ -69,7 +68,6 @@ import android.widget.ToggleButton; public class ConferenceActivity extends ListActivity implements LinphoneManagerReadyListener, LinphoneOnAudioChangedListener, - LinphoneOnVideoCallReadyListener, LinphoneOnCallStateChangedListener, LinphoneOnCallEncryptionChangedListener, Comparator, @@ -180,11 +178,6 @@ public class ConferenceActivity extends ListActivity implements mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted()); updateAddCallButton(); - - LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall(); - if (currentCall != null) { - tryToStartVideoActivity(currentCall, currentCall.getState()); - } } private void updateSoundLock() { @@ -513,7 +506,9 @@ public class ConferenceActivity extends ListActivity implements lc().removeFromConference(call); break; case R.id.addVideo: - LinphoneManager.getInstance().addVideo(); + if (!LinphoneManager.getInstance().addVideo()) { + LinphoneActivity.instance().startVideoActivity(); + } break; default: throw new RuntimeException("unknown id " + v.getId()); @@ -780,23 +775,11 @@ public class ConferenceActivity extends ListActivity implements control.setVisibility(showControl ? VISIBLE : GONE); } - private void tryToStartVideoActivity(LinphoneCall call, State state) { - if (State.StreamsRunning == state && call.getCurrentParamsCopy().getVideoEnabled()) { - if (call.cameraEnabled() ) { - LinphoneActivity.instance().startVideoActivity(); - } else { - Log.i("Not starting video call activity as the camera is disabled"); - } - } - } - public void onCallStateChanged(final LinphoneCall call, final State state, final String message) { final String stateStr = call + " " + state.toString(); Log.d("ConferenceActivity received state ",stateStr); - tryToStartVideoActivity(call, state); - mHandler.post(new Runnable() { public void run() { CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter(); @@ -966,11 +949,6 @@ public class ConferenceActivity extends ListActivity implements }); } - @Override - public void onRequestedVideoCallReady(LinphoneCall call) { - LinphoneActivity.instance().startVideoActivity(); - } - @Override public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken) { @@ -982,34 +960,4 @@ public class ConferenceActivity extends ListActivity implements }); } - /* - * public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2) - * return 0; - * - * boolean inConfC1 = c1.isInConference(); boolean inConfC2 = - * c2.isInConference(); if (inConfC1 && !inConfC2) return -1; if (!inConfC1 - * && inConfC2) return 1; - * - * int compUserName = - * c1.getRemoteAddress().getUserName().compareToIgnoreCase - * (c2.getRemoteAddress().getUserName()); if (inConfC1 && inConfC2) { return - * compUserName; } - * - * // bellow, ringings and incoming int c1State = c1.getState().value(); int - * c2State = c2.getState().value(); - * - * boolean c1StateIsEstablishing = c1State == State.IncomingReceived || - * c1State == State.ID_OUTGOING_RINGING; boolean c2StateIsEstablishing = - * c2State == State.IncomingReceived || c2State == - * State.ID_OUTGOING_RINGING; - * - * // Xor only one establishing state if (c1StateIsEstablishing ^ - * c2StateIsEstablishing) { // below return !c1StateIsEstablishing ? -1 : 1; - * } - * - * // Xor only one paused state if (c1State == State.Paused ^ c2State == - * State.Paused) { return c1State == State.Paused ? -1 : 1; } - * - * return compUserName; //Duration() - c1.getDuration(); } - */ } diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 70b5832f9..94e158ef6 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -23,6 +23,7 @@ import static android.content.Intent.ACTION_MAIN; import org.linphone.LinphoneManager.EcCalibrationListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; +import org.linphone.LinphoneSimpleListener.LinphoneOnVideoCallReadyListener; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCore; @@ -58,7 +59,11 @@ import android.widget.TextView; import android.widget.Toast; import android.widget.TabHost.TabSpec; -public class LinphoneActivity extends TabActivity implements SensorEventListener, ContactPicked, LinphoneOnCallStateChangedListener { +public class LinphoneActivity extends TabActivity implements + SensorEventListener, ContactPicked, + LinphoneOnCallStateChangedListener, + LinphoneOnVideoCallReadyListener + { public static final String DIALER_TAB = "dialer"; public static final String PREF_FIRST_LAUNCH = "pref_first_launch"; private static final int video_activity = 100; @@ -89,7 +94,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener return instance != null; } - static final LinphoneActivity instance() { + public static final LinphoneActivity instance() { if (instance != null) return instance; throw new RuntimeException("LinphoneActivity not instantiated yet"); @@ -462,6 +467,8 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener } public void startVideoActivity() { + LinphoneCall call = LinphoneManager.getLc().getCurrentCall(); + if (call != null) call.enableCamera(true); mHandler.post(new Runnable() { public void run() { startActivityForResult(new Intent().setClass( @@ -536,6 +543,11 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener } } } + + @Override + public void onVideoCallReady(LinphoneCall call) { + startVideoActivity(); + } } interface ContactPicked { diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index b26e8c1b5..9a88f2487 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -996,15 +996,14 @@ public final class LinphoneManager implements LinphoneCoreListener { e.commit(); } - private LinphoneCall requestedVideoCall; + /** + * + * @return false if already in video call. + */ public boolean addVideo() { - requestedVideoCall = mLc.getCurrentCall(); - if (requestedVideoCall == null) return false; - - if (!reinviteWithVideo()) { - listenerDispatcher.onAlreadyInVideoCall(); - } - return true; + LinphoneCall call = mLc.getCurrentCall(); + if (call != null) call.enableCamera(true); + return reinviteWithVideo(); } public boolean acceptCallIfIncomingPending() throws LinphoneCoreException { @@ -1160,10 +1159,6 @@ public final class LinphoneManager implements LinphoneCoreListener { this.serviceListener = s; } - public void onAlreadyInVideoCall() { - if (serviceListener != null) serviceListener.onAlreadyInVideoCall(); - } - public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken) { if (serviceListener != null) { @@ -1180,17 +1175,13 @@ public final class LinphoneManager implements LinphoneCoreListener { boolean sendCamera = shareMyCamera() && mLc.getConferenceSize() == 0; call.enableCamera(sendCamera); } - if (state == State.CallEnd && call == requestedVideoCall) { - requestedVideoCall = null; // drop reference - } if (state == State.CallEnd && mLc.getCallsNb() == 0) { routeAudioToReceiver(true); } - if (state == State.StreamsRunning && call == requestedVideoCall && call.getCurrentParamsCopy().getVideoEnabled()) { + if (state == State.StreamsRunning && call.getCurrentParamsCopy().getVideoEnabled()) { for (LinphoneOnVideoCallReadyListener l : getSimpleListeners(LinphoneOnVideoCallReadyListener.class)) { - l.onRequestedVideoCallReady(call); + l.onVideoCallReady(call); } - requestedVideoCall = null; } if (serviceListener != null) serviceListener.onCallStateChanged(call, state, message); for (LinphoneOnCallStateChangedListener l : getSimpleListeners(LinphoneOnCallStateChangedListener.class)) { diff --git a/src/org/linphone/LinphoneSimpleListener.java b/src/org/linphone/LinphoneSimpleListener.java index 66d5bf5bc..5aabf2b97 100644 --- a/src/org/linphone/LinphoneSimpleListener.java +++ b/src/org/linphone/LinphoneSimpleListener.java @@ -38,8 +38,6 @@ public interface LinphoneSimpleListener { void onRegistrationStateChanged(RegistrationState state, String message); void onRingerPlayerCreated(MediaPlayer mRingerPlayer); void onDisplayStatus(String message); - void onAlreadyInVideoCall(); - } @@ -61,6 +59,6 @@ public interface LinphoneSimpleListener { } public static interface LinphoneOnVideoCallReadyListener extends LinphoneSimpleListener { - void onRequestedVideoCallReady(LinphoneCall call); + void onVideoCallReady(LinphoneCall call); } } diff --git a/src/org/linphone/VideoCallActivity.java b/src/org/linphone/VideoCallActivity.java index 30753c247..831bb3156 100755 --- a/src/org/linphone/VideoCallActivity.java +++ b/src/org/linphone/VideoCallActivity.java @@ -286,7 +286,6 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh if (isFinishing()) { videoCall = null; // release reference } - LinphoneManager.getInstance().restoreUserRequestedSpeaker(); launched=false; synchronized (androidVideoWindowImpl) { /* this call will destroy native opengl renderer @@ -297,14 +296,10 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh LinphoneManager.getLc().setPreviewWindow(null); - if (LinphoneManager.getLc().isIncall()) { - // we're getting paused for real - if (getChangingConfigurations() == 0) { - LinphoneManager.getInstance().sendStaticImage(true); - } else { - LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation())); - LinphoneManager.getLc().updateCall(LinphoneManager.getLc().getCurrentCall(), null); - } + final LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall(); + if (currentCall != null && getChangingConfigurations() != 0) { + LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation())); + LinphoneManager.getLc().updateCall(currentCall, null); } if (mCallQualityUpdater!=null){ refreshHandler.removeCallbacks(mCallQualityUpdater); diff --git a/src/org/linphone/ui/AddVideoButton.java b/src/org/linphone/ui/AddVideoButton.java index b3cad9c8c..3e4ab05fa 100644 --- a/src/org/linphone/ui/AddVideoButton.java +++ b/src/org/linphone/ui/AddVideoButton.java @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.ui; +import org.linphone.LinphoneActivity; import org.linphone.LinphoneManager; import android.content.Context; @@ -38,6 +39,8 @@ public class AddVideoButton extends ImageButton implements OnClickListener { } public void onClick(View v) { - LinphoneManager.getInstance().addVideo(); + if (!LinphoneManager.getInstance().addVideo()) { + LinphoneActivity.instance().startVideoActivity(); + } } }