add video call activity

still to be debugged
This commit is contained in:
Jehan Monnier 2010-11-12 09:01:59 +01:00
parent df4852cf66
commit 597059ff45
12 changed files with 76 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_width="fill_parent">
android:layout_height="wrap_content"> <SurfaceView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/video_surface"></SurfaceView>
<SurfaceView android:id="@+id/SurfaceView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></SurfaceView>
</LinearLayout> </LinearLayout>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_video_enable">Enable video</string>
<string name="pref_video_enable_key">pref_escape_plus_key</string>
<string name="pref_escape_plus">Replace + by 00</string> <string name="pref_escape_plus">Replace + by 00</string>
<string name="pref_escape_plus_key">pref_escape_plus_key</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> <string name="pref_ilbc_summary">iLBC might be unavailable depending on ARM processor and Android OS version.</string>

View file

@ -35,6 +35,7 @@
<CheckBoxPreference android:key="@string/pref_video_enable_key" android:title="@string/pref_video_enable"></CheckBoxPreference>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -33,6 +33,7 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Build; import android.os.Build;
@ -99,7 +100,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
static String PREF_CHECK_CONFIG = "pref_check_config"; static String PREF_CHECK_CONFIG = "pref_check_config";
private static String CURRENT_ADDRESS = "org.linphone.current-address"; private static String CURRENT_ADDRESS = "org.linphone.current-address";
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
static int VIDEO_VIEW_ACTIVITY = 100;
/** /**
* *
* @return null if not ready yet * @return null if not ready yet
@ -463,6 +464,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
routeAudioToReceiver(); routeAudioToReceiver();
} }
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
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);
}
} }
private void exitCallMode() { private void exitCallMode() {
mCallControlRow.setVisibility(View.VISIBLE); mCallControlRow.setVisibility(View.VISIBLE);
@ -475,6 +483,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mMute.setChecked(true); mMute.setChecked(true);
mSpeaker.setChecked(false); mSpeaker.setChecked(false);
mDecline.setEnabled(false); mDecline.setEnabled(false);
if (LinphoneService.instance().getLinphoneCore().isVideoEnabled()) {
finishActivity(VIDEO_VIEW_ACTIVITY);
}
if (mWakeLock.isHeld())mWakeLock.release(); if (mWakeLock.isHeld())mWakeLock.release();
} }
private void routeAudioToSpeaker() { private void routeAudioToSpeaker() {

View file

@ -315,6 +315,15 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
throw new LinphoneConfigException(getString(R.string.wrong_settings),e); throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
} }
boolean isVideoEnabled = mPref.getBoolean(getString(R.string.pref_video_enable_key),false);
if (isVideoEnabled) {
try {
System.loadLibrary("msandroiddisplay");
} catch (Throwable e) {
Log.e(TAG, "cannot load video plugin", e);
}
}
mLinphoneCore.enableVideo(isVideoEnabled, isVideoEnabled);
//1 read proxy config from preferences //1 read proxy config from preferences
String lUserName = mPref.getString(getString(R.string.pref_username_key), null); String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
if (lUserName == null || lUserName.length()==0) { if (lUserName == null || lUserName.length()==0) {

View file

@ -0,0 +1,35 @@
/*
VideoCallActivity.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;
import org.linphone.core.Object;
import android.app.Activity;
import android.os.Bundle;
import android.view.SurfaceView;
public class VideoCallActivity extends Activity {
SurfaceView mVideoView;
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.videocall);
mVideoView = (SurfaceView) findViewById(R.id.video_surface);
LinphoneService.instance().getLinphoneCore().setVideoWindow((Object) mVideoView) ;
}
}

View file

@ -9,7 +9,7 @@ import android.view.SurfaceView;
import android.view.Surface.OutOfResourcesException; import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceHolder.Callback; import android.view.SurfaceHolder.Callback;
public class AndroidVideoWindowImpl implements VideoWindow { public class AndroidVideoWindowImpl implements Object {
private Bitmap mBitmap; private Bitmap mBitmap;
private SurfaceView mView; private SurfaceView mView;
private Surface mSurface; private Surface mSurface;

View file

@ -22,6 +22,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Vector; import java.util.Vector;
import android.view.SurfaceView;
class LinphoneCoreImpl implements LinphoneCore { class LinphoneCoreImpl implements LinphoneCore {
@ -71,6 +73,9 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void addFriend(long nativePtr,long friend); private native void addFriend(long nativePtr,long friend);
private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status);
private native long createChatRoom(long nativePtr,String to); private native long createChatRoom(long nativePtr,String to);
private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled);
private native boolean isVideoEnabled(long nativePtr);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener; mListener=listener;
@ -296,10 +301,10 @@ class LinphoneCoreImpl implements LinphoneCore {
public LinphoneChatRoom createChatRoom(String to) { public LinphoneChatRoom createChatRoom(String to) {
return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to));
} }
public void setPreviewWindow(VideoWindow w) { public void setPreviewWindow(Object w) {
if (mPreviewWindow!=null) if (mPreviewWindow!=null)
mPreviewWindow.setListener(null); mPreviewWindow.setListener(null);
mPreviewWindow=(AndroidVideoWindowImpl)w; mPreviewWindow=new AndroidVideoWindowImpl((SurfaceView)w);
mPreviewWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ mPreviewWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){
public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) {
setPreviewWindowId(nativePtr,null); setPreviewWindowId(nativePtr,null);
@ -310,7 +315,7 @@ class LinphoneCoreImpl implements LinphoneCore {
} }
}); });
} }
public void setVideoWindow(VideoWindow w) { public void setVideoWindow(Object w) {
if (mVideoWindow!=null) if (mVideoWindow!=null)
mVideoWindow.setListener(null); mVideoWindow.setListener(null);
mVideoWindow=(AndroidVideoWindowImpl)w; mVideoWindow=(AndroidVideoWindowImpl)w;
@ -324,5 +329,11 @@ class LinphoneCoreImpl implements LinphoneCore {
} }
}); });
} }
public void enableVideo(boolean vcap_enabled, boolean display_enabled) {
enableVideo(nativePtr,vcap_enabled, display_enabled);
}
public boolean isVideoEnabled() {
return isVideoEnabled(nativePtr);
}
} }