test outgoing calls

This commit is contained in:
Jehan Monnier 2010-01-27 17:49:01 +01:00
parent 63a6a2715d
commit a5a1673ff9
5 changed files with 63 additions and 40 deletions

View file

@ -22,9 +22,11 @@ video_jitt_comp=60
nortp_timeout=30
[sound]
playback_dev_id=AU: Audio Unit
ringer_dev_id=AU: Audio Unit
capture_dev_id=AU: Audio Unit
playback_dev_id=ANDROID SND: Android Sound card
ringer_dev_id=ANDROID SND: Android Sound card
capture_dev_id=ANDROID SND: Android Sound card
remote_ring=/data/data/org.linphone/files/ringback.wav
local_ring=/data/data/org.linphone/files/oldphone_mono.wav
[audio_codec_0]
mime=speex
@ -39,7 +41,7 @@ enabled=0
[audio_codec_2]
mime=speex
rate=8000
enabled=0
enabled=1
[audio_codec_3]
mime=GSM
@ -54,7 +56,7 @@ enabled=0
[audio_codec_5]
mime=GSM
rate=8000
enabled=0
enabled=1
[audio_codec_6]
mime=PCMU

View file

@ -26,10 +26,11 @@ public class Linphone extends Activity implements LinphoneCoreListener {
/** Called when the activity is first created. */
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
private static String LINPHONE_RC = "/data/data/org.linphone/files/.linphonerc";
private static String RINGBACK_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
private static String RING_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
private static String RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
private LinphoneCore mLinphoneCore;
private LinphoneProxyConfig mProxyConfig;
private LinphoneProxyConfig mProxyConfig;
private LinphoneAuthInfo mAuthInfo;
Timer mTimer = new Timer("Linphone scheduler");
@ -62,19 +63,23 @@ public class Linphone extends Activity implements LinphoneCoreListener {
};
mTimer.scheduleAtFixedRate(lTask, 0, 100);
} catch (Exception e) {
Log.e(TAG,"Cannot start linphone",e);
}
}
public void copyAssetsFromPackage() throws IOException {
copyIfNotExist(R.raw.oldphone_mono,RINGBACK_SND);
copyIfNotExist(R.raw.oldphone_mono,RING_SND);
copyIfNotExist(R.raw.ringback,RINGBACK_SND);
copyIfNotExist(R.raw.linphonerc,LINPHONE_FACTORY_RC);
}
private void copyIfNotExist(int ressourceId,String target) throws IOException {
File lFileToCopy = new File(target);
if (!lFileToCopy.exists()) {
FileOutputStream lOutputStream = openFileOutput (lFileToCopy.getName(), 0);
FileOutputStream lOutputStream = openFileOutput (lFileToCopy.getName(), 0);
InputStream lInputStream = getResources().openRawResource(ressourceId);
int readByte;
byte[] buff = new byte[8048];
@ -100,16 +105,22 @@ public class Linphone extends Activity implements LinphoneCoreListener {
}
public void displayStatus(LinphoneCore lc, String message) {
// TODO Auto-generated method stub
Log.i(TAG, message);
}
public void displayWarning(LinphoneCore lc, String message) {
// TODO Auto-generated method stub
}
public void generalState(LinphoneCore lc, GeneralState state) {
// TODO Auto-generated method stub
public void generalState(LinphoneCore lc, LinphoneCore.GeneralState state) {
Log.i(TAG, "new state ["+state+"]");
switch(state) {
case GSTATE_REG_OK: {
mLinphoneCore.invite("simon.morlat");
}
}
}
public void inviteReceived(LinphoneCore lc, String from) {
// TODO Auto-generated method stub

View file

@ -24,30 +24,37 @@ public interface LinphoneCore {
/*
* linphone core states
*/
interface GeneralState {
public enum GeneralState {
/* states for GSTATE_GROUP_POWER */
static int GSTATE_POWER_OFF =0; /* initial state */
static int GSTATE_POWER_STARTUP=1;
static int GSTATE_POWER_ON=2;
static int GSTATE_POWER_SHUTDOWN=3;
GSTATE_POWER_OFF(0), /* initial state */
GSTATE_POWER_STARTUP(1),
GSTATE_POWER_ON(2),
GSTATE_POWER_SHUTDOWN(3),
/* states for GSTATE_GROUP_REG */
static int GSTATE_REG_NONE=10; /* initial state */
static int GSTATE_REG_OK=11;
static int GSTATE_REG_FAILED=12;
GSTATE_REG_NONE(10), /* initial state */
GSTATE_REG_OK(11),
GSTATE_REG_FAILED(12),
/* states for GSTATE_GROUP_CALL */
static int GSTATE_CALL_IDLE=20; /* initial state */
static int GSTATE_CALL_OUT_INVITE=21;
static int GSTATE_CALL_OUT_CONNECTED=22;
static int GSTATE_CALL_IN_INVITE=23;
static int GSTATE_CALL_IN_CONNECTED=24;
static int GSTATE_CALL_END=25;
static int GSTATE_CALL_ERROR=26;
static int GSTATE_INVALID=27;
/**
* get new state {@link: }
*/
public int getNewState();
}
GSTATE_CALL_IDLE(20), /* initial state */
GSTATE_CALL_OUT_INVITE(21),
GSTATE_CALL_OUT_CONNECTED(22),
GSTATE_CALL_IN_INVITE(23),
GSTATE_CALL_IN_CONNECTED(24),
GSTATE_CALL_END(25),
GSTATE_CALL_ERROR(26),
GSTATE_INVALID(27);
private final int mValue;
GeneralState(int value) {
mValue = value;
}
public static GeneralState fromInt(int value) {
for (GeneralState state: GeneralState.values()) {
if (state.mValue == value) return state;
}
throw new RuntimeException("sate not found ["+value+"]");
}
}
/**
@ -69,7 +76,7 @@ public interface LinphoneCore {
void addAuthInfo(LinphoneAuthInfo info);
public void invite(String url);
public void invite(String uri);
public void iterate();
}

View file

@ -31,6 +31,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr);
private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
private native void invite(long nativePtr,String uri);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener;
nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata);
@ -48,8 +49,8 @@ class LinphoneCoreImpl implements LinphoneCore {
throw new RuntimeException("not implemenetd yet");
}
public void invite(String url) {
throw new RuntimeException("not implemenetd yet");
public void invite(String uri) {
invite(nativePtr,uri);
}
public void iterate() {

View file

@ -36,14 +36,16 @@ public interface LinphoneCoreListener {
public void authInfoRequested(LinphoneCore lc,String realm,String username);
/**< Callback that notifies various events with human readable text.
* @return */
public void displayStatus(LinphoneCore lc,String message);;
public void displayStatus(LinphoneCore lc,String message);
/**< Callback to display a message to the user
* @return */
public void displayMessage(LinphoneCore lc,String message);
/** Callback to display a warning to the user
* @return */
public void displayWarning(LinphoneCore lc,String message);
/**< State notification callback
* @return */
/** State notification callback
* @param state LinphoneCore.GeneralState
* @return
* */
public void generalState(LinphoneCore lc,LinphoneCore.GeneralState state);
}