Merge branch 'master' of git.linphone.org:linphone-android

This commit is contained in:
Sylvain Berfini 2011-09-23 13:41:17 +02:00
commit b7a3c705af
9 changed files with 149 additions and 61 deletions

View file

@ -1,11 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/video_frame" android:orientation="vertical" android:id="@+id/video_frame" android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent"> android:layout_height="fill_parent" android:layout_width="fill_parent">
<org.linphone.mediastream.video.display.GL2JNIView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/video_surface"></org.linphone.mediastream.video.display.GL2JNIView> <org.linphone.mediastream.video.display.GL2JNIView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/video_surface"></org.linphone.mediastream.video.display.GL2JNIView>
<SurfaceView android:layout_height="72dip" android:layout_width="88dip" android:id="@+id/video_capture_surface" android:layout_gravity="right|bottom" <SurfaceView
android:layout_margin="15dip"></SurfaceView> android:layout_height="72dip"
</FrameLayout> android:layout_width="88dip"
android:id="@+id/video_capture_surface"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="15dip"
android:layout_marginRight="15dip" >
</SurfaceView>
<ImageView
android:layout_width="88dip"
android:layout_height="72dip"
android:id="@+id/imageView1"
android:src="@drawable/mic_muted"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="15dip"
android:layout_marginRight="15dip" >
</ImageView>
</RelativeLayout>

View file

@ -1,10 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/video_frame" android:id="@+id/video_frame"
android:layout_height="fill_parent" android:layout_width="fill_parent"> android:layout_height="fill_parent" android:layout_width="fill_parent">
<org.linphone.mediastream.video.display.GL2JNIView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/video_surface"></org.linphone.mediastream.video.display.GL2JNIView> <org.linphone.mediastream.video.display.GL2JNIView android:visibility="visible" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/video_surface"></org.linphone.mediastream.video.display.GL2JNIView>
<SurfaceView android:layout_height="88dip" android:layout_width="72dip" android:id="@+id/video_capture_surface" android:layout_gravity="right|bottom" <SurfaceView
android:layout_margin="15dip"></SurfaceView> android:layout_height="88dip"
</FrameLayout> android:layout_width="72dip"
android:id="@+id/video_capture_surface"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dip"
android:layout_marginRight="15dip" >
</SurfaceView>
<ImageView
android:layout_width="72dip"
android:layout_height="88dip"
android:id="@+id/imageView1"
android:src="@drawable/mic_muted"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dip"
android:layout_marginRight="15dip" >
</ImageView>
</RelativeLayout>

View file

@ -304,14 +304,20 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
showDialog(INCOMING_CALL_DIALOG_ID); showDialog(INCOMING_CALL_DIALOG_ID);
} }
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
String from = LinphoneManager.getInstance().extractIncomingRemoteName();
String msg = String.format(getString(R.string.incoming_call_dialog_title), from);
((AlertDialog) dialog).setMessage(msg);
super.onPrepareDialog(id, dialog);
}
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
String from = LinphoneManager.getInstance().extractIncomingRemoteName();
View incomingCallView = getLayoutInflater().inflate(R.layout.incoming_call, null); View incomingCallView = getLayoutInflater().inflate(R.layout.incoming_call, null);
final Dialog dialog = new AlertDialog.Builder(this) final Dialog dialog = new AlertDialog.Builder(this)
.setMessage(String.format(getString(R.string.incoming_call_dialog_title), from)) .setMessage("")
.setCancelable(false) .setCancelable(false)
.setView(incomingCallView).create(); .setView(incomingCallView).create();

View file

@ -246,7 +246,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
if (rot != previousRotation) { if (rot != previousRotation) {
Log.d("New device rotation: ", rot); Log.d("New device rotation: ", rot);
// Returning rotation FROM ITS NATURAL ORIENTATION // Returning rotation FROM ITS NATURAL ORIENTATION
LinphoneManager.getLc().setDeviceRotation(rot); LinphoneCore lc=LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc!=null) lc.setDeviceRotation(rot);
//else ignore, we are probably exiting.
previousRotation = rot; previousRotation = rot;
} }
} }

View file

