Fix issues/behaviour on smartphones + update linphone/ms2/ortp
This commit is contained in:
parent
0245c56776
commit
273b42d72c
5 changed files with 286 additions and 169 deletions
|
@ -518,9 +518,10 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
mCamera.startPreview();
|
mCamera.startPreview();
|
||||||
} else if (LinphoneManager.getLc().isIncall())
|
} else if (LinphoneManager.getLc().isIncall())
|
||||||
{
|
{
|
||||||
if (mInCallControls != null)
|
if (mInCallControls != null) {
|
||||||
mInCallControls.setVisibility(View.VISIBLE);
|
mInCallControls.setVisibility(View.VISIBLE);
|
||||||
mCall.setVisibility(View.GONE);
|
mCall.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (mSwitchCamera != null)
|
if (mSwitchCamera != null)
|
||||||
mSwitchCamera.setVisibility(View.INVISIBLE);
|
mSwitchCamera.setVisibility(View.INVISIBLE);
|
||||||
|
|
|
@ -622,6 +622,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
||||||
{
|
{
|
||||||
// Android without neon doesn't support H264
|
// Android without neon doesn't support H264
|
||||||
findPreference(R.string.pref_video_codec_h264_key).setEnabled(false);
|
findPreference(R.string.pref_video_codec_h264_key).setEnabled(false);
|
||||||
|
findPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
addEchoPrefsListener();
|
addEchoPrefsListener();
|
||||||
|
|
|
@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
|
@ -44,6 +42,9 @@ import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
@ -60,13 +61,15 @@ import android.widget.RelativeLayout.LayoutParams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Android SDK >= 5
|
* For Android SDK >= 5
|
||||||
|
*
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class VideoCallActivity extends Activity implements LinphoneOnCallStateChangedListener, OnClickListener {
|
public class VideoCallActivity extends Activity implements
|
||||||
|
LinphoneOnCallStateChangedListener, OnClickListener {
|
||||||
private final static int DELAY_BEFORE_HIDING_CONTROLS = 2000;
|
private final static int DELAY_BEFORE_HIDING_CONTROLS = 2000;
|
||||||
private static final int numpadDialogId = 1;
|
private static final int numpadDialogId = 1;
|
||||||
|
|
||||||
private SurfaceView mVideoViewReady;
|
private SurfaceView mVideoViewReady;
|
||||||
private SurfaceView mVideoCaptureViewReady;
|
private SurfaceView mVideoCaptureViewReady;
|
||||||
public static boolean launched = false;
|
public static boolean launched = false;
|
||||||
|
@ -81,8 +84,10 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) {
|
if (!LinphoneManager.isInstanciated()
|
||||||
Log.e("No service running: avoid crash by finishing ", getClass().getName());
|
|| LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
Log.e("No service running: avoid crash by finishing ", getClass()
|
||||||
|
.getName());
|
||||||
// super.onCreate called earlier
|
// super.onCreate called earlier
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -90,80 +95,90 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
|
|
||||||
setContentView(R.layout.videocall);
|
setContentView(R.layout.videocall);
|
||||||
|
|
||||||
SurfaceView videoView = (SurfaceView) findViewById(R.id.video_surface);
|
SurfaceView videoView = (SurfaceView) findViewById(R.id.video_surface);
|
||||||
|
|
||||||
|
// ((FrameLayout)
|
||||||
|
// findViewById(R.id.video_frame)).bringChildToFront(findViewById(R.id.imageView1));
|
||||||
|
|
||||||
//((FrameLayout) findViewById(R.id.video_frame)).bringChildToFront(findViewById(R.id.imageView1));
|
|
||||||
|
|
||||||
SurfaceView captureView = (SurfaceView) findViewById(R.id.video_capture_surface);
|
SurfaceView captureView = (SurfaceView) findViewById(R.id.video_capture_surface);
|
||||||
captureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
captureView.getHolder()
|
||||||
|
.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||||
|
|
||||||
/* force surfaces Z ordering */
|
/* force surfaces Z ordering */
|
||||||
fixZOrder(videoView, captureView);
|
fixZOrder(videoView, captureView);
|
||||||
|
|
||||||
androidVideoWindowImpl = new AndroidVideoWindowImpl(videoView, captureView);
|
androidVideoWindowImpl = new AndroidVideoWindowImpl(videoView,
|
||||||
androidVideoWindowImpl.setListener(new AndroidVideoWindowImpl.VideoWindowListener() {
|
captureView);
|
||||||
|
androidVideoWindowImpl
|
||||||
public void onVideoRenderingSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
|
.setListener(new AndroidVideoWindowImpl.VideoWindowListener() {
|
||||||
LinphoneManager.getLc().setVideoWindow(vw);
|
|
||||||
mVideoViewReady = surface;
|
public void onVideoRenderingSurfaceReady(
|
||||||
}
|
AndroidVideoWindowImpl vw, SurfaceView surface) {
|
||||||
|
LinphoneManager.getLc().setVideoWindow(vw);
|
||||||
public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) {
|
mVideoViewReady = surface;
|
||||||
Log.d("VIDEO WINDOW destroyed!\n");
|
}
|
||||||
LinphoneManager.getLc().setVideoWindow(null);
|
|
||||||
}
|
public void onVideoRenderingSurfaceDestroyed(
|
||||||
|
AndroidVideoWindowImpl vw) {
|
||||||
public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
|
Log.d("VIDEO WINDOW destroyed!\n");
|
||||||
mVideoCaptureViewReady = surface;
|
LinphoneManager.getLc().setVideoWindow(null);
|
||||||
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
|
}
|
||||||
}
|
|
||||||
|
public void onVideoPreviewSurfaceReady(
|
||||||
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {
|
AndroidVideoWindowImpl vw, SurfaceView surface) {
|
||||||
// Remove references kept in jni code and restart camera
|
mVideoCaptureViewReady = surface;
|
||||||
LinphoneManager.getLc().setPreviewWindow(null);
|
LinphoneManager.getLc().setPreviewWindow(
|
||||||
}
|
mVideoCaptureViewReady);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
public void onVideoPreviewSurfaceDestroyed(
|
||||||
|
AndroidVideoWindowImpl vw) {
|
||||||
|
// Remove references kept in jni code and restart camera
|
||||||
|
LinphoneManager.getLc().setPreviewWindow(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
androidVideoWindowImpl.init();
|
androidVideoWindowImpl.init();
|
||||||
|
|
||||||
videoCall = LinphoneManager.getLc().getCurrentCall();
|
videoCall = LinphoneManager.getLc().getCurrentCall();
|
||||||
if (videoCall != null) {
|
if (videoCall != null) {
|
||||||
LinphoneManager lm = LinphoneManager.getInstance();
|
LinphoneManager lm = LinphoneManager.getInstance();
|
||||||
if (!lm.shareMyCamera() && !lm.isVideoInitiator() && videoCall.cameraEnabled()) {
|
if (!lm.shareMyCamera() && !lm.isVideoInitiator()
|
||||||
|
&& videoCall.cameraEnabled()) {
|
||||||
lm.sendStaticImage(true);
|
lm.sendStaticImage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePreview(videoCall.cameraEnabled());
|
updatePreview(videoCall.cameraEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
mControlsLayout = (LinearLayout) findViewById(R.id.incall_controls_layout);
|
mControlsLayout = (LinearLayout) findViewById(R.id.incall_controls_layout);
|
||||||
videoView.setOnTouchListener(new OnTouchListener() {
|
videoView.setOnTouchListener(new OnTouchListener() {
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if (mControlsLayout != null && mControlsLayout.getVisibility() == View.GONE)
|
if (mControlsLayout != null
|
||||||
{
|
&& mControlsLayout.getVisibility() == View.GONE) {
|
||||||
mControlsLayout.setVisibility(View.VISIBLE);
|
mControlsLayout.setVisibility(View.VISIBLE);
|
||||||
controlsHandler.postDelayed(mControls = new Runnable(){
|
controlsHandler.postDelayed(mControls = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
},DELAY_BEFORE_HIDING_CONTROLS);
|
}, DELAY_BEFORE_HIDING_CONTROLS);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!AndroidCameraConfiguration.hasSeveralCameras()) {
|
if (!AndroidCameraConfiguration.hasSeveralCameras()) {
|
||||||
findViewById(R.id.switch_camera).setVisibility(View.GONE);
|
findViewById(R.id.switch_camera).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Version.isXLargeScreen(this))
|
if (Version.isXLargeScreen(this)) {
|
||||||
{
|
|
||||||
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
||||||
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
||||||
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
|
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
|
||||||
|
@ -172,111 +187,206 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
findViewById(R.id.switch_camera).setOnClickListener(this);
|
findViewById(R.id.switch_camera).setOnClickListener(this);
|
||||||
findViewById(R.id.conf_simple_pause).setOnClickListener(this);
|
findViewById(R.id.conf_simple_pause).setOnClickListener(this);
|
||||||
findViewById(R.id.conf_simple_video).setOnClickListener(this);
|
findViewById(R.id.conf_simple_video).setOnClickListener(this);
|
||||||
|
|
||||||
if (LinphoneManager.getInstance().isSpeakerOn())
|
if (LinphoneManager.getInstance().isSpeakerOn()) {
|
||||||
{
|
|
||||||
ToggleImageButton speaker = (ToggleImageButton) findViewById(R.id.toggleSpeaker);
|
ToggleImageButton speaker = (ToggleImageButton) findViewById(R.id.toggleSpeaker);
|
||||||
speaker.setChecked(true);
|
speaker.setChecked(true);
|
||||||
speaker.setEnabled(false);
|
speaker.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack to force the redraw of the preview
|
// Hack to force the redraw of the preview
|
||||||
// Camera will be re-enabled in onResume just after anyway
|
// Camera will be re-enabled in onResume just after anyway
|
||||||
shouldRestartVideoOnResume = true;
|
shouldRestartVideoOnResume = true;
|
||||||
LinphoneManager.getLc().getCurrentCall().enableCamera(false);
|
LinphoneManager.getLc().getCurrentCall().enableCamera(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateQualityOfSignalIcon(float quality)
|
void updateQualityOfSignalIcon(float quality) {
|
||||||
{
|
|
||||||
ImageView qos = (ImageView) findViewById(R.id.QoS);
|
ImageView qos = (ImageView) findViewById(R.id.QoS);
|
||||||
if (quality >= 4) // Good Quality
|
if (quality >= 4) // Good Quality
|
||||||
{
|
{
|
||||||
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_4));
|
qos.setImageDrawable(getResources().getDrawable(
|
||||||
}
|
R.drawable.stat_sys_signal_4));
|
||||||
else if (quality >= 3) // Average quality
|
} else if (quality >= 3) // Average quality
|
||||||
{
|
{
|
||||||
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_3));
|
qos.setImageDrawable(getResources().getDrawable(
|
||||||
}
|
R.drawable.stat_sys_signal_3));
|
||||||
else if (quality >= 2) // Low quality
|
} else if (quality >= 2) // Low quality
|
||||||
{
|
{
|
||||||
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_2));
|
qos.setImageDrawable(getResources().getDrawable(
|
||||||
}
|
R.drawable.stat_sys_signal_2));
|
||||||
else if (quality >= 1) // Very low quality
|
} else if (quality >= 1) // Very low quality
|
||||||
{
|
{
|
||||||
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_1));
|
qos.setImageDrawable(getResources().getDrawable(
|
||||||
}
|
R.drawable.stat_sys_signal_1));
|
||||||
else // Worst quality
|
} else // Worst quality
|
||||||
{
|
{
|
||||||
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_0));
|
qos.setImageDrawable(getResources().getDrawable(
|
||||||
|
R.drawable.stat_sys_signal_0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rewriteToggleCameraItem(MenuItem item) {
|
||||||
|
if (LinphoneManager.getLc().getCurrentCall().cameraEnabled()) {
|
||||||
|
item.setTitle(getString(R.string.menu_videocall_toggle_camera_disable));
|
||||||
|
} else {
|
||||||
|
item.setTitle(getString(R.string.menu_videocall_toggle_camera_enable));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewriteChangeResolutionItem(MenuItem item) {
|
||||||
|
if (BandwidthManager.getInstance().isUserRestriction()) {
|
||||||
|
item.setTitle(getString(R.string.menu_videocall_change_resolution_when_low_resolution));
|
||||||
|
} else {
|
||||||
|
item.setTitle(getString(R.string.menu_videocall_change_resolution_when_high_resolution));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
if (Version.isXLargeScreen(this))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Inflate the currently selected menu XML resource.
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.videocall_activity_menu, menu);
|
||||||
|
|
||||||
|
rewriteToggleCameraItem(menu
|
||||||
|
.findItem(R.id.videocall_menu_toggle_camera));
|
||||||
|
rewriteChangeResolutionItem(menu
|
||||||
|
.findItem(R.id.videocall_menu_change_resolution));
|
||||||
|
|
||||||
|
if (!AndroidCameraConfiguration.hasSeveralCameras()) {
|
||||||
|
menu.findItem(R.id.videocall_menu_switch_camera).setVisible(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.videocall_menu_back_to_dialer:
|
||||||
|
finish();
|
||||||
|
LinphoneActivity.instance().startIncallActivity();
|
||||||
|
break;
|
||||||
|
case R.id.videocall_menu_change_resolution:
|
||||||
|
LinphoneManager.getInstance().changeResolution();
|
||||||
|
// previous call will cause graph reconstruction -> regive preview
|
||||||
|
// window
|
||||||
|
if (mVideoCaptureViewReady != null)
|
||||||
|
LinphoneManager.getLc()
|
||||||
|
.setPreviewWindow(mVideoCaptureViewReady);
|
||||||
|
rewriteChangeResolutionItem(item);
|
||||||
|
break;
|
||||||
|
case R.id.videocall_menu_terminate_call:
|
||||||
|
LinphoneManager.getInstance().terminateCall();
|
||||||
|
break;
|
||||||
|
case R.id.videocall_menu_toggle_camera:
|
||||||
|
boolean camEnabled = LinphoneManager.getInstance()
|
||||||
|
.toggleEnableCamera();
|
||||||
|
updatePreview(camEnabled);
|
||||||
|
Log.e("winwow camera enabled: " + camEnabled);
|
||||||
|
rewriteToggleCameraItem(item);
|
||||||
|
// previous call will cause graph reconstruction -> regive preview
|
||||||
|
// window
|
||||||
|
if (camEnabled) {
|
||||||
|
if (mVideoCaptureViewReady != null)
|
||||||
|
LinphoneManager.getLc().setPreviewWindow(
|
||||||
|
mVideoCaptureViewReady);
|
||||||
|
} else
|
||||||
|
LinphoneManager.getLc().setPreviewWindow(null);
|
||||||
|
break;
|
||||||
|
case R.id.videocall_menu_switch_camera:
|
||||||
|
int id = LinphoneManager.getLc().getVideoDevice();
|
||||||
|
id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
|
LinphoneManager.getLc().setVideoDevice(id);
|
||||||
|
CallManager.getInstance().updateCall();
|
||||||
|
// previous call will cause graph reconstruction -> regive preview
|
||||||
|
// window
|
||||||
|
if (mVideoCaptureViewReady != null)
|
||||||
|
LinphoneManager.getLc()
|
||||||
|
.setPreviewWindow(mVideoCaptureViewReady);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e("Unknown menu item [", item, "]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void updatePreview(boolean cameraCaptureEnabled) {
|
void updatePreview(boolean cameraCaptureEnabled) {
|
||||||
mVideoCaptureViewReady = null;
|
mVideoCaptureViewReady = null;
|
||||||
if (cameraCaptureEnabled) {
|
if (cameraCaptureEnabled) {
|
||||||
findViewById(R.id.imageView1).setVisibility(View.INVISIBLE);
|
findViewById(R.id.imageView1).setVisibility(View.INVISIBLE);
|
||||||
findViewById(R.id.video_capture_surface).setVisibility(View.VISIBLE);
|
findViewById(R.id.video_capture_surface)
|
||||||
|
.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
findViewById(R.id.video_capture_surface).setVisibility(View.INVISIBLE);
|
findViewById(R.id.video_capture_surface).setVisibility(
|
||||||
|
View.INVISIBLE);
|
||||||
findViewById(R.id.imageView1).setVisibility(View.VISIBLE);
|
findViewById(R.id.imageView1).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
findViewById(R.id.video_frame).requestLayout();
|
findViewById(R.id.video_frame).requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixZOrder(SurfaceView video, SurfaceView preview) {
|
void fixZOrder(SurfaceView video, SurfaceView preview) {
|
||||||
video.setZOrderOnTop(false);
|
video.setZOrderOnTop(false);
|
||||||
preview.setZOrderOnTop(true);
|
preview.setZOrderOnTop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (mVideoViewReady != null)
|
if (mVideoViewReady != null)
|
||||||
((GLSurfaceView)mVideoViewReady).onResume();
|
((GLSurfaceView) mVideoViewReady).onResume();
|
||||||
synchronized (androidVideoWindowImpl) {
|
synchronized (androidVideoWindowImpl) {
|
||||||
LinphoneManager.getLc().setVideoWindow(androidVideoWindowImpl);
|
LinphoneManager.getLc().setVideoWindow(androidVideoWindowImpl);
|
||||||
}
|
}
|
||||||
launched=true;
|
launched = true;
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
|
||||||
refreshHandler.postDelayed(mCallQualityUpdater=new Runnable(){
|
refreshHandler.postDelayed(mCallQualityUpdater = new Runnable() {
|
||||||
LinphoneCall mCurrentCall=LinphoneManager.getLc().getCurrentCall();
|
LinphoneCall mCurrentCall = LinphoneManager.getLc()
|
||||||
|
.getCurrentCall();
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mCurrentCall==null){
|
if (mCurrentCall == null) {
|
||||||
mCallQualityUpdater=null;
|
mCallQualityUpdater = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int oldQuality = 0;
|
int oldQuality = 0;
|
||||||
float newQuality = mCurrentCall.getCurrentQuality();
|
float newQuality = mCurrentCall.getCurrentQuality();
|
||||||
if ((int) newQuality != oldQuality){
|
if ((int) newQuality != oldQuality) {
|
||||||
updateQualityOfSignalIcon(newQuality);
|
updateQualityOfSignalIcon(newQuality);
|
||||||
}
|
}
|
||||||
if (launched){
|
if (launched) {
|
||||||
refreshHandler.postDelayed(this, 1000);
|
refreshHandler.postDelayed(this, 1000);
|
||||||
}else mCallQualityUpdater=null;
|
} else
|
||||||
|
mCallQualityUpdater = null;
|
||||||
}
|
}
|
||||||
},1000);
|
}, 1000);
|
||||||
|
|
||||||
if (mControlsLayout != null)
|
if (mControlsLayout != null)
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (shouldRestartVideoOnResume) {
|
if (shouldRestartVideoOnResume) {
|
||||||
LinphoneManager.getLc().getCurrentCall().enableCamera(true);
|
LinphoneManager.getLc().getCurrentCall().enableCamera(true);
|
||||||
shouldRestartVideoOnResume = false;
|
shouldRestartVideoOnResume = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode)) return true;
|
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode))
|
||||||
if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
|
return true;
|
||||||
|
if (Version.isXLargeScreen(this) && LinphoneUtils.onKeyBackGoHome(this, keyCode, event))
|
||||||
|
return true;
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
if (androidVideoWindowImpl != null) { // Prevent linphone from crashing if correspondent hang up while you are rotating
|
if (androidVideoWindowImpl != null) { // Prevent linphone from crashing
|
||||||
|
// if correspondent hang up
|
||||||
|
// while you are rotating
|
||||||
androidVideoWindowImpl.release();
|
androidVideoWindowImpl.release();
|
||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -284,36 +394,40 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(), ", inCall:", LinphoneManager.getLc().isIncall(),")");
|
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(),
|
||||||
|
", inCall:", LinphoneManager.getLc().isIncall(), ")");
|
||||||
LinphoneManager.removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
if (isFinishing()) {
|
if (isFinishing()) {
|
||||||
videoCall = null; // release reference
|
videoCall = null; // release reference
|
||||||
} else {
|
} else {
|
||||||
// Send NoWebcam since Android 4.0 can't get the video from the webcam if the activity is not in foreground
|
// Send NoWebcam since Android 4.0 can't get the video from the
|
||||||
|
// webcam if the activity is not in foreground
|
||||||
shouldRestartVideoOnResume = true;
|
shouldRestartVideoOnResume = true;
|
||||||
LinphoneManager.getLc().getCurrentCall().enableCamera(false);
|
LinphoneManager.getLc().getCurrentCall().enableCamera(false);
|
||||||
}
|
}
|
||||||
launched=false;
|
launched = false;
|
||||||
synchronized (androidVideoWindowImpl) {
|
synchronized (androidVideoWindowImpl) {
|
||||||
/* this call will destroy native opengl renderer
|
/*
|
||||||
* which is used by androidVideoWindowImpl
|
* this call will destroy native opengl renderer which is used by
|
||||||
|
* androidVideoWindowImpl
|
||||||
*/
|
*/
|
||||||
LinphoneManager.getLc().setVideoWindow(null);
|
LinphoneManager.getLc().setVideoWindow(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCallQualityUpdater!=null){
|
if (mCallQualityUpdater != null) {
|
||||||
refreshHandler.removeCallbacks(mCallQualityUpdater);
|
refreshHandler.removeCallbacks(mCallQualityUpdater);
|
||||||
mCallQualityUpdater=null;
|
mCallQualityUpdater = null;
|
||||||
}
|
}
|
||||||
if (mControls != null) {
|
if (mControls != null) {
|
||||||
controlsHandler.removeCallbacks(mControls);
|
controlsHandler.removeCallbacks(mControls);
|
||||||
mControls = null;
|
mControls = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
if (mWakeLock.isHeld())
|
||||||
|
mWakeLock.release();
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (mVideoViewReady != null)
|
if (mVideoViewReady != null)
|
||||||
((GLSurfaceView)mVideoViewReady).onPause();
|
((GLSurfaceView) mVideoViewReady).onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -325,12 +439,13 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resizePreview() {
|
private void resizePreview() {
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||||
|
.getDefaultDisplay();
|
||||||
int rotation = display.getRotation();
|
int rotation = display.getRotation();
|
||||||
LayoutParams params;
|
LayoutParams params;
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
if (Version.isXLargeScreen(this)) {
|
if (Version.isXLargeScreen(this)) {
|
||||||
w = 176;
|
w = 176;
|
||||||
|
@ -339,7 +454,7 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
w = 88;
|
w = 88;
|
||||||
h = 74;
|
h = 74;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
||||||
params = new LayoutParams(h, w);
|
params = new LayoutParams(h, w);
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,86 +465,88 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
mVideoCaptureViewReady.setLayoutParams(params);
|
mVideoCaptureViewReady.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
resizePreview();
|
resizePreview();
|
||||||
super.onConfigurationChanged(null);
|
super.onConfigurationChanged(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetControlsLayoutExpiration() {
|
private void resetControlsLayoutExpiration() {
|
||||||
if (mControls != null) {
|
if (mControls != null) {
|
||||||
controlsHandler.removeCallbacks(mControls);
|
controlsHandler.removeCallbacks(mControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
controlsHandler.postDelayed(mControls = new Runnable(){
|
controlsHandler.postDelayed(mControls = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
},DELAY_BEFORE_HIDING_CONTROLS);
|
}, DELAY_BEFORE_HIDING_CONTROLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
resetControlsLayoutExpiration();
|
resetControlsLayoutExpiration();
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.incallHang:
|
case R.id.incallHang:
|
||||||
terminateCurrentCallOrConferenceOrAll();
|
terminateCurrentCallOrConferenceOrAll();
|
||||||
break;
|
break;
|
||||||
case R.id.toggleSpeaker:
|
case R.id.toggleSpeaker:
|
||||||
if (((Checkable) v).isChecked()) {
|
if (((Checkable) v).isChecked()) {
|
||||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||||
} else {
|
} else {
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.incallNumpadShow:
|
case R.id.incallNumpadShow:
|
||||||
showDialog(numpadDialogId);
|
showDialog(numpadDialogId);
|
||||||
break;
|
break;
|
||||||
case R.id.toggleMuteMic:
|
case R.id.toggleMuteMic:
|
||||||
LinphoneManager.getLc().muteMic(((Checkable) v).isChecked());
|
LinphoneManager.getLc().muteMic(((Checkable) v).isChecked());
|
||||||
break;
|
break;
|
||||||
case R.id.switch_camera:
|
case R.id.switch_camera:
|
||||||
int id = LinphoneManager.getLc().getVideoDevice();
|
int id = LinphoneManager.getLc().getVideoDevice();
|
||||||
id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length;
|
id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
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
|
||||||
if (mVideoCaptureViewReady != null)
|
// window
|
||||||
LinphoneManager.getLc().setPreviewWindow(mVideoCaptureViewReady);
|
if (mVideoCaptureViewReady != null)
|
||||||
break;
|
LinphoneManager.getLc()
|
||||||
case R.id.conf_simple_pause:
|
.setPreviewWindow(mVideoCaptureViewReady);
|
||||||
finish();
|
break;
|
||||||
LinphoneActivity.instance().startIncallActivity();
|
case R.id.conf_simple_pause:
|
||||||
LinphoneManager.getLc().pauseCall(videoCall);
|
finish();
|
||||||
break;
|
LinphoneActivity.instance().startIncallActivity();
|
||||||
case R.id.conf_simple_video:
|
LinphoneManager.getLc().pauseCall(videoCall);
|
||||||
LinphoneCallParams params = videoCall.getCurrentParamsCopy();
|
break;
|
||||||
params.setVideoEnabled(false);
|
case R.id.conf_simple_video:
|
||||||
LinphoneManager.getLc().updateCall(videoCall, params);
|
LinphoneCallParams params = videoCall.getCurrentParamsCopy();
|
||||||
break;
|
params.setVideoEnabled(false);
|
||||||
case R.id.addCall:
|
LinphoneManager.getLc().updateCall(videoCall, params);
|
||||||
finish();
|
break;
|
||||||
break;
|
case R.id.addCall:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dialog onCreateDialog(final int id) {
|
protected Dialog onCreateDialog(final int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case numpadDialogId:
|
case numpadDialogId:
|
||||||
Numpad numpad = new Numpad(this, true);
|
Numpad numpad = new Numpad(this, true);
|
||||||
return new AlertDialog.Builder(this).setView(numpad)
|
return new AlertDialog.Builder(this)
|
||||||
.setPositiveButton(R.string.close_button_text, new
|
.setView(numpad)
|
||||||
DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.close_button_text,
|
||||||
public void onClick(DialogInterface dialog, int whichButton)
|
new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog,
|
||||||
dismissDialog(id);
|
int whichButton) {
|
||||||
}
|
dismissDialog(id);
|
||||||
})
|
}
|
||||||
.create();
|
}).create();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("unkown dialog id " + id);
|
throw new IllegalArgumentException("unkown dialog id " + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void terminateCurrentCallOrConferenceOrAll() {
|
private void terminateCurrentCallOrConferenceOrAll() {
|
||||||
LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall();
|
LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall();
|
||||||
if (currentCall != null) {
|
if (currentCall != null) {
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.linphone.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
|
@ -542,9 +540,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
terminateAllCalls(nativePtr);
|
terminateAllCalls(nativePtr);
|
||||||
}
|
}
|
||||||
private native Object getCall(long nativePtr, int position);
|
private native Object getCall(long nativePtr, int position);
|
||||||
@SuppressWarnings("unchecked") public synchronized List getCalls() {
|
@SuppressWarnings("unchecked") public synchronized Vector getCalls() {
|
||||||
int size = getCallsNb(nativePtr);
|
int size = getCallsNb(nativePtr);
|
||||||
List<LinphoneCall> calls = new ArrayList<LinphoneCall>(size);
|
Vector<LinphoneCall> calls = new Vector<LinphoneCall>(size);
|
||||||
for (int i=0; i < size; i++) {
|
for (int i=0; i < size; i++) {
|
||||||
calls.add((LinphoneCall)getCall(nativePtr, i));
|
calls.add((LinphoneCall)getCall(nativePtr, i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c0c9ebc214434556b50db8023e172048cf7a9866
|
Subproject commit 53d5f0c2bf8a5fbbfb04ce4126db81ff3da38916
|
Loading…
Reference in a new issue