From b92ecb8d63b6017c013a279c3a9f4b8d45b42dc4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 25 Nov 2010 11:13:28 +0100 Subject: [PATCH] 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. --- res/drawable/startvideo_green.png | Bin 0 -> 2997 bytes res/layout-land/dialer.xml | 52 +++++---- res/layout/dialer.xml | 13 +-- res/values/strings.xml | 13 ++- res/xml/preferences.xml | 5 +- src/org/linphone/DialerActivity.java | 94 ++++++++++++---- src/org/linphone/VideoCallActivity.java | 8 +- .../linphone/core/AndroidCameraRecord.java | 104 ++++++++---------- src/org/linphone/core/LinphoneCallImpl.java | 8 ++ .../linphone/core/LinphoneCallParamsImpl.java | 45 ++++++++ src/org/linphone/core/LinphoneCoreImpl.java | 32 +++++- .../core/tutorials/TestVideoActivity.java | 5 +- 12 files changed, 259 insertions(+), 120 deletions(-) create mode 100644 res/drawable/startvideo_green.png create mode 100644 src/org/linphone/core/LinphoneCallParamsImpl.java diff --git a/res/drawable/startvideo_green.png b/res/drawable/startvideo_green.png new file mode 100644 index 0000000000000000000000000000000000000000..1cc2e3e4bdc7d7b2024a89a67ccdfbd44f740e61 GIT binary patch literal 2997 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 - - - - + + + + - - - + + + + + - - - - - + + + + diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml index b9a3e91fd..2ac78e7b4 100644 --- a/res/layout/dialer.xml +++ b/res/layout/dialer.xml @@ -105,16 +105,15 @@ - - + + - - - + + + - - + diff --git a/res/values/strings.xml b/res/values/strings.xml index 5f2cedd30..8f2d27a54 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,7 +1,14 @@ - Enable video - pref_escape_plus_key + Video settings + Share my camera + Initiate video calls + Enable Video + Automatically send videos from my camera + pref_video_automatically_share_my_video_key + pref_video_initiate_call_with_video_key + Initiate outgoing calls with video + pref_video_enable_key Replace + by 00 pref_escape_plus_key iLBC might be unavailable depending on ARM processor and Android OS version. @@ -63,6 +70,8 @@ History Cannot build destination address from [%s] Clear +Cannot get call parameters +Cannot create default call parameters Cannot invite destination address [%s] registered to %s fails to register to %s diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 4bd4c821c..0e7c08ed5 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -36,7 +36,10 @@ - + + + + diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index 19e639648..321cef397 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -20,8 +20,10 @@ package org.linphone; import org.linphone.component.ToggleImageButton; import org.linphone.component.ToggleImageButton.OnCheckedChangeListener; +import org.linphone.core.AndroidCameraRecord; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; +import org.linphone.core.LinphoneCallParams; import org.linphone.core.LinphoneChatRoom; import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCoreException; @@ -59,7 +61,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { private TextView mAddress; private TextView mDisplayNameView; - + private TextView mStatus; private ImageButton mCall; private ImageButton mDecline; @@ -93,6 +95,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { private AudioManager mAudioManager; private PowerManager.WakeLock mWakeLock; private SharedPreferences mPref; + private ImageButton mAddVideo; static String PREF_CHECK_CONFIG = "pref_check_config"; private static String CURRENT_ADDRESS = "org.linphone.current-address"; @@ -148,9 +151,24 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mAddress.getEditableText().clear(); return true; } - }); + mAddVideo = (ImageButton) findViewById(R.id.AddVideo); + mAddVideo.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); + LinphoneCallParams params = lLinphoneCore.getCurrentCall().getCurrentParamsReadOnly(); + String msg; + if (params.getVideoEnabled()) { + msg = "In video call; going back to video call activity"; + startVideoView(); + } else { + msg = "Not in video call; should go try to reinvite with video"; + } + Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); + } + }); + mCall = (ImageButton) findViewById(R.id.Call); mCall.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -203,23 +221,27 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { getIntent().setData(null); } if (LinphoneService.isready()) { - LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore(); - if (lLinphoenCore.isIncall()) { - if(lLinphoenCore.isInComingInvitePending()) { + LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); + if (lLinphoneCore.isIncall()) { + if(lLinphoneCore.isInComingInvitePending()) { callPending(); } else { mCall.setEnabled(false); mHangup.setEnabled(!mCall.isEnabled()); + boolean prefVideoEnabled = getPref(getApplicationContext().getString(R.string.pref_video_enable_key)); + if (!prefVideoEnabled && !mCall.isEnabled()) { + mAddVideo.setEnabled(true); + } mCallControlRow.setVisibility(View.GONE); mInCallControlRow.setVisibility(View.VISIBLE); mAddressLayout.setVisibility(View.GONE); mInCallAddressLayout.setVisibility(View.VISIBLE); - mMute.setChecked(!lLinphoenCore.isMicMuted()); - String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName(); + mMute.setChecked(!lLinphoneCore.isMicMuted()); + String DisplayName = lLinphoneCore.getRemoteAddress().getDisplayName(); if (DisplayName!=null) { mDisplayNameView.setText(DisplayName); } else { - mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName()); + mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName()); } if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL) || Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) { @@ -394,6 +416,14 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } } } + private void startVideoView() { + //start video view + Intent lIntent = new Intent(); + lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + lIntent.setClass(this, VideoCallActivity.class); + startActivityForResult(lIntent,VIDEO_VIEW_ACTIVITY); + } + public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/}; public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { if (state == LinphoneCall.State.OutgoingInit) { @@ -404,13 +434,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { callPending(); } else if (state == LinphoneCall.State.Connected) { enterIncalMode(lc); - if (LinphoneService.instance().getLinphoneCore().isVideoEnabled()) { - //start video view - Intent lIntent = new Intent(); - lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - lIntent.setClass(this, VideoCallActivity.class); - startActivityForResult(lIntent,VIDEO_VIEW_ACTIVITY); - } } else if (state == LinphoneCall.State.Error) { if (mWakeLock.isHeld()) mWakeLock.release(); Toast toast = Toast.makeText(this @@ -420,6 +443,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { exitCallMode(); } else if (state == LinphoneCall.State.CallEnd) { exitCallMode(); + } else if (state == LinphoneCall.State.StreamsRunning) { + if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) { + startVideoView(); + } } } @@ -491,10 +518,20 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { private void callPending() { mDecline.setEnabled(true); routeAudioToSpeaker(); + + // Privacy setting to not share the user camera by default + boolean prefVideoEnable = getPref(getApplicationContext().getString(R.string.pref_video_enable_key)); + boolean prefAutomaticallyShareMyCamera = getPref(getApplicationContext().getString(R.string.pref_video_automatically_share_my_video_key)); + AndroidCameraRecord.setMuteCamera(!(prefVideoEnable && prefAutomaticallyShareMyCamera)); } public void newOutgoingCall(String aTo) { newOutgoingCall(aTo,null); } + + private boolean getPref(String key) { + return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(key, false); + } + public synchronized void newOutgoingCall(String aTo, String displayName) { String lto = aTo; if (aTo.contains(OutgoingCallReceiver.TAG)) { @@ -519,15 +556,26 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { return; } lAddress.setDisplayName(mDisplayName); - try { - lLinphoneCore.invite(lAddress); - } catch (LinphoneCoreException e) { - Toast toast = Toast.makeText(DialerActivity.this - ,String.format(getString(R.string.error_cannot_invite_address),mAddress.getText().toString()) - , Toast.LENGTH_LONG); - toast.show(); - return; + + try { + LinphoneCallParams lParams = lLinphoneCore.createDefaultCallParameters().copy(); + boolean prefVideoEnable = getPref(getApplicationContext().getString(R.string.pref_video_enable_key)); + boolean prefInitiateWithVideo = getPref(getApplicationContext().getString(R.string.pref_video_initiate_call_with_video_key)); + + if (prefVideoEnable && prefInitiateWithVideo && lParams.getVideoEnabled()) { + lParams.setVideoEnalbled(true); + lLinphoneCore.inviteAddressWithParams(lAddress, lParams); + } else { + lParams.setVideoEnalbled(false); + lLinphoneCore.inviteAddressWithParams(lAddress, lParams); } + } catch (LinphoneCoreException e) { + Toast toast = Toast.makeText(DialerActivity.this + ,String.format(getString(R.string.error_cannot_get_call_parameters),mAddress.getText().toString()) + , Toast.LENGTH_LONG); + toast.show(); + return; + } } private void setDigitListener(Button aButton,char dtmf) { class DialKeyListener implements OnClickListener ,OnTouchListener { diff --git a/src/org/linphone/VideoCallActivity.java b/src/org/linphone/VideoCallActivity.java index 2aae9e032..9c5466b17 100644 --- a/src/org/linphone/VideoCallActivity.java +++ b/src/org/linphone/VideoCallActivity.java @@ -24,7 +24,6 @@ import org.linphone.core.AndroidCameraRecord; import android.app.Activity; import android.os.Bundle; -import android.os.Handler; import android.util.Log; import android.view.SurfaceView; import android.view.View; @@ -33,9 +32,8 @@ import android.widget.FrameLayout; public class VideoCallActivity extends Activity { SurfaceView mVideoView; SurfaceView mVideoCaptureView; - private Handler mHandler = new Handler() ; private static boolean firstLaunch = true; - + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videocall); @@ -49,8 +47,8 @@ public class VideoCallActivity extends Activity { AndroidCameraRecord.setOrientationCode(rotation); if (!firstLaunch) workaroundCapturePreviewHiddenOnSubsequentRotations(); - - AndroidCameraRecord.setSurfaceView(mVideoCaptureView, mHandler); + + AndroidCameraRecord.setSurfaceView(mVideoCaptureView); firstLaunch = false; } diff --git a/src/org/linphone/core/AndroidCameraRecord.java b/src/org/linphone/core/AndroidCameraRecord.java index 4137192ba..c16ef065d 100644 --- a/src/org/linphone/core/AndroidCameraRecord.java +++ b/src/org/linphone/core/AndroidCameraRecord.java @@ -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(); + } + + } } diff --git a/src/org/linphone/core/LinphoneCallImpl.java b/src/org/linphone/core/LinphoneCallImpl.java index c71883b57..4c9a770c9 100644 --- a/src/org/linphone/core/LinphoneCallImpl.java +++ b/src/org/linphone/core/LinphoneCallImpl.java @@ -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(); + } } diff --git a/src/org/linphone/core/LinphoneCallParamsImpl.java b/src/org/linphone/core/LinphoneCallParamsImpl.java new file mode 100644 index 000000000..add724f21 --- /dev/null +++ b/src/org/linphone/core/LinphoneCallParamsImpl.java @@ -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)); + } + +} diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 1f389a608..91913e322 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -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); + } } diff --git a/src/org/linphone/core/tutorials/TestVideoActivity.java b/src/org/linphone/core/tutorials/TestVideoActivity.java index e016cad25..0623e34dc 100644 --- a/src/org/linphone/core/tutorials/TestVideoActivity.java +++ b/src/org/linphone/core/tutorials/TestVideoActivity.java @@ -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); }