Simplify & fix i/o video params
This commit is contained in:
parent
7343d5810d
commit
3cbbd36f2a
7 changed files with 97 additions and 21 deletions
|
@ -98,11 +98,11 @@
|
|||
|
||||
<string name="pref_video_settings_title">Paramètres vidéo</string>
|
||||
<string name="pref_video_automatically_share_my_video_title">Partager ma vidéo</string>
|
||||
<string name="pref_video_automatically_accept_video_title">Accepter vidéo entrante</string>
|
||||
<string name="pref_video_automatically_accept_video_title">Accepter appels vidéo</string>
|
||||
<string name="pref_video_automatically_share_my_video">Envoyer ma vidéo automatiquement</string>
|
||||
<string name="pref_video_automatically_accept_video">Accepter automatiquement la vidéo</string>
|
||||
<string name="pref_video_automatically_accept_video">Toujours accepter les demandes d\'appels vidéo</string>
|
||||
<string name="pref_video_initiate_call_with_video_title">Initier les appels en vidéo</string>
|
||||
<string name="pref_video_initiate_call_with_video"></string>
|
||||
<string name="pref_video_initiate_call_with_video">Toujours envoyer des demandes d\'appels vidéo</string>
|
||||
<string name="pref_video_enable_title">Activer la vidéo</string>
|
||||
<string name="pref_animation_enable_title">Activer les animations</string>
|
||||
<string name="pref_escape_plus">Remplacer + par 00</string>
|
||||
|
|
|
@ -130,11 +130,11 @@
|
|||
<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_accept_video_title">Accept incoming camera</string>
|
||||
<string name="pref_video_automatically_accept_video_title">Accept incoming video requests</string>
|
||||
<string name="pref_video_automatically_share_my_video">Automatically send my camera</string>
|
||||
<string name="pref_video_automatically_accept_video">Automatically accept correspondent\'s camera</string>
|
||||
<string name="pref_video_automatically_accept_video">Always accept video requests</string>
|
||||
<string name="pref_video_initiate_call_with_video_title">Initiate video calls</string>
|
||||
<string name="pref_video_initiate_call_with_video"></string>
|
||||
<string name="pref_video_initiate_call_with_video">Always send video requests</string>
|
||||
<string name="pref_video_enable_title">Enable Video</string>
|
||||
<string name="pref_animation_enable_title">Enable Animations</string>
|
||||
<string name="pref_escape_plus">Replace + by 00</string>
|
||||
|
|
|
@ -153,7 +153,8 @@
|
|||
android:key="@string/pref_video_use_front_camera_key"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/pref_video_use_front_camera_title"
|
||||
android:dependency="@string/pref_video_enable_key"/>
|
||||
android:dependency="@string/pref_video_enable_key"
|
||||
android:layout="@layout/hidden"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_video_initiate_call_with_video_key"
|
||||
|
@ -167,7 +168,8 @@
|
|||
android:title="@string/pref_video_automatically_share_my_video_title"
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/pref_video_automatically_share_my_video"
|
||||
android:dependency="@string/pref_video_enable_key"/>
|
||||
android:dependency="@string/pref_video_enable_key"
|
||||
android:layout="@layout/hidden"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_video_automatically_accept_video_key"
|
||||
|
|
|
@ -148,7 +148,12 @@ public class DialerFragment extends Fragment {
|
|||
|
||||
public void resetLayout(boolean callTransfer) {
|
||||
isCallTransferOngoing = callTransfer;
|
||||
if (LinphoneManager.getLc() != null && LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lc.getCallsNb() > 0) {
|
||||
if (isCallTransferOngoing) {
|
||||
mCall.setImageResource(R.drawable.transfer_call);
|
||||
mCall.setExternalClickListener(transferListener);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.linphone.core.LinphoneCall;
|
|||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.ui.Numpad;
|
||||
|
||||
|
@ -34,6 +35,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -60,6 +62,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
LinphoneOnCallEncryptionChangedListener,
|
||||
OnClickListener {
|
||||
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
|
||||
|
||||
private static InCallActivity instance;
|
||||
|
||||
private Handler mHandler = new Handler();
|
||||
|
@ -75,6 +78,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
private Numpad numpad;
|
||||
private int cameraNumber;
|
||||
private Animation slideOutLeftToRight, slideInRightToLeft, slideInBottomToTop, slideInTopToBottom, slideOutBottomToTop, slideOutTopToBottom;
|
||||
private CountDownTimer timer;
|
||||
|
||||
public static InCallActivity instance() {
|
||||
return instance;
|
||||
|
@ -322,15 +326,14 @@ public class InCallActivity extends FragmentActivity implements
|
|||
if (!displayVideo) {
|
||||
LinphoneCallParams params = call.getCurrentParamsCopy();
|
||||
params.setVideoEnabled(false);
|
||||
|
||||
LinphoneManager.getLc().updateCall(call, params);
|
||||
replaceFragmentVideoByAudio();
|
||||
|
||||
video.setBackgroundResource(R.drawable.video_on);
|
||||
setCallControlsVisibleAndRemoveCallbacks();
|
||||
|
||||
} else {
|
||||
LinphoneManager.getInstance().addVideo();
|
||||
|
||||
isSpeakerEnabled = true;
|
||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||
speaker.setBackgroundResource(R.drawable.speaker_on);
|
||||
|
@ -809,6 +812,39 @@ public class InCallActivity extends FragmentActivity implements
|
|||
finish();
|
||||
}
|
||||
|
||||
private void acceptCallUpdate(boolean accept) {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||
if (call == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinphoneCallParams params = call.getCurrentParamsCopy();
|
||||
if (accept) {
|
||||
params.setVideoEnabled(true);
|
||||
LinphoneManager.getLc().enableVideo(true, true);
|
||||
}
|
||||
|
||||
try {
|
||||
LinphoneManager.getLc().acceptCallUpdate(call, params);
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (accept) {
|
||||
isSpeakerEnabled = true;
|
||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||
speaker.setBackgroundResource(R.drawable.speaker_on);
|
||||
|
||||
replaceFragmentAudioByVideo();
|
||||
video.setBackgroundResource(R.drawable.video_off);
|
||||
displayVideoCallControlsIfHidden();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStateChanged(final LinphoneCall call, State state, String message) {
|
||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
|
@ -846,6 +882,35 @@ public class InCallActivity extends FragmentActivity implements
|
|||
});
|
||||
}
|
||||
|
||||
if (state == State.CallUpdatedByRemote) {
|
||||
// If the correspondent proposes video while audio call
|
||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
||||
boolean autoAcceptCameraPolicy = LinphoneManager.getInstance().isAutoAcceptCamera();
|
||||
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
//TODO: ask the user it's choice
|
||||
|
||||
// We let 30 secs for the user to decide
|
||||
timer = new CountDownTimer(30000, 1000) {
|
||||
public void onTick(long millisUntilFinished) { }
|
||||
public void onFinish() {
|
||||
acceptCallUpdate(false);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
});
|
||||
} else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
acceptCallUpdate(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
|||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.ui.AvatarWithShadow;
|
||||
import org.linphone.ui.LinphoneSliders;
|
||||
|
@ -128,7 +129,12 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
|||
LinphoneManager.getLc().terminateCall(mCall);
|
||||
}
|
||||
private void answer() {
|
||||
if (!LinphoneManager.getInstance().acceptCall(mCall)) {
|
||||
LinphoneCallParams params = mCall.getCurrentParamsCopy();
|
||||
if (mCall.getRemoteParams().getVideoEnabled() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
||||
params.setVideoEnabled(true);
|
||||
}
|
||||
|
||||
if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
|
||||
// the above method takes care of Samsung Galaxy S
|
||||
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
|
@ -136,7 +142,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
|||
return;
|
||||
}
|
||||
|
||||
if (mCall.getCurrentParamsCopy().getVideoEnabled()) {
|
||||
if (mCall.getRemoteParams().getVideoEnabled() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
||||
LinphoneActivity.instance().startVideoActivity(mCall);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
|
@ -482,7 +483,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
mLc.setRing(null);
|
||||
mLc.setRootCA(mLinphoneRootCaFile);
|
||||
mLc.setPlayFile(mPauseSoundFile);
|
||||
mLc.setVideoPolicy(isAutoInitiateVideoCalls(), isAutoAcceptCamera());
|
||||
|
||||
int availableCores = Runtime.getRuntime().availableProcessors();
|
||||
Log.w("MediaStreamer : " + availableCores + " cores detected and configured");
|
||||
|
@ -656,6 +656,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
setSignalingTransportsFromConfiguration(initialTransports);
|
||||
initMediaEncryption();
|
||||
|
||||
mLc.setVideoPolicy(isAutoInitiateVideoCalls(), isAutoAcceptCamera());
|
||||
|
||||
try {
|
||||
// Configure audio codecs
|
||||
// enableDisableAudioCodec("speex", 32000, 1, R.string.pref_codec_speex32_key);
|
||||
|
@ -1109,10 +1111,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
return getPrefBoolean(R.string.pref_video_enable_key, false);
|
||||
}
|
||||
|
||||
public boolean shareMyCamera() {
|
||||
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_automatically_share_my_video_key, false);
|
||||
}
|
||||
|
||||
public boolean isAutoAcceptCamera() {
|
||||
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_automatically_accept_video_key, false);
|
||||
}
|
||||
|
@ -1184,12 +1182,12 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean acceptCall(LinphoneCall call) {
|
||||
public boolean acceptCallWithParams(LinphoneCall call, LinphoneCallParams params) {
|
||||
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
|
||||
setAudioModeIncallForGalaxyS();
|
||||
|
||||
try {
|
||||
mLc.acceptCall(call);
|
||||
mLc.acceptCallWithParams(call, params);
|
||||
return true;
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.i(e, "Accept call failed");
|
||||
|
|
Loading…
Reference in a new issue