add codec management

start OUTGOING Call intent management
This commit is contained in:
Jehan Monnier 2010-06-18 11:01:12 +02:00
parent 5eb58f95f1
commit e41ca841fa
17 changed files with 211 additions and 16 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,3 @@
[submodule "msandroid"]
path = submodules/msandroid
url = git://git.linphone.org/msandroid.git
[submodule "linphone"]
path = submodules/linphone
url = git://git.savannah.nongnu.org/linphone.git

View file

@ -12,11 +12,8 @@ include $(root-dir)/submodules/linphone/oRTP/build/android/Android.mk
include $(root-dir)/submodules/linphone/mediastreamer2/build/android/Android.mk
include $(root-dir)/submodules/msandroid/Android.mk
include $(root-dir)/submodules/msilbc/Android.mk
include $(root-dir)/submodules/linphone/build/android/Android.mk

View file

@ -47,9 +47,14 @@
</activity>
<service android:name=".LinphoneService">
</service>
<receiver android:name="NetworkManager"><intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action>
</intent-filter>
</receiver>
<receiver android:name="NetworkManager">
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action>
</intent-filter>
</receiver>
<receiver android:name="OutgoingCallReceiver" >
<intent-filter android:priority="0"><action android:name="android.intent.action.NEW_OUTGOING_CALL"></action>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
@ -58,5 +63,6 @@
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
</manifest>

View file

@ -1,4 +1,4 @@
APP_PROJECT_PATH := $(call my-dir)/
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 libmsandroidsnd liblinphone
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 liblinphone
APP_BUILD_SCRIPT:=$(call my-dir)/Android.mk
APP_PLATFORM := android-3

Binary file not shown.

View file

@ -6,6 +6,7 @@ mtu=0
[sip]
sip_port=5060
sip_random_port=1
guess_hostname=1
contact=sip:unknown@unknown-host
inc_timeout=15

View file

@ -1,5 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_enable_outbound_proxy">Outbound proxy</string>
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>
<string name="pref_codec_pcma">pcma</string>
<string name="pref_codec_pcma_key">pref_codec_pcma_key</string>
<string name="pref_codec_pcmu">pcmu</string>
<string name="pref_codec_pcmu_key">pref_codec_pcmu_key</string>
<string name="pref_codec_gsm">gsm</string>
<string name="pref_codec_gsm_key">pref_codec_gsm_key</string>
<string name="pref_codec_ilbc">ilbc</string>
<string name="pref_codec_ilbc_key">pref_codec_ilbc_key</string>
<string name="pref_codec_speex8">speex 8 Khz</string>
<string name="pref_codec_speex8_key">pref_codec_speex8_key</string>
<string name="pref_codec_speex16">speex 16 Khz</string>
<string name="pref_codec_speex16_key">pref_codec_speex16_key</string>
<string name="pref_codecs">Codecs</string>
<string name="pref_codecs_key">pref_codecs_key</string>
<string name="place_call_chooser">Place a call</string>
<string name="pref_debug">Debug</string>
<string name="about_text">Linphone %s SIP (rfc 3261) compatible phone under GNU Public License V2\n http://www.linphone.org\n© 2010 Belledonne Communications</string>
<string name="menu_about">About</string>

View file

