diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 0e7c08ed5..b53581d04 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -15,7 +15,7 @@
+ android:title="@string/pref_codec_speex16" android:defaultValue="true" android:enabled="false">
@@ -36,8 +36,8 @@
-
-
+
+
diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java
index 07e0656f0..b99e39051 100644
--- a/src/org/linphone/DialerActivity.java
+++ b/src/org/linphone/DialerActivity.java
@@ -101,7 +101,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private SharedPreferences mPref;
private ImageButton mAddVideo;
- static String PREF_CHECK_CONFIG = "pref_check_config";
+ private static final String PREF_CHECK_CONFIG = "pref_check_config";
+ private static final String PREF_FIRST_LAUNCH = "pref_first_launch";
private static String CURRENT_ADDRESS = "org.linphone.current-address";
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
static int VIDEO_VIEW_ACTIVITY = 100;
@@ -256,7 +257,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else {
mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName());
}
- configureMuteButtons();
+ configureMuteAndSpeakerButtons();
mWakeLock.acquire();
}
}
@@ -391,33 +392,38 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
try{
LinphoneService.instance().initFromConf();
} catch (LinphoneConfigException ec) {
- Log.w(LinphoneService.TAG,"no valid settings found",ec);
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- TextView lDialogTextView = new TextView(this);
- lDialogTextView.setAutoLinkMask(0x0f/*all*/);
- lDialogTextView.setPadding(10, 10, 10, 10);
- lDialogTextView.setText(Html.fromHtml(getString(R.string.initial_config_error) ));
- builder.setCustomTitle(lDialogTextView)
- .setCancelable(false)
- .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- LinphoneActivity.instance().startprefActivity();
- }
- }).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
+ if (mPref.getBoolean(PREF_FIRST_LAUNCH, true)) {
+ Log.w(LinphoneService.TAG,"no valid settings found - first launch",ec);
+ LinphoneActivity.instance().startprefActivity();
+ mPref.edit().putBoolean(PREF_FIRST_LAUNCH, false).commit();
+ } else {
+ Log.w(LinphoneService.TAG,"no valid settings found", ec);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ TextView lDialogTextView = new TextView(this);
+ lDialogTextView.setAutoLinkMask(0x0f/*all*/);
+ lDialogTextView.setPadding(10, 10, 10, 10);
+ lDialogTextView.setText(Html.fromHtml(getString(R.string.initial_config_error)));
+ builder.setCustomTitle(lDialogTextView)
+ .setCancelable(false)
+ .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ LinphoneActivity.instance().startprefActivity();
+ }
+ }).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ }).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
+ dialog.cancel();
+ }
+ });
+ if (mPref.getBoolean(PREF_CHECK_CONFIG, false) == false) {
+ builder.create().show();
}
- }).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
- dialog.cancel();
- }
- });
- if (mPref.getBoolean(PREF_CHECK_CONFIG, false) == false) {
- builder.create().show();
}
-
} catch (Exception e ) {
Log.e(LinphoneService.TAG,"Cannot get initial config", e);
}
@@ -457,8 +463,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else if (state == LinphoneCall.State.CallEnd) {
exitCallMode();
} else if (state == LinphoneCall.State.StreamsRunning) {
- if (!VideoCallActivity.launched && LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) {
- startVideoView(VIDEO_VIEW_ACTIVITY);
+ if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) {
+ if (!VideoCallActivity.launched) {
+ startVideoView(VIDEO_VIEW_ACTIVITY);
+ }
}
}
mCurrentCallState = state;
@@ -488,7 +496,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mDisplayNameView.setText(lc.getRemoteAddress().toString());
}
}
- configureMuteButtons();
+ configureMuteAndSpeakerButtons();
if (mSpeaker.isChecked()) {
routeAudioToSpeaker();
@@ -497,9 +505,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
}
- private void configureMuteButtons() {
+ private void configureMuteAndSpeakerButtons() {
mMute.setChecked(LinphoneService.instance().getLinphoneCore().isMicMuted());
- if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
+ if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER)
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
mSpeaker.setChecked(true);
} else {
@@ -534,7 +542,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
private void routeAudioToReceiver() {
if (Integer.parseInt(Build.VERSION.SDK) <=4 /* supportedVideoSizes;
public AndroidCameraRecord(RecorderParams parameters) {
@@ -47,7 +48,9 @@ public abstract class AndroidCameraRecord {
setRotation(parameters.rotation);
}
-
+ protected List getSupportedPreviewSizes(Camera.Parameters parameters) {
+ return Collections.emptyList();
+ }
public void startPreview() { // FIXME throws exception?
if (previewStarted) {
@@ -73,7 +76,7 @@ public abstract class AndroidCameraRecord {
Camera.Parameters parameters=camera.getParameters();
if (supportedVideoSizes == null) {
- supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes();
+ supportedVideoSizes = getSupportedPreviewSizes(camera.getParameters());
}
parameters.set("camera-id", params.cameraId);
@@ -83,18 +86,7 @@ public abstract class AndroidCameraRecord {
parameters.setPreviewSize(params.height, params.width);
}
parameters.setPreviewFrameRate(Math.round(params.fps));
- if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
- Log.w(tag, "Auto Focus supported by camera device");
- parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
- } else {
- Log.w(tag, "Auto Focus not supported by camera device");
- if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {
- Log.w(tag, "Infinity Focus supported by camera device");
- parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
- } else {
- Log.w(tag, "Infinity Focus not supported by camera device");
- }
- }
+
onSettingCameraParameters(parameters);
camera.setParameters(parameters);
diff --git a/src/org/linphone/core/AndroidCameraRecordBufferedImpl.java b/src/org/linphone/core/AndroidCameraRecordBufferedImpl.java
index f58698df2..9f8b2d1c0 100644
--- a/src/org/linphone/core/AndroidCameraRecordBufferedImpl.java
+++ b/src/org/linphone/core/AndroidCameraRecordBufferedImpl.java
@@ -30,7 +30,7 @@ import android.util.Log;
* @author Guillaume Beraudo
*
*/
-public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl {
+public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 {
public AndroidCameraRecordBufferedImpl(RecorderParams parameters) {
diff --git a/src/org/linphone/core/AndroidCameraRecordImplAPI5.java b/src/org/linphone/core/AndroidCameraRecordImplAPI5.java
new file mode 100644
index 000000000..7ff307d03
--- /dev/null
+++ b/src/org/linphone/core/AndroidCameraRecordImplAPI5.java
@@ -0,0 +1,64 @@
+/*
+AndroidCameraRecordImplAPI5.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone.core;
+
+import java.util.List;
+
+import android.hardware.Camera;
+import android.hardware.Camera.Parameters;
+import android.hardware.Camera.Size;
+import android.util.Log;
+
+
+public class AndroidCameraRecordImplAPI5 extends AndroidCameraRecordImpl {
+
+ public AndroidCameraRecordImplAPI5(RecorderParams parameters) {
+ super(parameters);
+ }
+
+ @Override
+ protected void onSettingCameraParameters(Parameters parameters) {
+ super.onSettingCameraParameters(parameters);
+
+ if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
+ Log.w(tag, "Auto Focus supported by camera device");
+ parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
+ } else {
+ Log.w(tag, "Auto Focus not supported by camera device");
+ if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {
+ Log.w(tag, "Infinity Focus supported by camera device");
+ parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
+ } else {
+ Log.w(tag, "Infinity Focus not supported by camera device");
+ }
+ }
+ }
+
+ public static List oneShotSupportedVideoSizes() {
+ Camera camera = Camera.open();
+ List supportedVideoSizes =camera.getParameters().getSupportedPreviewSizes();
+ camera.release();
+ return supportedVideoSizes;
+ }
+
+ @Override
+ protected List getSupportedPreviewSizes(Parameters parameters) {
+ return parameters.getSupportedPreviewSizes();
+ }
+}
diff --git a/src/org/linphone/core/AndroidCameraRecordManager.java b/src/org/linphone/core/AndroidCameraRecordManager.java
index 4c767b887..c6bae18da 100644
--- a/src/org/linphone/core/AndroidCameraRecordManager.java
+++ b/src/org/linphone/core/AndroidCameraRecordManager.java
@@ -24,7 +24,6 @@ import java.util.Map;
import org.linphone.core.AndroidCameraRecord.RecorderParams;
-import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Build;
import android.util.Log;
@@ -41,7 +40,6 @@ import android.view.SurfaceHolder.Callback;
*
*/
public class AndroidCameraRecordManager {
- public static final int CAMERA_ID_FIXME_USE_PREFERENCE = 0;
private static final int version = Integer.parseInt(Build.VERSION.SDK);
private static Map instances = new HashMap();
@@ -52,7 +50,8 @@ public class AndroidCameraRecordManager {
}
/**
- * @param cameraId : see max_camera_id
+ * Instance for a given camera
+ * @param cameraId : starting from 0
* @return
*/
public static final synchronized AndroidCameraRecordManager getInstance(int cameraId) {
@@ -69,6 +68,9 @@ public class AndroidCameraRecordManager {
return m;
}
+ /**
+ * @return instance for the default camera
+ */
public static final synchronized AndroidCameraRecordManager getInstance() {
return getInstance(0);
}
@@ -148,6 +150,8 @@ public class AndroidCameraRecordManager {
parameters.surfaceView = surfaceView;
if (version >= 8) {
recorder = new AndroidCameraRecordBufferedImpl(parameters);
+ } else if (version >= 5) {
+ recorder = new AndroidCameraRecordImplAPI5(parameters);
} else {
recorder = new AndroidCameraRecordImpl(parameters);
}
@@ -164,6 +168,10 @@ public class AndroidCameraRecordManager {
// FIXME select right camera
+ /**
+ * Eventually null if API < 5.
+ *
+ */
public List supportedVideoSizes() {
if (supportedVideoSizes != null) {
return supportedVideoSizes;
@@ -174,9 +182,12 @@ public class AndroidCameraRecordManager {
if (supportedVideoSizes != null) return supportedVideoSizes;
}
- Camera camera = Camera.open();
- supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes();
- camera.release();
+ if (version >= 5) {
+ supportedVideoSizes = AndroidCameraRecordImplAPI5.oneShotSupportedVideoSizes();
+ }
+
+ // eventually null
+
return supportedVideoSizes;
}