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:
Guillaume Beraudo 2010-11-25 11:13:28 +01:00
parent 0e2a868694
commit b92ecb8d63
12 changed files with 259 additions and 120 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -5,32 +5,42 @@
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/Addresslayout">
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
android:hint="sip:" android:layout_width="fill_parent"
android:lines="1" android:layout_weight="0.2"></EditText>
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
android:layout_width="fill_parent" android:layout_weight="0.8" android:text="&lt;"></Button>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/Addresslayout">
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
android:hint="sip:" android:layout_width="fill_parent" android:lines="1"
android:layout_weight="0.2"></EditText>
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
android:layout_width="fill_parent" android:layout_weight="0.8"
android:text="&lt;"></Button>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout">
<EditText android:text="@+id/EditText01"
android:layout_height="wrap_content" android:lines="1"
android:id="@+id/DisplayNameView" android:clickable="false"
android:cursorVisible="false" android:gravity="center"
android:layout_width="fill_parent"></EditText>
</LinearLayout>
<FrameLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout">
<EditText android:text="@+id/EditText01"
android:layout_height="wrap_content" android:lines="1"
android:id="@+id/DisplayNameView" android:clickable="false"
android:cursorVisible="false" android:gravity="center"
android:layout_width="fill_parent"></EditText>
<org.linphone.component.ToggleImageButton
android:id="@+id/mic_mute_button" android:layout_height="wrap_content"
android:layout_width="wrap_content" toggled="@drawable/mic_muted"
untoggled="@drawable/mic_active" android:layout_weight="0.5"
android:layout_gravity="left|center_vertical" />
<org.linphone.component.ToggleImageButton
android:id="@+id/speaker_button" android:layout_height="wrap_content"
android:layout_width="wrap_content" toggled="@drawable/speaker_32_on"
untoggled="@drawable/speaker_32_off" android:layout_weight="0.5"
android:layout_gravity="right|center_vertical" />
</FrameLayout>
</LinearLayout>
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
android:layout_height="fill_parent" android:layout_weight="1">
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1" android:background="@drawable/clavier_bg"></ToggleButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"></ImageButton>
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:drawableTop="@drawable/speaker_32_off"></ToggleButton>
</TableRow>
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow" >
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/AddVideo" android:layout_weight="1" android:src="@drawable/startvideo_green" android:background="@drawable/clavier_bg"></ImageButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
</TableRow>
</TableLayout>
<LinearLayout android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/CallControlRow" android:layout_weight="1">

View file

@ -105,16 +105,15 @@
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/AddVideo" android:layout_weight="1" android:src="@drawable/startvideo_green" android:background="@drawable/clavier_bg"></ImageButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
</TableRow>
</TableLayout>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
</TableLayout>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/CallControlRow">
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg">
</ImageButton>
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg"></ImageButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
</LinearLayout><EditText android:layout_width="fill_parent" android:id="@+id/status_label" android:clickable="false" android:focusable="false" android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:layout_height="wrap_content" android:background="@android:color/transparent" android:textColor="@android:color/white"></EditText>
</LinearLayout>

View file

@ -1,7 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_video_enable">Enable video</string>
<string name="pref_video_enable_key">pref_escape_plus_key</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_initiate_call_with_video_title">Initiate video calls</string>
<string name="pref_video_enable_title">Enable Video</string>
<string name="pref_video_automatically_share_my_video">Automatically send videos from my camera</string>
<string name="pref_video_automatically_share_my_video_key">pref_video_automatically_share_my_video_key</string>
<string name="pref_video_initiate_call_with_video_key">pref_video_initiate_call_with_video_key</string>
<string name="pref_video_initiate_call_with_video">Initiate outgoing calls with video</string>
<string name="pref_video_enable_key">pref_video_enable_key</string>
<string name="pref_escape_plus">Replace + by 00</string>
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
<string name="pref_ilbc_summary">iLBC might be unavailable depending on ARM processor and Android OS version.</string>
@ -63,6 +70,8 @@
<string name="tab_history">History</string>
<string name="warning_wrong_destination_address">Cannot build destination address from [%s]</string>
<string name="menu_clear_history">Clear</string>
<string name="error_cannot_get_call_parameters">Cannot get call parameters</string>
<string name="error_cannot_create_default_parameters">Cannot create default call parameters</string>
<string name="error_cannot_invite_address">Cannot invite destination address [%s]</string>
<string name="notification_registered">registered to %s </string>
<string name="notification_register_failure">fails to register to %s</string>

View file

@ -36,7 +36,10 @@
<CheckBoxPreference android:key="@string/pref_video_enable_key" android:title="@string/pref_video_enable"></CheckBoxPreference>
<CheckBoxPreference android:defaultValue="true" android:title="@string/pref_video_enable_title" android:key="@string/pref_video_enable_key"></CheckBoxPreference>
<PreferenceScreen android:title="@string/pref_video_settings_title" android:dependency="@string/pref_video_enable_key"><CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key" android:defaultValue="false" android:title="@string/pref_video_initiate_call_with_video_title" android:summary="@string/pref_video_initiate_call_with_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_automatically_share_my_video_key" android:title="@string/pref_video_automatically_share_my_video_title" android:defaultValue="false" android:summary="@string/pref_video_automatically_share_my_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -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 {

View file

@ -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;
}

View file

@ -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();
}
}
}

View file

@ -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();
}
}

View 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));
}
}

View file

@ -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);
}
}

View file

@ -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);
}