@ -301,10 +301,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void onAlreadyInCall(); public void onAlreadyInCall();
} }
public void toggleEnableCamera() { public boolean toggleEnableCamera() {
if (mLc.isIncall()) { if (mLc.isIncall()) {
mLc.getCurrentCall().enableCamera(!mLc.getCurrentCall().cameraEnabled()); boolean enabled = !mLc.getCurrentCall().cameraEnabled();
mLc.getCurrentCall().enableCamera(enabled);
return enabled;
} }
return false;
} }
public void sendStaticImage(boolean send) { public void sendStaticImage(boolean send) {

View file

@ -20,8 +20,7 @@ package org.linphone;
import junit.runner.Version; import org.linphone.core.LinphoneCall;
import org.linphone.core.Log; import org.linphone.core.Log;
import org.linphone.mediastream.video.AndroidVideoWindowImpl; import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
@ -36,6 +35,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.View;
/** /**
* For Android SDK >= 5 * For Android SDK >= 5
@ -43,8 +43,8 @@ import android.view.SurfaceView;
* *
*/ */
public class VideoCallActivity extends SoftVolumeActivity { public class VideoCallActivity extends SoftVolumeActivity {
private SurfaceView mVideoView; private SurfaceView mVideoViewReady;
private SurfaceView mVideoCaptureView; private SurfaceView mVideoCaptureViewReady;
public static boolean launched = false; public static boolean launched = false;
private WakeLock mWakeLock; private WakeLock mWakeLock;
@ -56,21 +56,24 @@ public class VideoCallActivity extends SoftVolumeActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.videocall); setContentView(R.layout.videocall);
mVideoView = (SurfaceView) findViewById(R.id.video_surface); SurfaceView videoView = (SurfaceView) findViewById(R.id.video_surface);
mVideoCaptureView = (SurfaceView) findViewById(R.id.video_capture_surface); //((FrameLayout) findViewById(R.id.video_frame)).bringChildToFront(findViewById(R.id.imageView1));
mVideoCaptureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
SurfaceView captureView = (SurfaceView) findViewById(R.id.video_capture_surface);
captureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
/* force surfaces Z ordering */ /* force surfaces Z ordering */
if (org.linphone.mediastream.Version.sdkAboveOrEqual(5)) { if (org.linphone.mediastream.Version.sdkAboveOrEqual(5)) {
fixZOrder(); fixZOrder(videoView, captureView);
} }
androidVideoWindowImpl = new AndroidVideoWindowImpl(mVideoView, mVideoCaptureView); androidVideoWindowImpl = new AndroidVideoWindowImpl(videoView, captureView);
androidVideoWindowImpl.setListener(new AndroidVideoWindowImpl.VideoWindowListener() { androidVideoWindowImpl.setListener(new AndroidVideoWindowImpl.VideoWindowListener() {
public void onVideoRenderingSurfaceReady(AndroidVideoWindowImpl vw) { public void onVideoRenderingSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
LinphoneManager.getLc().setVideoWindow(vw); LinphoneManager.getLc().setVideoWindow(vw);
mVideoViewReady = surface;
} }
public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) { public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) {
@ -78,8 +81,9 @@ public class VideoCallActivity extends SoftVolumeActivity {
LinphoneManager.getLc().setVideoWindow(null); LinphoneManager.getLc().setVideoWindow(null);
} }
public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw) { public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureView); mVideoCaptureViewReady = surface;
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
} }
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) { public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {
@ -96,23 +100,45 @@ public class VideoCallActivity extends SoftVolumeActivity {
// Before creating the graph, the orientation must be known to LC => this is done here // Before creating the graph, the orientation must be known to LC => this is done here
LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation())); LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation()));
if (!LinphoneManager.getInstance().shareMyCamera()) if (LinphoneManager.getLc().isIncall()) {
LinphoneManager.getInstance().sendStaticImage(false); LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
if (call != null) {
boolean camEnabled = call.cameraEnabled();
LinphoneManager.getInstance().sendStaticImage(!camEnabled);
updatePreview(camEnabled);
}
}
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,Log.TAG); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,Log.TAG);
mWakeLock.acquire(); mWakeLock.acquire();
} }
void fixZOrder() { void updatePreview(boolean cameraCaptureEnabled) {
mVideoView.setZOrderOnTop(false); mVideoCaptureViewReady = null;
mVideoCaptureView.setZOrderOnTop(true); if (cameraCaptureEnabled) {
findViewById(R.id.imageView1).setVisibility(View.INVISIBLE);
findViewById(R.id.video_capture_surface).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.video_capture_surface).setVisibility(View.INVISIBLE);
findViewById(R.id.imageView1).setVisibility(View.VISIBLE);
}
findViewById(R.id.video_frame).requestLayout();
}
void fixZOrder(SurfaceView video, SurfaceView preview) {
video.setZOrderOnTop(false);
preview.setZOrderOnTop(true);
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
((GLSurfaceView)mVideoView).onResume(); if (mVideoViewReady != null)
((GLSurfaceView)mVideoViewReady).onResume();
} }
@ -158,16 +184,24 @@ public class VideoCallActivity extends SoftVolumeActivity {
case R.id.videocall_menu_change_resolution: case R.id.videocall_menu_change_resolution:
LinphoneManager.getInstance().changeResolution(); LinphoneManager.getInstance().changeResolution();
// previous call will cause graph reconstruction -> regive preview window // previous call will cause graph reconstruction -> regive preview window
if (mVideoCaptureViewReady != null)
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
rewriteChangeResolutionItem(item); rewriteChangeResolutionItem(item);
break; break;
case R.id.videocall_menu_terminate_call: case R.id.videocall_menu_terminate_call:
LinphoneManager.getInstance().terminateCall(); LinphoneManager.getInstance().terminateCall();
break; break;
case R.id.videocall_menu_toggle_camera: case R.id.videocall_menu_toggle_camera:
LinphoneManager.getInstance().toggleEnableCamera(); boolean camEnabled = LinphoneManager.getInstance().toggleEnableCamera();
updatePreview(camEnabled);
Log.e("winwow camera enabled: " + camEnabled);
rewriteToggleCameraItem(item); rewriteToggleCameraItem(item);
// previous call will cause graph reconstruction -> regive preview window // previous call will cause graph reconstruction -> regive preview window
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureView); if (camEnabled) {
if (mVideoCaptureViewReady != null)
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
} else
LinphoneManager.getLc().setPreviewWindow(null);
break; break;
case R.id.videocall_menu_switch_camera: case R.id.videocall_menu_switch_camera:
int id = LinphoneManager.getLc().getVideoDevice(); int id = LinphoneManager.getLc().getVideoDevice();
@ -175,12 +209,13 @@ public class VideoCallActivity extends SoftVolumeActivity {
LinphoneManager.getLc().setVideoDevice(id); LinphoneManager.getLc().setVideoDevice(id);
CallManager.getInstance().updateCall(); CallManager.getInstance().updateCall();
// previous call will cause graph reconstruction -> regive preview window // previous call will cause graph reconstruction -> regive preview window
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureView); if (mVideoCaptureViewReady != null)
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
break; break;
default: default:
Log.e("Unknown menu item [",item,"]"); Log.e("Unknown menu item [",item,"]");
break; break;
} }
return true; return true;
} }
@ -195,11 +230,21 @@ public class VideoCallActivity extends SoftVolumeActivity {
@Override @Override
protected void onPause() { protected void onPause() {
Log.d("onPause VideoCallActivity"); Log.d("onPause VideoCallActivity");
if (!isFinishing() && LinphoneManager.getLc().isIncall()) {
// we're getting paused for real
if (getChangingConfigurations() == 0) {
LinphoneManager.getInstance().sendStaticImage(true);
} else {
LinphoneManager.getLc().setDeviceRotation(AndroidVideoWindowImpl.rotationToAngle(getWindowManager().getDefaultDisplay().getOrientation()));
LinphoneManager.getLc().updateCall(LinphoneManager.getLc().getCurrentCall(), null);
}
}
LinphoneManager.getLc().setVideoWindow(null); LinphoneManager.getLc().setVideoWindow(null);
LinphoneManager.getLc().setPreviewWindow(null); LinphoneManager.getLc().setPreviewWindow(null);
LinphoneManager.getInstance().sendStaticImage(true);
if (mWakeLock.isHeld()) mWakeLock.release(); if (mWakeLock.isHeld()) mWakeLock.release();
super.onPause(); super.onPause();
((GLSurfaceView)mVideoView).onPause(); if (mVideoViewReady != null)
((GLSurfaceView)mVideoViewReady).onPause();
} }
} }