@ -9,12 +9,29 @@
android:key="@string/pref_domain_key"></EditTextPreference>
<EditTextPreference android:title="@string/pref_proxy"
android:key="@string/pref_proxy_key"></EditTextPreference>
</PreferenceCategory>
<CheckBoxPreference android:enabled="true" android:selectable="false" android:key="@string/pref_enable_outbound_proxy_key" android:title="@string/pref_enable_outbound_proxy"></CheckBoxPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_advanced">
<PreferenceScreen android:title="@string/pref_codecs" android:key="@string/pref_codecs_key">
<CheckBoxPreference android:key="@string/pref_codec_speex16_key"
android:title="@string/pref_codec_speex16" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_speex8_key"
android:title="@string/pref_codec_speex8" android:defaultValue="true"></CheckBoxPreference>
<!-- CheckBoxPreference android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc" android:enabled="true"></CheckBoxPreference-->
<CheckBoxPreference android:key="@string/pref_codec_gsm_key"
android:title="@string/pref_codec_gsm" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_pcmu_key"
android:title="@string/pref_codec_pcmu" android:defaultValue="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_codec_pcma_key"
android:title="@string/pref_codec_pcma" android:defaultValue="true"></CheckBoxPreference>
</PreferenceScreen>
<EditTextPreference android:title="@string/pref_prefix"
android:key="@string/pref_prefix_key"></EditTextPreference>
<CheckBoxPreference android:key="@string/pref_debug_key" android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_debug_key"
android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -122,6 +122,26 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.getData() != null) {
//incoming call requested
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.place_call_chooser))
.setCancelable(false)
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
;
}
}).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
builder.create().show();
}
}
@Override
protected void onPause() {
// TODO Auto-generated method stub

View file

@ -32,6 +32,7 @@ import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.core.LinphoneCore.GeneralState;
@ -306,7 +307,40 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
}
//escape +
lDefaultProxyConfig.setDialEscapePlus(true);
//outbound proxy
if (mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key), false)) {
lDefaultProxyConfig.setRoute(lProxy);
}
}
//codec config
PayloadType lPt = mLinphoneCore.findPayloadType("speex", 16000);
if (lPt !=null) {
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex16_key),false);
mLinphoneCore.enablePayloadType(lPt, enable);
}
lPt = mLinphoneCore.findPayloadType("speex", 8000);
if (lPt !=null) {
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex8_key),false);
mLinphoneCore.enablePayloadType(lPt, enable);
}
lPt = mLinphoneCore.findPayloadType("GSM", 8000);
if (lPt !=null) {
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_gsm_key),false);
mLinphoneCore.enablePayloadType(lPt, enable);
}
lPt = mLinphoneCore.findPayloadType("PCMU", 8000);
if (lPt !=null) {
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcmu_key),false);
mLinphoneCore.enablePayloadType(lPt, enable);
}
lPt = mLinphoneCore.findPayloadType("PCMA", 8000);
if (lPt !=null) {
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcma_key),false);
mLinphoneCore.enablePayloadType(lPt, enable);
}
//init network state
ConnectivityManager lConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo lInfo = lConnectivityManager.getActiveNetworkInfo();

View file

@ -0,0 +1,40 @@
/*
OutgoingCallReceiver.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 android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String to = intent.getStringExtra("android.intent.extra.PHONE_NUMBER");
setResult(Activity.RESULT_OK,null, null);
Intent lIntent = new Intent();
lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
lIntent.setClass(context, LinphoneActivity.class);
lIntent.setData(Uri.parse("tel://"+to));
context.startActivity(lIntent);
}
}

View file

@ -62,4 +62,10 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
@Override
public native void setDebugMode(boolean enable);
@Override
public void setLogHandler(LinphoneLogHandler handler) {
//not implemented on Android
}
}

View file

@ -56,7 +56,8 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void sendDtmf(long nativePtr,char dtmf);
private native void clearCallLogs(long nativePtr);
private native boolean isMicMuted(long nativePtr);
private native long findPayloadType(long nativePtr, String mime, int clockRate);
private native int enablePayloadType(long nativePtr, long payloadType, boolean enable);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener;
@ -190,4 +191,19 @@ class LinphoneCoreImpl implements LinphoneCore {
public boolean isMicMuted() {
return isMicMuted(nativePtr);
}
public PayloadType findPayloadType(String mime, int clockRate) {
long playLoadType = findPayloadType(nativePtr, mime, clockRate);
if (playLoadType == 0) {
return null;
} else {
return new PayloadTypeImpl(playLoadType);
}
}
public void enablePayloadType(PayloadType pt, boolean enable)
throws LinphoneCoreException {
if (enablePayloadType(nativePtr,((PayloadTypeImpl)pt).nativePtr,enable) != 0) {
throw new LinphoneCoreException("cannot enable payload type ["+pt+"]");
}
}
}

View file

@ -69,6 +69,9 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
private native void setDialEscapePlus(long ptr, boolean value);
private native String getRoute(long ptr);
private native int setRoute(long ptr,String uri);
public void enableRegister(boolean value) {
enableRegister(nativePtr,value);
}
@ -114,4 +117,12 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
public boolean registerEnabled() {
return isRegisterEnabled(nativePtr);
}
public String getRoute() {
return getRoute(nativePtr);
}
public void setRoute(String routeUri) throws LinphoneCoreException {
if (setRoute(nativePtr, routeUri) != 0) {
throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
}
}
}

View file

@ -0,0 +1,34 @@
/*
PayloadTypeImpl.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;
class PayloadTypeImpl implements PayloadType {
protected final long nativePtr;
private native String toString(long ptr);
protected PayloadTypeImpl(long aNativePtr) {
nativePtr = aNativePtr;
}
public String toString() {
return toString(nativePtr);
}
}

@ -1 +1 @@
Subproject commit 7609ab2a4a4b9c8a7ddf3ac0acf9e43dc23c2046
Subproject commit a17cdb896f3df16b9715ab1a0bc57992857dfa24

@ -1 +0,0 @@
Subproject commit 3dd9bd6aa57641e16db7fb7503d4cd039dfb3c70