mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 20:18:09 +00:00
Moved mic and speaker buttons in dialer.
Added camera call button. Added video preferences. Share camera on received call according to preference settings. Invite with(out) according to preference settings.
This commit is contained in:
parent
c505024cc7
commit
dc20fb7739
5 changed files with 133 additions and 61 deletions
|
|
@ -23,7 +23,6 @@ import android.hardware.Camera.ErrorCallback;
|
|||
import android.hardware.Camera.Parameters;
|
||||
import android.hardware.Camera.PreviewCallback;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
|
@ -39,33 +38,26 @@ public abstract class AndroidCameraRecord {
|
|||
protected int fps;
|
||||
protected int height;
|
||||
protected int width;
|
||||
private int longTermVisibility;
|
||||
|
||||
private boolean visibilityChangeable = false;
|
||||
private PreviewCallback storedPreviewCallback;
|
||||
|
||||
private static AndroidCameraRecord instance;
|
||||
private static Handler handler;
|
||||
private static boolean previewStarted;
|
||||
private static boolean parametersSet;
|
||||
protected static int orientationCode;
|
||||
private static boolean mute;
|
||||
private static final String tag="Linphone";
|
||||
|
||||
public AndroidCameraRecord() {
|
||||
// TODO check if another instance is loaded and kill it.
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void setParameters(int height, int width, float fps, boolean hide) {
|
||||
public void setParameters(int height, int width, float fps) {
|
||||
this.fps = Math.round(fps);
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.longTermVisibility = hide ? SurfaceView.GONE : SurfaceView.VISIBLE;
|
||||
|
||||
if (surfaceView != null) {
|
||||
Log.d("Linphone", "Surfaceview defined and ready; starting video capture");
|
||||
instance.startPreview();
|
||||
} else {
|
||||
Log.w("Linphone", "Surfaceview not defined; postponning video capture");
|
||||
}
|
||||
parametersSet = true;
|
||||
startPreview();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -74,16 +66,27 @@ public abstract class AndroidCameraRecord {
|
|||
* It will start automatically
|
||||
*/
|
||||
private void startPreview() {
|
||||
assert surfaceView != null;
|
||||
if (mute) {
|
||||
Log.d(tag, "Not starting preview as camera has been muted");
|
||||
return;
|
||||
}
|
||||
if (surfaceView == null) {
|
||||
Log.w(tag, "Surfaceview not defined; postponning video capture");
|
||||
return;
|
||||
}
|
||||
if (!parametersSet) {
|
||||
Log.w(tag, "Parameters not set; postponning video capture");
|
||||
return;
|
||||
}
|
||||
|
||||
if (previewStarted) {
|
||||
Log.w("Linphone", "Already started");
|
||||
Log.w(tag, "Already started");
|
||||
return;
|
||||
}
|
||||
|
||||
if (surfaceView.getVisibility() != SurfaceView.VISIBLE) {
|
||||
// Illegal state
|
||||
Log.e("Linphone", "Illegal state: video capture surface view is not visible");
|
||||
Log.e(tag, "Illegal state: video capture surface view is not visible");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +94,7 @@ public abstract class AndroidCameraRecord {
|
|||
camera=Camera.open();
|
||||
camera.setErrorCallback(new ErrorCallback() {
|
||||
public void onError(int error, Camera camera) {
|
||||
Log.e("Linphone", "Camera error : " + error);
|
||||
Log.e(tag, "Camera error : " + error);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -101,15 +104,15 @@ public abstract class AndroidCameraRecord {
|
|||
parameters.setPreviewSize(width, height);
|
||||
parameters.setPreviewFrameRate(fps);
|
||||
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
Log.w("Linphone", "Auto Focus supported by camera device");
|
||||
Log.w(tag, "Auto Focus supported by camera device");
|
||||
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
|
||||
} else {
|
||||
Log.w("Linphone", "Auto Focus not supported by camera device");
|
||||
Log.w(tag, "Auto Focus not supported by camera device");
|
||||
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {
|
||||
Log.w("Linphone", "Infinity Focus supported by camera device");
|
||||
Log.w(tag, "Infinity Focus supported by camera device");
|
||||
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
|
||||
} else {
|
||||
Log.w("Linphone", "Infinity Focus not supported by camera device");
|
||||
Log.w(tag, "Infinity Focus not supported by camera device");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +126,7 @@ public abstract class AndroidCameraRecord {
|
|||
camera.setPreviewDisplay(holder);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Log.e("Linphone", "Exception in Video capture setPreviewDisplay()", t);
|
||||
Log.e(tag, "Exception in Video capture setPreviewDisplay()", t);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -131,7 +134,7 @@ public abstract class AndroidCameraRecord {
|
|||
camera.startPreview();
|
||||
previewStarted = true;
|
||||
} catch (Throwable e) {
|
||||
Log.e("Linphone", "Can't start camera preview");
|
||||
Log.e(tag, "Can't start camera preview");
|
||||
}
|
||||
|
||||
previewStarted = true;
|
||||
|
|
@ -143,11 +146,6 @@ public abstract class AndroidCameraRecord {
|
|||
reallySetPreviewCallback(camera, storedPreviewCallback);
|
||||
}
|
||||
|
||||
|
||||
visibilityChangeable = true;
|
||||
if (surfaceView.getVisibility() != longTermVisibility) {
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
onCameraStarted(camera);
|
||||
}
|
||||
|
|
@ -167,7 +165,7 @@ public abstract class AndroidCameraRecord {
|
|||
|
||||
public void setOrStorePreviewCallBack(PreviewCallback cb) {
|
||||
if (camera == null) {
|
||||
Log.w("Linphone", "Capture camera not ready, storing callback");
|
||||
Log.w(tag, "Capture camera not ready, storing callback");
|
||||
this.storedPreviewCallback = cb;
|
||||
return;
|
||||
}
|
||||
|
|
@ -177,8 +175,7 @@ public abstract class AndroidCameraRecord {
|
|||
|
||||
|
||||
|
||||
public static final void setSurfaceView(final SurfaceView sv, Handler mHandler) {
|
||||
AndroidCameraRecord.handler = mHandler;
|
||||
public static final void setSurfaceView(final SurfaceView sv) {
|
||||
SurfaceHolder holder = sv.getHolder();
|
||||
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
|
||||
|
|
@ -187,7 +184,7 @@ public abstract class AndroidCameraRecord {
|
|||
AndroidCameraRecord.surfaceView = null;
|
||||
|
||||
if (camera == null) {
|
||||
Log.e("Linphone", "Video capture: illegal state: surface destroyed but camera is already null");
|
||||
Log.e(tag, "Video capture: illegal state: surface destroyed but camera is already null");
|
||||
return;
|
||||
}
|
||||
camera.setPreviewCallback(null); // TODO check if used whatever the SDK version
|
||||
|
|
@ -195,12 +192,12 @@ public abstract class AndroidCameraRecord {
|
|||
camera.release();
|
||||
camera=null;
|
||||
previewStarted = false;
|
||||
Log.w("Linphone", "Video capture Surface destroyed");
|
||||
Log.w(tag, "Video capture Surface destroyed");
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
AndroidCameraRecord.surfaceView = sv;
|
||||
Log.w("Linphone", "Video capture surface created");
|
||||
Log.w(tag, "Video capture surface created");
|
||||
|
||||
if (instance != null) {
|
||||
instance.startPreview();
|
||||
|
|
@ -211,33 +208,13 @@ public abstract class AndroidCameraRecord {
|
|||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {
|
||||
Log.w("Linphone", "Video capture surface changed");
|
||||
Log.w(tag, "Video capture surface changed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateVisibility() {
|
||||
if (!visibilityChangeable) {
|
||||
throw new IllegalStateException("Visilibity not changeable now");
|
||||
}
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
Log.d("Linphone", "Changing video capture surface view visibility :" + longTermVisibility);
|
||||
surfaceView.setVisibility(longTermVisibility);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setVisibility(int visibility) {
|
||||
if (visibility == this.longTermVisibility) return;
|
||||
|
||||
this.longTermVisibility = visibility;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
|
||||
public void stopCaptureCallback() {
|
||||
if (camera != null) {
|
||||
|
|
@ -256,6 +233,21 @@ public abstract class AndroidCameraRecord {
|
|||
protected int getOrientationCode() {
|
||||
return orientationCode;
|
||||
}
|
||||
|
||||
public static void setMuteCamera(boolean m) {
|
||||
if (m == mute) return;
|
||||
|
||||
mute = m;
|
||||
if (mute && previewStarted) {
|
||||
camera.stopPreview();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mute) {
|
||||
instance.startPreview();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
private native boolean isIncoming(long nativePtr);
|
||||
native private long getRemoteAddress(long nativePtr);
|
||||
native private int getState(long nativePtr);
|
||||
private native long getCurrentParams(long nativePtr);
|
||||
|
||||
protected LinphoneCallImpl(long aNativePtr) {
|
||||
nativePtr = aNativePtr;
|
||||
ref(nativePtr);
|
||||
|
|
@ -58,6 +60,12 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
public State getState() {
|
||||
return LinphoneCall.State.fromInt(getState(nativePtr));
|
||||
}
|
||||
public LinphoneCallParams getCurrentParamsReadOnly() {
|
||||
return new LinphoneCallParamsImpl(getCurrentParams(nativePtr));
|
||||
}
|
||||
public LinphoneCallParams getCurrentParamsReadWrite() {
|
||||
return getCurrentParamsReadOnly().copy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
45
LinphoneCallParamsImpl.java
Normal file
45
LinphoneCallParamsImpl.java
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
LinphoneCallParamsImpl.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;
|
||||
|
||||
public class LinphoneCallParamsImpl implements LinphoneCallParams {
|
||||
protected final long nativePtr;
|
||||
|
||||
public LinphoneCallParamsImpl(long nativePtr) {
|
||||
this.nativePtr = nativePtr;
|
||||
}
|
||||
|
||||
private native void enableVideo(long nativePtr, boolean b);
|
||||
private native boolean getVideoEnabled(long nativePtr);
|
||||
private native long copy(long nativePtr);
|
||||
|
||||
|
||||
public boolean getVideoEnabled() {
|
||||
return getVideoEnabled(nativePtr);
|
||||
}
|
||||
|
||||
public void setVideoEnalbled(boolean b) {
|
||||
enableVideo(nativePtr, b);
|
||||
}
|
||||
|
||||
public LinphoneCallParams copy() {
|
||||
return new LinphoneCallParamsImpl(copy(nativePtr));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -55,6 +55,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native void muteMic(long nativePtr,boolean isMuted);
|
||||
private native long interpretUrl(long nativePtr,String destination);
|
||||
private native long inviteAddress(long nativePtr,long to);
|
||||
private native long inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam);
|
||||
private native void sendDtmf(long nativePtr,char dtmf);
|
||||
private native void clearCallLogs(long nativePtr);
|
||||
private native boolean isMicMuted(long nativePtr);
|
||||
|
|
@ -78,6 +79,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native int getFirewallPolicy(long nativePtr);
|
||||
private native void setStunServer(long nativePtr, String stun_server);
|
||||
private native String getStunServer(long nativePtr);
|
||||
private native long createDefaultCallParams(long nativePtr);
|
||||
private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
|
||||
|
||||
|
||||
private static String TAG = "LinphoneCore";
|
||||
|
||||
|
|
@ -211,14 +215,15 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
throw new LinphoneCoreException("Cannot interpret ["+destination+"]");
|
||||
}
|
||||
}
|
||||
public LinphoneCall invite(LinphoneAddress to) {
|
||||
public LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException {
|
||||
long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr);
|
||||
if (lNativePtr!=0) {
|
||||
return new LinphoneCallImpl(lNativePtr);
|
||||
} else {
|
||||
return null;
|
||||
throw new LinphoneCoreException("Unable to invite address " + to.asString());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDtmf(char number) {
|
||||
sendDtmf(nativePtr,number);
|
||||
}
|
||||
|
|
@ -351,4 +356,27 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public void setStunServer(String stunServer) {
|
||||
setStunServer(nativePtr,stunServer);
|
||||
}
|
||||
|
||||
public LinphoneCallParams createDefaultCallParameters() {
|
||||
return new LinphoneCallParamsImpl(createDefaultCallParams(nativePtr));
|
||||
}
|
||||
|
||||
public LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException {
|
||||
long ptrDestination = ((LinphoneAddressImpl)to).nativePtr;
|
||||
long ptrParams =((LinphoneCallParamsImpl)params).nativePtr;
|
||||
|
||||
long lcNativePtr = inviteAddressWithParams(nativePtr, ptrDestination, ptrParams);
|
||||
if (lcNativePtr!=0) {
|
||||
return new LinphoneCallImpl(lcNativePtr);
|
||||
} else {
|
||||
throw new LinphoneCoreException("Unable to invite with params " + to.asString());
|
||||
}
|
||||
}
|
||||
|
||||
public int updateCall(LinphoneCall call, LinphoneCallParams params) {
|
||||
long ptrCall = ((LinphoneCallImpl) call).nativePtr;
|
||||
long ptrParams = ((LinphoneCallParamsImpl)params).nativePtr;
|
||||
|
||||
return updateCall(nativePtr, ptrCall, ptrParams);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.linphone.core.AndroidCameraRecord;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.SurfaceView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -51,11 +50,11 @@ public class TestVideoActivity extends Activity {
|
|||
// SurfaceHolder holder=surfaceView.getHolder();
|
||||
// holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
|
||||
AndroidCameraRecord.setSurfaceView(surfaceView, new Handler());
|
||||
AndroidCameraRecord.setSurfaceView(surfaceView);
|
||||
|
||||
JavaCameraRecordImpl recorder = new JavaCameraRecordImpl();
|
||||
recorder.setDebug((TextView) findViewById(R.id.videotest_debug));
|
||||
recorder.setParameters(288, 352, rate, false);
|
||||
recorder.setParameters(288, 352, rate);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue