Enhance concomitant video + conferencing.

This commit is contained in:
Guillaume Beraudo 2011-10-18 12:04:55 +02:00
parent 5fe6a522ba
commit 95e8740e38
10 changed files with 76 additions and 42 deletions

View file

@ -12,6 +12,7 @@
<bool name="use_incall_activity">false</bool>
<bool name="use_conference_activity">true</bool>
<bool name="use_video_activity">true</bool>
<bool name="autostart_video_activity">false</bool>
<bool name="use_incoming_call_dialog">false</bool>
<bool name="use_incoming_call_activity">true</bool>
<bool name="show_full_remote_address_on_incoming_call">true</bool>

View file

@ -108,9 +108,9 @@
<string name="menu_videocall_terminate_call_title">Terminate call</string>
<string name="pref_video_settings_title">Video settings</string>
<string name="pref_video_automatically_share_my_video_title">Share my camera</string>
<string name="pref_video_automatically_share_my_video">Automatically send my camera on incoming calls</string>
<string name="pref_video_initiate_call_with_video_title">Initiate video calls</string>
<string name="pref_video_initiate_call_with_video">Always send my camera on outgoing calls</string>
<string name="pref_video_automatically_share_my_video">Send my camera on video capable calls</string>
<string name="pref_video_initiate_call_with_video_title">Initiate video capable calls</string>
<string name="pref_video_initiate_call_with_video">Disable to remove negotiation of video codecs for outgoing calls</string>
<string name="pref_video_enable_title">Enable Video</string>
<string name="pref_escape_plus">Replace + by 00</string>
<string name="pref_ilbc_summary">iLBC might be unavailable depending on ARM processor and Android OS version.</string>

View file