View file

@ -35,14 +35,17 @@ class LinphoneCallImpl implements LinphoneCall {
private native boolean isEchoCancellationEnabled(long nativePtr) ; private native boolean isEchoCancellationEnabled(long nativePtr) ;
private native void enableEchoLimiter(long nativePtr,boolean enable); private native void enableEchoLimiter(long nativePtr,boolean enable);
private native boolean isEchoLimiterEnabled(long nativePtr); private native boolean isEchoLimiterEnabled(long nativePtr);
private native long getReplacedCall(long nativePtr); private native Object getReplacedCall(long nativePtr);
private native int getDuration(long nativePtr); private native int getDuration(long nativePtr);
private native float getCurrentQuality(long nativePtr); private native float getCurrentQuality(long nativePtr);
private native float getAverageQuality(long nativePtr); private native float getAverageQuality(long nativePtr);
private native String getAuthenticationToken(long nativePtr); private native String getAuthenticationToken(long nativePtr);
private native boolean isAuthenticationTokenVerified(long nativePtr); private native boolean isAuthenticationTokenVerified(long nativePtr);
private native boolean areStreamsEncrypted(long nativePtr); private native boolean areStreamsEncrypted(long nativePtr);
/*
* This method must always be called from JNI, nothing else.
*/
protected LinphoneCallImpl(long aNativePtr) { protected LinphoneCallImpl(long aNativePtr) {
nativePtr = aNativePtr; nativePtr = aNativePtr;
} }
@ -98,11 +101,7 @@ class LinphoneCallImpl implements LinphoneCall {
return isEchoLimiterEnabled(nativePtr); return isEchoLimiterEnabled(nativePtr);
} }
public LinphoneCall getReplacedCall(){ public LinphoneCall getReplacedCall(){
long callptr=getReplacedCall(nativePtr); return (LinphoneCall)getReplacedCall(nativePtr);
if (callptr!=0){
return new LinphoneCallImpl(callptr);
}
return null;
} }
public int getDuration() { public int getDuration() {

View file

@ -42,7 +42,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void clearProxyConfigs(long nativePtr); private native void clearProxyConfigs(long nativePtr);
private native void addAuthInfo(long nativePtr,long authInfoNativePtr); private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
private native long invite(long nativePtr,String uri); private native Object invite(long nativePtr,String uri);
private native void terminateCall(long nativePtr, long call); private native void terminateCall(long nativePtr, long call);
private native long getRemoteAddress(long nativePtr); private native long getRemoteAddress(long nativePtr);
private native boolean isInCall(long nativePtr); private native boolean isInCall(long nativePtr);
@ -56,8 +56,8 @@ class LinphoneCoreImpl implements LinphoneCore {
private native float getPlaybackGain(long nativeptr); private native float getPlaybackGain(long nativeptr);
private native void muteMic(long nativePtr,boolean isMuted); private native void muteMic(long nativePtr,boolean isMuted);
private native long interpretUrl(long nativePtr,String destination); private native long interpretUrl(long nativePtr,String destination);
private native long inviteAddress(long nativePtr,long to); private native Object inviteAddress(long nativePtr,long to);
private native long inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); private native Object inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam);
private native void sendDtmf(long nativePtr,char dtmf); private native void sendDtmf(long nativePtr,char dtmf);
private native void clearCallLogs(long nativePtr); private native void clearCallLogs(long nativePtr);
private native boolean isMicMuted(long nativePtr); private native boolean isMicMuted(long nativePtr);
@ -140,12 +140,7 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized LinphoneCall invite(String uri) { public synchronized LinphoneCall invite(String uri) {
isValid(); isValid();
long lNativePtr = invite(nativePtr,uri); return (LinphoneCall)invite(nativePtr,uri);
if (lNativePtr!=0) {
return new LinphoneCallImpl(lNativePtr);
} else {
return null;
}
} }
public synchronized void iterate() { public synchronized void iterate() {
@ -239,9 +234,9 @@ class LinphoneCoreImpl implements LinphoneCore {
} }
} }
public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException {
long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); LinphoneCall call = (LinphoneCall)inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr);
if (lNativePtr!=0) { if (call!=null) {
return new LinphoneCallImpl(lNativePtr); return call;
} else { } else {
throw new LinphoneCoreException("Unable to invite address " + to.asString()); throw new LinphoneCoreException("Unable to invite address " + to.asString());
} }
@ -361,9 +356,9 @@ class LinphoneCoreImpl implements LinphoneCore {
long ptrDestination = ((LinphoneAddressImpl)to).nativePtr; long ptrDestination = ((LinphoneAddressImpl)to).nativePtr;
long ptrParams =((LinphoneCallParamsImpl)params).nativePtr; long ptrParams =((LinphoneCallParamsImpl)params).nativePtr;
long lcNativePtr = inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); LinphoneCall call = (LinphoneCall)inviteAddressWithParams(nativePtr, ptrDestination, ptrParams);
if (lcNativePtr!=0) { if (call!=null) {
return new LinphoneCallImpl(lcNativePtr); return call;
} else { } else {
throw new LinphoneCoreException("Unable to invite with params " + to.asString()); throw new LinphoneCoreException("Unable to invite with params " + to.asString());
} }

@ -1 +1 @@
Subproject commit 73acd25082b213ba0ce6cd77cecd736b34b4bdc2 Subproject commit 33c884f493d473a1373a7d219ecfd07db60e50cc