@ -27,8 +27,9 @@ import java.util.Comparator;
import java.util.List;
import org.linphone.LinphoneManagerWaitHelper.LinphoneManagerReadyListener;
import org.linphone.LinphoneSimpleListener.LinphoneAudioChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
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;
@ -65,8 +66,10 @@ import android.widget.ToggleButton;
*/
public class ConferenceActivity extends ListActivity implements
LinphoneManagerReadyListener,
LinphoneAudioChangedListener,
LinphoneOnCallStateChangedListener, Comparator<LinphoneCall>,
LinphoneOnAudioChangedListener,
LinphoneOnVideoCallReadyListener,
LinphoneOnCallStateChangedListener,
Comparator<LinphoneCall>,
OnClickListener {
private View confHeaderView;
@ -112,6 +115,9 @@ public class ConferenceActivity extends ListActivity implements
private LinphoneManagerWaitHelper waitHelper;
private ToggleButton mMuteMicButton;
private ToggleButton mSpeakerButton;
private boolean useVideoActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.conferencing);
@ -133,6 +139,7 @@ public class ConferenceActivity extends ListActivity implements
waitHelper = new LinphoneManagerWaitHelper(this, this);
waitHelper.doManagerDependentOnCreate();
useVideoActivity = getResources().getBoolean(R.bool.use_video_activity);
// workaroundStatusBarBug();
super.onCreate(savedInstanceState);
}
@ -429,8 +436,7 @@ public class ConferenceActivity extends ListActivity implements
lc().removeFromConference(call);
break;
case R.id.addVideo:
VideoCallActivity.call = call;
LinphoneActivity.instance().startVideoActivity();
LinphoneManager.getInstance().addVideo();
break;
default:
throw new RuntimeException("unknown id " + v.getId());
@ -570,7 +576,9 @@ public class ConferenceActivity extends ListActivity implements
final int numberOfCalls = linphoneCalls.size();
boolean showAddVideo = State.StreamsRunning == state && !isInConference
&& Version.isVideoCapable() && LinphoneManager.getInstance().isVideoEnabled();
&& useVideoActivity
&& Version.isVideoCapable()
&& LinphoneManager.getInstance().isVideoEnabled();
View addVideoButton = v.findViewById(R.id.addVideo);
setVisibility(addVideoButton, showAddVideo);
@ -780,6 +788,11 @@ public class ConferenceActivity extends ListActivity implements
});
}
@Override
public void onRequestedVideoCallReady(LinphoneCall call) {
LinphoneActivity.instance().startVideoActivity();
}
/*
* public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2)
* return 0;

View file

@ -87,7 +87,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
private PowerManager.WakeLock mWakeLock;
private SharedPreferences mPref;
private boolean useIncallActivity;
private boolean useVideoActivity;
private boolean useConferenceActivity;
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
@ -109,7 +108,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
useIncallActivity = getResources().getBoolean(R.bool.use_incall_activity);
useConferenceActivity = getResources().getBoolean(R.bool.use_conference_activity);
useVideoActivity = getResources().getBoolean(R.bool.use_video_activity);
// Don't use Linphone Manager in the onCreate as it takes time in LinphoneService to initialize it.
mPref = PreferenceManager.getDefaultSharedPreferences(this);
@ -288,7 +286,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
}
private void exitCallMode(LinphoneCall call) {
private void exitCallMode() {
if (getResources().getBoolean(R.bool.use_incoming_call_activity)) {
finishActivity(INCOMING_CALL_ACTIVITY);
} else if (getResources().getBoolean(R.bool.use_incoming_call_dialog)) {
@ -315,14 +313,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
mHangup.setEnabled(false);
if (useVideoActivity && LinphoneManager.getLc().isVideoEnabled()
&& VideoCallActivity.call == call) {
LinphoneActivity.instance().finishVideoActivity();
BandwidthManager.getInstance().setUserRestriction(false);
LinphoneManager.getInstance().resetCameraFromPreferences();
}
if (mWakeLock.isHeld()) mWakeLock.release();
LinphoneManager.stopProximitySensorForActivity(LinphoneActivity.instance());
@ -377,7 +367,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
boolean prefAutoShareMyCamera = mPref.getBoolean(getString(key), false);
boolean videoMuted = !(prefVideoEnable && prefAutoShareMyCamera);
LinphoneManager.getLc().getCurrentCall().enableCamera(prefAutoShareMyCamera);
LinphoneManager.getLc().getCurrentCall().enableCamera(!(videoMuted || useConferenceActivity));
}
}
});
@ -465,12 +455,12 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
showToast(R.string.call_error, message);
if (lc.getCallsNb() == 0){
if (mWakeLock.isHeld()) mWakeLock.release();
exitCallMode(call);
exitCallMode();
LinphoneActivity.instance().stopOrientationSensor();
}
}else if (state==LinphoneCall.State.CallEnd){
if (lc.getCallsNb() == 0){
exitCallMode(call);
exitCallMode();
LinphoneActivity.instance().stopOrientationSensor();
}
}

View file

@ -46,9 +46,9 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import org.linphone.LinphoneSimpleListener.LinphoneAudioChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
import org.linphone.LinphoneSimpleListener.LinphoneAudioChangedListener.AudioState;
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
@ -199,7 +199,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
} else {
mAudioManager.setSpeakerphoneOn(speakerOn);
}
for (LinphoneAudioChangedListener listener : getSimpleListeners(LinphoneAudioChangedListener.class)) {
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
listener.onAudioStateChanged(speakerOn ? AudioState.SPEAKER : AudioState.EARPIECE);
}
}
@ -917,7 +917,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
public boolean shareMyCamera() {
return mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
return isVideoEnabled() && mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
}
public void setAudioModeIncallForGalaxyS() {
@ -953,11 +953,15 @@ public final class LinphoneManager implements LinphoneCoreListener {
e.commit();
}
public void addVideo() {
if (!LinphoneManager.getLc().isIncall()) return;
private LinphoneCall requestedVideoCall;
public boolean addVideo() {
requestedVideoCall = mLc.getCurrentCall();
if (requestedVideoCall == null) return false;
if (!reinviteWithVideo()) {
listenerDispatcher.onAlreadyInVideoCall();
}
return true;
}
public boolean acceptCallIfIncomingPending() throws LinphoneCoreException {
@ -1129,9 +1133,18 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void onCallStateChanged(LinphoneCall call, State state,
String message) {
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()) {
for (LinphoneOnVideoCallReadyListener l : getSimpleListeners(LinphoneOnVideoCallReadyListener.class)) {
l.onRequestedVideoCallReady(call);
}
requestedVideoCall = null;
}
if (serviceListener != null) serviceListener.onCallStateChanged(call, state, message);
for (LinphoneOnCallStateChangedListener l : getSimpleListeners(LinphoneOnCallStateChangedListener.class)) {
l.onCallStateChanged(call, state, message);

View file

@ -342,6 +342,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else if (state == LinphoneCall.State.StreamsRunning) {
if (Version.isVideoCapable()
&& getResources().getBoolean(R.bool.autostart_video_activity)
&& getResources().getBoolean(R.bool.use_video_activity)
&& !VideoCallActivity.launched && LinphoneActivity.isInstanciated()
&& call.getCurrentParamsCopy().getVideoEnabled()) {

View file

@ -35,8 +35,8 @@ public interface LinphoneSimpleListener {
void onRegistrationStateChanged(RegistrationState state, String message);
void onRingerPlayerCreated(MediaPlayer mRingerPlayer);
void onDisplayStatus(String message);
void onAlreadyInVideoCall();
void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken);
void onAlreadyInVideoCall();
}
@ -48,8 +48,12 @@ public interface LinphoneSimpleListener {
void onCallStateChanged(LinphoneCall call, State state, String message);
}
public static interface LinphoneAudioChangedListener extends LinphoneSimpleListener {
public static interface LinphoneOnAudioChangedListener extends LinphoneSimpleListener {
public enum AudioState {EARPIECE, SPEAKER}
void onAudioStateChanged(AudioState state);
}
public static interface LinphoneOnVideoCallReadyListener extends LinphoneSimpleListener {
void onRequestedVideoCallReady(LinphoneCall call);
}
}

View file

@ -20,8 +20,10 @@ package org.linphone;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
import org.linphone.core.LinphoneCall;
import org.linphone.core.Log;
import org.linphone.core.LinphoneCall.State;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
@ -46,11 +48,11 @@ import android.widget.ImageView;
* @author Guillaume Beraudo
*
*/
public class VideoCallActivity extends Activity {
public class VideoCallActivity extends Activity implements LinphoneOnCallStateChangedListener {
private SurfaceView mVideoViewReady;
private SurfaceView mVideoCaptureViewReady;
public static boolean launched = false;
public static LinphoneCall call;
private LinphoneCall videoCall;
private WakeLock mWakeLock;
private Handler refreshHandler = new Handler();
@ -106,13 +108,11 @@ public class VideoCallActivity extends Activity {
// Before creating the graph, the orientation must be known to LC => this is done here
LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation()));
if (LinphoneManager.getLc().isIncall()) {
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
if (call != null) {
updatePreview(call.cameraEnabled());
}
videoCall = LinphoneManager.getLc().getCurrentCall();
if (videoCall != null) {
updatePreview(videoCall.cameraEnabled());
}
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,Log.TAG);
@ -169,6 +169,7 @@ public class VideoCallActivity extends Activity {
if (mVideoViewReady != null)
((GLSurfaceView)mVideoViewReady).onResume();
launched=true;
LinphoneManager.getInstance().addListener(this);
refreshHandler.postDelayed(mCallQualityUpdater=new Runnable(){
LinphoneCall mCurrentCall=LinphoneManager.getLc().getCurrentCall();
public void run() {
@ -281,8 +282,9 @@ public class VideoCallActivity extends Activity {
@Override
protected void onPause() {
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(), ", inCall:", LinphoneManager.getLc().isIncall(), ", changingConf:", getChangingConfigurations());
LinphoneManager.getInstance().removeListener(this);
if (isFinishing()) {
call = null; // release reference
videoCall = null; // release reference
}
LinphoneManager.getInstance().restoreUserRequestedSpeaker();
launched=false;
@ -314,4 +316,14 @@ public class VideoCallActivity extends Activity {
if (mVideoViewReady != null)
((GLSurfaceView)mVideoViewReady).onPause();
}
@Override
public void onCallStateChanged(LinphoneCall call, State state,
String message) {
if (call == videoCall && state == State.CallEnd) {
BandwidthManager.getInstance().setUserRestriction(false);
LinphoneManager.getInstance().resetCameraFromPreferences();
finish();
}
}
}

@ -1 +1 @@
Subproject commit 9e8c64cff496d2794fe352a6a3907e0e36988931
Subproject commit c27b9b6702f62cdbd2143c1ccc85b8980b83adac

@ -1 +1 @@
Subproject commit e740628ab7cb69acae8751572506dfc840028607
Subproject commit 67daaaa14d1d6ec4322f54c43a372fa51ee312de