From cb424561404f671fb4642fac21189859d516d5f8 Mon Sep 17 00:00:00 2001 From: jehan Date: Mon, 18 Jan 2010 18:04:25 +0100 Subject: [PATCH 001/288] initial commit --- LinphoneAuthInfo.java | 23 ++++++++++++ LinphoneCore.java | 68 ++++++++++++++++++++++++++++++++++++ LinphoneCoreException.java | 42 ++++++++++++++++++++++ LinphoneCoreFactory.java | 43 +++++++++++++++++++++++ LinphoneCoreImpl.java | 63 +++++++++++++++++++++++++++++++++ LinphoneCoreListener.java | 49 ++++++++++++++++++++++++++ LinphoneProxyConfig.java | 25 +++++++++++++ LinphoneProxyConfigImpl.java | 54 ++++++++++++++++++++++++++++ 8 files changed, 367 insertions(+) create mode 100644 LinphoneAuthInfo.java create mode 100644 LinphoneCore.java create mode 100644 LinphoneCoreException.java create mode 100644 LinphoneCoreFactory.java create mode 100644 LinphoneCoreImpl.java create mode 100644 LinphoneCoreListener.java create mode 100644 LinphoneProxyConfig.java create mode 100644 LinphoneProxyConfigImpl.java diff --git a/LinphoneAuthInfo.java b/LinphoneAuthInfo.java new file mode 100644 index 000000000..0b8865f42 --- /dev/null +++ b/LinphoneAuthInfo.java @@ -0,0 +1,23 @@ +/* +LinphoneAuthInfo.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; + +public interface LinphoneAuthInfo { + +} diff --git a/LinphoneCore.java b/LinphoneCore.java new file mode 100644 index 000000000..f10cf0df3 --- /dev/null +++ b/LinphoneCore.java @@ -0,0 +1,68 @@ +/* +LinphoneCore.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; + +import java.io.File; +import java.net.URI; + +public interface LinphoneCore { + /* + * linphone core states + */ + interface 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; + /* 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; + /* 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(); +} + + + public LinphoneProxyConfig createProxyConfig(URI identity,URI proxy,URI route); + + public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); + + /** + * @return null if no default proxyconfig + */ + public LinphoneProxyConfig getDefaultProxyConfig(); + + void addAuthInfo(LinphoneAuthInfo info); + + public void invite(String url); + + public void iterate(); +} diff --git a/LinphoneCoreException.java b/LinphoneCoreException.java new file mode 100644 index 000000000..069e114a0 --- /dev/null +++ b/LinphoneCoreException.java @@ -0,0 +1,42 @@ +/* +LinphoneCoreException.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; + +public class LinphoneCoreException extends Exception { + + public LinphoneCoreException() { + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(String detailMessage) { + super(detailMessage); + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(Throwable throwable) { + super(throwable); + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + // TODO Auto-generated constructor stub + } + +} diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java new file mode 100644 index 000000000..6a8c69493 --- /dev/null +++ b/LinphoneCoreFactory.java @@ -0,0 +1,43 @@ +/* +LinphoneCoreFactory.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; + +import java.io.File; + +public class LinphoneCoreFactory { + static { + System.loadLibrary("liblinphone"); + } + static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory(); + + public static LinphoneCoreFactory instance() { + + return theLinphoneCoreFactory; + } + public LinphoneAuthInfo createAuthInfo(String username,String password) { + throw new RuntimeException("Not Implemented yet"); + } + + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) { + throw new RuntimeException("Not Implemented yet"); + } + + + +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java new file mode 100644 index 000000000..958a66b9a --- /dev/null +++ b/LinphoneCoreImpl.java @@ -0,0 +1,63 @@ +/* +LinphoneCoreImpl.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; + +import java.io.File; +import java.io.IOException; +import java.net.URI; + +public class LinphoneCoreImpl implements LinphoneCore { + + private final LinphoneCoreListener mListener; + private final long nativePtr; + private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); + private native void iterate(long nativePtr); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { + mListener=listener; + nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); + } + + public void addAuthInfo(LinphoneAuthInfo info) { + // TODO Auto-generated method stub + + } + + public LinphoneProxyConfig createProxyConfig(URI identity, URI proxy,URI route) { + return new LinphoneProxyConfigImpl(identity, proxy, route); + } + + public LinphoneProxyConfig getDefaultProxyConfig() { + // TODO Auto-generated method stub + return null; + } + + public void invite(String url) { + // TODO Auto-generated method stub + } + + public void iterate() { + iterate(nativePtr); + } + + public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { + // TODO Auto-generated method stub + + } + +} diff --git a/LinphoneCoreListener.java b/LinphoneCoreListener.java new file mode 100644 index 000000000..e8a0279f3 --- /dev/null +++ b/LinphoneCoreListener.java @@ -0,0 +1,49 @@ +/* +LinphoneCoreListener.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; + + + +public interface LinphoneCoreListener { + + /**< Notifies the application that it should show up + * @return */ + public void show(LinphoneCore lc); + /**< Notifies incoming calls + * @return */ + public void inviteReceived(LinphoneCore lc,String from); + /**< Notify calls terminated by far end + * @return */ + public void byeReceived(LinphoneCore lc,String from); + /**< Ask the application some authentication information + * @return */ + 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);; + /**< 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 */ + public void generalState(LinphoneCore lc,LinphoneCore.GeneralState state); +} diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java new file mode 100644 index 000000000..fb8b68eb3 --- /dev/null +++ b/LinphoneProxyConfig.java @@ -0,0 +1,25 @@ +/* +LinphoneProxyConfig.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; + +public interface LinphoneProxyConfig { + + void enableRegister(boolean value); + +} diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java new file mode 100644 index 000000000..84e470045 --- /dev/null +++ b/LinphoneProxyConfigImpl.java @@ -0,0 +1,54 @@ +/* +LinphoneProxyConfigImpl.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; + +import java.net.URI; + + +public class LinphoneProxyConfigImpl implements LinphoneProxyConfig { + + final long nativePtr; + protected LinphoneProxyConfigImpl(URI identity,URI proxy,URI route) { + nativePtr = createAndAdd(); + edit(nativePtr); + setIdentity(nativePtr,identity.getScheme()+":"+identity.getHost()); + done(nativePtr); + } + + protected void finalize() throws Throwable { + deleteNative(nativePtr); + } + private native long createAndAdd(); + private native long deleteNative(long ptr); + + private native void edit(long ptr); + private native void done(long ptr); + + private native void setIdentity(long ptr,String identity); + /*private native void setProxy(long ptr,String identity);*/ + + private native void enableRegister(long ptr,boolean value); + + public void enableRegister(boolean value) { + edit(nativePtr); + enableRegister(nativePtr,value); + done(nativePtr); + } + +} From 135fac65cf96ecb9325bcb4c74a3890ab0059885 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 21 Jan 2010 17:31:28 +0100 Subject: [PATCH 002/288] first succesfull register --- LinphoneAuthInfo.java | 2 ++ LinphoneAuthInfoImpl.java | 13 +++++++++++++ LinphoneCore.java | 13 ++++++++++--- LinphoneCoreException.java | 1 + LinphoneCoreFactory.java | 9 +++++---- LinphoneCoreImpl.java | 28 +++++++++++++++++----------- LinphoneProxyConfig.java | 1 + LinphoneProxyConfigImpl.java | 33 +++++++++++++++++---------------- 8 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 LinphoneAuthInfoImpl.java diff --git a/LinphoneAuthInfo.java b/LinphoneAuthInfo.java index 0b8865f42..2a5dbaf2d 100644 --- a/LinphoneAuthInfo.java +++ b/LinphoneAuthInfo.java @@ -21,3 +21,5 @@ package org.linphone.core; public interface LinphoneAuthInfo { } + + diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java new file mode 100644 index 000000000..15a064ec9 --- /dev/null +++ b/LinphoneAuthInfoImpl.java @@ -0,0 +1,13 @@ +package org.linphone.core; + +class LinphoneAuthInfoImpl implements LinphoneAuthInfo { + protected final long nativePtr; + private native long newLinphoneAuthInfo(String username, String userid, String passwd, String ha1,String realm); + private native void delete(long ptr); + protected LinphoneAuthInfoImpl(String username,String password) { + nativePtr = newLinphoneAuthInfo(username,null,password,null,null); + } + protected void finalize() throws Throwable { + delete(nativePtr); + } +} diff --git a/LinphoneCore.java b/LinphoneCore.java index f10cf0df3..8dccff830 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -18,8 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import java.io.File; -import java.net.URI; + public interface LinphoneCore { /* @@ -51,8 +50,16 @@ public interface LinphoneCore { } - public LinphoneProxyConfig createProxyConfig(URI identity,URI proxy,URI route); + /** + * @param identity sip uri sip:jehan@linphone.org + * @param proxy sip uri (sip:linphone.org) + * @param route optionnal sip usi (sip:linphone.org) + * @return + */ + public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route) throws LinphoneCoreException; + public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException; + public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); /** diff --git a/LinphoneCoreException.java b/LinphoneCoreException.java index 069e114a0..abec2943e 100644 --- a/LinphoneCoreException.java +++ b/LinphoneCoreException.java @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +@SuppressWarnings("serial") public class LinphoneCoreException extends Exception { public LinphoneCoreException() { diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java index 6a8c69493..265ba65dd 100644 --- a/LinphoneCoreFactory.java +++ b/LinphoneCoreFactory.java @@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import java.io.File; +import java.io.IOException; public class LinphoneCoreFactory { static { - System.loadLibrary("liblinphone"); + System.loadLibrary("linphone"); } static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory(); @@ -31,11 +32,11 @@ public class LinphoneCoreFactory { return theLinphoneCoreFactory; } public LinphoneAuthInfo createAuthInfo(String username,String password) { - throw new RuntimeException("Not Implemented yet"); + return new LinphoneAuthInfoImpl(username,password) ; } - public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) { - throw new RuntimeException("Not Implemented yet"); + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { + return new LinphoneCoreImpl(listener,userConfig,factoryConfig,userdata); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 958a66b9a..f922cef08 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,35 +20,36 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import java.net.URI; -public class LinphoneCoreImpl implements LinphoneCore { + +class LinphoneCoreImpl implements LinphoneCore { private final LinphoneCoreListener mListener; private final long nativePtr; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); + private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr); + private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr); + private native void addAuthInfo(long nativePtr,long authInfoNativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); } public void addAuthInfo(LinphoneAuthInfo info) { - // TODO Auto-generated method stub - + addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); } - public LinphoneProxyConfig createProxyConfig(URI identity, URI proxy,URI route) { + public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route) throws LinphoneCoreException { return new LinphoneProxyConfigImpl(identity, proxy, route); } public LinphoneProxyConfig getDefaultProxyConfig() { - // TODO Auto-generated method stub - return null; + throw new RuntimeException("not implemenetd yet"); } public void invite(String url) { - // TODO Auto-generated method stub + throw new RuntimeException("not implemenetd yet"); } public void iterate() { @@ -56,8 +57,13 @@ public class LinphoneCoreImpl implements LinphoneCore { } public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { - // TODO Auto-generated method stub - + setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr); } - + public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ + if (addProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { + throw new LinphoneCoreException("bad proxy config"); + } + } + + } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index fb8b68eb3..b4b5fd8b8 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -22,4 +22,5 @@ public interface LinphoneProxyConfig { void enableRegister(boolean value); + } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 84e470045..0fa1a85b7 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -18,37 +18,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import java.net.URI; -public class LinphoneProxyConfigImpl implements LinphoneProxyConfig { - final long nativePtr; - protected LinphoneProxyConfigImpl(URI identity,URI proxy,URI route) { - nativePtr = createAndAdd(); - edit(nativePtr); - setIdentity(nativePtr,identity.getScheme()+":"+identity.getHost()); - done(nativePtr); +class LinphoneProxyConfigImpl implements LinphoneProxyConfig { + + protected final long nativePtr; + protected LinphoneProxyConfigImpl(String identity,String proxy,String route) throws LinphoneCoreException { + nativePtr = newLinphoneProxyConfig(); + setIdentity(nativePtr,identity); + if (setProxy(nativePtr,proxy)!=0) { + throw new LinphoneCoreException("Bad proxy address ["+proxy+"]"); + } } protected void finalize() throws Throwable { - deleteNative(nativePtr); + delete(nativePtr); } - private native long createAndAdd(); - private native long deleteNative(long ptr); + private native long newLinphoneProxyConfig(); + private native void delete(long ptr); - private native void edit(long ptr); - private native void done(long ptr); + //private native void edit(long ptr); + //private native void done(long ptr); private native void setIdentity(long ptr,String identity); - /*private native void setProxy(long ptr,String identity);*/ + private native int setProxy(long ptr,String proxy); private native void enableRegister(long ptr,boolean value); public void enableRegister(boolean value) { - edit(nativePtr); + //edit(nativePtr); enableRegister(nativePtr,value); - done(nativePtr); + //done(nativePtr); } } From b99a6532195bdb0aa13826dcc0d12e9253a47b0a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 27 Jan 2010 17:49:01 +0100 Subject: [PATCH 003/288] test outgoing calls --- LinphoneCore.java | 51 ++++++++++++++++++++++----------------- LinphoneCoreImpl.java | 5 ++-- LinphoneCoreListener.java | 8 +++--- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 8dccff830..8df865468 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -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(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f922cef08..444091ac8 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -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() { diff --git a/LinphoneCoreListener.java b/LinphoneCoreListener.java index e8a0279f3..f48f8a9eb 100644 --- a/LinphoneCoreListener.java +++ b/LinphoneCoreListener.java @@ -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); } From f91275deffac99a67ba5969b433fcaa6219b117f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 5 Feb 2010 17:49:43 +0100 Subject: [PATCH 004/288] -phone view -settings --- LinphoneCore.java | 16 ++++++++++--- LinphoneCoreImpl.java | 23 +++++++++++++++--- LinphoneProxyConfig.java | 26 +++++++++++++++++++- LinphoneProxyConfigImpl.java | 46 +++++++++++++++++++++++++++--------- 4 files changed, 93 insertions(+), 18 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 8df865468..4e608452c 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -61,18 +61,28 @@ public interface LinphoneCore { * @param identity sip uri sip:jehan@linphone.org * @param proxy sip uri (sip:linphone.org) * @param route optionnal sip usi (sip:linphone.org) + * @param register should be initiated * @return */ - public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route) throws LinphoneCoreException; + public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route,boolean enableRegister) throws LinphoneCoreException; + /** + * clear all added proxy config + */ + public void clearProxyConfigs(); public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException; public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); /** - * @return null if no default proxyconfig + * @return null if no default proxy config */ - public LinphoneProxyConfig getDefaultProxyConfig(); + public LinphoneProxyConfig getDefaultProxyConfig() ; + + /** + * clear all the added auth info + */ + void clearAuthInfos(); void addAuthInfo(LinphoneAuthInfo info); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 444091ac8..2cc292911 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -28,8 +28,13 @@ class LinphoneCoreImpl implements LinphoneCore { private final long nativePtr; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); + private native long getDefaultProxyConfig(long nativePtr); + private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr); private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr); + private native void clearAuthInfos(long nativePtr); + + private native void clearProxyConfigs(long nativePtr); 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 { @@ -41,12 +46,17 @@ class LinphoneCoreImpl implements LinphoneCore { addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); } - public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route) throws LinphoneCoreException { - return new LinphoneProxyConfigImpl(identity, proxy, route); + public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException { + return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister); } public LinphoneProxyConfig getDefaultProxyConfig() { - throw new RuntimeException("not implemenetd yet"); + long lNativePtr = getDefaultProxyConfig(nativePtr); + if (lNativePtr!=0) { + return new LinphoneProxyConfigImpl(lNativePtr); + } else { + return null; + } } public void invite(String uri) { @@ -65,6 +75,13 @@ class LinphoneCoreImpl implements LinphoneCore { throw new LinphoneCoreException("bad proxy config"); } } + public void clearAuthInfos() { + clearAuthInfos(nativePtr); + + } + public void clearProxyConfigs() { + clearProxyConfigs(nativePtr); + } } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index b4b5fd8b8..17085de82 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -20,7 +20,31 @@ package org.linphone.core; public interface LinphoneProxyConfig { - void enableRegister(boolean value); + /** + * Unregister proxy config a enable edition + */ + public void edit(); + /** + * Validate proxy config changes. Start registration in case + */ + public void done(); + /** + * sip user made by sip:username@domain + */ + public void setIdentity(String identity) throws LinphoneCoreException; + /** + * Set proxy uri, like sip:linphone.org:5060 + * @param proxyUri + * @throws LinphoneCoreException + */ + public void setProxy(String proxyUri) throws LinphoneCoreException; + /** + * Enable register for this proxy config. + * Register message is issued after call to {@link #done()} + * @param value + * @throws LinphoneCoreException + */ + public void enableRegister(boolean value) throws LinphoneCoreException; } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 0fa1a85b7..f1de9707b 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -18,28 +18,37 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.Linphone; + +import android.util.Log; + class LinphoneProxyConfigImpl implements LinphoneProxyConfig { protected final long nativePtr; - protected LinphoneProxyConfigImpl(String identity,String proxy,String route) throws LinphoneCoreException { + boolean ownPtr = false; + protected LinphoneProxyConfigImpl(String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException { nativePtr = newLinphoneProxyConfig(); - setIdentity(nativePtr,identity); - if (setProxy(nativePtr,proxy)!=0) { - throw new LinphoneCoreException("Bad proxy address ["+proxy+"]"); - } + setIdentity(identity); + setProxy(proxy); + enableRegister(enableRegister); + ownPtr=true; + Log.w(Linphone.TAG, "route ["+route+"] not used yet"); + } + protected LinphoneProxyConfigImpl(long aNativePtr) { + nativePtr = aNativePtr; + ownPtr=false; } - protected void finalize() throws Throwable { - delete(nativePtr); + if (ownPtr) delete(nativePtr); } private native long newLinphoneProxyConfig(); private native void delete(long ptr); - //private native void edit(long ptr); - //private native void done(long ptr); + private native void edit(long ptr); + private native void done(long ptr); private native void setIdentity(long ptr,String identity); private native int setProxy(long ptr,String proxy); @@ -47,9 +56,24 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void enableRegister(long ptr,boolean value); public void enableRegister(boolean value) { - //edit(nativePtr); enableRegister(nativePtr,value); - //done(nativePtr); } + public void done() { + done(nativePtr); + } + + public void edit() { + edit(nativePtr); + } + + public void setIdentity(String identity) throws LinphoneCoreException { + setIdentity(nativePtr,identity); + } + + public void setProxy(String proxyUri) throws LinphoneCoreException { + if (setProxy(nativePtr,proxyUri)!=0) { + throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]"); + } + } } From 358f29c5ccc09ba6dfcc28ccd6a1c2b7efb3962a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 8 Feb 2010 18:36:16 +0100 Subject: [PATCH 005/288] start GUI binding --- LinphoneCore.java | 2 ++ LinphoneCoreImpl.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/LinphoneCore.java b/LinphoneCore.java index 4e608452c..8ae0effd3 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -88,5 +88,7 @@ public interface LinphoneCore { public void invite(String uri); + public void terminateCall(); + public void iterate(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 2cc292911..0e4956566 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -37,6 +37,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void clearProxyConfigs(long nativePtr); private native void addAuthInfo(long nativePtr,long authInfoNativePtr); private native void invite(long nativePtr,String uri); + private native void terminateCall(long nativePtr); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -82,6 +84,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void clearProxyConfigs() { clearProxyConfigs(nativePtr); } + public void terminateCall() { + terminateCall(nativePtr); + } } From 08ab87eaf8a928f9342261e935970e04b14f9d3c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Feb 2010 15:46:01 +0100 Subject: [PATCH 006/288] phone book integration --- LinphoneAddress.java | 37 ++++++++++++++++++++++ LinphoneAddressImpl.java | 61 ++++++++++++++++++++++++++++++++++++ LinphoneAuthInfoImpl.java | 18 +++++++++++ LinphoneCore.java | 5 +++ LinphoneCoreImpl.java | 9 ++++++ LinphoneProxyConfig.java | 8 +++-- LinphoneProxyConfigImpl.java | 5 +++ 7 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 LinphoneAddress.java create mode 100644 LinphoneAddressImpl.java diff --git a/LinphoneAddress.java b/LinphoneAddress.java new file mode 100644 index 000000000..d7ad7c4b0 --- /dev/null +++ b/LinphoneAddress.java @@ -0,0 +1,37 @@ +/* +LinphoneAddress.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; + +public interface LinphoneAddress { + /** + * Human display name + * @return null if not set + */ + public String getDisplayName(); + /** + * userinfo + * @return null if not set + */ + public String getUserName(); + /** + * + * @return null if not set + */ + public String getDomain(); +} diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java new file mode 100644 index 000000000..83176180e --- /dev/null +++ b/LinphoneAddressImpl.java @@ -0,0 +1,61 @@ +/* +LinphoneAddressImpl.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; + + + +public class LinphoneAddressImpl implements LinphoneAddress { + protected final long nativePtr; + boolean ownPtr = false; + private native long newLinphoneAddressImpl(String uri,String displayName); + private native void delete(long ptr); + private native String getDisplayName(long ptr); + private native String getUserName(long ptr); + private native String getDomain(long ptr); + + + protected LinphoneAddressImpl(String username,String domain,String displayName) { + nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); + } + protected LinphoneAddressImpl(long aNativePtr) { + nativePtr = aNativePtr; + ownPtr=false; + } + protected void finalize() throws Throwable { + if (ownPtr) delete(nativePtr); + } + public String getDisplayName() { + return getDisplayName(nativePtr); + } + public String getDomain() { + return getDomain(nativePtr); + } + public String getUserName() { + return getUserName(nativePtr); + } + + public String toString() { + String tmp=""; + if (getDisplayName()!=null) { + tmp="<"+getDisplayName()+">"; + } + return tmp+"sip:"+getUserName()+"@"+getDomain(); + } + +} diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index 15a064ec9..719101883 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -1,3 +1,21 @@ +/* +LinphoneAuthInfoImpl.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 LinphoneAuthInfoImpl implements LinphoneAuthInfo { diff --git a/LinphoneCore.java b/LinphoneCore.java index 8ae0effd3..0a327f481 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -89,6 +89,11 @@ public interface LinphoneCore { public void invite(String uri); public void terminateCall(); + /** + * get the remote address in case of in/out call + * @return null if no call engaged yet + */ + public LinphoneAddress getRemoteAddress(); public void iterate(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0e4956566..2ef2895f6 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -38,6 +38,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void addAuthInfo(long nativePtr,long authInfoNativePtr); private native void invite(long nativePtr,String uri); private native void terminateCall(long nativePtr); + private native long getRemoteAddress(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -87,6 +88,14 @@ class LinphoneCoreImpl implements LinphoneCore { public void terminateCall() { terminateCall(nativePtr); } + public LinphoneAddress getRemoteAddress() { + long ptr = getRemoteAddress(nativePtr); + if (ptr==0) { + return null; + } else { + return new LinphoneAddressImpl(ptr); + } + } } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index 17085de82..8e338e613 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -45,6 +45,10 @@ public interface LinphoneProxyConfig { * @throws LinphoneCoreException */ public void enableRegister(boolean value) throws LinphoneCoreException; - - + /** + * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 + * @param number + * @return + */ + public String normalizePhoneNumber(String number); } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index f1de9707b..7c65c7b28 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -55,6 +55,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void enableRegister(long ptr,boolean value); + private native String normalizePhoneNumber(long ptr,String number); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); } @@ -76,4 +78,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]"); } } + public String normalizePhoneNumber(String number) { + return normalizePhoneNumber(nativePtr,number); + } } From 8f449aabbe7a28043f4317af253db3d04b9d77be Mon Sep 17 00:00:00 2001 From: jehan monnier Date: Sun, 14 Feb 2010 09:52:18 +0100 Subject: [PATCH 007/288] more jni functions implemented --- LinphoneAddress.java | 5 +++++ LinphoneAddressImpl.java | 11 +++++------ LinphoneCoreFactory.java | 3 +++ LinphoneProxyConfig.java | 11 +++++++++++ LinphoneProxyConfigImpl.java | 10 ++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/LinphoneAddress.java b/LinphoneAddress.java index d7ad7c4b0..619bd4fb8 100644 --- a/LinphoneAddress.java +++ b/LinphoneAddress.java @@ -34,4 +34,9 @@ public interface LinphoneAddress { * @return null if not set */ public String getDomain(); + + /** + * @return an URI version of the address that can be used to place a call using {@link LinphoneCore#invite(String)} + */ + public String toUri(); } diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index 83176180e..fd80db86e 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -28,7 +28,7 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native String getDisplayName(long ptr); private native String getUserName(long ptr); private native String getDomain(long ptr); - + private native String toUri(long ptr); protected LinphoneAddressImpl(String username,String domain,String displayName) { nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); @@ -51,11 +51,10 @@ public class LinphoneAddressImpl implements LinphoneAddress { } public String toString() { - String tmp=""; - if (getDisplayName()!=null) { - tmp="<"+getDisplayName()+">"; - } - return tmp+"sip:"+getUserName()+"@"+getDomain(); + return toUri(); + } + public String toUri() { + return toUri(nativePtr); } } diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java index 265ba65dd..4cbded4f9 100644 --- a/LinphoneCoreFactory.java +++ b/LinphoneCoreFactory.java @@ -39,6 +39,9 @@ public class LinphoneCoreFactory { return new LinphoneCoreImpl(listener,userConfig,factoryConfig,userdata); } + public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName) { + return new LinphoneAddressImpl(username,domain,displayName); + } } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index 8e338e613..97c7d21a6 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -51,4 +51,15 @@ public interface LinphoneProxyConfig { * @return */ public String normalizePhoneNumber(String number); + /** + * usefull function to automatically add internationnal prefix to e164 phone numbers + * @param prefix + */ + public void setDialPrefix(String prefix); + + /** + * rget domain host name or ip + * @return may be null + */ + public String getDomain(); } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 7c65c7b28..a82418cdb 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -55,8 +55,12 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void enableRegister(long ptr,boolean value); + private native void setDialPrefix(long ptr, String prefix); + private native String normalizePhoneNumber(long ptr,String number); + private native String getDomain(long ptr); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); } @@ -81,4 +85,10 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { public String normalizePhoneNumber(String number) { return normalizePhoneNumber(nativePtr,number); } + public void setDialPrefix(String prefix) { + setDialPrefix(nativePtr, prefix); + } + public String getDomain() { + return getDomain(nativePtr); + } } From 7b6ccba59eab576a65a2af91c5ba411ea680e9a0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 15 Feb 2010 18:01:06 +0100 Subject: [PATCH 008/288] many bug fixes + audio routing + incoming call --- LinphoneCore.java | 22 ++++++++++++++++++++- LinphoneCoreImpl.java | 37 +++++++++++++++++++++++------------- LinphoneProxyConfig.java | 6 ++++++ LinphoneProxyConfigImpl.java | 8 +++++++- 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 0a327f481..59747220c 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -94,6 +94,26 @@ public interface LinphoneCore { * @return null if no call engaged yet */ public LinphoneAddress getRemoteAddress(); - + /** + * + * @return TRUE if there is a call running or pending. + */ + public boolean isIncall(); + /** + * + * @return Returns true if in incoming call is pending, ie waiting for being answered or declined. + */ + public boolean isInComingInvitePending(); public void iterate(); + /** + * Accept an incoming call. + * + * Basically the application is notified of incoming calls within the + * {@link LinphoneCoreListener#inviteReceived(LinphoneCore, String)} listener. + * The application can later respond positively to the call using + * this method. + */ + public void acceptCall(); + + } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 2ef2895f6..2997033e5 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -39,21 +39,24 @@ class LinphoneCoreImpl implements LinphoneCore { private native void invite(long nativePtr,String uri); private native void terminateCall(long nativePtr); private native long getRemoteAddress(long nativePtr); + private native boolean isInCall(long nativePtr); + private native boolean isInComingInvitePending(long nativePtr); + private native void acceptCall(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); } - public void addAuthInfo(LinphoneAuthInfo info) { + public synchronized void addAuthInfo(LinphoneAuthInfo info) { addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); } - public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException { + public synchronized LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException { return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister); } - public LinphoneProxyConfig getDefaultProxyConfig() { + public synchronized LinphoneProxyConfig getDefaultProxyConfig() { long lNativePtr = getDefaultProxyConfig(nativePtr); if (lNativePtr!=0) { return new LinphoneProxyConfigImpl(lNativePtr); @@ -62,33 +65,33 @@ class LinphoneCoreImpl implements LinphoneCore { } } - public void invite(String uri) { + public synchronized void invite(String uri) { invite(nativePtr,uri); } - public void iterate() { + public synchronized void iterate() { iterate(nativePtr); } - public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { + public synchronized void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr); } - public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ + public synchronized void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ if (addProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { throw new LinphoneCoreException("bad proxy config"); } } - public void clearAuthInfos() { + public synchronized void clearAuthInfos() { clearAuthInfos(nativePtr); } - public void clearProxyConfigs() { + public synchronized void clearProxyConfigs() { clearProxyConfigs(nativePtr); } - public void terminateCall() { + public synchronized void terminateCall() { terminateCall(nativePtr); } - public LinphoneAddress getRemoteAddress() { + public synchronized LinphoneAddress getRemoteAddress() { long ptr = getRemoteAddress(nativePtr); if (ptr==0) { return null; @@ -96,6 +99,14 @@ class LinphoneCoreImpl implements LinphoneCore { return new LinphoneAddressImpl(ptr); } } - - + public synchronized boolean isIncall() { + return isInCall(nativePtr); + } + public synchronized boolean isInComingInvitePending() { + return isInComingInvitePending(nativePtr); + } + public synchronized void acceptCall() { + acceptCall(nativePtr); + + } } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index 97c7d21a6..a7fe6b850 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -56,6 +56,12 @@ public interface LinphoneProxyConfig { * @param prefix */ public void setDialPrefix(String prefix); + /** + * * Sets whether liblinphone should replace "+" by "00" in dialed numbers (passed to + * {@link LinphoneCore#invite(String)}). + * @param value default value is false + */ + public void setDialEscapePlus(boolean value); /** * rget domain host name or ip diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index a82418cdb..af2722dd2 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -42,7 +42,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { ownPtr=false; } protected void finalize() throws Throwable { - if (ownPtr) delete(nativePtr); + Log.e(Linphone.TAG,"fixme, should release underlying proxy config"); + // FIXME if (ownPtr) delete(nativePtr); } private native long newLinphoneProxyConfig(); private native void delete(long ptr); @@ -61,6 +62,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native String getDomain(long ptr); + private native void setDialEscapePlus(long ptr, boolean value); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); } @@ -91,4 +94,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { public String getDomain() { return getDomain(nativePtr); } + public void setDialEscapePlus(boolean value) { + setDialEscapePlus(nativePtr,value); + } } From 3f0612f88f3851f35e98b02893a5ea4d7046ac9e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 18 Feb 2010 18:29:40 +0100 Subject: [PATCH 009/288] -create LinphoneService -fix landscape ui -create History tab view --- LinphoneCallLog.java | 31 ++++++++++++++++++++++++ LinphoneCallLogImpl.java | 46 ++++++++++++++++++++++++++++++++++++ LinphoneCore.java | 7 ++++++ LinphoneCoreImpl.java | 12 ++++++++++ LinphoneProxyConfigImpl.java | 6 ++--- 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 LinphoneCallLog.java create mode 100644 LinphoneCallLogImpl.java diff --git a/LinphoneCallLog.java b/LinphoneCallLog.java new file mode 100644 index 000000000..19d851a43 --- /dev/null +++ b/LinphoneCallLog.java @@ -0,0 +1,31 @@ +/* +LinPhoneCallLog.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; + +public interface LinphoneCallLog { + public enum CallDirection { + CallOutgoing,Callincoming + } + + public LinphoneAddress getFrom(); + + public LinphoneAddress getTo (); + + public LinphoneCallLog.CallDirection getDirection(); +} diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java new file mode 100644 index 000000000..c35eea2c7 --- /dev/null +++ b/LinphoneCallLogImpl.java @@ -0,0 +1,46 @@ +/* +LinPhoneCallLogImpl.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 LinphoneCallLogImpl implements LinphoneCallLog { + + protected final long nativePtr; + + private native long getFrom(long nativePtr); + private native long getTo(long nativePtr); + private native boolean isIncoming(long nativePtr); + LinphoneCallLogImpl(long aNativePtr) { + nativePtr = aNativePtr; + } + + + public CallDirection getDirection() { + return isIncoming(nativePtr)?CallDirection.Callincoming:CallDirection.CallOutgoing; + } + + public LinphoneAddress getFrom() { + return new LinphoneAddressImpl(getFrom(nativePtr)); + } + + public LinphoneAddress getTo() { + return new LinphoneAddressImpl(getTo(nativePtr)); + } + +} diff --git a/LinphoneCore.java b/LinphoneCore.java index 59747220c..c39ef36f2 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import java.util.List; + public interface LinphoneCore { @@ -116,4 +118,9 @@ public interface LinphoneCore { public void acceptCall(); + /** + * @return a list of LinphoneCallLog + */ + public List getCallLogs(); + } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 2997033e5..80d24bd67 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,6 +20,8 @@ package org.linphone.core; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; class LinphoneCoreImpl implements LinphoneCore { @@ -42,6 +44,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native boolean isInCall(long nativePtr); private native boolean isInComingInvitePending(long nativePtr); private native void acceptCall(long nativePtr); + private native long getCallLog(long nativePtr,int position); + private native int getNumberOfCallLogs(long nativePtr); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -109,4 +114,11 @@ class LinphoneCoreImpl implements LinphoneCore { acceptCall(nativePtr); } + public List getCallLogs() { + List logs = new ArrayList(); + for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) { + logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i))); + } + return logs; + } } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index af2722dd2..3794c58bf 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import org.linphone.Linphone; +import org.linphone.LinphoneService; import android.util.Log; @@ -35,14 +35,14 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { setProxy(proxy); enableRegister(enableRegister); ownPtr=true; - Log.w(Linphone.TAG, "route ["+route+"] not used yet"); + Log.w(LinphoneService.TAG, "route ["+route+"] not used yet"); } protected LinphoneProxyConfigImpl(long aNativePtr) { nativePtr = aNativePtr; ownPtr=false; } protected void finalize() throws Throwable { - Log.e(Linphone.TAG,"fixme, should release underlying proxy config"); + Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); // FIXME if (ownPtr) delete(nativePtr); } private native long newLinphoneProxyConfig(); From dedf30d1e4031cdea3f91ae3381a929f9638d9cf Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 19 Feb 2010 17:04:40 +0100 Subject: [PATCH 010/288] enhanced history tab --- LinphoneCore.java | 5 +++++ LinphoneCoreImpl.java | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index c39ef36f2..c886c4038 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -123,4 +123,9 @@ public interface LinphoneCore { */ public List getCallLogs(); + /** + * destroy linphone core and free all underlying resources + */ + public void destroy(); + } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 80d24bd67..ba6f5a384 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -23,11 +23,15 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.linphone.LinphoneService; + +import android.util.Log; + class LinphoneCoreImpl implements LinphoneCore { private final LinphoneCoreListener mListener; - private final long nativePtr; + private long nativePtr = 0; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); private native long getDefaultProxyConfig(long nativePtr); @@ -46,22 +50,29 @@ class LinphoneCoreImpl implements LinphoneCore { private native void acceptCall(long nativePtr); private native long getCallLog(long nativePtr,int position); private native int getNumberOfCallLogs(long nativePtr); + private native void delete(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); } + protected void finalize() throws Throwable { + + } public synchronized void addAuthInfo(LinphoneAuthInfo info) { + isValid(); addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); } public synchronized LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException { + isValid(); return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister); } public synchronized LinphoneProxyConfig getDefaultProxyConfig() { + isValid(); long lNativePtr = getDefaultProxyConfig(nativePtr); if (lNativePtr!=0) { return new LinphoneProxyConfigImpl(lNativePtr); @@ -71,32 +82,40 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void invite(String uri) { + isValid(); invite(nativePtr,uri); } public synchronized void iterate() { + isValid(); iterate(nativePtr); } public synchronized void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { + isValid(); setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr); } public synchronized void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ + isValid(); if (addProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { throw new LinphoneCoreException("bad proxy config"); } } public synchronized void clearAuthInfos() { + isValid(); clearAuthInfos(nativePtr); } public synchronized void clearProxyConfigs() { + isValid(); clearProxyConfigs(nativePtr); } public synchronized void terminateCall() { + isValid(); terminateCall(nativePtr); } public synchronized LinphoneAddress getRemoteAddress() { + isValid(); long ptr = getRemoteAddress(nativePtr); if (ptr==0) { return null; @@ -105,20 +124,35 @@ class LinphoneCoreImpl implements LinphoneCore { } } public synchronized boolean isIncall() { + isValid(); return isInCall(nativePtr); } public synchronized boolean isInComingInvitePending() { + isValid(); return isInComingInvitePending(nativePtr); } public synchronized void acceptCall() { + isValid(); acceptCall(nativePtr); } - public List getCallLogs() { + public synchronized List getCallLogs() { + isValid(); List logs = new ArrayList(); for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) { logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i))); } return logs; } + public synchronized void destroy() { + isValid(); + delete(nativePtr); + nativePtr = 0; + } + + private void isValid() { + if (nativePtr == 0) { + throw new RuntimeException("object already destroyed"); + } + } } From b167fe09a936bd4db8b68ebcd6eb669db7ff5ba0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 3 Mar 2010 18:12:26 +0100 Subject: [PATCH 011/288] add Networkmanager class --- LinphoneCore.java | 9 +++++++++ LinphoneCoreImpl.java | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/LinphoneCore.java b/LinphoneCore.java index c886c4038..1f8e73449 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -123,6 +123,15 @@ public interface LinphoneCore { */ public List getCallLogs(); + /** + * This method is called by the application to notify the Linphone core library when network is reachable. + * Calling this method with true trigger Linphone to initiate a registration process for all proxy + * configuration with parameter register set to enable. + * This method disable the automatic registration mode. It means you must call this method after each network state changes + * @param network state + * + */ + public void setNetworkStateReachable(boolean isReachable); /** * destroy linphone core and free all underlying resources */ diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index ba6f5a384..b1dedfeb4 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -51,6 +51,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native long getCallLog(long nativePtr,int position); private native int getNumberOfCallLogs(long nativePtr); private native void delete(long nativePtr); + private native void setNetworkStateReachable(long nativePtr,boolean isReachable); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -155,4 +156,7 @@ class LinphoneCoreImpl implements LinphoneCore { throw new RuntimeException("object already destroyed"); } } + public void setNetworkStateReachable(boolean isReachable) { + setNetworkStateReachable(nativePtr,isReachable); + } } From 5136048097ff6946a8fcc331c2ea4b50b51e7fff Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 15 Mar 2010 18:04:58 +0100 Subject: [PATCH 012/288] add support for mute/speaker --- LinphoneCore.java | 10 ++++++++++ LinphoneCoreImpl.java | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 1f8e73449..915062118 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -136,5 +136,15 @@ public interface LinphoneCore { * destroy linphone core and free all underlying resources */ public void destroy(); + /** + * Allow to control play level before entering sound card: + * @param level in db + */ + public void setSoftPlayLevel(float gain); + /** + * get play level before entering sound card: + * @return level in db + */ + public float getSoftPlayLevel(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b1dedfeb4..81685e886 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -51,7 +51,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native long getCallLog(long nativePtr,int position); private native int getNumberOfCallLogs(long nativePtr); private native void delete(long nativePtr); - private native void setNetworkStateReachable(long nativePtr,boolean isReachable); + private native void setNetworkStateReachable(long nativePtr,boolean isReachable); + private native void setSoftPlayLevel(long nativeptr, float gain); + private native float getSoftPlayLevel(long nativeptr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -159,4 +161,11 @@ class LinphoneCoreImpl implements LinphoneCore { public void setNetworkStateReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } + public void setSoftPlayLevel(float gain) { + setSoftPlayLevel(nativePtr,gain); + + } + public float getSoftPlayLevel() { + return getSoftPlayLevel(nativePtr); + } } From 083b74b9257700e23c409070a56c024d0534c9bc Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 16 Mar 2010 12:37:05 +0100 Subject: [PATCH 013/288] fix sip uri presentation in History fix landscape mode --- LinphoneCore.java | 6 ++++++ LinphoneCoreImpl.java | 11 ++++++----- LinphoneProxyConfigImpl.java | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 915062118..753dfa12f 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -146,5 +146,11 @@ public interface LinphoneCore { * @return level in db */ public float getSoftPlayLevel(); + /** + * Mutes or unmutes the local microphone. + * @param isMuted + */ + public void muteMic(boolean isMuted); + } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 81685e886..eda069112 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -23,14 +23,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.linphone.LinphoneService; - -import android.util.Log; - class LinphoneCoreImpl implements LinphoneCore { - private final LinphoneCoreListener mListener; + @SuppressWarnings("unused") + private final LinphoneCoreListener mListener; //to make sure to keep a reference on this object private long nativePtr = 0; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); @@ -54,6 +51,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setNetworkStateReachable(long nativePtr,boolean isReachable); private native void setSoftPlayLevel(long nativeptr, float gain); private native float getSoftPlayLevel(long nativeptr); + private native void muteMic(long nativePtr,boolean isMuted); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -168,4 +166,7 @@ class LinphoneCoreImpl implements LinphoneCore { public float getSoftPlayLevel() { return getSoftPlayLevel(nativePtr); } + public void muteMic(boolean isMuted) { + muteMic(nativePtr,isMuted); + } } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 3794c58bf..11e746946 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -42,8 +42,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { ownPtr=false; } protected void finalize() throws Throwable { - Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); - // FIXME if (ownPtr) delete(nativePtr); + //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); + if (ownPtr) delete(nativePtr); } private native long newLinphoneProxyConfig(); private native void delete(long ptr); From d4015a2afb19ab59895e67cfc6744a03e449070e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 16 Mar 2010 18:15:00 +0100 Subject: [PATCH 014/288] add about menu --- LinphoneAddress.java | 6 +++++- LinphoneAddressImpl.java | 5 +++++ LinphoneCore.java | 9 +++++++++ LinphoneCoreImpl.java | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/LinphoneAddress.java b/LinphoneAddress.java index 619bd4fb8..86271674c 100644 --- a/LinphoneAddress.java +++ b/LinphoneAddress.java @@ -34,7 +34,11 @@ public interface LinphoneAddress { * @return null if not set */ public String getDomain(); - + /** + * set display name + * @param name + */ + public void setDisplayName(String name); /** * @return an URI version of the address that can be used to place a call using {@link LinphoneCore#invite(String)} */ diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index fd80db86e..50036ac7d 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -29,6 +29,8 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native String getUserName(long ptr); private native String getDomain(long ptr); private native String toUri(long ptr); + private native String setDisplayName(long ptr,String name); + protected LinphoneAddressImpl(String username,String domain,String displayName) { nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); @@ -56,5 +58,8 @@ public class LinphoneAddressImpl implements LinphoneAddress { public String toUri() { return toUri(nativePtr); } + public void setDisplayName(String name) { + setDisplayName(nativePtr,name); + } } diff --git a/LinphoneCore.java b/LinphoneCore.java index 753dfa12f..4245c5518 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -90,6 +90,8 @@ public interface LinphoneCore { public void invite(String uri); + public void invite(LinphoneAddress to); + public void terminateCall(); /** * get the remote address in case of in/out call @@ -151,6 +153,13 @@ public interface LinphoneCore { * @param isMuted */ public void muteMic(boolean isMuted); + /** + * Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended + * @param destination + * @return + * @throws If no LinphonrAddress can be built from destination + */ + public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException; } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index eda069112..173d5846c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -52,6 +52,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setSoftPlayLevel(long nativeptr, float gain); private native float getSoftPlayLevel(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); + private native long interpretUrl(long nativePtr,String destination); + private native void inviteAddress(long nativePtr,long to); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -169,4 +171,15 @@ class LinphoneCoreImpl implements LinphoneCore { public void muteMic(boolean isMuted) { muteMic(nativePtr,isMuted); } + public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException { + long lAddress = interpretUrl(nativePtr,destination); + if (lAddress != 0) { + return new LinphoneAddressImpl(lAddress); + } else { + throw new LinphoneCoreException("Cannot interpret ["+destination+"]"); + } + } + public void invite(LinphoneAddress to) { + inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); + } } From 7cef363a1786f46009e280775a59cc102ba1085e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 18 Mar 2010 18:13:56 +0100 Subject: [PATCH 015/288] add clear history to call history tab --- LinphoneAddressImpl.java | 3 ++- LinphoneCore.java | 11 +++++++++-- LinphoneCoreImpl.java | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index 50036ac7d..ed879338c 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -30,6 +30,7 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native String getDomain(long ptr); private native String toUri(long ptr); private native String setDisplayName(long ptr,String name); + private native String toString(long ptr); protected LinphoneAddressImpl(String username,String domain,String displayName) { @@ -53,7 +54,7 @@ public class LinphoneAddressImpl implements LinphoneAddress { } public String toString() { - return toUri(); + return toString(nativePtr); } public String toUri() { return toUri(nativePtr); diff --git a/LinphoneCore.java b/LinphoneCore.java index 4245c5518..6ab7e2348 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -160,6 +160,13 @@ public interface LinphoneCore { * @throws If no LinphonrAddress can be built from destination */ public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException; - - + /** + * Initiate a dtmf signal if in call + * @param number + */ + public void sendDtmf(char number); + /** + * + */ + public void clearCallLogs(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 173d5846c..ed938a841 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -54,6 +54,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); private native void inviteAddress(long nativePtr,long to); + private native void sendDtmf(long nativePtr,char dtmf); + private native void clearCallLogs(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -182,4 +184,10 @@ class LinphoneCoreImpl implements LinphoneCore { public void invite(LinphoneAddress to) { inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); } + public void sendDtmf(char number) { + sendDtmf(nativePtr,number); + } + public void clearCallLogs() { + clearCallLogs(nativePtr); + } } From b079162b23ca5f85a41ce1634b937296f921b280 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 23 Mar 2010 10:03:15 +0100 Subject: [PATCH 016/288] add support for android 1.5 --- LinphoneCore.java | 2 +- LinphoneCoreImpl.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LinphoneCore.java b/LinphoneCore.java index 6ab7e2348..a145c4a68 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -72,7 +72,7 @@ public interface LinphoneCore { */ public void clearProxyConfigs(); - public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException; + public void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException; public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index ed938a841..12d3707e7 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -34,7 +34,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native long getDefaultProxyConfig(long nativePtr); private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr); - private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr); + private native int addProxyConfig(LinphoneProxyConfig jprtoxyCfg,long nativePtr,long proxyCfgNativePtr); private native void clearAuthInfos(long nativePtr); private native void clearProxyConfigs(long nativePtr); @@ -100,9 +100,9 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr); } - public synchronized void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ + public synchronized void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{ isValid(); - if (addProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { + if (addProxyConfig(proxyCfg,nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { throw new LinphoneCoreException("bad proxy config"); } } From add223eb06a12d7bec82d51ddba177c1d95768d6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 23 Mar 2010 17:41:30 +0100 Subject: [PATCH 017/288] add first start configuration checking --- LinphoneCoreFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java index 4cbded4f9..24315f6dd 100644 --- a/LinphoneCoreFactory.java +++ b/LinphoneCoreFactory.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; public class LinphoneCoreFactory { + static { System.loadLibrary("linphone"); } @@ -42,6 +43,11 @@ public class LinphoneCoreFactory { public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName) { return new LinphoneAddressImpl(username,domain,displayName); } - + + /** + * Enable verbose traces + * @param enable + */ + public native void setDebugMode(boolean enable); } From 226f635662c85d26e2d3a8c811f0bd3e41122f23 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 25 Mar 2010 14:14:10 +0100 Subject: [PATCH 018/288] extend wake lock scope to screen to avoid sound system from going to standby --- LinphoneCore.java | 5 +++++ LinphoneCoreImpl.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/LinphoneCore.java b/LinphoneCore.java index a145c4a68..8609e04e1 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -153,6 +153,11 @@ public interface LinphoneCore { * @param isMuted */ public void muteMic(boolean isMuted); + /** + * + * @return true is mic is muted + */ + public boolean isMicMuted(); /** * Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended * @param destination diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 12d3707e7..a1087f24d 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -56,6 +56,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void inviteAddress(long nativePtr,long to); private native void sendDtmf(long nativePtr,char dtmf); private native void clearCallLogs(long nativePtr); + private native boolean isMicMuted(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -190,4 +191,7 @@ class LinphoneCoreImpl implements LinphoneCore { public void clearCallLogs() { clearCallLogs(nativePtr); } + public boolean isMicMuted() { + return isMicMuted(nativePtr); + } } From 02a38337438ecf71b37ec12276d096f34964658e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 7 Apr 2010 09:09:56 +0200 Subject: [PATCH 019/288] add all deps as submodules --- LinphoneAddress.java | 46 ---------- LinphoneAuthInfo.java | 25 ------ LinphoneCallLog.java | 31 ------- LinphoneCore.java | 177 ------------------------------------- LinphoneCoreException.java | 43 --------- LinphoneCoreFactory.java | 53 ----------- LinphoneCoreListener.java | 51 ----------- LinphoneProxyConfig.java | 71 --------------- 8 files changed, 497 deletions(-) delete mode 100644 LinphoneAddress.java delete mode 100644 LinphoneAuthInfo.java delete mode 100644 LinphoneCallLog.java delete mode 100644 LinphoneCore.java delete mode 100644 LinphoneCoreException.java delete mode 100644 LinphoneCoreFactory.java delete mode 100644 LinphoneCoreListener.java delete mode 100644 LinphoneProxyConfig.java diff --git a/LinphoneAddress.java b/LinphoneAddress.java deleted file mode 100644 index 86271674c..000000000 --- a/LinphoneAddress.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -LinphoneAddress.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; - -public interface LinphoneAddress { - /** - * Human display name - * @return null if not set - */ - public String getDisplayName(); - /** - * userinfo - * @return null if not set - */ - public String getUserName(); - /** - * - * @return null if not set - */ - public String getDomain(); - /** - * set display name - * @param name - */ - public void setDisplayName(String name); - /** - * @return an URI version of the address that can be used to place a call using {@link LinphoneCore#invite(String)} - */ - public String toUri(); -} diff --git a/LinphoneAuthInfo.java b/LinphoneAuthInfo.java deleted file mode 100644 index 2a5dbaf2d..000000000 --- a/LinphoneAuthInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -LinphoneAuthInfo.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; - -public interface LinphoneAuthInfo { - -} - - diff --git a/LinphoneCallLog.java b/LinphoneCallLog.java deleted file mode 100644 index 19d851a43..000000000 --- a/LinphoneCallLog.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -LinPhoneCallLog.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; - -public interface LinphoneCallLog { - public enum CallDirection { - CallOutgoing,Callincoming - } - - public LinphoneAddress getFrom(); - - public LinphoneAddress getTo (); - - public LinphoneCallLog.CallDirection getDirection(); -} diff --git a/LinphoneCore.java b/LinphoneCore.java deleted file mode 100644 index 8609e04e1..000000000 --- a/LinphoneCore.java +++ /dev/null @@ -1,177 +0,0 @@ -/* -LinphoneCore.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; - -import java.util.List; - - - -public interface LinphoneCore { - /* - * linphone core states - */ - public enum GeneralState { - /* states for GSTATE_GROUP_POWER */ - GSTATE_POWER_OFF(0), /* initial state */ - GSTATE_POWER_STARTUP(1), - GSTATE_POWER_ON(2), - GSTATE_POWER_SHUTDOWN(3), - /* states for GSTATE_GROUP_REG */ - GSTATE_REG_NONE(10), /* initial state */ - GSTATE_REG_OK(11), - GSTATE_REG_FAILED(12), - /* states for GSTATE_GROUP_CALL */ - 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+"]"); - } - } - - - /** - * @param identity sip uri sip:jehan@linphone.org - * @param proxy sip uri (sip:linphone.org) - * @param route optionnal sip usi (sip:linphone.org) - * @param register should be initiated - * @return - */ - public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route,boolean enableRegister) throws LinphoneCoreException; - /** - * clear all added proxy config - */ - public void clearProxyConfigs(); - - public void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException; - - public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); - - /** - * @return null if no default proxy config - */ - public LinphoneProxyConfig getDefaultProxyConfig() ; - - /** - * clear all the added auth info - */ - void clearAuthInfos(); - - void addAuthInfo(LinphoneAuthInfo info); - - public void invite(String uri); - - public void invite(LinphoneAddress to); - - public void terminateCall(); - /** - * get the remote address in case of in/out call - * @return null if no call engaged yet - */ - public LinphoneAddress getRemoteAddress(); - /** - * - * @return TRUE if there is a call running or pending. - */ - public boolean isIncall(); - /** - * - * @return Returns true if in incoming call is pending, ie waiting for being answered or declined. - */ - public boolean isInComingInvitePending(); - public void iterate(); - /** - * Accept an incoming call. - * - * Basically the application is notified of incoming calls within the - * {@link LinphoneCoreListener#inviteReceived(LinphoneCore, String)} listener. - * The application can later respond positively to the call using - * this method. - */ - public void acceptCall(); - - - /** - * @return a list of LinphoneCallLog - */ - public List getCallLogs(); - - /** - * This method is called by the application to notify the Linphone core library when network is reachable. - * Calling this method with true trigger Linphone to initiate a registration process for all proxy - * configuration with parameter register set to enable. - * This method disable the automatic registration mode. It means you must call this method after each network state changes - * @param network state - * - */ - public void setNetworkStateReachable(boolean isReachable); - /** - * destroy linphone core and free all underlying resources - */ - public void destroy(); - /** - * Allow to control play level before entering sound card: - * @param level in db - */ - public void setSoftPlayLevel(float gain); - /** - * get play level before entering sound card: - * @return level in db - */ - public float getSoftPlayLevel(); - /** - * Mutes or unmutes the local microphone. - * @param isMuted - */ - public void muteMic(boolean isMuted); - /** - * - * @return true is mic is muted - */ - public boolean isMicMuted(); - /** - * Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended - * @param destination - * @return - * @throws If no LinphonrAddress can be built from destination - */ - public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException; - /** - * Initiate a dtmf signal if in call - * @param number - */ - public void sendDtmf(char number); - /** - * - */ - public void clearCallLogs(); -} diff --git a/LinphoneCoreException.java b/LinphoneCoreException.java deleted file mode 100644 index abec2943e..000000000 --- a/LinphoneCoreException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -LinphoneCoreException.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; - -@SuppressWarnings("serial") -public class LinphoneCoreException extends Exception { - - public LinphoneCoreException() { - // TODO Auto-generated constructor stub - } - - public LinphoneCoreException(String detailMessage) { - super(detailMessage); - // TODO Auto-generated constructor stub - } - - public LinphoneCoreException(Throwable throwable) { - super(throwable); - // TODO Auto-generated constructor stub - } - - public LinphoneCoreException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - // TODO Auto-generated constructor stub - } - -} diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java deleted file mode 100644 index 24315f6dd..000000000 --- a/LinphoneCoreFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -LinphoneCoreFactory.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; - -import java.io.File; -import java.io.IOException; - -public class LinphoneCoreFactory { - - static { - System.loadLibrary("linphone"); - } - static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory(); - - public static LinphoneCoreFactory instance() { - - return theLinphoneCoreFactory; - } - public LinphoneAuthInfo createAuthInfo(String username,String password) { - return new LinphoneAuthInfoImpl(username,password) ; - } - - public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { - return new LinphoneCoreImpl(listener,userConfig,factoryConfig,userdata); - } - - public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName) { - return new LinphoneAddressImpl(username,domain,displayName); - } - - /** - * Enable verbose traces - * @param enable - */ - public native void setDebugMode(boolean enable); - -} diff --git a/LinphoneCoreListener.java b/LinphoneCoreListener.java deleted file mode 100644 index f48f8a9eb..000000000 --- a/LinphoneCoreListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -LinphoneCoreListener.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; - - - -public interface LinphoneCoreListener { - - /**< Notifies the application that it should show up - * @return */ - public void show(LinphoneCore lc); - /**< Notifies incoming calls - * @return */ - public void inviteReceived(LinphoneCore lc,String from); - /**< Notify calls terminated by far end - * @return */ - public void byeReceived(LinphoneCore lc,String from); - /**< Ask the application some authentication information - * @return */ - 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); - /**< 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 - * @param state LinphoneCore.GeneralState - * @return - * */ - public void generalState(LinphoneCore lc,LinphoneCore.GeneralState state); -} diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java deleted file mode 100644 index a7fe6b850..000000000 --- a/LinphoneProxyConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -/* -LinphoneProxyConfig.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; - -public interface LinphoneProxyConfig { - - /** - * Unregister proxy config a enable edition - */ - public void edit(); - /** - * Validate proxy config changes. Start registration in case - */ - public void done(); - /** - * sip user made by sip:username@domain - */ - public void setIdentity(String identity) throws LinphoneCoreException; - /** - * Set proxy uri, like sip:linphone.org:5060 - * @param proxyUri - * @throws LinphoneCoreException - */ - public void setProxy(String proxyUri) throws LinphoneCoreException; - /** - * Enable register for this proxy config. - * Register message is issued after call to {@link #done()} - * @param value - * @throws LinphoneCoreException - */ - public void enableRegister(boolean value) throws LinphoneCoreException; - /** - * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 - * @param number - * @return - */ - public String normalizePhoneNumber(String number); - /** - * usefull function to automatically add internationnal prefix to e164 phone numbers - * @param prefix - */ - public void setDialPrefix(String prefix); - /** - * * Sets whether liblinphone should replace "+" by "00" in dialed numbers (passed to - * {@link LinphoneCore#invite(String)}). - * @param value default value is false - */ - public void setDialEscapePlus(boolean value); - - /** - * rget domain host name or ip - * @return may be null - */ - public String getDomain(); -} From bf88d70ea31a78e142541555d6951966dd5e706d Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 8 Apr 2010 11:09:05 +0200 Subject: [PATCH 020/288] fix crash on simulator when setting display name --- LinphoneAddressImpl.java | 6 +++++- LinphoneCoreImpl.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index ed879338c..3f11322ed 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -29,13 +29,17 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native String getUserName(long ptr); private native String getDomain(long ptr); private native String toUri(long ptr); - private native String setDisplayName(long ptr,String name); + private native void setDisplayName(long ptr,String name); private native String toString(long ptr); protected LinphoneAddressImpl(String username,String domain,String displayName) { nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); } + protected LinphoneAddressImpl(long aNativePtr,boolean javaOwnPtr) { + nativePtr = aNativePtr; + ownPtr=javaOwnPtr; + } protected LinphoneAddressImpl(long aNativePtr) { nativePtr = aNativePtr; ownPtr=false; diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index a1087f24d..9768066cc 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -177,7 +177,7 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException { long lAddress = interpretUrl(nativePtr,destination); if (lAddress != 0) { - return new LinphoneAddressImpl(lAddress); + return new LinphoneAddressImpl(lAddress,true); } else { throw new LinphoneCoreException("Cannot interpret ["+destination+"]"); } From a9a5d5d19a65d49fa07819a9434a44dc67d0d775 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 27 Apr 2010 14:59:03 +0200 Subject: [PATCH 021/288] Refactor LinphonecoreFactory --- LinphoneAuthInfoImpl.java | 25 +++++++++++++++++++++++++ LinphoneCoreImpl.java | 5 +---- LinphoneProxyConfigImpl.java | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index 719101883..fcea4900c 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -28,4 +28,29 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo { protected void finalize() throws Throwable { delete(nativePtr); } + public String getPassword() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public String getRealm() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public String getUsername() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public void setPassword(String password) { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + + } + public void setRealm(String realm) { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public void setUsername(String username) { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 9768066cc..d752cfdc0 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -72,10 +72,7 @@ class LinphoneCoreImpl implements LinphoneCore { addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); } - public synchronized LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException { - isValid(); - return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister); - } + public synchronized LinphoneProxyConfig getDefaultProxyConfig() { isValid(); diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 11e746946..90cc16bfb 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -97,4 +97,19 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { public void setDialEscapePlus(boolean value) { setDialEscapePlus(nativePtr,value); } + public String getIdentity() { + throw new RuntimeException("not implemeneted yet"); + } + public String getProxy() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public boolean isRegistered() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } + public boolean registerEnabled() { + // TODO Auto-generated method stub + throw new RuntimeException("not implemeneted yet"); + } } From 41510592f2ef088cd205f67738203c06f8d67bb8 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Sun, 2 May 2010 19:23:44 +0200 Subject: [PATCH 022/288] add status bar --- LinphoneAddressImpl.java | 27 +++++++++++++++ LinphoneAuthInfoImpl.java | 4 +-- LinphoneCallLogImpl.java | 2 +- LinphoneCoreFactoryImpl.java | 65 ++++++++++++++++++++++++++++++++++++ LinphoneCoreImpl.java | 7 ++-- LinphoneProxyConfigImpl.java | 16 +++++---- 6 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 LinphoneCoreFactoryImpl.java diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index 3f11322ed..bf4670ec3 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -66,5 +66,32 @@ public class LinphoneAddressImpl implements LinphoneAddress { public void setDisplayName(String name) { setDisplayName(nativePtr,name); } + public String asString() { + return toString(); + } + public String asStringUriOnly() { + return toUri(nativePtr); + } + public void clean() { + throw new RuntimeException("Not implemented"); + } + public String getPort() { + return String.valueOf(getPortInt()); + } + public int getPortInt() { + return getPortInt(); + } + public void setDomain(String domain) { + throw new RuntimeException("Not implemented"); + } + public void setPort(String port) { + throw new RuntimeException("Not implemented"); + } + public void setPortInt(int port) { + throw new RuntimeException("Not implemented"); + } + public void setUserName(String username) { + throw new RuntimeException("Not implemented"); + } } diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index fcea4900c..7f9e54dd2 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -22,8 +22,8 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo { protected final long nativePtr; private native long newLinphoneAuthInfo(String username, String userid, String passwd, String ha1,String realm); private native void delete(long ptr); - protected LinphoneAuthInfoImpl(String username,String password) { - nativePtr = newLinphoneAuthInfo(username,null,password,null,null); + protected LinphoneAuthInfoImpl(String username,String password, String realm) { + nativePtr = newLinphoneAuthInfo(username,null,password,null,realm); } protected void finalize() throws Throwable { delete(nativePtr); diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index c35eea2c7..b0360d194 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -32,7 +32,7 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public CallDirection getDirection() { - return isIncoming(nativePtr)?CallDirection.Callincoming:CallDirection.CallOutgoing; + return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing; } public LinphoneAddress getFrom() { diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java new file mode 100644 index 000000000..a34eabcae --- /dev/null +++ b/LinphoneCoreFactoryImpl.java @@ -0,0 +1,65 @@ +/* +LinphoneCoreFactoryImpl.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; + +import java.io.File; +import java.io.IOException; + +public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { + + static { + System.loadLibrary("linphone"); + } + @Override + public LinphoneAuthInfo createAuthInfo(String username, String password, + String realm) { + return new LinphoneAuthInfoImpl(username,password,realm); + } + + @Override + public LinphoneAddress createLinphoneAddress(String username, + String domain, String displayName) { + return new LinphoneAddressImpl(username,domain,displayName); + } + + @Override + public LinphoneAddress createLinphoneAddress(String address) { + throw new RuntimeException("Not implemeneted yet"); + } + + @Override + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, + String userConfig, String factoryConfig, Object userdata) + throws LinphoneCoreException { + try { + return new LinphoneCoreImpl(listener,new File(userConfig),new File(factoryConfig),userdata); + } catch (IOException e) { + throw new LinphoneCoreException("Cannot create LinphoneCore",e); + } + } + + @Override + public LinphoneProxyConfig createProxyConfig(String identity, String proxy, + String route, boolean enableRegister) throws LinphoneCoreException { + return new LinphoneProxyConfigImpl(identity,proxy,route,enableRegister); + } + + @Override + public native void setDebugMode(boolean enable); +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index d752cfdc0..547e4bc0d 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,8 +20,7 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.Vector; class LinphoneCoreImpl implements LinphoneCore { @@ -139,9 +138,9 @@ class LinphoneCoreImpl implements LinphoneCore { acceptCall(nativePtr); } - public synchronized List getCallLogs() { + public synchronized Vector getCallLogs() { isValid(); - List logs = new ArrayList(); + Vector logs = new Vector(); for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) { logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i))); } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 90cc16bfb..01080bfc0 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -52,10 +52,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void done(long ptr); private native void setIdentity(long ptr,String identity); + private native String getIdentity(long ptr); private native int setProxy(long ptr,String proxy); + private native String getProxy(long ptr); + private native void enableRegister(long ptr,boolean value); + private native boolean isRegisterEnabled(long ptr); + private native boolean isRegistered(long ptr); private native void setDialPrefix(long ptr, String prefix); private native String normalizePhoneNumber(long ptr,String number); @@ -98,18 +103,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { setDialEscapePlus(nativePtr,value); } public String getIdentity() { - throw new RuntimeException("not implemeneted yet"); + return getIdentity(nativePtr); } public String getProxy() { - // TODO Auto-generated method stub - throw new RuntimeException("not implemeneted yet"); + return getProxy(nativePtr); } public boolean isRegistered() { - // TODO Auto-generated method stub - throw new RuntimeException("not implemeneted yet"); + return isRegistered(nativePtr); } public boolean registerEnabled() { - // TODO Auto-generated method stub - throw new RuntimeException("not implemeneted yet"); + return isRegisterEnabled(nativePtr); } } From 75f5c45f15d6c185a941911bbac779339cf2c79b Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 18 Jun 2010 11:01:12 +0200 Subject: [PATCH 023/288] add codec management start OUTGOING Call intent management --- LinphoneCoreFactoryImpl.java | 6 ++++++ LinphoneCoreImpl.java | 18 +++++++++++++++++- LinphoneProxyConfigImpl.java | 11 +++++++++++ PayloadTypeImpl.java | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 PayloadTypeImpl.java diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index a34eabcae..712e27b63 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -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 + + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 547e4bc0d..376831473 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -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+"]"); + } + + } } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 01080bfc0..7ffb164b2 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -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+"]"); + } + } } diff --git a/PayloadTypeImpl.java b/PayloadTypeImpl.java new file mode 100644 index 000000000..28c206786 --- /dev/null +++ b/PayloadTypeImpl.java @@ -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); + } +} From 963ba861443223fcad75adcaf5f700f660abbf75 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 28 Jun 2010 17:34:55 +0200 Subject: [PATCH 024/288] add EC support --- LinphoneCoreImpl.java | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 376831473..55d25dbe1 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -48,8 +48,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getNumberOfCallLogs(long nativePtr); private native void delete(long nativePtr); private native void setNetworkStateReachable(long nativePtr,boolean isReachable); - private native void setSoftPlayLevel(long nativeptr, float gain); - private native float getSoftPlayLevel(long nativeptr); + private native void setPlaybackGain(long nativeptr, float gain); + private native float getPlaybackGain(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); private native void inviteAddress(long nativePtr,long to); @@ -58,6 +58,8 @@ class LinphoneCoreImpl implements LinphoneCore { 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); + private native void enableEchoCancellation(long nativePtr,boolean enable); + private native boolean isEchoCancellationEnabled(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -161,12 +163,12 @@ class LinphoneCoreImpl implements LinphoneCore { public void setNetworkStateReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } - public void setSoftPlayLevel(float gain) { - setSoftPlayLevel(nativePtr,gain); + public void setPlaybackGain(float gain) { + setPlaybackGain(nativePtr,gain); } - public float getSoftPlayLevel() { - return getSoftPlayLevel(nativePtr); + public float getPlaybackGain() { + return getPlaybackGain(nativePtr); } public void muteMic(boolean isMuted) { muteMic(nativePtr,isMuted); @@ -192,6 +194,7 @@ class LinphoneCoreImpl implements LinphoneCore { return isMicMuted(nativePtr); } public PayloadType findPayloadType(String mime, int clockRate) { + isValid(); long playLoadType = findPayloadType(nativePtr, mime, clockRate); if (playLoadType == 0) { return null; @@ -201,9 +204,19 @@ class LinphoneCoreImpl implements LinphoneCore { } public void enablePayloadType(PayloadType pt, boolean enable) throws LinphoneCoreException { + isValid(); if (enablePayloadType(nativePtr,((PayloadTypeImpl)pt).nativePtr,enable) != 0) { throw new LinphoneCoreException("cannot enable payload type ["+pt+"]"); } } + public void enableEchoCancellation(boolean enable) { + isValid(); + enableEchoCancellation(nativePtr, enable); + } + public boolean isEchoCancellationEnabled() { + isValid(); + return isEchoCancellationEnabled(nativePtr); + + } } From 728865a441ce591c34254d10f07b0ba3dcee0f07 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 13 Sep 2010 23:44:29 +0200 Subject: [PATCH 025/288] new liblinphonne multi call api inband dtmf is pcm codec play dtmf on digit pressed --- LinphoneCallImpl.java | 63 +++++++++++++++++++++++++++++++++++ LinphoneCoreImpl.java | 76 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 LinphoneCallImpl.java diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java new file mode 100644 index 000000000..c71883b57 --- /dev/null +++ b/LinphoneCallImpl.java @@ -0,0 +1,63 @@ +/* +LinphoneCallImpl.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 LinphoneCallImpl implements LinphoneCall { + + protected final long nativePtr; + boolean ownPtr = false; + native private void ref(long ownPtr); + native private void unref(long ownPtr); + native private long getCallLog(long nativePtr); + private native boolean isIncoming(long nativePtr); + native private long getRemoteAddress(long nativePtr); + native private int getState(long nativePtr); + protected LinphoneCallImpl(long aNativePtr) { + nativePtr = aNativePtr; + ref(nativePtr); + } + protected void finalize() throws Throwable { + unref(nativePtr); + } + public LinphoneCallLog getCallLog() { + long lNativePtr = getCallLog(nativePtr); + if (lNativePtr!=0) { + return new LinphoneCallLogImpl(lNativePtr); + } else { + return null; + } + } + public CallDirection getDirection() { + return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing; + } + public LinphoneAddress getRemoteAddress() { + long lNativePtr = getRemoteAddress(nativePtr); + if (lNativePtr!=0) { + return new LinphoneAddressImpl(lNativePtr); + } else { + return null; + } + } + public State getState() { + return LinphoneCall.State.fromInt(getState(nativePtr)); + } + + +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 55d25dbe1..e042b3951 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -38,12 +38,12 @@ class LinphoneCoreImpl implements LinphoneCore { private native void clearProxyConfigs(long nativePtr); private native void addAuthInfo(long nativePtr,long authInfoNativePtr); - private native void invite(long nativePtr,String uri); - private native void terminateCall(long nativePtr); + private native long invite(long nativePtr,String uri); + private native void terminateCall(long nativePtr, long call); private native long getRemoteAddress(long nativePtr); private native boolean isInCall(long nativePtr); private native boolean isInComingInvitePending(long nativePtr); - private native void acceptCall(long nativePtr); + private native void acceptCall(long nativePtr, long call); private native long getCallLog(long nativePtr,int position); private native int getNumberOfCallLogs(long nativePtr); private native void delete(long nativePtr); @@ -52,7 +52,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native float getPlaybackGain(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); - private native void inviteAddress(long nativePtr,long to); + private native long inviteAddress(long nativePtr,long to); private native void sendDtmf(long nativePtr,char dtmf); private native void clearCallLogs(long nativePtr); private native boolean isMicMuted(long nativePtr); @@ -60,6 +60,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native int enablePayloadType(long nativePtr, long payloadType, boolean enable); private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr); + private native long getCurrentCall(long nativePtr) ; + private native void playDtmf(long nativePtr,char dtmf,int duration); + private native void stopDtmf(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -86,9 +89,14 @@ class LinphoneCoreImpl implements LinphoneCore { } } - public synchronized void invite(String uri) { + public synchronized LinphoneCall invite(String uri) { isValid(); - invite(nativePtr,uri); + long lNativePtr = invite(nativePtr,uri); + if (lNativePtr!=0) { + return new LinphoneCallImpl(lNativePtr); + } else { + return null; + } } public synchronized void iterate() { @@ -115,9 +123,9 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); clearProxyConfigs(nativePtr); } - public synchronized void terminateCall() { + public synchronized void terminateCall(LinphoneCall aCall) { isValid(); - terminateCall(nativePtr); + if (aCall!=null)terminateCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr); } public synchronized LinphoneAddress getRemoteAddress() { isValid(); @@ -136,9 +144,9 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); return isInComingInvitePending(nativePtr); } - public synchronized void acceptCall() { + public synchronized void acceptCall(LinphoneCall aCall) { isValid(); - acceptCall(nativePtr); + acceptCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr); } public synchronized Vector getCallLogs() { @@ -181,8 +189,13 @@ class LinphoneCoreImpl implements LinphoneCore { throw new LinphoneCoreException("Cannot interpret ["+destination+"]"); } } - public void invite(LinphoneAddress to) { - inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); + public LinphoneCall invite(LinphoneAddress to) { + long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); + if (lNativePtr!=0) { + return new LinphoneCallImpl(lNativePtr); + } else { + return null; + } } public void sendDtmf(char number) { sendDtmf(nativePtr,number); @@ -219,4 +232,43 @@ class LinphoneCoreImpl implements LinphoneCore { return isEchoCancellationEnabled(nativePtr); } + + public synchronized LinphoneCall getCurrentCall() { + isValid(); + long lNativePtr = getCurrentCall(nativePtr); + if (lNativePtr!=0) { + return new LinphoneCallImpl(lNativePtr); + } else { + return null; + } + } + + public int getPlayLevel() { + // TODO Auto-generated method stub + return 0; + } + public void setPlayLevel(int level) { + // TODO Auto-generated method stub + + } + public void setSignalingTransport(Transport aTransport) { + // TODO Auto-generated method stub + + } + public void enableSpeaker(boolean value) { + // TODO Auto-generated method stub + + } + public boolean isSpeakerEnabled() { + // TODO Auto-generated method stub + return false; + } + public void playDtmf(char number, int duration) { + playDtmf(nativePtr,number, duration); + + } + public void stopDtmf() { + stopDtmf(nativePtr); + } + } From 2804666ea8ea99e72dcee3cca6c12837fcee1288 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 22 Oct 2010 18:33:55 +0200 Subject: [PATCH 026/288] add presence and messaging apis --- LinphoneCoreFactoryImpl.java | 10 ++++++++++ LinphoneCoreImpl.java | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 712e27b63..a6f899f31 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -68,4 +68,14 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //not implemented on Android } + + @Override + LinphoneFriend createLinphoneFriend(String friendUri) { + return new LinphoneFriendImpl(friendUri); + } + + @Override + LinphoneFriend createLinphoneFriend() { + return createLinphoneFriend(null); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index e042b3951..0143dc7d5 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -64,6 +64,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native void playDtmf(long nativePtr,char dtmf,int duration); private native void stopDtmf(long nativePtr); + private native void addFriend(long nativePtr,long friend); + private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); + private native long createChatRoom(long nativePtr,String to); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -270,5 +274,18 @@ class LinphoneCoreImpl implements LinphoneCore { public void stopDtmf() { stopDtmf(nativePtr); } + + public void addFriend(LinphoneFriend lf) throws LinphoneCoreException { + addFriend(nativePtr,((LinphoneFriendImpl)lf).nativePtr); + + } + public void setPresenceInfo(int minute_away, String alternative_contact, + OnlineStatus status) { + setPresenceInfo(nativePtr,minute_away,alternative_contact,status.mValue); + + } + public LinphoneChatRoom createChatRoom(String to) { + return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); + } } From ef61932d1d4dda7ed063fa33bc1ec9b19b4136c7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 22 Oct 2010 18:36:22 +0200 Subject: [PATCH 027/288] Merge branch 'master' of belledonne-communications.com:linphone-android --- LinphoneChatRoomImpl.java | 37 ++++++++++++++++++ LinphoneFriendImpl.java | 80 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 LinphoneChatRoomImpl.java create mode 100644 LinphoneFriendImpl.java diff --git a/LinphoneChatRoomImpl.java b/LinphoneChatRoomImpl.java new file mode 100644 index 000000000..76874675d --- /dev/null +++ b/LinphoneChatRoomImpl.java @@ -0,0 +1,37 @@ +/* +LinphoneChatRoomImpl.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 LinphoneChatRoomImpl implements LinphoneChatRoom { + protected final long nativePtr; + private native long getPeerAddress(long ptr); + private native void sendMessage(long ptr, String message); + + protected LinphoneChatRoomImpl(long aNativePtr) { + nativePtr = aNativePtr; + } + + public LinphoneAddress getPeerAddress() { + return new LinphoneAddressImpl(getPeerAddress(nativePtr)); + } + + public void sendMessage(String message) { + sendMessage(nativePtr,message); + } +} diff --git a/LinphoneFriendImpl.java b/LinphoneFriendImpl.java new file mode 100644 index 000000000..bae44679f --- /dev/null +++ b/LinphoneFriendImpl.java @@ -0,0 +1,80 @@ +/* +LinphoneFriendImpl.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 LinphoneFriendImpl implements LinphoneFriend { + protected final long nativePtr; + private native long newLinphoneFriend(String friendUri); + private native void setAddress(long nativePtr,long friend); + private native long getAddress(long nativePtr); + private native void setIncSubscribePolicy(long nativePtr,int enumValue); + private native int getIncSubscribePolicy(long nativePtr); + private native void enableSubscribes(long nativePtr,boolean value); + private native boolean isSubscribesEnabled(long nativePtr); + private native int getStatus(long nativePtr); + private native void edit(long nativePtr); + private native void done(long nativePtr); + + private native void delete(long ptr); + boolean ownPtr = false; + protected LinphoneFriendImpl() { + nativePtr = newLinphoneFriend(null); + } + protected LinphoneFriendImpl(String friendUri) { + nativePtr = newLinphoneFriend(friendUri); + } + protected LinphoneFriendImpl(long aNativePtr) { + nativePtr = aNativePtr; + ownPtr=false; + } + protected void finalize() throws Throwable { + if (ownPtr) delete(nativePtr); + } + public void setAddress(LinphoneAddress anAddress) { + this.setAddress(nativePtr, ((LinphoneAddressImpl)anAddress).nativePtr); + + } + public LinphoneAddress getAddress() { + return new LinphoneAddressImpl(getAddress(nativePtr)); + } + public void setIncSubscribePolicy(SubscribePolicy policy) { + setIncSubscribePolicy(nativePtr,policy.mValue); + + } + public SubscribePolicy getIncSubscribePolicy() { + return SubscribePolicy.fromInt(getIncSubscribePolicy(nativePtr)) ; + } + public void enableSubscribes(boolean enable) { + enableSubscribes(nativePtr, enable); + } + public boolean isSubscribesEnabled() { + return isSubscribesEnabled(nativePtr); + } + + public OnlineStatus getStatus() { + return OnlineStatus.fromInt(getStatus(nativePtr)); + } + public void edit() { + edit(nativePtr); + } + public void done() { + done(nativePtr); + } + +} From 4fb072b0a1d9f64bf4236751d3ed1f877e243d7e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 26 Oct 2010 11:13:29 +0200 Subject: [PATCH 028/288] adapt to api addons --- LinphoneCoreFactoryImpl.java | 12 ++++++++++++ LinphoneCoreImpl.java | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 712e27b63..e86f0b100 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -68,4 +68,16 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //not implemented on Android } + + @Override + LinphoneFriend createLinphoneFriend(String friendUri) { + // TODO Auto-generated method stub + return null; + } + + @Override + LinphoneFriend createLinphoneFriend() { + // TODO Auto-generated method stub + return null; + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index e042b3951..223a52fdc 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -270,5 +270,18 @@ class LinphoneCoreImpl implements LinphoneCore { public void stopDtmf() { stopDtmf(nativePtr); } + public void addFriend(LinphoneFriend lf) throws LinphoneCoreException { + // TODO Auto-generated method stub + + } + public LinphoneChatRoom createChatRoom(String to) { + // TODO Auto-generated method stub + return null; + } + public void setPresenceInfo(int minuteAway, String alternativeContact, + OnlineStatus status) { + // TODO Auto-generated method stub + + } } From ff57fa0a2891ce3cc9de773a8c922e7ffa7547c3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 1 Nov 2010 11:33:21 +0100 Subject: [PATCH 029/288] video in progress --- AndroidVideoWindowImpl.java | 75 +++++++++++++++++++++++++++++++++++++ LinphoneCoreImpl.java | 32 ++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 AndroidVideoWindowImpl.java diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java new file mode 100644 index 000000000..f1927e184 --- /dev/null +++ b/AndroidVideoWindowImpl.java @@ -0,0 +1,75 @@ +package org.linphone.core; + +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Bitmap.Config; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.Surface.OutOfResourcesException; +import android.view.SurfaceHolder.Callback; + +public class AndroidVideoWindowImpl implements VideoWindow { + private Bitmap mBitmap; + private SurfaceView mView; + private Surface mSurface; + private VideoWindowListener mListener; + public static interface VideoWindowListener{ + void onSurfaceReady(AndroidVideoWindowImpl vw); + void onSurfaceDestroyed(AndroidVideoWindowImpl vw); + }; + public AndroidVideoWindowImpl(SurfaceView view){ + mView=view; + mBitmap=null; + mSurface=null; + mListener=null; + view.getHolder().addCallback(new Callback(){ + public void surfaceChanged(SurfaceHolder holder, int format, + int width, int height) { + synchronized(AndroidVideoWindowImpl.this){ + mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); + if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); + mSurface=holder.getSurface(); + } + } + + public void surfaceCreated(SurfaceHolder holder) { + } + + public void surfaceDestroyed(SurfaceHolder holder) { + synchronized(AndroidVideoWindowImpl.this){ + mBitmap=null; + if (mListener!=null) + mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); + mSurface=null; + } + } + }); + } + public void setListener(VideoWindowListener l){ + mListener=l; + } + public Surface getSurface(){ + return mView.getHolder().getSurface(); + } + public Bitmap getBitmap(){ + return mBitmap; + } + //Called by the mediastreamer2 android display filter + public synchronized void update(){ + if (mSurface!=null){ + try { + Canvas canvas=mSurface.lockCanvas(null); + canvas.drawBitmap(mBitmap, 0, 0, null); + mSurface.unlockCanvasAndPost(canvas); + + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (OutOfResourcesException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 223a52fdc..aad67304a 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -63,6 +63,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native long getCurrentCall(long nativePtr) ; private native void playDtmf(long nativePtr,char dtmf,int duration); private native void stopDtmf(long nativePtr); + private native void setVideoWindowId(long nativePtr, Object wid); + private native void setPreviewWindowId(long nativePtr, Object wid); + private AndroidVideoWindowImpl mVideoWindow; + private AndroidVideoWindowImpl mPreviewWindow; LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -283,5 +287,33 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub } + public void setPreviewWindow(VideoWindow w) { + if (mPreviewWindow!=null) + mPreviewWindow.setListener(null); + mPreviewWindow=(AndroidVideoWindowImpl)w; + mPreviewWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ + public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { + setPreviewWindowId(nativePtr,null); + } + + public void onSurfaceReady(AndroidVideoWindowImpl vw) { + setPreviewWindowId(nativePtr,vw); + } + }); + } + public void setVideoWindow(VideoWindow w) { + if (mVideoWindow!=null) + mVideoWindow.setListener(null); + mVideoWindow=(AndroidVideoWindowImpl)w; + mVideoWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ + public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { + setVideoWindowId(nativePtr,null); + } + + public void onSurfaceReady(AndroidVideoWindowImpl vw) { + setVideoWindowId(nativePtr,vw); + } + }); + } } From d68b8fb8ea8a085c9d467bbd2788bec10591927a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 5 Nov 2010 17:42:40 +0100 Subject: [PATCH 030/288] Added activities to support java port of the C tutorials. --- LinphoneAddressImpl.java | 3 + LinphoneCoreFactoryImpl.java | 17 +++- LinphoneCoreImpl.java | 14 +++ tutorials/AndroidTutorialNotifier.java | 49 +++++++++ tutorials/TutorialBuddyStatusActivity.java | 98 ++++++++++++++++++ tutorials/TutorialChatRoomActivity.java | 98 ++++++++++++++++++ tutorials/TutorialHelloWorldActivity.java | 98 ++++++++++++++++++ tutorials/TutorialRegistrationActivity.java | 105 ++++++++++++++++++++ 8 files changed, 478 insertions(+), 4 deletions(-) create mode 100644 tutorials/AndroidTutorialNotifier.java create mode 100644 tutorials/TutorialBuddyStatusActivity.java create mode 100644 tutorials/TutorialChatRoomActivity.java create mode 100644 tutorials/TutorialHelloWorldActivity.java create mode 100644 tutorials/TutorialRegistrationActivity.java diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index bf4670ec3..b9d290971 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -32,6 +32,9 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native void setDisplayName(long ptr,String name); private native String toString(long ptr); + protected LinphoneAddressImpl(String identity) { + nativePtr = newLinphoneAddressImpl(identity, null); + } protected LinphoneAddressImpl(String username,String domain,String displayName) { nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index a6f899f31..1b4e9aaf0 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -39,8 +39,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } @Override - public LinphoneAddress createLinphoneAddress(String address) { - throw new RuntimeException("Not implemeneted yet"); + public LinphoneAddress createLinphoneAddress(String identity) { + return new LinphoneAddressImpl(identity); } @Override @@ -54,6 +54,15 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } } + @Override + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException { + try { + return new LinphoneCoreImpl(listener); + } catch (IOException e) { + throw new LinphoneCoreException("Cannot create LinphoneCore",e); + } + } + @Override public LinphoneProxyConfig createProxyConfig(String identity, String proxy, String route, boolean enableRegister) throws LinphoneCoreException { @@ -70,12 +79,12 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } @Override - LinphoneFriend createLinphoneFriend(String friendUri) { + public LinphoneFriend createLinphoneFriend(String friendUri) { return new LinphoneFriendImpl(friendUri); } @Override - LinphoneFriend createLinphoneFriend() { + public LinphoneFriend createLinphoneFriend() { return createLinphoneFriend(null); } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0143dc7d5..83a78a00e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -72,6 +72,11 @@ class LinphoneCoreImpl implements LinphoneCore { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); } + LinphoneCoreImpl(LinphoneCoreListener listener) throws IOException { + mListener=listener; + nativePtr = newLinphoneCore(listener,null,null,null); + } + protected void finalize() throws Throwable { } @@ -287,5 +292,14 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneChatRoom createChatRoom(String to) { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } + public void setPreviewWindow(VideoWindow w) { + throw new RuntimeException("not implemented yet"); + // TODO Auto-generated method stub + + } + public void setVideoWindow(VideoWindow w) { + throw new RuntimeException("not implemented yet"); + // TODO Auto-generated method stub + } } diff --git a/tutorials/AndroidTutorialNotifier.java b/tutorials/AndroidTutorialNotifier.java new file mode 100644 index 000000000..01e0555e2 --- /dev/null +++ b/tutorials/AndroidTutorialNotifier.java @@ -0,0 +1,49 @@ +/* +AndroidTutorialNotifier.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.tutorials; + +import android.os.Handler; +import android.widget.TextView; + +/** + * Write notifications to a TextView widget. + * + * @author Guillaume Beraudo + * + */ +public class AndroidTutorialNotifier extends TutorialNotifier { + + private Handler mHandler; + private TextView outputTextView; + + public AndroidTutorialNotifier(Handler mHandler, final TextView outputTextView) { + this.mHandler = mHandler; + this.outputTextView = outputTextView; + } + + + @Override + public void notify(final String s) { + mHandler.post(new Runnable() { + public void run() { + outputTextView.setText(s + "\n" + outputTextView.getText()); + } + }); + } +} diff --git a/tutorials/TutorialBuddyStatusActivity.java b/tutorials/TutorialBuddyStatusActivity.java new file mode 100644 index 000000000..376afadfb --- /dev/null +++ b/tutorials/TutorialBuddyStatusActivity.java @@ -0,0 +1,98 @@ +/* +TutorialBuddyStatusActivity.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.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the BuddyStatus example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialBuddyStatusActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialBuddyStatus tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create BuddyStatus object + tutorial = new TutorialBuddyStatus(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialChatRoomActivity.java b/tutorials/TutorialChatRoomActivity.java new file mode 100644 index 000000000..aa4623eeb --- /dev/null +++ b/tutorials/TutorialChatRoomActivity.java @@ -0,0 +1,98 @@ +/* +TutorialChatRoomActivity.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.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the chatroom example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialChatRoomActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialChatRoom tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create HelloWorld object + tutorial = new TutorialChatRoom(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialHelloWorldActivity.java b/tutorials/TutorialHelloWorldActivity.java new file mode 100644 index 000000000..3ef643a61 --- /dev/null +++ b/tutorials/TutorialHelloWorldActivity.java @@ -0,0 +1,98 @@ +/* +TutorialHelloWorldActivity.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.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the HelloWorld example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialHelloWorldActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialHelloWorld tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create HelloWorld object + tutorial = new TutorialHelloWorld(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java new file mode 100644 index 000000000..4da10f632 --- /dev/null +++ b/tutorials/TutorialRegistrationActivity.java @@ -0,0 +1,105 @@ +/* +TutorialRegistrationActivity.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.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the registration example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { + + private static final String defaultSipAddress = "sip:8182449901ip@mty11.axtel.net"; + private static final String defaultSipPassword = "49901"; + private TextView sipAddressWidget; + private TextView sipPasswordWidget; + private TutorialRegistration tutorial; + private Button buttonCall; + private Handler mHandler = new Handler(); + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + sipPasswordWidget = (TextView) findViewById(R.id.Password); + sipPasswordWidget.setVisibility(TextView.VISIBLE); + sipPasswordWidget.setText(defaultSipPassword); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create Tutorial object + tutorial = new TutorialRegistration(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial( + sipAddressWidget.getText().toString(), + sipPasswordWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} From 51daf1eea6660f0fc233de504308371d1e199206 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 9 Nov 2010 09:26:40 +0100 Subject: [PATCH 031/288] Removed dependency on GUI framework. --- LinphoneProxyConfigImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 7ffb164b2..f1dcb70a4 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -18,9 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import org.linphone.LinphoneService; - -import android.util.Log; @@ -35,7 +32,6 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { setProxy(proxy); enableRegister(enableRegister); ownPtr=true; - Log.w(LinphoneService.TAG, "route ["+route+"] not used yet"); } protected LinphoneProxyConfigImpl(long aNativePtr) { nativePtr = aNativePtr; From 299b7c95c342533a776358f44780c18ba2bedb02 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 9 Nov 2010 09:29:06 +0100 Subject: [PATCH 032/288] Cleanup --- tutorials/TutorialBuddyStatusActivity.java | 2 +- tutorials/TutorialChatRoomActivity.java | 2 +- tutorials/TutorialHelloWorldActivity.java | 2 +- tutorials/TutorialRegistrationActivity.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/TutorialBuddyStatusActivity.java b/tutorials/TutorialBuddyStatusActivity.java index 376afadfb..d42607d16 100644 --- a/tutorials/TutorialBuddyStatusActivity.java +++ b/tutorials/TutorialBuddyStatusActivity.java @@ -36,7 +36,7 @@ import android.widget.TextView; */ public class TutorialBuddyStatusActivity extends Activity { - private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private static final String defaultSipAddress = "sip:"; private TextView sipAddressWidget; private TutorialBuddyStatus tutorial; private Handler mHandler = new Handler() ; diff --git a/tutorials/TutorialChatRoomActivity.java b/tutorials/TutorialChatRoomActivity.java index aa4623eeb..f7dab4ce7 100644 --- a/tutorials/TutorialChatRoomActivity.java +++ b/tutorials/TutorialChatRoomActivity.java @@ -36,7 +36,7 @@ import android.widget.TextView; */ public class TutorialChatRoomActivity extends Activity { - private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private static final String defaultSipAddress = "sip:"; private TextView sipAddressWidget; private TutorialChatRoom tutorial; private Handler mHandler = new Handler() ; diff --git a/tutorials/TutorialHelloWorldActivity.java b/tutorials/TutorialHelloWorldActivity.java index 3ef643a61..60bd872c7 100644 --- a/tutorials/TutorialHelloWorldActivity.java +++ b/tutorials/TutorialHelloWorldActivity.java @@ -36,7 +36,7 @@ import android.widget.TextView; */ public class TutorialHelloWorldActivity extends Activity { - private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private static final String defaultSipAddress = "sip:"; private TextView sipAddressWidget; private TutorialHelloWorld tutorial; private Handler mHandler = new Handler() ; diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java index 4da10f632..d87446140 100644 --- a/tutorials/TutorialRegistrationActivity.java +++ b/tutorials/TutorialRegistrationActivity.java @@ -35,8 +35,8 @@ import android.widget.TextView; */ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { - private static final String defaultSipAddress = "sip:8182449901ip@mty11.axtel.net"; - private static final String defaultSipPassword = "49901"; + private static final String defaultSipAddress = "sip:"; + private static final String defaultSipPassword = ""; private TextView sipAddressWidget; private TextView sipPasswordWidget; private TutorialRegistration tutorial; From c909af1791c901c7ea656273b978f26c9a40f061 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Nov 2010 09:01:59 +0100 Subject: [PATCH 033/288] add video call activity still to be debugged --- AndroidVideoWindowImpl.java | 2 +- LinphoneCoreImpl.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index f1927e184..2bba92d72 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -9,7 +9,7 @@ import android.view.SurfaceView; import android.view.Surface.OutOfResourcesException; import android.view.SurfaceHolder.Callback; -public class AndroidVideoWindowImpl implements VideoWindow { +public class AndroidVideoWindowImpl implements Object { private Bitmap mBitmap; private SurfaceView mView; private Surface mSurface; diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 657cdc407..e8d13a4cd 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -22,6 +22,8 @@ import java.io.File; import java.io.IOException; import java.util.Vector; +import android.view.SurfaceView; + class LinphoneCoreImpl implements LinphoneCore { @@ -71,6 +73,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native void addFriend(long nativePtr,long friend); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); 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 { mListener=listener; @@ -296,10 +301,10 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneChatRoom createChatRoom(String to) { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } - public void setPreviewWindow(VideoWindow w) { + public void setPreviewWindow(Object w) { if (mPreviewWindow!=null) mPreviewWindow.setListener(null); - mPreviewWindow=(AndroidVideoWindowImpl)w; + mPreviewWindow=new AndroidVideoWindowImpl((SurfaceView)w); mPreviewWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { setPreviewWindowId(nativePtr,null); @@ -310,7 +315,7 @@ class LinphoneCoreImpl implements LinphoneCore { } }); } - public void setVideoWindow(VideoWindow w) { + public void setVideoWindow(Object w) { if (mVideoWindow!=null) mVideoWindow.setListener(null); 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); + } } From aa8101f5bfc895e959857cac952c51f394639a9f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Nov 2010 09:52:56 +0100 Subject: [PATCH 034/288] fix video view --- AndroidVideoWindowImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 2bba92d72..2bb4314f5 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -9,7 +9,7 @@ import android.view.SurfaceView; import android.view.Surface.OutOfResourcesException; import android.view.SurfaceHolder.Callback; -public class AndroidVideoWindowImpl implements Object { +public class AndroidVideoWindowImpl { private Bitmap mBitmap; private SurfaceView mView; private Surface mSurface; From ec2fd191a8bdc04572f5b417a2d64d456c902054 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 12 Nov 2010 14:11:50 +0100 Subject: [PATCH 035/288] Fixed wrong cast --- LinphoneCoreImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index e8d13a4cd..da53636bc 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -318,7 +318,7 @@ class LinphoneCoreImpl implements LinphoneCore { public void setVideoWindow(Object w) { if (mVideoWindow!=null) mVideoWindow.setListener(null); - mVideoWindow=(AndroidVideoWindowImpl)w; + mVideoWindow=new AndroidVideoWindowImpl((SurfaceView) w); mVideoWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { setVideoWindowId(nativePtr,null); From e9b5957dc3c0660059dc6e2e326fa0e9ccb5475d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 12 Nov 2010 14:16:01 +0100 Subject: [PATCH 036/288] Draft for Android video capture. --- AndroidCameraRecord.java | 127 ++++++++++++++++++++++++++++ AndroidCameraRecordImpl.java | 49 +++++++++++ tutorials/JavaCameraRecordImpl.java | 69 +++++++++++++++ tutorials/TestVideoActivity.java | 70 +++++++++++++++ 4 files changed, 315 insertions(+) create mode 100644 AndroidCameraRecord.java create mode 100644 AndroidCameraRecordImpl.java create mode 100644 tutorials/JavaCameraRecordImpl.java create mode 100644 tutorials/TestVideoActivity.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java new file mode 100644 index 000000000..ae07c6d56 --- /dev/null +++ b/AndroidCameraRecord.java @@ -0,0 +1,127 @@ +/* +AndroidCameraRecordImpl.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; + +import android.hardware.Camera; +import android.hardware.Camera.PreviewCallback; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; + + +public abstract class AndroidCameraRecord implements SurfaceHolder.Callback { + + protected Camera camera; + private static SurfaceView surfaceView; // should be initialized first... + protected int rate; + private int visibility = SurfaceView.GONE; // Automatically hidden + private boolean visibilityChangeable = false; + + protected final SurfaceView getSurfaceView() { + return surfaceView; + } + + /** + * AndroidCameraRecord.setSurfaceView() should be called first. + * @param rate + */ + public AndroidCameraRecord(int rate) { + camera=Camera.open(); + SurfaceHolder holder = surfaceView.getHolder(); + holder.addCallback(this); + + this.rate = rate; + } + + + /** + * AndroidCameraRecord.setSurfaceView() should be called first. + * @param rate + * @param visilibity + */ + public AndroidCameraRecord(int rate, int visilibity) { + this(rate); + this.visibility = visilibity; + } + + + public void surfaceCreated(SurfaceHolder holder) { + try { + camera.setPreviewDisplay(holder); + } + catch (Throwable t) { + Log.e("PictureDemo-surfaceCallback", "Exception in setPreviewDisplay()", t); + } + + + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + Camera.Parameters parameters=camera.getParameters(); + + parameters.setPreviewSize(width, height); + parameters.setPreviewFrameRate(rate); + camera.setParameters(parameters); + + camera.startPreview(); + + visibilityChangeable = true; + if (surfaceView.getVisibility() != visibility) { + updateVisibility(); + } + + } + + public void surfaceDestroyed(SurfaceHolder holder) { + camera.stopPreview(); + camera.release(); + camera=null; + } + + public void setPreviewCallBack(PreviewCallback cb) { + camera.setPreviewCallback(cb); + } + + private void updateVisibility() { + if (!visibilityChangeable) { + throw new IllegalStateException("Visilibity not changeable now"); + } + + surfaceView.setVisibility(visibility); + } + + public void setVisibility(int visibility) { + if (visibility == this.visibility) return; + + this.visibility = visibility; + updateVisibility(); + } + + public static final void setSurfaceView(SurfaceView sv) { + AndroidCameraRecord.surfaceView = sv; + } + + + /** + * Hook to add back a buffer for reuse in capture. + * Override in a version supporting addPreviewCallBackWithBuffer() + * @param buffer buffer to reuse + */ + public void addBackCaptureBuffer(byte[] buffer) {} +} diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java new file mode 100644 index 000000000..c9173d1da --- /dev/null +++ b/AndroidCameraRecordImpl.java @@ -0,0 +1,49 @@ +/* +AndroidCameraRecordImpl.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; + +import android.hardware.Camera; +import android.hardware.Camera.PreviewCallback; +import android.util.Log; + +/** + * Record from Android camera. + * + * @author Guillaume Beraudo + * + */ +public class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { + + private long filterCtxPtr; + + public AndroidCameraRecordImpl(long filterCtxPtr, int rate) { + super(rate); + this.filterCtxPtr = filterCtxPtr; + setPreviewCallBack(this); + } + + + private native void putImage(long filterCtxPtr, byte[] buffer); + + public void onPreviewFrame(byte[] data, Camera camera) { + Log.d("onPreviewFrame: ", Integer.toString(data.length)); + putImage(filterCtxPtr, data); + } + +} diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java new file mode 100644 index 000000000..45499db78 --- /dev/null +++ b/tutorials/JavaCameraRecordImpl.java @@ -0,0 +1,69 @@ +/* +JavaCameraRecordImpl.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.tutorials; + +import org.linphone.core.AndroidCameraRecord; + +import android.hardware.Camera; +import android.hardware.Camera.PreviewCallback; +import android.util.Log; +import android.widget.TextView; + +public class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { + + private TextView debug; + private long count = 0; + private float averageCalledRate; + private int averageWindowSize = 2 * rate; + + private long startTime; + private long endTime; + + + public JavaCameraRecordImpl(int rate) { + super(rate); + setPreviewCallBack(this); + } + + public JavaCameraRecordImpl(int rate, int visilibity) { + super(rate, visilibity); + setPreviewCallBack(this); + } + + public void setDebug(TextView debug) { + this.debug = debug; + } + + public void onPreviewFrame(byte[] data, Camera camera) { + + if ((count % averageWindowSize) == 0) { + endTime = System.currentTimeMillis(); + averageCalledRate = (100000 * averageWindowSize) / (endTime - startTime); + averageCalledRate /= 100f; + startTime = endTime; + } + + count++; + + String msg = "Frame " + count + ": " + data.length + "bytes (avg="+averageCalledRate+"frames/s)"; + if (debug != null) debug.setText(msg); + Log.d("onPreviewFrame:", msg); + } + +} diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java new file mode 100644 index 000000000..6526e1cce --- /dev/null +++ b/tutorials/TestVideoActivity.java @@ -0,0 +1,70 @@ +/* +TutorialHelloWorldActivity.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.tutorials; + +import org.linphone.R; +import org.linphone.core.AndroidCameraRecord; + +import android.app.Activity; +import android.os.Bundle; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.widget.TextView; + +/** + * Activity for displaying and starting the HelloWorld example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TestVideoActivity extends Activity { + + private SurfaceView surfaceView; + private static final int rate = 15; + + + + + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.videotest); + + surfaceView=(SurfaceView)findViewById(R.id.videotest_surfaceView); + + SurfaceHolder holder=surfaceView.getHolder(); + holder.setFixedSize(320, 240); + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + + AndroidCameraRecord.setSurfaceView(surfaceView); + + JavaCameraRecordImpl manager = new JavaCameraRecordImpl(rate, SurfaceView.VISIBLE); + manager.setDebug((TextView) findViewById(R.id.videotest_debug)); + + } + + + + + + +} From d047b7aabd677fd48963f4166388abb86d15678e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sun, 14 Nov 2010 19:15:27 +0100 Subject: [PATCH 037/288] bugfixes and makefile improvements --- AndroidVideoWindowImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 2bb4314f5..87e1dc525 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -28,8 +28,9 @@ public class AndroidVideoWindowImpl { int width, int height) { synchronized(AndroidVideoWindowImpl.this){ mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); - if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); mSurface=holder.getSurface(); + if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); + } } @@ -38,10 +39,10 @@ public class AndroidVideoWindowImpl { public void surfaceDestroyed(SurfaceHolder holder) { synchronized(AndroidVideoWindowImpl.this){ - mBitmap=null; if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); mSurface=null; + mBitmap=null; } } }); From 97144546e2c1f0263576ae8e792a3f68a8b1bfec Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 15 Nov 2010 19:19:32 +0100 Subject: [PATCH 038/288] fix video deadlock and double instanciation of VideoActivity --- AndroidVideoWindowImpl.java | 11 +++++++---- LinphoneCoreImpl.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 87e1dc525..efac2d826 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -3,6 +3,7 @@ package org.linphone.core; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Bitmap.Config; +import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -14,6 +15,7 @@ public class AndroidVideoWindowImpl { private SurfaceView mView; private Surface mSurface; private VideoWindowListener mListener; + static private String TAG = "Linphone"; public static interface VideoWindowListener{ void onSurfaceReady(AndroidVideoWindowImpl vw); void onSurfaceDestroyed(AndroidVideoWindowImpl vw); @@ -26,12 +28,12 @@ public class AndroidVideoWindowImpl { view.getHolder().addCallback(new Callback(){ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + Log.i(TAG,"Surface is being changed."); synchronized(AndroidVideoWindowImpl.this){ mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); mSurface=holder.getSurface(); - if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); - } + if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); } public void surfaceCreated(SurfaceHolder holder) { @@ -39,11 +41,11 @@ public class AndroidVideoWindowImpl { public void surfaceDestroyed(SurfaceHolder holder) { synchronized(AndroidVideoWindowImpl.this){ - if (mListener!=null) - mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); mSurface=null; mBitmap=null; } + if (mListener!=null) + mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); } }); } @@ -74,3 +76,4 @@ public class AndroidVideoWindowImpl { } } } + diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index da53636bc..c96373cb8 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -75,7 +75,7 @@ class LinphoneCoreImpl implements LinphoneCore { 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); - + private static String TAG = "LinphoneCore"; LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; From b7886ab9a70f7875c9d6e70663140334416ec4ac Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 17 Nov 2010 10:44:39 +0100 Subject: [PATCH 039/288] fix crash on simulator --- LinphoneCoreImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 83a78a00e..775a83895 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -292,14 +292,22 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneChatRoom createChatRoom(String to) { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } - public void setPreviewWindow(VideoWindow w) { + public void setPreviewWindow(Object w) { throw new RuntimeException("not implemented yet"); // TODO Auto-generated method stub } - public void setVideoWindow(VideoWindow w) { + public void setVideoWindow(Object w) { throw new RuntimeException("not implemented yet"); // TODO Auto-generated method stub } + public void enableVideo(boolean vcap_enabled, boolean display_enabled) { + // TODO Auto-generated method stub + + } + public boolean isVideoEnabled() { + // TODO Auto-generated method stub + return false; + } } From 37842c4b7cb6158a464eaf03542b22276a4e1f19 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 17 Nov 2010 15:52:42 +0100 Subject: [PATCH 040/288] First working Android video version. --- AndroidCameraRecord.java | 230 ++++++++++++++++++++------- AndroidCameraRecordBufferedImpl.java | 69 ++++++++ AndroidCameraRecordImpl.java | 55 ++++++- tutorials/JavaCameraRecordImpl.java | 15 +- tutorials/TestVideoActivity.java | 19 +-- 5 files changed, 302 insertions(+), 86 deletions(-) create mode 100644 AndroidCameraRecordBufferedImpl.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index ae07c6d56..6ebce9856 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -19,102 +19,176 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import android.hardware.Camera; +import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.PreviewCallback; +import android.os.Build; +import android.os.Handler; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.SurfaceHolder.Callback; -public abstract class AndroidCameraRecord implements SurfaceHolder.Callback { +public abstract class AndroidCameraRecord { + + public static final int ANDROID_VERSION = Integer.parseInt(Build.VERSION.SDK); + protected static Camera camera; + private static SurfaceView surfaceView; + + protected int fps; + protected int height; + protected int width; + private int longTermVisibility; - protected Camera camera; - private static SurfaceView surfaceView; // should be initialized first... - protected int rate; - private int visibility = SurfaceView.GONE; // Automatically hidden private boolean visibilityChangeable = false; + private PreviewCallback storedPreviewCallback; - protected final SurfaceView getSurfaceView() { - return surfaceView; + private static AndroidCameraRecord instance; + private static Handler handler; + private static boolean previewStarted; + + public AndroidCameraRecord() { + // TODO check if another instance is loaded and kill it. + instance = this; } - /** - * AndroidCameraRecord.setSurfaceView() should be called first. - * @param rate + public void setParameters(int height, int width, float fps, boolean hide) { + this.fps = Math.round(fps); + this.height = height; + this.width = width; + this.longTermVisibility = hide ? SurfaceView.GONE : SurfaceView.VISIBLE; + + if (surfaceView != null) { + Log.d("Linphone", "Surfaceview defined and ready; starting video capture"); + instance.startPreview(); + } else { + Log.w("Linphone", "Surfaceview not defined; postponning video capture"); + } + } + + /* + * AndroidCameraRecord.setSurfaceView() should be called first, from the Activity code. + * It will start automatically */ - public AndroidCameraRecord(int rate) { + private void startPreview() { + assert surfaceView != null; + + if (previewStarted) { + Log.w("Linphone", "Already started"); + return; + } + + if (surfaceView.getVisibility() != SurfaceView.VISIBLE) { + // Illegal state + Log.e("Linphone", "Illegal state: video capture surface view is not visible"); + return; + } + + camera=Camera.open(); + camera.setErrorCallback(new ErrorCallback() { + public void onError(int error, Camera camera) { + Log.e("Linphone", "Camera error : " + error); + } + }); + + + Camera.Parameters parameters=camera.getParameters(); + + parameters.setPreviewSize(width, height); + parameters.setPreviewFrameRate(fps); + camera.setParameters(parameters); + + SurfaceHolder holder = surfaceView.getHolder(); - holder.addCallback(this); - - this.rate = rate; - } - - - /** - * AndroidCameraRecord.setSurfaceView() should be called first. - * @param rate - * @param visilibity - */ - public AndroidCameraRecord(int rate, int visilibity) { - this(rate); - this.visibility = visilibity; - } - - - public void surfaceCreated(SurfaceHolder holder) { try { camera.setPreviewDisplay(holder); } catch (Throwable t) { - Log.e("PictureDemo-surfaceCallback", "Exception in setPreviewDisplay()", t); + Log.e("Linphone", "Exception in Video capture setPreviewDisplay()", t); } - } + try { + camera.startPreview(); + previewStarted = true; + } catch (Throwable e) { + Log.e("Linphone", "Can't start camera preview"); + } - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Camera.Parameters parameters=camera.getParameters(); + previewStarted = true; - parameters.setPreviewSize(width, height); - parameters.setPreviewFrameRate(rate); - camera.setParameters(parameters); - - camera.startPreview(); + + + // Register callback to get capture buffer + if (storedPreviewCallback != null) { + reallySetPreviewCallback(camera, storedPreviewCallback); + } + visibilityChangeable = true; - if (surfaceView.getVisibility() != visibility) { + if (surfaceView.getVisibility() != longTermVisibility) { updateVisibility(); } - + + onCameraStarted(camera); } + - public void surfaceDestroyed(SurfaceHolder holder) { - camera.stopPreview(); - camera.release(); - camera=null; - } - public void setPreviewCallBack(PreviewCallback cb) { - camera.setPreviewCallback(cb); - } - private void updateVisibility() { - if (!visibilityChangeable) { - throw new IllegalStateException("Visilibity not changeable now"); + /** + * Hook. + * @param camera + */ + public void onCameraStarted(Camera camera) {} + + public void setOrStorePreviewCallBack(PreviewCallback cb) { + if (camera == null) { + Log.w("Linphone", "Capture camera not ready, storing callback"); + this.storedPreviewCallback = cb; + return; } - - surfaceView.setVisibility(visibility); + + reallySetPreviewCallback(camera, cb); } - public void setVisibility(int visibility) { - if (visibility == this.visibility) return; - this.visibility = visibility; - updateVisibility(); - } + + public static final void setSurfaceView(final SurfaceView sv, Handler mHandler) { + AndroidCameraRecord.handler = mHandler; + SurfaceHolder holder = sv.getHolder(); + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - public static final void setSurfaceView(SurfaceView sv) { - AndroidCameraRecord.surfaceView = sv; + holder.addCallback(new Callback() { + public void surfaceDestroyed(SurfaceHolder holder) { + AndroidCameraRecord.surfaceView = null; + + if (camera == null) { + Log.e("AndroidCameraRecord.surfaceDestroyed", "illegal state"); + return; + } + camera.setPreviewCallback(null); // TODO check if used whatever the SDK version + camera.stopPreview(); + camera.release(); + camera=null; + previewStarted = false; + Log.w("Linphone", "The video capture Surface view has been destroyed"); + } + + public void surfaceCreated(SurfaceHolder holder) { + AndroidCameraRecord.surfaceView = sv; + + if (instance != null) { + instance.startPreview(); + } + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + // Do nothing + } + }); } @@ -124,4 +198,40 @@ public abstract class AndroidCameraRecord implements SurfaceHolder.Callback { * @param buffer buffer to reuse */ public void addBackCaptureBuffer(byte[] buffer) {} + + + + private void updateVisibility() { + if (!visibilityChangeable) { + throw new IllegalStateException("Visilibity not changeable now"); + } + + handler.post(new Runnable() { + public void run() { + Log.d("Linphone", "Changing video capture surface view visibility :" + longTermVisibility); + surfaceView.setVisibility(longTermVisibility); + } + }); + } + + public void setVisibility(int visibility) { + if (visibility == this.longTermVisibility) return; + + this.longTermVisibility = visibility; + updateVisibility(); + } + + + public void stopCaptureCallback() { + if (camera != null) { + reallySetPreviewCallback(camera, null); + } + } + + protected void reallySetPreviewCallback(Camera camera, PreviewCallback cb) { + camera.setPreviewCallback(cb); + } + } + + diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java new file mode 100644 index 000000000..c65f479ad --- /dev/null +++ b/AndroidCameraRecordBufferedImpl.java @@ -0,0 +1,69 @@ +/* +AndroidCameraRecord8Impl.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; + +import android.hardware.Camera; +import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.Size; +import android.util.Log; + +/** + * + * Android >= 8 (2.2) version. + * @author Guillaume Beraudo + * + */ +public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { + + public AndroidCameraRecordBufferedImpl(long filterCtxPtr) { + super(filterCtxPtr); + } + + @Override + protected void reallySetPreviewCallback(Camera camera, PreviewCallback cb) { + Log.d("Linphone", "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); + camera.setPreviewCallbackWithBuffer(cb); + } + + @Override + public void addBackCaptureBuffer(byte[] buffer) { + camera.addCallbackBuffer(buffer); + } + + @Override + public void onCameraStarted(Camera camera) { + super.onCameraStarted(camera); + + Size s = camera.getParameters().getPreviewSize(); + int wishedBufferSize = s.height * s.width * 3 / 2; + + camera.addCallbackBuffer(new byte[wishedBufferSize]); + camera.addCallbackBuffer(new byte[wishedBufferSize]); +/* + for (int i=1; i < 30; i++) { + camera.addCallbackBuffer(new byte[wishedBufferSize]); + }*/ + } + + @Override + protected void badBufferLengthReceived(byte[] buffer, int expectedBufferLength) { + super.badBufferLengthReceived(buffer, expectedBufferLength); + addBackCaptureBuffer(buffer); + } +} diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index c9173d1da..aab29a183 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -20,6 +20,7 @@ package org.linphone.core; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.Size; import android.util.Log; /** @@ -31,19 +32,63 @@ import android.util.Log; public class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { private long filterCtxPtr; + private double timeElapsedBetweenFrames = 0; + private long lastFrameTime = 0; - public AndroidCameraRecordImpl(long filterCtxPtr, int rate) { - super(rate); - this.filterCtxPtr = filterCtxPtr; - setPreviewCallBack(this); + public AndroidCameraRecordImpl(long filterCtxPtr) { + super(); + + try { + this.filterCtxPtr = filterCtxPtr; + setOrStorePreviewCallBack(this); + } catch (Throwable e) { + Log.e("Linphone", "Error"); + } + } private native void putImage(long filterCtxPtr, byte[] buffer); + public void onPreviewFrame(byte[] data, Camera camera) { - Log.d("onPreviewFrame: ", Integer.toString(data.length)); + if (data == null) { + Log.e("Linphone", "onPreviewFrame Called with null buffer"); + return; + } + + Size s = camera.getParameters().getPreviewSize(); + int expectedBuffLength = s.width * s.height * 3 /2; + if (expectedBuffLength != data.length) { + badBufferLengthReceived(data, expectedBuffLength); + return; + } + + long curTime = System.currentTimeMillis(); + if (lastFrameTime == 0) { + lastFrameTime = curTime; + putImage(filterCtxPtr, data); + return; + } + + double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; + if (1 / currentTimeElapsed > fps) { +// Log.d("Linphone", "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); + addBackCaptureBuffer(data); + return; + } + lastFrameTime = curTime; + timeElapsedBetweenFrames = currentTimeElapsed; + + // Log.d("onPreviewFrame: ", Integer.toString(data.length)); putImage(filterCtxPtr, data); } + + // Hook + protected void badBufferLengthReceived(byte[] data, int expectedBuffLength) { + Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + + " whereas expected is " + expectedBuffLength + " don't calling putImage"); + } + } diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index 45499db78..30c1838f6 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -30,21 +30,16 @@ public class JavaCameraRecordImpl extends AndroidCameraRecord implements Preview private TextView debug; private long count = 0; private float averageCalledRate; - private int averageWindowSize = 2 * rate; private long startTime; private long endTime; - public JavaCameraRecordImpl(int rate) { - super(rate); - setPreviewCallBack(this); + public JavaCameraRecordImpl() { + super(); + setOrStorePreviewCallBack(this); } - public JavaCameraRecordImpl(int rate, int visilibity) { - super(rate, visilibity); - setPreviewCallBack(this); - } public void setDebug(TextView debug) { this.debug = debug; @@ -52,9 +47,9 @@ public class JavaCameraRecordImpl extends AndroidCameraRecord implements Preview public void onPreviewFrame(byte[] data, Camera camera) { - if ((count % averageWindowSize) == 0) { + if ((count % 2 * fps) == 0) { endTime = System.currentTimeMillis(); - averageCalledRate = (100000 * averageWindowSize) / (endTime - startTime); + averageCalledRate = (100000 * 2 * fps) / (endTime - startTime); averageCalledRate /= 100f; startTime = endTime; } diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index 6526e1cce..e016cad25 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -23,7 +23,7 @@ import org.linphone.core.AndroidCameraRecord; import android.app.Activity; import android.os.Bundle; -import android.view.SurfaceHolder; +import android.os.Handler; import android.view.SurfaceView; import android.widget.TextView; @@ -36,14 +36,11 @@ import android.widget.TextView; public class TestVideoActivity extends Activity { private SurfaceView surfaceView; - private static final int rate = 15; + private static final int rate = 7; - - - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -51,14 +48,14 @@ public class TestVideoActivity extends Activity { surfaceView=(SurfaceView)findViewById(R.id.videotest_surfaceView); - SurfaceHolder holder=surfaceView.getHolder(); - holder.setFixedSize(320, 240); - holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); +// SurfaceHolder holder=surfaceView.getHolder(); +// holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - AndroidCameraRecord.setSurfaceView(surfaceView); + AndroidCameraRecord.setSurfaceView(surfaceView, new Handler()); - JavaCameraRecordImpl manager = new JavaCameraRecordImpl(rate, SurfaceView.VISIBLE); - manager.setDebug((TextView) findViewById(R.id.videotest_debug)); + JavaCameraRecordImpl recorder = new JavaCameraRecordImpl(); + recorder.setDebug((TextView) findViewById(R.id.videotest_debug)); + recorder.setParameters(288, 352, rate, false); } From a79e8f7f9e79169bc8d15e953dfc1fc40df05d51 Mon Sep 17 00:00:00 2001 From: guillaume Date: Thu, 18 Nov 2010 15:01:15 +0100 Subject: [PATCH 041/288] addbackbuffer managed directly in java code --- AndroidCameraRecord.java | 8 -------- AndroidCameraRecordBufferedImpl.java | 11 +++-------- AndroidCameraRecordImpl.java | 9 ++------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 6ebce9856..17d9f8f9a 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -192,14 +192,6 @@ public abstract class AndroidCameraRecord { } - /** - * Hook to add back a buffer for reuse in capture. - * Override in a version supporting addPreviewCallBackWithBuffer() - * @param buffer buffer to reuse - */ - public void addBackCaptureBuffer(byte[] buffer) {} - - private void updateVisibility() { if (!visibilityChangeable) { diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index c65f479ad..715f17765 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -41,11 +41,6 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { camera.setPreviewCallbackWithBuffer(cb); } - @Override - public void addBackCaptureBuffer(byte[] buffer) { - camera.addCallbackBuffer(buffer); - } - @Override public void onCameraStarted(Camera camera) { super.onCameraStarted(camera); @@ -62,8 +57,8 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { } @Override - protected void badBufferLengthReceived(byte[] buffer, int expectedBufferLength) { - super.badBufferLengthReceived(buffer, expectedBufferLength); - addBackCaptureBuffer(buffer); + public void onPreviewFrame(byte[] data, Camera camera) { + super.onPreviewFrame(data, camera); + camera.addCallbackBuffer(data); } } diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index aab29a183..6186e458a 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -60,7 +60,8 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev Size s = camera.getParameters().getPreviewSize(); int expectedBuffLength = s.width * s.height * 3 /2; if (expectedBuffLength != data.length) { - badBufferLengthReceived(data, expectedBuffLength); + Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + + " whereas expected is " + expectedBuffLength + " don't calling putImage"); return; } @@ -74,7 +75,6 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; if (1 / currentTimeElapsed > fps) { // Log.d("Linphone", "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); - addBackCaptureBuffer(data); return; } lastFrameTime = curTime; @@ -85,10 +85,5 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev } - // Hook - protected void badBufferLengthReceived(byte[] data, int expectedBuffLength) { - Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length - + " whereas expected is " + expectedBuffLength + " don't calling putImage"); - } } From ae34456f2ad9ade1ed2922f42620132cb66e4d69 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 19 Nov 2010 11:42:46 +0100 Subject: [PATCH 042/288] fix for display --- LinphoneCoreImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index c96373cb8..99be0fb2b 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -335,5 +335,4 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isVideoEnabled() { return isVideoEnabled(nativePtr); } - } From 7d71181e174154330812743542812e49c1db67f3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 19 Nov 2010 16:40:29 +0100 Subject: [PATCH 043/288] add stun preference --- LinphoneCoreImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 99be0fb2b..1f389a608 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -69,12 +69,16 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setPreviewWindowId(long nativePtr, Object wid); private AndroidVideoWindowImpl mVideoWindow; private AndroidVideoWindowImpl mPreviewWindow; - private native void addFriend(long nativePtr,long friend); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); 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); + private native void setFirewallPolicy(long nativePtr, int enum_value); + private native int getFirewallPolicy(long nativePtr); + private native void setStunServer(long nativePtr, String stun_server); + private native String getStunServer(long nativePtr); + private static String TAG = "LinphoneCore"; LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -335,4 +339,16 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isVideoEnabled() { return isVideoEnabled(nativePtr); } + public FirewallPolicy getFirewallPolicy() { + return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr)); + } + public String getStunServer() { + return getStunServer(nativePtr); + } + public void setFirewallPolicy(FirewallPolicy pol) { + setFirewallPolicy(nativePtr,pol.value()); + } + public void setStunServer(String stunServer) { + setStunServer(nativePtr,stunServer); + } } From 2300dfa730ee2fbfb7b8407922445ad1df575174 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 22 Nov 2010 11:23:43 +0100 Subject: [PATCH 044/288] Added Orientation change support and video capture preview --- AndroidCameraRecord.java | 23 ++++++++++++++++++++--- AndroidCameraRecordImpl.java | 6 +++--- AndroidVideoWindowImpl.java | 5 ++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 17d9f8f9a..df6a395ea 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -46,6 +46,7 @@ public abstract class AndroidCameraRecord { private static AndroidCameraRecord instance; private static Handler handler; private static boolean previewStarted; + private static int orientationCode; public AndroidCameraRecord() { // TODO check if another instance is loaded and kill it. @@ -66,6 +67,7 @@ public abstract class AndroidCameraRecord { } } + /* * AndroidCameraRecord.setSurfaceView() should be called first, from the Activity code. * It will start automatically @@ -97,9 +99,14 @@ public abstract class AndroidCameraRecord { parameters.setPreviewSize(width, height); parameters.setPreviewFrameRate(fps); +// parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_EDOF); camera.setParameters(parameters); + camera.setDisplayOrientation(90 * orientationCode); +// parameters.setRotation() + + SurfaceHolder holder = surfaceView.getHolder(); try { camera.setPreviewDisplay(holder); @@ -165,7 +172,7 @@ public abstract class AndroidCameraRecord { AndroidCameraRecord.surfaceView = null; if (camera == null) { - Log.e("AndroidCameraRecord.surfaceDestroyed", "illegal state"); + Log.e("Linphone", "Video capture: illegal state: surface destroyed but camera is already null"); return; } camera.setPreviewCallback(null); // TODO check if used whatever the SDK version @@ -173,20 +180,23 @@ public abstract class AndroidCameraRecord { camera.release(); camera=null; previewStarted = false; - Log.w("Linphone", "The video capture Surface view has been destroyed"); + Log.w("Linphone", "Video capture Surface destroyed"); } public void surfaceCreated(SurfaceHolder holder) { AndroidCameraRecord.surfaceView = sv; + Log.w("Linphone", "Video capture surface created"); if (instance != null) { instance.startPreview(); } + + holder.isCreating(); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - // Do nothing + Log.w("Linphone", "Video capture surface changed"); } }); } @@ -223,7 +233,14 @@ public abstract class AndroidCameraRecord { protected void reallySetPreviewCallback(Camera camera, PreviewCallback cb) { camera.setPreviewCallback(cb); } + + public static void setOrientationCode(int orientation) { + AndroidCameraRecord.orientationCode = (4 + 1 - orientation) % 4; + } + protected int getOrientationCode() { + return orientationCode; + } } diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index 6186e458a..db4e128de 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -48,7 +48,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev } - private native void putImage(long filterCtxPtr, byte[] buffer); + private native void putImage(long filterCtxPtr, byte[] buffer, int orientation); public void onPreviewFrame(byte[] data, Camera camera) { @@ -68,7 +68,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; - putImage(filterCtxPtr, data); + putImage(filterCtxPtr, data, getOrientationCode()); return; } @@ -81,7 +81,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev timeElapsedBetweenFrames = currentTimeElapsed; // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data); + putImage(filterCtxPtr, data, getOrientationCode()); } diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index efac2d826..ca9968e4c 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -34,9 +34,11 @@ public class AndroidVideoWindowImpl { mSurface=holder.getSurface(); } if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); + Log.w("Linphone", "Video display surface changed"); } - public void surfaceCreated(SurfaceHolder holder) { + public void surfaceCreated(SurfaceHolder holder) { + Log.w("Linphone", "Video display surface created"); } public void surfaceDestroyed(SurfaceHolder holder) { @@ -46,6 +48,7 @@ public class AndroidVideoWindowImpl { } if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); + Log.w("Linphone", "Video display surface destroyed"); } }); } From 405d0b06ab9228789ea99f83e28854636c3ad051 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 22 Nov 2010 17:20:11 +0100 Subject: [PATCH 045/288] Added focus support. Rotation functinonal. --- AndroidCameraRecord.java | 25 ++++++++++++++++++++----- AndroidCameraRecordBufferedImpl.java | 10 ++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index df6a395ea..4137192ba 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -20,6 +20,7 @@ package org.linphone.core; import android.hardware.Camera; import android.hardware.Camera.ErrorCallback; +import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.os.Build; import android.os.Handler; @@ -46,7 +47,7 @@ public abstract class AndroidCameraRecord { private static AndroidCameraRecord instance; private static Handler handler; private static boolean previewStarted; - private static int orientationCode; + protected static int orientationCode; public AndroidCameraRecord() { // TODO check if another instance is loaded and kill it. @@ -99,11 +100,21 @@ public abstract class AndroidCameraRecord { parameters.setPreviewSize(width, height); parameters.setPreviewFrameRate(fps); -// parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_EDOF); - camera.setParameters(parameters); - camera.setDisplayOrientation(90 * orientationCode); -// parameters.setRotation() + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { + Log.w("Linphone", "Auto Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); + } else { + Log.w("Linphone", "Auto Focus not supported by camera device"); + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { + Log.w("Linphone", "Infinity Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); + } else { + Log.w("Linphone", "Infinity Focus not supported by camera device"); + } + } + onSettingParameters(parameters); + camera.setParameters(parameters); @@ -144,6 +155,10 @@ public abstract class AndroidCameraRecord { + protected void onSettingParameters(Parameters parameters) { + + } + /** * Hook. * @param camera diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index 715f17765..886ad222e 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import android.hardware.Camera; +import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; import android.util.Log; @@ -61,4 +62,13 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { super.onPreviewFrame(data, camera); camera.addCallbackBuffer(data); } + + @Override + protected void onSettingParameters(Parameters parameters) { + super.onSettingParameters(parameters); + // Only on v8 hardware + camera.setDisplayOrientation(90 * orientationCode); + } + + } From c505024cc79e7e9fe902cd983462d3fb8b0e516a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 23 Nov 2010 09:27:51 +0100 Subject: [PATCH 046/288] Define getStatus(): throw not implemented exception --- LinphoneCallLogImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index b0360d194..1bdb84720 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -42,5 +42,8 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public LinphoneAddress getTo() { return new LinphoneAddressImpl(getTo(nativePtr)); } + public CallStatus getStatus() { + throw new RuntimeException("not implemented yet"); + } } From dc20fb7739ea78b8ff90643ca053c770424d2e21 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 25 Nov 2010 11:13:28 +0100 Subject: [PATCH 047/288] Moved mic and speaker buttons in dialer. Added camera call button. Added video preferences. Share camera on received call according to preference settings. Invite with(out) according to preference settings. --- AndroidCameraRecord.java | 104 ++++++++++++++----------------- LinphoneCallImpl.java | 8 +++ LinphoneCallParamsImpl.java | 45 +++++++++++++ LinphoneCoreImpl.java | 32 +++++++++- tutorials/TestVideoActivity.java | 5 +- 5 files changed, 133 insertions(+), 61 deletions(-) create mode 100644 LinphoneCallParamsImpl.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 4137192ba..c16ef065d 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -23,7 +23,6 @@ import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.os.Build; -import android.os.Handler; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -39,33 +38,26 @@ public abstract class AndroidCameraRecord { protected int fps; protected int height; protected int width; - private int longTermVisibility; - - private boolean visibilityChangeable = false; private PreviewCallback storedPreviewCallback; private static AndroidCameraRecord instance; - private static Handler handler; private static boolean previewStarted; + private static boolean parametersSet; protected static int orientationCode; + private static boolean mute; + private static final String tag="Linphone"; public AndroidCameraRecord() { // TODO check if another instance is loaded and kill it. instance = this; } - public void setParameters(int height, int width, float fps, boolean hide) { + public void setParameters(int height, int width, float fps) { this.fps = Math.round(fps); this.height = height; this.width = width; - this.longTermVisibility = hide ? SurfaceView.GONE : SurfaceView.VISIBLE; - - if (surfaceView != null) { - Log.d("Linphone", "Surfaceview defined and ready; starting video capture"); - instance.startPreview(); - } else { - Log.w("Linphone", "Surfaceview not defined; postponning video capture"); - } + parametersSet = true; + startPreview(); } @@ -74,16 +66,27 @@ public abstract class AndroidCameraRecord { * It will start automatically */ private void startPreview() { - assert surfaceView != null; + if (mute) { + Log.d(tag, "Not starting preview as camera has been muted"); + return; + } + if (surfaceView == null) { + Log.w(tag, "Surfaceview not defined; postponning video capture"); + return; + } + if (!parametersSet) { + Log.w(tag, "Parameters not set; postponning video capture"); + return; + } if (previewStarted) { - Log.w("Linphone", "Already started"); + Log.w(tag, "Already started"); return; } if (surfaceView.getVisibility() != SurfaceView.VISIBLE) { // Illegal state - Log.e("Linphone", "Illegal state: video capture surface view is not visible"); + Log.e(tag, "Illegal state: video capture surface view is not visible"); return; } @@ -91,7 +94,7 @@ public abstract class AndroidCameraRecord { camera=Camera.open(); camera.setErrorCallback(new ErrorCallback() { public void onError(int error, Camera camera) { - Log.e("Linphone", "Camera error : " + error); + Log.e(tag, "Camera error : " + error); } }); @@ -101,15 +104,15 @@ public abstract class AndroidCameraRecord { parameters.setPreviewSize(width, height); parameters.setPreviewFrameRate(fps); if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { - Log.w("Linphone", "Auto Focus supported by camera device"); + Log.w(tag, "Auto Focus supported by camera device"); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); } else { - Log.w("Linphone", "Auto Focus not supported by camera device"); + Log.w(tag, "Auto Focus not supported by camera device"); if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { - Log.w("Linphone", "Infinity Focus supported by camera device"); + Log.w(tag, "Infinity Focus supported by camera device"); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); } else { - Log.w("Linphone", "Infinity Focus not supported by camera device"); + Log.w(tag, "Infinity Focus not supported by camera device"); } } @@ -123,7 +126,7 @@ public abstract class AndroidCameraRecord { camera.setPreviewDisplay(holder); } catch (Throwable t) { - Log.e("Linphone", "Exception in Video capture setPreviewDisplay()", t); + Log.e(tag, "Exception in Video capture setPreviewDisplay()", t); } @@ -131,7 +134,7 @@ public abstract class AndroidCameraRecord { camera.startPreview(); previewStarted = true; } catch (Throwable e) { - Log.e("Linphone", "Can't start camera preview"); + Log.e(tag, "Can't start camera preview"); } previewStarted = true; @@ -143,11 +146,6 @@ public abstract class AndroidCameraRecord { reallySetPreviewCallback(camera, storedPreviewCallback); } - - visibilityChangeable = true; - if (surfaceView.getVisibility() != longTermVisibility) { - updateVisibility(); - } onCameraStarted(camera); } @@ -167,7 +165,7 @@ public abstract class AndroidCameraRecord { public void setOrStorePreviewCallBack(PreviewCallback cb) { if (camera == null) { - Log.w("Linphone", "Capture camera not ready, storing callback"); + Log.w(tag, "Capture camera not ready, storing callback"); this.storedPreviewCallback = cb; return; } @@ -177,8 +175,7 @@ public abstract class AndroidCameraRecord { - public static final void setSurfaceView(final SurfaceView sv, Handler mHandler) { - AndroidCameraRecord.handler = mHandler; + public static final void setSurfaceView(final SurfaceView sv) { SurfaceHolder holder = sv.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); @@ -187,7 +184,7 @@ public abstract class AndroidCameraRecord { AndroidCameraRecord.surfaceView = null; if (camera == null) { - Log.e("Linphone", "Video capture: illegal state: surface destroyed but camera is already null"); + Log.e(tag, "Video capture: illegal state: surface destroyed but camera is already null"); return; } camera.setPreviewCallback(null); // TODO check if used whatever the SDK version @@ -195,12 +192,12 @@ public abstract class AndroidCameraRecord { camera.release(); camera=null; previewStarted = false; - Log.w("Linphone", "Video capture Surface destroyed"); + Log.w(tag, "Video capture Surface destroyed"); } public void surfaceCreated(SurfaceHolder holder) { AndroidCameraRecord.surfaceView = sv; - Log.w("Linphone", "Video capture surface created"); + Log.w(tag, "Video capture surface created"); if (instance != null) { instance.startPreview(); @@ -211,33 +208,13 @@ public abstract class AndroidCameraRecord { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.w("Linphone", "Video capture surface changed"); + Log.w(tag, "Video capture surface changed"); } }); } - private void updateVisibility() { - if (!visibilityChangeable) { - throw new IllegalStateException("Visilibity not changeable now"); - } - - handler.post(new Runnable() { - public void run() { - Log.d("Linphone", "Changing video capture surface view visibility :" + longTermVisibility); - surfaceView.setVisibility(longTermVisibility); - } - }); - } - - public void setVisibility(int visibility) { - if (visibility == this.longTermVisibility) return; - - this.longTermVisibility = visibility; - updateVisibility(); - } - public void stopCaptureCallback() { if (camera != null) { @@ -256,6 +233,21 @@ public abstract class AndroidCameraRecord { protected int getOrientationCode() { return orientationCode; } + + public static void setMuteCamera(boolean m) { + if (m == mute) return; + + mute = m; + if (mute && previewStarted) { + camera.stopPreview(); + return; + } + + if (!mute) { + instance.startPreview(); + } + + } } diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index c71883b57..4c9a770c9 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -29,6 +29,8 @@ class LinphoneCallImpl implements LinphoneCall { private native boolean isIncoming(long nativePtr); native private long getRemoteAddress(long nativePtr); native private int getState(long nativePtr); + private native long getCurrentParams(long nativePtr); + protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; ref(nativePtr); @@ -58,6 +60,12 @@ class LinphoneCallImpl implements LinphoneCall { public State getState() { return LinphoneCall.State.fromInt(getState(nativePtr)); } + public LinphoneCallParams getCurrentParamsReadOnly() { + return new LinphoneCallParamsImpl(getCurrentParams(nativePtr)); + } + public LinphoneCallParams getCurrentParamsReadWrite() { + return getCurrentParamsReadOnly().copy(); + } } diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java new file mode 100644 index 000000000..add724f21 --- /dev/null +++ b/LinphoneCallParamsImpl.java @@ -0,0 +1,45 @@ +/* +LinphoneCallParamsImpl.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; + +public class LinphoneCallParamsImpl implements LinphoneCallParams { + protected final long nativePtr; + + public LinphoneCallParamsImpl(long nativePtr) { + this.nativePtr = nativePtr; + } + + private native void enableVideo(long nativePtr, boolean b); + private native boolean getVideoEnabled(long nativePtr); + private native long copy(long nativePtr); + + + public boolean getVideoEnabled() { + return getVideoEnabled(nativePtr); + } + + public void setVideoEnalbled(boolean b) { + enableVideo(nativePtr, b); + } + + public LinphoneCallParams copy() { + return new LinphoneCallParamsImpl(copy(nativePtr)); + } + +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 1f389a608..91913e322 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -55,6 +55,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); private native long inviteAddress(long nativePtr,long to); + private native long inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); private native void sendDtmf(long nativePtr,char dtmf); private native void clearCallLogs(long nativePtr); private native boolean isMicMuted(long nativePtr); @@ -78,6 +79,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getFirewallPolicy(long nativePtr); private native void setStunServer(long nativePtr, String stun_server); private native String getStunServer(long nativePtr); + private native long createDefaultCallParams(long nativePtr); + private native int updateCall(long ptrLc, long ptrCall, long ptrParams); + private static String TAG = "LinphoneCore"; @@ -211,14 +215,15 @@ class LinphoneCoreImpl implements LinphoneCore { throw new LinphoneCoreException("Cannot interpret ["+destination+"]"); } } - public LinphoneCall invite(LinphoneAddress to) { + public LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); if (lNativePtr!=0) { return new LinphoneCallImpl(lNativePtr); } else { - return null; + throw new LinphoneCoreException("Unable to invite address " + to.asString()); } } + public void sendDtmf(char number) { sendDtmf(nativePtr,number); } @@ -351,4 +356,27 @@ class LinphoneCoreImpl implements LinphoneCore { public void setStunServer(String stunServer) { setStunServer(nativePtr,stunServer); } + + public LinphoneCallParams createDefaultCallParameters() { + return new LinphoneCallParamsImpl(createDefaultCallParams(nativePtr)); + } + + public LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException { + long ptrDestination = ((LinphoneAddressImpl)to).nativePtr; + long ptrParams =((LinphoneCallParamsImpl)params).nativePtr; + + long lcNativePtr = inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); + if (lcNativePtr!=0) { + return new LinphoneCallImpl(lcNativePtr); + } else { + throw new LinphoneCoreException("Unable to invite with params " + to.asString()); + } + } + + public int updateCall(LinphoneCall call, LinphoneCallParams params) { + long ptrCall = ((LinphoneCallImpl) call).nativePtr; + long ptrParams = ((LinphoneCallParamsImpl)params).nativePtr; + + return updateCall(nativePtr, ptrCall, ptrParams); + } } diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index e016cad25..0623e34dc 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -23,7 +23,6 @@ import org.linphone.core.AndroidCameraRecord; import android.app.Activity; import android.os.Bundle; -import android.os.Handler; import android.view.SurfaceView; import android.widget.TextView; @@ -51,11 +50,11 @@ public class TestVideoActivity extends Activity { // SurfaceHolder holder=surfaceView.getHolder(); // holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - AndroidCameraRecord.setSurfaceView(surfaceView, new Handler()); + AndroidCameraRecord.setSurfaceView(surfaceView); JavaCameraRecordImpl recorder = new JavaCameraRecordImpl(); recorder.setDebug((TextView) findViewById(R.id.videotest_debug)); - recorder.setParameters(288, 352, rate, false); + recorder.setParameters(288, 352, rate); } From 11ad5c7d021f93257058b97de187c54ce26b69d5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 25 Nov 2010 14:01:51 +0100 Subject: [PATCH 048/288] use default ring file instead of oldring.wav --- LinphoneCallImpl.java | 3 +++ LinphoneCallLogImpl.java | 4 ++++ LinphoneCoreImpl.java | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index c71883b57..ed8f00708 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -58,6 +58,9 @@ class LinphoneCallImpl implements LinphoneCall { public State getState() { return LinphoneCall.State.fromInt(getState(nativePtr)); } + public LinphoneCallParams getCurrentParamsReadOnly() { + throw new RuntimeException("Not Implemenetd yet"); + } } diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index b0360d194..c9c8b8ffe 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -42,5 +42,9 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public LinphoneAddress getTo() { return new LinphoneAddressImpl(getTo(nativePtr)); } + public CallStatus getStatus() { + // TODO Auto-generated method stub + return null; + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 775a83895..01b98bda4 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -67,6 +67,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void addFriend(long nativePtr,long friend); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); private native long createChatRoom(long nativePtr,String to); + private native void setRing(long nativePtr, String path); + private native String getRing(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -309,5 +311,39 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } + public void setStunServer(String stun_server) { + // TODO Auto-generated method stub + + } + public String getStunServer() { + // TODO Auto-generated method stub + return null; + } + public void setFirewallPolicy(FirewallPolicy pol) { + // TODO Auto-generated method stub + + } + public FirewallPolicy getFirewallPolicy() { + // TODO Auto-generated method stub + return null; + } + public void setRing(String path) { + setRing(nativePtr,path); + + } + public String getRing() { + return getRing(nativePtr); + } + public LinphoneCall inviteAddressWithParams(LinphoneAddress destination, + LinphoneCallParams params) throws LinphoneCoreException { + throw new RuntimeException("Not Implemenetd yet"); + } + public int updateCall(LinphoneCall call, LinphoneCallParams params) { + throw new RuntimeException("Not Implemenetd yet"); + } + public LinphoneCallParams createDefaultCallParameters() { + throw new RuntimeException("Not Implemenetd yet"); + } + } From 3c26f241c1ee443fc00be8aee388d1c0b88e2e5d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 26 Nov 2010 15:04:38 +0100 Subject: [PATCH 049/288] Added menu to videocall activity: - high/low resolution - enable/disable camera - return to dialer - terminate call Added bandwidth manager to manage video profiles and update current and subsequent calls. Added VideoSize semantics and jni wrappings on linphoneCore. --- AndroidCameraRecord.java | 65 +++++++++++++++++++++++++++++-------- LinphoneCallImpl.java | 2 -- LinphoneCallParamsImpl.java | 2 +- LinphoneCoreImpl.java | 28 +++++++++++++++- 4 files changed, 79 insertions(+), 18 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index c16ef065d..138912f57 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -18,10 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import java.util.ArrayList; +import java.util.List; + import android.hardware.Camera; import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.Size; import android.os.Build; import android.util.Log; import android.view.SurfaceHolder; @@ -44,8 +48,9 @@ public abstract class AndroidCameraRecord { private static boolean previewStarted; private static boolean parametersSet; protected static int orientationCode; - private static boolean mute; + private static boolean muted; private static final String tag="Linphone"; + private static List supportedVideoSizes; public AndroidCameraRecord() { // TODO check if another instance is loaded and kill it. @@ -66,7 +71,7 @@ public abstract class AndroidCameraRecord { * It will start automatically */ private void startPreview() { - if (mute) { + if (muted) { Log.d(tag, "Not starting preview as camera has been muted"); return; } @@ -100,6 +105,9 @@ public abstract class AndroidCameraRecord { Camera.Parameters parameters=camera.getParameters(); + if (supportedVideoSizes == null) { + supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); + } parameters.setPreviewSize(width, height); parameters.setPreviewFrameRate(fps); @@ -174,6 +182,13 @@ public abstract class AndroidCameraRecord { } + private static void stopPreview() { + camera.setPreviewCallback(null); // TODO check if used whatever the SDK version + camera.stopPreview(); + camera.release(); + camera=null; + previewStarted = false; + } public static final void setSurfaceView(final SurfaceView sv) { SurfaceHolder holder = sv.getHolder(); @@ -187,11 +202,7 @@ public abstract class AndroidCameraRecord { Log.e(tag, "Video capture: illegal state: surface destroyed but camera is already null"); return; } - camera.setPreviewCallback(null); // TODO check if used whatever the SDK version - camera.stopPreview(); - camera.release(); - camera=null; - previewStarted = false; + stopPreview(); Log.w(tag, "Video capture Surface destroyed"); } @@ -235,19 +246,45 @@ public abstract class AndroidCameraRecord { } public static void setMuteCamera(boolean m) { - if (m == mute) return; + if (m == muted) return; - mute = m; - if (mute && previewStarted) { - camera.stopPreview(); + muted = m; + if (muted && previewStarted) { + stopPreview(); return; } - if (!mute) { + if (!muted) { instance.startPreview(); } } + + public static void toggleMute() { + setMuteCamera(!muted); + } + + public static List supportedVideoSizes() { + if (supportedVideoSizes != null) { + return new ArrayList(supportedVideoSizes); + } + + if (camera == null) { + camera = Camera.open(); + supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); + camera.release(); + return supportedVideoSizes; + } + + throw new RuntimeException("Should not be there"); + } + + public static boolean getCameraMuted() { + return muted; + } + + public static void invalidateParameters() { + parametersSet = false; + stopPreview(); + } } - - diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 4c9a770c9..b6194c26f 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -66,6 +66,4 @@ class LinphoneCallImpl implements LinphoneCall { public LinphoneCallParams getCurrentParamsReadWrite() { return getCurrentParamsReadOnly().copy(); } - - } diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index add724f21..1242ee996 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -34,7 +34,7 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { return getVideoEnabled(nativePtr); } - public void setVideoEnalbled(boolean b) { + public void setVideoEnabled(boolean b) { enableVideo(nativePtr, b); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 91913e322..532a7ae2c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -81,7 +81,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native String getStunServer(long nativePtr); private native long createDefaultCallParams(long nativePtr); private native int updateCall(long ptrLc, long ptrCall, long ptrParams); - + private native void setUploadBandwidth(long nativePtr, int bw); + private native void setDownloadBandwidth(long nativePtr, int bw); + private native void setPreferredVideoSize(long nativePtr, int width, int heigth); + private native int[] getPreferredVideoSize(long nativePtr); private static String TAG = "LinphoneCore"; @@ -379,4 +382,27 @@ class LinphoneCoreImpl implements LinphoneCore { return updateCall(nativePtr, ptrCall, ptrParams); } + + + public void setUploadBandwidth(int bw) { + setUploadBandwidth(nativePtr, bw); + } + + public void setDownloadBandwidth(int bw) { + setDownloadBandwidth(nativePtr, bw); + } + + public void setPreferredVideoSize(VideoSize vSize) { + setPreferredVideoSize(nativePtr, vSize.getWidth(), vSize.getHeight()); + } + + public VideoSize getPreferredVideoSize() { + int[] nativeSize = getPreferredVideoSize(nativePtr); + + VideoSize vSize = new VideoSize(); + vSize.setWidth(nativeSize[0]); + vSize.setHeight(nativeSize[1]); + + return vSize; + } } From a115f7a9d7b985c60858188875450d11a9ea1a1e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 10:53:03 +0100 Subject: [PATCH 050/288] fix bad merges and rename some methods --- LinphoneCoreImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f0f4dc15d..c67c18dc9 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -385,9 +385,6 @@ class LinphoneCoreImpl implements LinphoneCore { return updateCall(nativePtr, ptrCall, ptrParams); } -<<<<<<< HEAD - - public void setUploadBandwidth(int bw) { setUploadBandwidth(nativePtr, bw); } @@ -406,14 +403,20 @@ class LinphoneCoreImpl implements LinphoneCore { VideoSize vSize = new VideoSize(); vSize.setWidth(nativeSize[0]); vSize.setHeight(nativeSize[1]); - return vSize; -======= + } public void setRing(String path) { setRing(nativePtr, path); } public String getRing() { return getRing(nativePtr); ->>>>>>> c95431295dc09c5558d38c6de49fa071c957d926 + } + public boolean isNetworkReachable() { + // TODO Auto-generated method stub + return false; + } + public void setNetworkReachable(boolean isReachable) { + // TODO Auto-generated method stub + } } From b091437c6f376a061b7994e0d98d9c311153113f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 12:01:44 +0100 Subject: [PATCH 051/288] fix setNetworkReachable --- AndroidCameraRecord.java | 8 +++++--- AndroidVideoWindowImpl.java | 1 + LinphoneCoreImpl.java | 6 +----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 138912f57..eb6a10865 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -183,9 +183,11 @@ public abstract class AndroidCameraRecord { private static void stopPreview() { - camera.setPreviewCallback(null); // TODO check if used whatever the SDK version - camera.stopPreview(); - camera.release(); + if (camera!=null){ + camera.setPreviewCallback(null); // TODO check if used whatever the SDK version + camera.stopPreview(); + camera.release(); + } camera=null; previewStarted = false; } diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index ca9968e4c..9f6281bec 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -80,3 +80,4 @@ public class AndroidVideoWindowImpl { } } + diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index c67c18dc9..745c8c358 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -200,7 +200,7 @@ class LinphoneCoreImpl implements LinphoneCore { throw new RuntimeException("object already destroyed"); } } - public void setNetworkStateReachable(boolean isReachable) { + public void setNetworkReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } public void setPlaybackGain(float gain) { @@ -415,8 +415,4 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } - public void setNetworkReachable(boolean isReachable) { - // TODO Auto-generated method stub - - } } From 3f7a0b217fc223fd3b09dd63098ecf367f632d3d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 29 Nov 2010 12:08:13 +0100 Subject: [PATCH 052/288] Added camera record manager to drive Video record class. --- AndroidCameraRecord.java | 175 +++++++----------------- AndroidCameraRecordBufferedImpl.java | 11 +- AndroidCameraRecordImpl.java | 27 ++-- AndroidCameraRecordManager.java | 190 +++++++++++++++++++++++++++ tutorials/JavaCameraRecordImpl.java | 16 ++- tutorials/TestVideoActivity.java | 9 +- 6 files changed, 277 insertions(+), 151 deletions(-) create mode 100644 AndroidCameraRecordManager.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 138912f57..560f4c947 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -26,70 +26,36 @@ import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; -import android.os.Build; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; -import android.view.SurfaceHolder.Callback; public abstract class AndroidCameraRecord { - public static final int ANDROID_VERSION = Integer.parseInt(Build.VERSION.SDK); - protected static Camera camera; - private static SurfaceView surfaceView; + protected Camera camera; + private RecorderParams params; - protected int fps; - protected int height; - protected int width; private PreviewCallback storedPreviewCallback; - - private static AndroidCameraRecord instance; - private static boolean previewStarted; - private static boolean parametersSet; - protected static int orientationCode; - private static boolean muted; + private boolean previewStarted; + protected int orientationCode; private static final String tag="Linphone"; - private static List supportedVideoSizes; + private List supportedVideoSizes; - public AndroidCameraRecord() { - // TODO check if another instance is loaded and kill it. - instance = this; - } - - public void setParameters(int height, int width, float fps) { - this.fps = Math.round(fps); - this.height = height; - this.width = width; - parametersSet = true; - startPreview(); + public AndroidCameraRecord(RecorderParams parameters) { + this.params = parameters; + setRotation(parameters.rotation); } - /* - * AndroidCameraRecord.setSurfaceView() should be called first, from the Activity code. - * It will start automatically - */ - private void startPreview() { - if (muted) { - Log.d(tag, "Not starting preview as camera has been muted"); - return; - } - if (surfaceView == null) { - Log.w(tag, "Surfaceview not defined; postponning video capture"); - return; - } - if (!parametersSet) { - Log.w(tag, "Parameters not set; postponning video capture"); - return; - } - + + public void startPreview() { // FIXME throws exception? if (previewStarted) { Log.w(tag, "Already started"); return; } - if (surfaceView.getVisibility() != SurfaceView.VISIBLE) { + if (params.surfaceView.getVisibility() != SurfaceView.VISIBLE) { // Illegal state Log.e(tag, "Illegal state: video capture surface view is not visible"); return; @@ -109,8 +75,9 @@ public abstract class AndroidCameraRecord { supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); } - parameters.setPreviewSize(width, height); - parameters.setPreviewFrameRate(fps); + parameters.set("camera-id", params.cameraId); + parameters.setPreviewSize(params.width, params.height); + parameters.setPreviewFrameRate(Math.round(params.fps)); if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { Log.w(tag, "Auto Focus supported by camera device"); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); @@ -127,9 +94,8 @@ public abstract class AndroidCameraRecord { onSettingParameters(parameters); camera.setParameters(parameters); - - SurfaceHolder holder = surfaceView.getHolder(); + SurfaceHolder holder = params.surfaceView.getHolder(); try { camera.setPreviewDisplay(holder); } @@ -151,7 +117,7 @@ public abstract class AndroidCameraRecord { // Register callback to get capture buffer if (storedPreviewCallback != null) { - reallySetPreviewCallback(camera, storedPreviewCallback); + lowLevelSetPreviewCallback(camera, storedPreviewCallback); } @@ -171,120 +137,69 @@ public abstract class AndroidCameraRecord { */ public void onCameraStarted(Camera camera) {} - public void setOrStorePreviewCallBack(PreviewCallback cb) { + public void storePreviewCallBack(PreviewCallback cb) { if (camera == null) { Log.w(tag, "Capture camera not ready, storing callback"); this.storedPreviewCallback = cb; return; } - reallySetPreviewCallback(camera, cb); + lowLevelSetPreviewCallback(camera, cb); } - private static void stopPreview() { - camera.setPreviewCallback(null); // TODO check if used whatever the SDK version + void stopPreview() { + if (!previewStarted) return; + lowLevelSetPreviewCallback(camera, null); camera.stopPreview(); camera.release(); camera=null; previewStarted = false; } - public static final void setSurfaceView(final SurfaceView sv) { - SurfaceHolder holder = sv.getHolder(); - holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - - holder.addCallback(new Callback() { - public void surfaceDestroyed(SurfaceHolder holder) { - AndroidCameraRecord.surfaceView = null; - - if (camera == null) { - Log.e(tag, "Video capture: illegal state: surface destroyed but camera is already null"); - return; - } - stopPreview(); - Log.w(tag, "Video capture Surface destroyed"); - } - - public void surfaceCreated(SurfaceHolder holder) { - AndroidCameraRecord.surfaceView = sv; - Log.w(tag, "Video capture surface created"); - - if (instance != null) { - instance.startPreview(); - } - - holder.isCreating(); - } - - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - Log.w(tag, "Video capture surface changed"); - } - }); - } - - - public void stopCaptureCallback() { if (camera != null) { - reallySetPreviewCallback(camera, null); + lowLevelSetPreviewCallback(camera, null); } } - protected void reallySetPreviewCallback(Camera camera, PreviewCallback cb) { - camera.setPreviewCallback(cb); - } + protected abstract void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb); - public static void setOrientationCode(int orientation) { - AndroidCameraRecord.orientationCode = (4 + 1 - orientation) % 4; + public void setRotation(int rotation) { + orientationCode = (4 + 1 - rotation) % 4; } protected int getOrientationCode() { return orientationCode; } - public static void setMuteCamera(boolean m) { - if (m == muted) return; - muted = m; - if (muted && previewStarted) { - stopPreview(); - return; - } + + + public static class RecorderParams { + public float fps; + public int height; + public int width; + + final long filterDataNativePtr; + int cameraId; + int rotation; + public SurfaceView surfaceView; - if (!muted) { - instance.startPreview(); + public RecorderParams(long ptr) { + filterDataNativePtr = ptr; } - } - public static void toggleMute() { - setMuteCamera(!muted); + + + + public boolean isStarted() { + return previewStarted; } - public static List supportedVideoSizes() { - if (supportedVideoSizes != null) { - return new ArrayList(supportedVideoSizes); - } - - if (camera == null) { - camera = Camera.open(); - supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); - camera.release(); - return supportedVideoSizes; - } - - throw new RuntimeException("Should not be there"); - } - - public static boolean getCameraMuted() { - return muted; - } - - public static void invalidateParameters() { - parametersSet = false; - stopPreview(); + public List getSupportedVideoSizes() { + return new ArrayList(supportedVideoSizes); } } diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index 886ad222e..9445b40ee 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -32,13 +32,16 @@ import android.util.Log; */ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { - public AndroidCameraRecordBufferedImpl(long filterCtxPtr) { - super(filterCtxPtr); + + public AndroidCameraRecordBufferedImpl(RecorderParams parameters) { + super(parameters); } @Override - protected void reallySetPreviewCallback(Camera camera, PreviewCallback cb) { - Log.d("Linphone", "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); + protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { + if (cb != null) { + Log.d("Linphone", "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); + } camera.setPreviewCallbackWithBuffer(cb); } diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index db4e128de..38ca02fec 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -34,17 +34,14 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev private long filterCtxPtr; private double timeElapsedBetweenFrames = 0; private long lastFrameTime = 0; + private final long expectedTimeBetweenFrames; - public AndroidCameraRecordImpl(long filterCtxPtr) { - super(); + public AndroidCameraRecordImpl(RecorderParams parameters) { + super(parameters); + expectedTimeBetweenFrames = 1l / Math.round(parameters.fps); + filterCtxPtr = parameters.filterDataNativePtr; - try { - this.filterCtxPtr = filterCtxPtr; - setOrStorePreviewCallBack(this); - } catch (Throwable e) { - Log.e("Linphone", "Error"); - } - + storePreviewCallBack(this); } @@ -56,6 +53,10 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev Log.e("Linphone", "onPreviewFrame Called with null buffer"); return; } + if (filterCtxPtr == 0l) { + Log.e("Linphone", "onPreviewFrame Called with no filterCtxPtr set"); + return; + } Size s = camera.getParameters().getPreviewSize(); int expectedBuffLength = s.width * s.height * 3 /2; @@ -73,7 +74,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev } double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; - if (1 / currentTimeElapsed > fps) { + if (currentTimeElapsed < expectedTimeBetweenFrames) { // Log.d("Linphone", "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); return; } @@ -85,5 +86,11 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev } + @Override + protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { + camera.setPreviewCallback(cb); + } + + } diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java new file mode 100644 index 000000000..9295bf0b0 --- /dev/null +++ b/AndroidCameraRecordManager.java @@ -0,0 +1,190 @@ +/* +AndroidCameraRecordManager.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; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.linphone.core.AndroidCameraRecord.RecorderParams; + +import android.hardware.Camera; +import android.hardware.Camera.Size; +import android.os.Build; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.SurfaceHolder.Callback; + + + +/** + * Manage the video capture; one instance per camera. + * + * @author Guillaume Beraudo + * + */ +public class AndroidCameraRecordManager { + public static final int CAMERA_ID_FIXME_USE_PREFERENCE = 0; + private static final int version = Integer.parseInt(Build.VERSION.SDK); + private static Map instances = new HashMap(); + + + // singleton + private AndroidCameraRecordManager(int cameraId) { + this.cameraId = cameraId; + } + + /** + * @param cameraId : see max_camera_id + * @return + */ + public static final synchronized AndroidCameraRecordManager getInstance(int cameraId) { + if (cameraId < 0) { + Log.e("Linphone", "Asking unmanageable camera " + cameraId); + return null; + } + + AndroidCameraRecordManager m = instances.get(cameraId); + if (m == null) { + m = new AndroidCameraRecordManager(cameraId); + instances.put(cameraId, m); + } + return m; + } + + public static final synchronized AndroidCameraRecordManager getInstance() { + return getInstance(0); + } + + private AndroidCameraRecord.RecorderParams parameters; + private SurfaceView surfaceView; + private boolean muted; + + + private AndroidCameraRecord recorder; + private final Integer cameraId; + + private List supportedVideoSizes; + private int rotation; + + + public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { + RecorderParams p = new RecorderParams(filterDataPtr); + p.fps = fps; + p.width = width; + p.height = height; + p.cameraId = cameraId; + parameters = p; + } + + + public final void setSurfaceView(final SurfaceView sv, final int rotation) { + this.rotation = rotation; + SurfaceHolder holder = sv.getHolder(); + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + + holder.addCallback(new Callback() { + public void surfaceDestroyed(SurfaceHolder holder) { + surfaceView = null; + stopVideoRecording(); + } + + public void surfaceCreated(SurfaceHolder holder) { + surfaceView = sv; + tryToStartVideoRecording(); + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) {} + }); + } + + public void setMuted(boolean muteState) { + if (muteState == muted) return; + muted = muteState; + if (muted) { + stopVideoRecording(); + } else { + tryToStartVideoRecording(); + } + } + public void toggleMute() { + setMuted(!muted); + } + public boolean isMuted() { + return muted; + } + + + private void tryToStartVideoRecording() { + if (muted || surfaceView == null || parameters == null) return; + + parameters.rotation = rotation; + parameters.surfaceView = surfaceView; + if (version > 8) { + recorder = new AndroidCameraRecordBufferedImpl(parameters); + } else { + recorder = new AndroidCameraRecordImpl(parameters); + } + + recorder.startPreview(); + } + + public void stopVideoRecording() { + if (recorder != null) { + recorder.stopPreview(); + recorder = null; + } + } + + + // FIXME select right camera + public List supportedVideoSizes() { + if (supportedVideoSizes != null) { + return supportedVideoSizes; + } + + if (recorder != null) { + supportedVideoSizes = recorder.getSupportedVideoSizes(); + if (supportedVideoSizes != null) return supportedVideoSizes; + } + + Camera camera = Camera.open(); + supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); + camera.release(); + return supportedVideoSizes; + } + + + public boolean isRecording() { + if (recorder != null) { + return recorder.isStarted(); + } + + return false; + } + + public void invalidateParameters() { + if (isRecording()) stopVideoRecording(); + parameters = null; + + } + +} diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index 30c1838f6..12594ccef 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -33,11 +33,13 @@ public class JavaCameraRecordImpl extends AndroidCameraRecord implements Preview private long startTime; private long endTime; + private int fps; - - public JavaCameraRecordImpl() { - super(); - setOrStorePreviewCallBack(this); + + public JavaCameraRecordImpl(AndroidCameraRecord.RecorderParams parameters) { + super(parameters); + storePreviewCallBack(this); + fps = Math.round(parameters.fps); } @@ -61,4 +63,10 @@ public class JavaCameraRecordImpl extends AndroidCameraRecord implements Preview Log.d("onPreviewFrame:", msg); } + + @Override + protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { + camera.setPreviewCallback(cb); + } + } diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index 0623e34dc..4b4ccc09e 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -50,11 +50,14 @@ public class TestVideoActivity extends Activity { // SurfaceHolder holder=surfaceView.getHolder(); // holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - AndroidCameraRecord.setSurfaceView(surfaceView); + AndroidCameraRecord.RecorderParams params = new AndroidCameraRecord.RecorderParams(0); + params.surfaceView = surfaceView; + params.width = 352; + params.height = 288; + params.fps = rate; - JavaCameraRecordImpl recorder = new JavaCameraRecordImpl(); + JavaCameraRecordImpl recorder = new JavaCameraRecordImpl(params); recorder.setDebug((TextView) findViewById(R.id.videotest_debug)); - recorder.setParameters(288, 352, rate); } From 944aa6f02857bf93811ea3f13bd23d95e98c4c0b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 29 Nov 2010 14:37:42 +0100 Subject: [PATCH 053/288] Fix regression framerate control. --- AndroidCameraRecordImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index 38ca02fec..0409d5cb4 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -34,11 +34,11 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev private long filterCtxPtr; private double timeElapsedBetweenFrames = 0; private long lastFrameTime = 0; - private final long expectedTimeBetweenFrames; + private final double expectedTimeBetweenFrames; public AndroidCameraRecordImpl(RecorderParams parameters) { super(parameters); - expectedTimeBetweenFrames = 1l / Math.round(parameters.fps); + expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; storePreviewCallBack(this); From 7b9233ddf839fa712c2b706837d19ae5c9cbe59c Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 29 Nov 2010 14:40:00 +0100 Subject: [PATCH 054/288] Fix regression not using buffered capture on android v8. --- AndroidCameraRecordManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 9295bf0b0..159cc4c5a 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -138,7 +138,7 @@ public class AndroidCameraRecordManager { parameters.rotation = rotation; parameters.surfaceView = surfaceView; - if (version > 8) { + if (version >= 8) { recorder = new AndroidCameraRecordBufferedImpl(parameters); } else { recorder = new AndroidCameraRecordImpl(parameters); From 6c9b1ab07933197e91098e8c316b962e5edec2e0 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 29 Nov 2010 14:41:51 +0100 Subject: [PATCH 055/288] Cosmetics cleanup. --- AndroidCameraRecord.java | 20 ++++++++------------ AndroidCameraRecordBufferedImpl.java | 12 ++++-------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 560f4c947..c691a3176 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -52,7 +52,8 @@ public abstract class AndroidCameraRecord { public void startPreview() { // FIXME throws exception? if (previewStarted) { Log.w(tag, "Already started"); - return; + throw new RuntimeException("Video recorder already started"); + // return } if (params.surfaceView.getVisibility() != SurfaceView.VISIBLE) { @@ -91,7 +92,7 @@ public abstract class AndroidCameraRecord { } } - onSettingParameters(parameters); + onSettingCameraParameters(parameters); camera.setParameters(parameters); @@ -114,33 +115,28 @@ public abstract class AndroidCameraRecord { previewStarted = true; - // Register callback to get capture buffer - if (storedPreviewCallback != null) { - lowLevelSetPreviewCallback(camera, storedPreviewCallback); - } + lowLevelSetPreviewCallback(camera, storedPreviewCallback); - onCameraStarted(camera); + onPreviewStarted(camera); } - protected void onSettingParameters(Parameters parameters) { - - } + protected void onSettingCameraParameters(Parameters parameters) {} /** * Hook. * @param camera */ - public void onCameraStarted(Camera camera) {} + public void onPreviewStarted(Camera camera) {} public void storePreviewCallBack(PreviewCallback cb) { + this.storedPreviewCallback = cb; if (camera == null) { Log.w(tag, "Capture camera not ready, storing callback"); - this.storedPreviewCallback = cb; return; } diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index 9445b40ee..f58698df2 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -46,18 +46,14 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { } @Override - public void onCameraStarted(Camera camera) { - super.onCameraStarted(camera); + public void onPreviewStarted(Camera camera) { + super.onPreviewStarted(camera); Size s = camera.getParameters().getPreviewSize(); int wishedBufferSize = s.height * s.width * 3 / 2; camera.addCallbackBuffer(new byte[wishedBufferSize]); camera.addCallbackBuffer(new byte[wishedBufferSize]); -/* - for (int i=1; i < 30; i++) { - camera.addCallbackBuffer(new byte[wishedBufferSize]); - }*/ } @Override @@ -67,8 +63,8 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { } @Override - protected void onSettingParameters(Parameters parameters) { - super.onSettingParameters(parameters); + protected void onSettingCameraParameters(Parameters parameters) { + super.onSettingCameraParameters(parameters); // Only on v8 hardware camera.setDisplayOrientation(90 * orientationCode); } From 0e3fb02e229115fe62ec7d40ee38a8eab483a832 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 15:06:17 +0100 Subject: [PATCH 056/288] fixed orientation doesn't work --- AndroidVideoWindowImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 9f6281bec..ec7eb2cbb 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -48,10 +48,16 @@ public class AndroidVideoWindowImpl { } if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); - Log.w("Linphone", "Video display surface destroyed"); + Log.d("Linphone", "Video display surface destroyed"); } }); } + static final int LANDSCAPE=0; + static final int PORTRAIT=1; + public void requestOrientation(int orientation){ + //Surface.setOrientation(0, orientation==LANDSCAPE ? 1 : 0); + //Log.d("Linphone", "Orientation changed."); + } public void setListener(VideoWindowListener l){ mListener=l; } From f54a55d359a906f8e2dfb44252febd3bc968c3d0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 30 Nov 2010 19:02:11 +0100 Subject: [PATCH 057/288] add proxy suport to TutorialBuddyStatusActivity --- tutorials/TutorialBuddyStatusActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tutorials/TutorialBuddyStatusActivity.java b/tutorials/TutorialBuddyStatusActivity.java index d42607d16..1bf4f981f 100644 --- a/tutorials/TutorialBuddyStatusActivity.java +++ b/tutorials/TutorialBuddyStatusActivity.java @@ -38,6 +38,9 @@ public class TutorialBuddyStatusActivity extends Activity { private static final String defaultSipAddress = "sip:"; private TextView sipAddressWidget; + private TextView mySipAddressWidget; + private TextView mySipPasswordWidget; + private TutorialBuddyStatus tutorial; private Handler mHandler = new Handler() ; private Button buttonCall; @@ -49,6 +52,12 @@ public class TutorialBuddyStatusActivity extends Activity { sipAddressWidget = (TextView) findViewById(R.id.AddressId); sipAddressWidget.setText(defaultSipAddress); + mySipAddressWidget = (TextView) findViewById(R.id.MyAddressId); + mySipAddressWidget.setVisibility(View.VISIBLE); + mySipPasswordWidget = (TextView) findViewById(R.id.Password); + mySipPasswordWidget.setVisibility(TextView.VISIBLE); + + // Output text to the outputText widget final TextView outputText = (TextView) findViewById(R.id.OutputText); final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); @@ -84,7 +93,9 @@ public class TutorialBuddyStatusActivity extends Activity { public void run() { super.run(); try { - tutorial.launchTutorial(sipAddressWidget.getText().toString()); + String myIdentity = mySipAddressWidget.getText().length()>0?mySipAddressWidget.getText().toString():null; + String myPassword = mySipPasswordWidget.getText().length()>0?mySipPasswordWidget.getText().toString():null; + tutorial.launchTutorial(sipAddressWidget.getText().toString(), myIdentity, myPassword); mHandler.post(new Runnable() { public void run() { buttonCall.setEnabled(true); From 8f406c57066cf0e8b002d5f46c5488030e0d0166 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 11:39:19 +0100 Subject: [PATCH 058/288] Portrait mode. --- AndroidCameraRecord.java | 7 ++++++- AndroidCameraRecordImpl.java | 8 +++++--- AndroidCameraRecordManager.java | 13 ++++++++++--- LinphoneCallImpl.java | 5 +++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index c691a3176..9d8b2f144 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -77,7 +77,11 @@ public abstract class AndroidCameraRecord { } parameters.set("camera-id", params.cameraId); - parameters.setPreviewSize(params.width, params.height); + if (!params.videoDimensionsInverted) { + parameters.setPreviewSize(params.width, params.height); + } else { + parameters.setPreviewSize(params.height, params.width); + } parameters.setPreviewFrameRate(Math.round(params.fps)); if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { Log.w(tag, "Auto Focus supported by camera device"); @@ -182,6 +186,7 @@ public abstract class AndroidCameraRecord { int cameraId; int rotation; public SurfaceView surfaceView; + boolean videoDimensionsInverted; public RecorderParams(long ptr) { filterDataNativePtr = ptr; diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index 0409d5cb4..2d3087854 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -35,17 +35,19 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev private double timeElapsedBetweenFrames = 0; private long lastFrameTime = 0; private final double expectedTimeBetweenFrames; + private boolean videoDimensionsInverted; public AndroidCameraRecordImpl(RecorderParams parameters) { super(parameters); expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; + videoDimensionsInverted = parameters.videoDimensionsInverted; storePreviewCallBack(this); } - private native void putImage(long filterCtxPtr, byte[] buffer, int orientation); + private native void putImage(long filterCtxPtr, byte[] buffer, int orientation, boolean videoDimensionsInverted); public void onPreviewFrame(byte[] data, Camera camera) { @@ -69,7 +71,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; - putImage(filterCtxPtr, data, getOrientationCode()); + putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted); return; } @@ -82,7 +84,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev timeElapsedBetweenFrames = currentTimeElapsed; // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data, getOrientationCode()); + putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted); } diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 159cc4c5a..02e7eb497 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -44,7 +44,7 @@ public class AndroidCameraRecordManager { public static final int CAMERA_ID_FIXME_USE_PREFERENCE = 0; private static final int version = Integer.parseInt(Build.VERSION.SDK); private static Map instances = new HashMap(); - + // singleton private AndroidCameraRecordManager(int cameraId) { @@ -83,16 +83,19 @@ public class AndroidCameraRecordManager { private List supportedVideoSizes; private int rotation; + private static final String tag = "Linphone"; public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { + stopVideoRecording(); RecorderParams p = new RecorderParams(filterDataPtr); p.fps = fps; p.width = width; p.height = height; p.cameraId = cameraId; + p.videoDimensionsInverted = width < height; parameters = p; - } + } public final void setSurfaceView(final SurfaceView sv, final int rotation) { @@ -103,16 +106,20 @@ public class AndroidCameraRecordManager { holder.addCallback(new Callback() { public void surfaceDestroyed(SurfaceHolder holder) { surfaceView = null; + Log.d(tag , "Video capture surface destroyed"); stopVideoRecording(); } public void surfaceCreated(SurfaceHolder holder) { surfaceView = sv; + Log.d(tag , "Video capture surface created"); tryToStartVideoRecording(); } public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) {} + int height) { + Log.d(tag , "Video capture surface changed"); + } }); } diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index b6194c26f..a73492274 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -30,6 +30,7 @@ class LinphoneCallImpl implements LinphoneCall { native private long getRemoteAddress(long nativePtr); native private int getState(long nativePtr); private native long getCurrentParams(long nativePtr); + private native void enableCamera(long nativePtr, boolean enabled); protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -66,4 +67,8 @@ class LinphoneCallImpl implements LinphoneCall { public LinphoneCallParams getCurrentParamsReadWrite() { return getCurrentParamsReadOnly().copy(); } + + public void enableCamera(boolean enabled) { + enableCamera(nativePtr, enabled); + } } From 8b7584e4c644d8adde23fbfe711a911e4a711374 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 14:24:39 +0100 Subject: [PATCH 059/288] Fix video capture not restarting on setParameters from filter. --- AndroidCameraRecordManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 02e7eb497..800879dd5 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -95,6 +95,7 @@ public class AndroidCameraRecordManager { p.cameraId = cameraId; p.videoDimensionsInverted = width < height; parameters = p; + tryToStartVideoRecording(); } From bf7f4a028643204629c9526cb0efe8336791fa79 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 17:03:22 +0100 Subject: [PATCH 060/288] Cleanup. --- AndroidCameraRecordManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 800879dd5..4c767b887 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -189,10 +189,10 @@ public class AndroidCameraRecordManager { return false; } + public void invalidateParameters() { - if (isRecording()) stopVideoRecording(); + stopVideoRecording(); parameters = null; - } } From fb6a4a0bb508e66439f194e9a0d538f7f6ce8fc2 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 2 Dec 2010 12:29:51 +0100 Subject: [PATCH 061/288] Fix links to ABI>=5 in video code preventing use with old telephones. Disable video when ABI<5 or ILBC not found. Automatically open preference activity on linphone first launch. --- AndroidCameraRecord.java | 22 +++------- AndroidCameraRecordBufferedImpl.java | 2 +- AndroidCameraRecordImplAPI5.java | 64 ++++++++++++++++++++++++++++ AndroidCameraRecordManager.java | 23 +++++++--- 4 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 AndroidCameraRecordImplAPI5.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 9d8b2f144..7fa4746bb 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import android.hardware.Camera; @@ -39,7 +40,7 @@ public abstract class AndroidCameraRecord { private PreviewCallback storedPreviewCallback; private boolean previewStarted; protected int orientationCode; - private static final String tag="Linphone"; + protected static final String tag="Linphone"; private List supportedVideoSizes; public AndroidCameraRecord(RecorderParams parameters) { @@ -47,7 +48,9 @@ public abstract class AndroidCameraRecord { setRotation(parameters.rotation); } - + protected List getSupportedPreviewSizes(Camera.Parameters parameters) { + return Collections.emptyList(); + } public void startPreview() { // FIXME throws exception? if (previewStarted) { @@ -73,7 +76,7 @@ public abstract class AndroidCameraRecord { Camera.Parameters parameters=camera.getParameters(); if (supportedVideoSizes == null) { - supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); + supportedVideoSizes = getSupportedPreviewSizes(camera.getParameters()); } parameters.set("camera-id", params.cameraId); @@ -83,18 +86,7 @@ public abstract class AndroidCameraRecord { parameters.setPreviewSize(params.height, params.width); } parameters.setPreviewFrameRate(Math.round(params.fps)); - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { - Log.w(tag, "Auto Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); - } else { - Log.w(tag, "Auto Focus not supported by camera device"); - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { - Log.w(tag, "Infinity Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); - } else { - Log.w(tag, "Infinity Focus not supported by camera device"); - } - } + onSettingCameraParameters(parameters); camera.setParameters(parameters); diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index f58698df2..9f8b2d1c0 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -30,7 +30,7 @@ import android.util.Log; * @author Guillaume Beraudo * */ -public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImpl { +public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 { public AndroidCameraRecordBufferedImpl(RecorderParams parameters) { diff --git a/AndroidCameraRecordImplAPI5.java b/AndroidCameraRecordImplAPI5.java new file mode 100644 index 000000000..7ff307d03 --- /dev/null +++ b/AndroidCameraRecordImplAPI5.java @@ -0,0 +1,64 @@ +/* +AndroidCameraRecordImplAPI5.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; + +import java.util.List; + +import android.hardware.Camera; +import android.hardware.Camera.Parameters; +import android.hardware.Camera.Size; +import android.util.Log; + + +public class AndroidCameraRecordImplAPI5 extends AndroidCameraRecordImpl { + + public AndroidCameraRecordImplAPI5(RecorderParams parameters) { + super(parameters); + } + + @Override + protected void onSettingCameraParameters(Parameters parameters) { + super.onSettingCameraParameters(parameters); + + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { + Log.w(tag, "Auto Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); + } else { + Log.w(tag, "Auto Focus not supported by camera device"); + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { + Log.w(tag, "Infinity Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); + } else { + Log.w(tag, "Infinity Focus not supported by camera device"); + } + } + } + + public static List oneShotSupportedVideoSizes() { + Camera camera = Camera.open(); + List supportedVideoSizes =camera.getParameters().getSupportedPreviewSizes(); + camera.release(); + return supportedVideoSizes; + } + + @Override + protected List getSupportedPreviewSizes(Parameters parameters) { + return parameters.getSupportedPreviewSizes(); + } +} diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 4c767b887..c6bae18da 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -24,7 +24,6 @@ import java.util.Map; import org.linphone.core.AndroidCameraRecord.RecorderParams; -import android.hardware.Camera; import android.hardware.Camera.Size; import android.os.Build; import android.util.Log; @@ -41,7 +40,6 @@ import android.view.SurfaceHolder.Callback; * */ public class AndroidCameraRecordManager { - public static final int CAMERA_ID_FIXME_USE_PREFERENCE = 0; private static final int version = Integer.parseInt(Build.VERSION.SDK); private static Map instances = new HashMap(); @@ -52,7 +50,8 @@ public class AndroidCameraRecordManager { } /** - * @param cameraId : see max_camera_id + * Instance for a given camera + * @param cameraId : starting from 0 * @return */ public static final synchronized AndroidCameraRecordManager getInstance(int cameraId) { @@ -69,6 +68,9 @@ public class AndroidCameraRecordManager { return m; } + /** + * @return instance for the default camera + */ public static final synchronized AndroidCameraRecordManager getInstance() { return getInstance(0); } @@ -148,6 +150,8 @@ public class AndroidCameraRecordManager { parameters.surfaceView = surfaceView; if (version >= 8) { recorder = new AndroidCameraRecordBufferedImpl(parameters); + } else if (version >= 5) { + recorder = new AndroidCameraRecordImplAPI5(parameters); } else { recorder = new AndroidCameraRecordImpl(parameters); } @@ -164,6 +168,10 @@ public class AndroidCameraRecordManager { // FIXME select right camera + /** + * Eventually null if API < 5. + * + */ public List supportedVideoSizes() { if (supportedVideoSizes != null) { return supportedVideoSizes; @@ -174,9 +182,12 @@ public class AndroidCameraRecordManager { if (supportedVideoSizes != null) return supportedVideoSizes; } - Camera camera = Camera.open(); - supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes(); - camera.release(); + if (version >= 5) { + supportedVideoSizes = AndroidCameraRecordImplAPI5.oneShotSupportedVideoSizes(); + } + + // eventually null + return supportedVideoSizes; } From 6df330a6b4f6d45a651fd3d27a25d686f752a186 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Dec 2010 16:13:01 +0100 Subject: [PATCH 062/288] Add video codecs preference. Integrate JNI code for getting list of available video codecs. --- LinphoneCoreImpl.java | 16 +++++++++++++++- PayloadTypeImpl.java | 13 ++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 745c8c358..62741c7ef 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -85,9 +85,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setDownloadBandwidth(long nativePtr, int bw); private native void setPreferredVideoSize(long nativePtr, int width, int heigth); private native int[] getPreferredVideoSize(long nativePtr); - private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); + private native long[] listVideoPayloadTypes(long nativePtr); + private static String TAG = "LinphoneCore"; @@ -415,4 +416,17 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } + + public PayloadType[] listVideoCodecs() { + long[] typesPtr = listVideoPayloadTypes(nativePtr); + if (typesPtr == null) return null; + + PayloadType[] codecs = new PayloadType[typesPtr.length]; + + for (int i=0; i < codecs.length; i++) { + codecs[i] = new PayloadTypeImpl(typesPtr[i]); + } + + return codecs; + } } diff --git a/PayloadTypeImpl.java b/PayloadTypeImpl.java index 28c206786..864b094ff 100644 --- a/PayloadTypeImpl.java +++ b/PayloadTypeImpl.java @@ -24,10 +24,21 @@ class PayloadTypeImpl implements PayloadType { protected final long nativePtr; private native String toString(long ptr); - + private native String getMime(long ptr); + private native int getRate(long ptr); + protected PayloadTypeImpl(long aNativePtr) { nativePtr = aNativePtr; } + + public int getRate() { + return getRate(nativePtr); + } + + public String getMime() { + return getMime(nativePtr); + } + public String toString() { return toString(nativePtr); } From 7adf2c94b8bd25b3caf1cb743d0b34cd85e83a98 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 6 Dec 2010 11:40:28 +0100 Subject: [PATCH 063/288] implement enablePublish --- LinphoneCoreImpl.java | 17 ++++++++++++++++- LinphoneProxyConfigImpl.java | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 01b98bda4..5aa6a1ce0 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -179,7 +179,7 @@ class LinphoneCoreImpl implements LinphoneCore { throw new RuntimeException("object already destroyed"); } } - public void setNetworkStateReachable(boolean isReachable) { + public void setNetworkReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } public void setPlaybackGain(float gain) { @@ -344,6 +344,21 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneCallParams createDefaultCallParameters() { throw new RuntimeException("Not Implemenetd yet"); } + public boolean isNetworkReachable() { + throw new RuntimeException("Not Implemenetd yet"); + } + public void setUploadBandwidth(int bw) { + throw new RuntimeException("Not Implemenetd yet"); + } + public void setDownloadBandwidth(int bw) { + throw new RuntimeException("Not Implemenetd yet"); + } + public void setPreferredVideoSize(VideoSize vSize) { + throw new RuntimeException("Not Implemenetd yet"); + } + public VideoSize getPreferredVideoSize() { + throw new RuntimeException("Not Implemenetd yet"); + } } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index f1dcb70a4..1b718d5a7 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -67,6 +67,9 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native String getRoute(long ptr); private native int setRoute(long ptr,String uri); + private native void enablePublish(long ptr,boolean enable); + private native boolean publishEnabled(long ptr); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); @@ -121,4 +124,11 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { throw new LinphoneCoreException("cannot set route ["+routeUri+"]"); } } + public void enablePublish(boolean enable) { + enablePublish(nativePtr,enable); + + } + public boolean publishEnabled() { + return publishEnabled(nativePtr); + } } From 289140257f58020e60fd16658a9c0b0079726d1a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 6 Dec 2010 12:16:23 +0100 Subject: [PATCH 064/288] fix unimplemented method --- LinphoneCallImpl.java | 3 +++ LinphoneCoreImpl.java | 3 +++ PayloadTypeImpl.java | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index ed8f00708..ca9d9d55f 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -61,6 +61,9 @@ class LinphoneCallImpl implements LinphoneCall { public LinphoneCallParams getCurrentParamsReadOnly() { throw new RuntimeException("Not Implemenetd yet"); } + public void enableCamera(boolean enabled) { + throw new RuntimeException("Not Implemenetd yet"); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 5aa6a1ce0..83df6de86 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -359,6 +359,9 @@ class LinphoneCoreImpl implements LinphoneCore { public VideoSize getPreferredVideoSize() { throw new RuntimeException("Not Implemenetd yet"); } + public PayloadType[] listVideoCodecs() { + throw new RuntimeException("Not Implemenetd yet"); + } } diff --git a/PayloadTypeImpl.java b/PayloadTypeImpl.java index 28c206786..821e1a091 100644 --- a/PayloadTypeImpl.java +++ b/PayloadTypeImpl.java @@ -31,4 +31,8 @@ class PayloadTypeImpl implements PayloadType { public String toString() { return toString(nativePtr); } + + public String getMime() { + throw new RuntimeException("Not Implemenetd yet"); + } } From 77745099ba904b7ff0bf1563ab9129c611f50182 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 6 Dec 2010 14:31:49 +0100 Subject: [PATCH 065/288] Fixed current CallParams not copied. Fixed not always sending static image on camera muted. Improved organization of preference activity. --- LinphoneCallImpl.java | 9 +++------ LinphoneCallParamsImpl.java | 11 ++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index a73492274..74c701a72 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -29,7 +29,7 @@ class LinphoneCallImpl implements LinphoneCall { private native boolean isIncoming(long nativePtr); native private long getRemoteAddress(long nativePtr); native private int getState(long nativePtr); - private native long getCurrentParams(long nativePtr); + private native long getCurrentParamsCopy(long nativePtr); private native void enableCamera(long nativePtr, boolean enabled); protected LinphoneCallImpl(long aNativePtr) { @@ -61,11 +61,8 @@ class LinphoneCallImpl implements LinphoneCall { public State getState() { return LinphoneCall.State.fromInt(getState(nativePtr)); } - public LinphoneCallParams getCurrentParamsReadOnly() { - return new LinphoneCallParamsImpl(getCurrentParams(nativePtr)); - } - public LinphoneCallParams getCurrentParamsReadWrite() { - return getCurrentParamsReadOnly().copy(); + public LinphoneCallParams getCurrentParamsCopy() { + return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); } public void enableCamera(boolean enabled) { diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index 1242ee996..33d460697 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -27,7 +27,7 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { private native void enableVideo(long nativePtr, boolean b); private native boolean getVideoEnabled(long nativePtr); - private native long copy(long nativePtr); + private native void destroy(long nativePtr); public boolean getVideoEnabled() { @@ -37,9 +37,10 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { public void setVideoEnabled(boolean b) { enableVideo(nativePtr, b); } - - public LinphoneCallParams copy() { - return new LinphoneCallParamsImpl(copy(nativePtr)); + + @Override + protected void finalize() throws Throwable { + destroy(nativePtr); + super.finalize(); } - } From 2b829b72b6b990b9e6eab653407ac30c7347f4ed Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 6 Dec 2010 15:06:59 +0100 Subject: [PATCH 066/288] Fixed unimplemented methods. Full brightness on videocall activity. --- LinphoneProxyConfigImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index f1dcb70a4..5bf4971d0 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -121,4 +121,10 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { throw new LinphoneCoreException("cannot set route ["+routeUri+"]"); } } + public void enablePublish(boolean enable) { + throw new RuntimeException("not implemented"); + } + public boolean publishEnabled() { + throw new RuntimeException("not implemented"); + } } From 16749d14d3f6535b6ba399a5d0d8962b740979ea Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 7 Dec 2010 10:32:52 +0100 Subject: [PATCH 067/288] Simplify registration tutorial. --- tutorials/TutorialRegistrationActivity.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java index d87446140..6da10f3d6 100644 --- a/tutorials/TutorialRegistrationActivity.java +++ b/tutorials/TutorialRegistrationActivity.java @@ -42,6 +42,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { private TutorialRegistration tutorial; private Button buttonCall; private Handler mHandler = new Handler(); + private TextView outputText; @Override @@ -55,7 +56,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { sipPasswordWidget.setText(defaultSipPassword); // Output text to the outputText widget - final TextView outputText = (TextView) findViewById(R.id.OutputText); + outputText = (TextView) findViewById(R.id.OutputText); final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); @@ -66,6 +67,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { // Assign call action to call button buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setText("Register"); buttonCall.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TutorialLaunchingThread thread = new TutorialLaunchingThread(); @@ -74,13 +76,9 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { } }); - // Assign stop action to stop button + // Hide stop button Button buttonStop = (Button) findViewById(R.id.ButtonStop); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - tutorial.stopMainLoop(); - } - }); + buttonStop.setVisibility(View.GONE); } @@ -92,13 +90,9 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { tutorial.launchTutorial( sipAddressWidget.getText().toString(), sipPasswordWidget.getText().toString()); - mHandler.post(new Runnable() { - public void run() { - buttonCall.setEnabled(true); - } - }); } catch (LinphoneCoreException e) { e.printStackTrace(); + outputText.setText(e.getMessage() +"\n"+outputText.getText()); } } } From 5566daf9b1dc7451909dcdf3e1c2b730e6ddf896 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 9 Dec 2010 09:08:12 +0100 Subject: [PATCH 068/288] Fixed and improved video test. --- tutorials/JavaCameraRecordImpl.java | 9 ++ tutorials/TestVideoActivity.java | 160 ++++++++++++++++++++++++---- 2 files changed, 150 insertions(+), 19 deletions(-) diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index 12594ccef..33cc6b22e 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -22,6 +22,7 @@ import org.linphone.core.AndroidCameraRecord; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.Size; import android.util.Log; import android.widget.TextView; @@ -49,6 +50,14 @@ public class JavaCameraRecordImpl extends AndroidCameraRecord implements Preview public void onPreviewFrame(byte[] data, Camera camera) { + Size s = camera.getParameters().getPreviewSize(); + int expectedBuffLength = s.width * s.height * 3 /2; + if (expectedBuffLength != data.length) { + Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + + " whereas expected is " + expectedBuffLength + " don't calling putImage"); + return; + } + if ((count % 2 * fps) == 0) { endTime = System.currentTimeMillis(); averageCalledRate = (100000 * 2 * fps) / (endTime - startTime); diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index 4b4ccc09e..971b8f73f 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -15,16 +15,27 @@ 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.tutorials; +import java.util.Stack; + import org.linphone.R; import org.linphone.core.AndroidCameraRecord; +import org.linphone.core.VideoSize; import android.app.Activity; import android.os.Bundle; +import android.util.Log; +import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.View; +import android.view.SurfaceHolder.Callback; +import android.view.View.OnClickListener; +import android.view.ViewGroup.LayoutParams; +import android.widget.Button; import android.widget.TextView; +import static org.linphone.core.VideoSize.*; /** * Activity for displaying and starting the HelloWorld example on Android phone. @@ -32,38 +43,149 @@ import android.widget.TextView; * @author Guillaume Beraudo * */ -public class TestVideoActivity extends Activity { +public class TestVideoActivity extends Activity implements Callback, OnClickListener { private SurfaceView surfaceView; private static final int rate = 7; + private JavaCameraRecordImpl recorder; + private static String tag = "Linphone"; + private TextView debugView; + private Button nextSize; + private Button changeCamera; + private Button changeOrientation; + private AndroidCameraRecord.RecorderParams params; + + private Stack videoSizes = createSizesToTest(); + private int currentCameraId = 2; + private boolean currentOrientationIsPortrait = false; + private int width; + private int height; + private boolean started; + + - - - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videotest); surfaceView=(SurfaceView)findViewById(R.id.videotest_surfaceView); + + nextSize = (Button) findViewById(R.id.test_video_size); + nextSize.setOnClickListener(this); + + changeCamera = (Button) findViewById(R.id.test_video_camera); + changeCamera.setText("Cam"+otherCameraId(currentCameraId)); + changeCamera.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + changeCamera.setText("Cam"+currentCameraId); + currentCameraId = otherCameraId(currentCameraId); + updateRecording(); + } + }); -// SurfaceHolder holder=surfaceView.getHolder(); -// holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - - AndroidCameraRecord.RecorderParams params = new AndroidCameraRecord.RecorderParams(0); - params.surfaceView = surfaceView; - params.width = 352; - params.height = 288; - params.fps = rate; + changeOrientation = (Button) findViewById(R.id.test_video_orientation); + changeOrientation.setText(orientationToString(!currentOrientationIsPortrait)); + changeOrientation.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + currentOrientationIsPortrait = !currentOrientationIsPortrait; + changeOrientation.setText(orientationToString(!currentOrientationIsPortrait)); - JavaCameraRecordImpl recorder = new JavaCameraRecordImpl(params); - recorder.setDebug((TextView) findViewById(R.id.videotest_debug)); - + if (width == 0 || height == 0) return; + int newWidth = currentOrientationIsPortrait? Math.min(height, width) : Math.max(height, width); + int newHeight = currentOrientationIsPortrait? Math.max(height, width) : Math.min(height, width); + changeSurfaceViewLayout(newWidth, newHeight); // will change width and height on surfaceChanged + } + }); + + SurfaceHolder holder = surfaceView.getHolder(); + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + holder.addCallback(this); + + + debugView = (TextView) findViewById(R.id.videotest_debug); + } + + protected void updateRecording() { + if (width == 0 || height == 0) return; + if (recorder != null) recorder.stopPreview(); + + params = new AndroidCameraRecord.RecorderParams(0); + params.surfaceView = surfaceView; + params.width = width; + params.height = height; + params.fps = rate; + params.cameraId = currentCameraId; + + recorder = new JavaCameraRecordImpl(params); +// recorder.setDebug(debugView); + debugView.setText(orientationToString(currentOrientationIsPortrait) + + " w="+width + " h="+height+ " cam"+currentCameraId); + recorder.startPreview(); + + } + + private String orientationToString(boolean orientationIsPortrait) { + return orientationIsPortrait? "Por" : "Lan"; + } + private int otherCameraId(int currentId) { + return (currentId == 2) ? 1 : 2; + } + public void onClick(View v) { + nextSize.setText("Next"); + started=true; + if (videoSizes.isEmpty()) { + videoSizes = createSizesToTest(); + } + + VideoSize size = videoSizes.pop(); + changeSurfaceViewLayout(size.getWidth(), size.getHeight()); + + // on surface changed the recorder will be restarted with new values + // and the surface will be resized } - - - + private void changeSurfaceViewLayout(int width, int height) { + LayoutParams params = surfaceView.getLayoutParams(); + params.height = height; + params.width = width; + surfaceView.setLayoutParams(params); + + } + private Stack createSizesToTest() { + Stack stack = new Stack(); + + stack.push(VideoSize.createStandard(QCIF, false)); + stack.push(VideoSize.createStandard(CIF, false)); + stack.push(VideoSize.createStandard(QVGA, false)); + stack.push(VideoSize.createStandard(HVGA, false)); + stack.push(new VideoSize(640,480)); + stack.push(new VideoSize(800,480)); + return stack; + } + + + + + public void surfaceDestroyed(SurfaceHolder holder) { + surfaceView = null; + Log.d(tag , "Video capture surface destroyed"); + if (recorder != null) recorder.stopPreview(); + } + + public void surfaceCreated(SurfaceHolder holder) { + Log.d(tag , "Video capture surface created"); + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + if (!started) return; + if (recorder != null) recorder.stopPreview(); + + this.width = width; + this.height = height; + + updateRecording(); + } } From 90a5674b978b020637a89782fc90321027a3e629 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 9 Dec 2010 09:13:12 +0100 Subject: [PATCH 069/288] Preliminary support for front camera. --- AndroidCameraRecord.java | 41 ++++++++++----- AndroidCameraRecordBufferedImpl.java | 2 +- AndroidCameraRecordImpl.java | 15 +++--- AndroidCameraRecordManager.java | 77 +++++++++++++++++----------- LinphoneCallParamsImpl.java | 5 ++ 5 files changed, 88 insertions(+), 52 deletions(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 7fa4746bb..a34322f7f 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -39,13 +39,14 @@ public abstract class AndroidCameraRecord { private PreviewCallback storedPreviewCallback; private boolean previewStarted; - protected int orientationCode; + protected int displayOrientation; protected static final String tag="Linphone"; private List supportedVideoSizes; + private Size currentPreviewSize; public AndroidCameraRecord(RecorderParams parameters) { this.params = parameters; - setRotation(parameters.rotation); + setDisplayOrientation(parameters.rotation); } protected List getSupportedPreviewSizes(Camera.Parameters parameters) { @@ -75,11 +76,14 @@ public abstract class AndroidCameraRecord { Camera.Parameters parameters=camera.getParameters(); + parameters.set("camera-id",params.cameraId); + camera.setParameters(parameters); + parameters = camera.getParameters(); if (supportedVideoSizes == null) { - supportedVideoSizes = getSupportedPreviewSizes(camera.getParameters()); + supportedVideoSizes = new ArrayList(getSupportedPreviewSizes(parameters)); } - parameters.set("camera-id", params.cameraId); + if (!params.videoDimensionsInverted) { parameters.setPreviewSize(params.width, params.height); } else { @@ -91,6 +95,7 @@ public abstract class AndroidCameraRecord { onSettingCameraParameters(parameters); camera.setParameters(parameters); + currentPreviewSize = camera.getParameters().getPreviewSize(); SurfaceHolder holder = params.surfaceView.getHolder(); try { @@ -140,12 +145,13 @@ public abstract class AndroidCameraRecord { } - void stopPreview() { + public void stopPreview() { if (!previewStarted) return; lowLevelSetPreviewCallback(camera, null); camera.stopPreview(); camera.release(); camera=null; + if (currentPreviewSize != null) currentPreviewSize = null; previewStarted = false; } @@ -158,12 +164,16 @@ public abstract class AndroidCameraRecord { protected abstract void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb); - public void setRotation(int rotation) { - orientationCode = (4 + 1 - rotation) % 4; + public void setDisplayOrientation(int rotation) { + displayOrientation = rotation; } - protected int getOrientationCode() { - return orientationCode; + protected int rotateCapturedFrame() { + if (params.cameraId == 2) { + return 0; + } else { + return (4 + 1 - displayOrientation) % 4; + } } @@ -175,10 +185,10 @@ public abstract class AndroidCameraRecord { public int width; final long filterDataNativePtr; - int cameraId; - int rotation; + public int cameraId; + public int rotation; public SurfaceView surfaceView; - boolean videoDimensionsInverted; + public boolean videoDimensionsInverted; public RecorderParams(long ptr) { filterDataNativePtr = ptr; @@ -195,4 +205,11 @@ public abstract class AndroidCameraRecord { public List getSupportedVideoSizes() { return new ArrayList(supportedVideoSizes); } + + + protected int getExpectedBufferLength() { + if (currentPreviewSize == null) return -1; + + return currentPreviewSize.width * currentPreviewSize.height * 3 /2; + } } diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index 9f8b2d1c0..232d15970 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -66,7 +66,7 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 protected void onSettingCameraParameters(Parameters parameters) { super.onSettingCameraParameters(parameters); // Only on v8 hardware - camera.setDisplayOrientation(90 * orientationCode); + camera.setDisplayOrientation(90 * displayOrientation); } diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index 2d3087854..daf26ea4e 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -20,7 +20,6 @@ package org.linphone.core; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; -import android.hardware.Camera.Size; import android.util.Log; /** @@ -35,19 +34,19 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev private double timeElapsedBetweenFrames = 0; private long lastFrameTime = 0; private final double expectedTimeBetweenFrames; - private boolean videoDimensionsInverted; + private boolean sizesInverted; public AndroidCameraRecordImpl(RecorderParams parameters) { super(parameters); expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; - videoDimensionsInverted = parameters.videoDimensionsInverted; + sizesInverted = parameters.videoDimensionsInverted; storePreviewCallBack(this); } - private native void putImage(long filterCtxPtr, byte[] buffer, int orientation, boolean videoDimensionsInverted); + private native void putImage(long filterCtxPtr, byte[] buffer, int rotate, boolean sizesInverted); public void onPreviewFrame(byte[] data, Camera camera) { @@ -60,8 +59,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev return; } - Size s = camera.getParameters().getPreviewSize(); - int expectedBuffLength = s.width * s.height * 3 /2; + int expectedBuffLength = getExpectedBufferLength(); if (expectedBuffLength != data.length) { Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + " whereas expected is " + expectedBuffLength + " don't calling putImage"); @@ -71,7 +69,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; - putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted); + putImage(filterCtxPtr, data, rotateCapturedFrame(), sizesInverted); return; } @@ -84,10 +82,11 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev timeElapsedBetweenFrames = currentTimeElapsed; // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted); + putImage(filterCtxPtr, data, rotateCapturedFrame(), sizesInverted); } + @Override protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { camera.setPreviewCallback(cb); diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index c6bae18da..a19413eb7 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -18,9 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.linphone.core.AndroidCameraRecord.RecorderParams; @@ -41,38 +39,21 @@ import android.view.SurfaceHolder.Callback; */ public class AndroidCameraRecordManager { private static final int version = Integer.parseInt(Build.VERSION.SDK); - private static Map instances = new HashMap(); - + private static final String tag = "Linphone"; + private static AndroidCameraRecordManager instance; // singleton - private AndroidCameraRecordManager(int cameraId) { - this.cameraId = cameraId; - } + private AndroidCameraRecordManager() {} - /** - * Instance for a given camera - * @param cameraId : starting from 0 - * @return - */ - public static final synchronized AndroidCameraRecordManager getInstance(int cameraId) { - if (cameraId < 0) { - Log.e("Linphone", "Asking unmanageable camera " + cameraId); - return null; - } - - AndroidCameraRecordManager m = instances.get(cameraId); - if (m == null) { - m = new AndroidCameraRecordManager(cameraId); - instances.put(cameraId, m); - } - return m; - } /** - * @return instance for the default camera + * @return instance */ public static final synchronized AndroidCameraRecordManager getInstance() { - return getInstance(0); + if (instance == null) { + instance = new AndroidCameraRecordManager(); + } + return instance; } private AndroidCameraRecord.RecorderParams parameters; @@ -81,11 +62,26 @@ public class AndroidCameraRecordManager { private AndroidCameraRecord recorder; - private final Integer cameraId; + private List supportedVideoSizes; private int rotation; - private static final String tag = "Linphone"; + + private boolean useFrontCamera; + public void setUseFrontCamera(boolean value) { + if (useFrontCamera == value) return; + this.useFrontCamera = value; + + if (parameters != null) { + parameters.cameraId = cameraId(); + if (isRecording()) { + stopVideoRecording(); + tryToStartVideoRecording(); + } + } + } + public boolean isUseFrontCamera() {return useFrontCamera;} + public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { @@ -94,15 +90,16 @@ public class AndroidCameraRecordManager { p.fps = fps; p.width = width; p.height = height; - p.cameraId = cameraId; + p.cameraId = cameraId(); p.videoDimensionsInverted = width < height; + // width and height will be inverted in Recorder on startPreview parameters = p; tryToStartVideoRecording(); } public final void setSurfaceView(final SurfaceView sv, final int rotation) { - this.rotation = rotation; + this.rotation = useFrontCamera ? 1 : rotation; SurfaceHolder holder = sv.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); @@ -206,4 +203,22 @@ public class AndroidCameraRecordManager { parameters = null; } + public int[] doYouSupportThisVideoSize(int[] askedSize) { + final int askedW = askedSize[0]; + final int askedH = askedSize[1]; + Log.d(tag, "w"+askedW); + Log.d(tag, "h"+askedH); + if (useFrontCamera && isPortraitSize(askedW, askedH)) { + return new int[] {askedH, askedW}; // only landscape supported + } else { + return askedSize; + } + } + private boolean isPortraitSize(int width, int height) { + return width < height; + } + + private static final int rearCamId() {return 1;} + private static final int frontCamId() {return 2;} + private final int cameraId() {return useFrontCamera? frontCamId() : rearCamId(); } } diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index 33d460697..ef05eb228 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -27,6 +27,7 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { private native void enableVideo(long nativePtr, boolean b); private native boolean getVideoEnabled(long nativePtr); + private native void audioBandwidth(long nativePtr, int bw); private native void destroy(long nativePtr); @@ -43,4 +44,8 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { destroy(nativePtr); super.finalize(); } + + public void setAudioBandwidth(int value) { + audioBandwidth(nativePtr, value); + } } From 74096f25ba3d272ce4a267fa18e96707d492308d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 9 Dec 2010 16:09:38 +0100 Subject: [PATCH 070/288] Refactor code to use the new InviteManager which in turn uses the Bandwidth and Camera managers. Improved front camera support. --- AndroidCameraRecordManager.java | 34 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index a19413eb7..c5f409394 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -184,7 +184,7 @@ public class AndroidCameraRecordManager { } // eventually null - + return supportedVideoSizes; } @@ -203,21 +203,33 @@ public class AndroidCameraRecordManager { parameters = null; } - public int[] doYouSupportThisVideoSize(int[] askedSize) { - final int askedW = askedSize[0]; - final int askedH = askedSize[1]; - Log.d(tag, "w"+askedW); - Log.d(tag, "h"+askedH); - if (useFrontCamera && isPortraitSize(askedW, askedH)) { - return new int[] {askedH, askedW}; // only landscape supported + /** + * Naive simple version. + * @param askedSize + * @return + */ + public VideoSize doYouSupportThisVideoSize(VideoSize askedSize) { + Log.d(tag, "Asking camera if it supports size "+askedSize); + if (useFrontCamera && askedSize.isPortrait()) { + return askedSize.createInverted(); // only landscape supported } else { return askedSize; } } - private boolean isPortraitSize(int width, int height) { - return width < height; - } + + private VideoSize closestVideoSize(VideoSize vSize, int defaultSizeCode, boolean defaultIsPortrait) { + VideoSize testSize = vSize.isPortrait() ? vSize.createInverted() : vSize; + + for (Size s : AndroidCameraRecordManager.getInstance().supportedVideoSizes()) { + if (s.height == testSize.getHeight() && s.width == testSize.getWidth()) { + return vSize; + } + } + + return VideoSize.createStandard(defaultSizeCode, defaultIsPortrait); + } + private static final int rearCamId() {return 1;} private static final int frontCamId() {return 2;} private final int cameraId() {return useFrontCamera? frontCamId() : rearCamId(); } From 2961330867f630250f5d4af0c5452eff6fc7a2e9 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 9 Dec 2010 22:52:27 +0100 Subject: [PATCH 071/288] Capture preview is now dynamically resized to fit Linphonecore preferredVideoSize. --- AndroidCameraRecordManager.java | 13 +++++++++++-- LinphoneCoreImpl.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index c5f409394..023dcffa4 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -32,7 +32,7 @@ import android.view.SurfaceHolder.Callback; /** - * Manage the video capture; one instance per camera. + * Manage the video capture, only on for all cameras. * * @author Guillaume Beraudo * @@ -81,6 +81,10 @@ public class AndroidCameraRecordManager { } } public boolean isUseFrontCamera() {return useFrontCamera;} + public boolean toggleUseFrontCamera() { + setUseFrontCamera(!useFrontCamera); + return useFrontCamera; + } @@ -132,13 +136,18 @@ public class AndroidCameraRecordManager { tryToStartVideoRecording(); } } - public void toggleMute() { + public boolean toggleMute() { setMuted(!muted); + return muted; } public boolean isMuted() { return muted; } + public void tryResumingVideoRecording() { + if (isRecording()) return; + tryToStartVideoRecording(); + } private void tryToStartVideoRecording() { if (muted || surfaceView == null || parameters == null) return; diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 62741c7ef..b9b8855ca 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -90,7 +90,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native long[] listVideoPayloadTypes(long nativePtr); - private static String TAG = "LinphoneCore"; + private static final String TAG = "LinphoneCore"; LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; From bbdc548d74ecea04a3514a3563365abbc4764b53 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Dec 2010 16:42:04 +0100 Subject: [PATCH 072/288] fix orientation in 2.2 --- AndroidCameraRecordBufferedImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordBufferedImpl.java index 232d15970..ad54341c3 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordBufferedImpl.java @@ -66,7 +66,7 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 protected void onSettingCameraParameters(Parameters parameters) { super.onSettingCameraParameters(parameters); // Only on v8 hardware - camera.setDisplayOrientation(90 * displayOrientation); + camera.setDisplayOrientation(90 * rotateCapturedFrame()); } From 1a18fe6207b08e209ada35b1c48617b38e2b828a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 13 Dec 2010 14:04:38 +0100 Subject: [PATCH 073/288] Rotate information according to cameraId. --- AndroidCameraRecord.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index a34322f7f..84ad452ef 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -169,7 +169,9 @@ public abstract class AndroidCameraRecord { } protected int rotateCapturedFrame() { - if (params.cameraId == 2) { + if (params.videoDimensionsInverted) { + return 1; // always rotate 90° + } else if (params.cameraId == 2) { return 0; } else { return (4 + 1 - displayOrientation) % 4; From aa289edda101f712dd438803ffc20f47233f454b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 13 Dec 2010 15:21:12 +0100 Subject: [PATCH 074/288] Bind proxyconfig properties and update registration tutorial. --- LinphoneProxyConfigImpl.java | 13 +++++++++++++ tutorials/TutorialRegistrationActivity.java | 11 ++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index f1dcb70a4..0145724b3 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.core.LinphoneCore.RegistrationState; + @@ -25,6 +27,10 @@ package org.linphone.core; class LinphoneProxyConfigImpl implements LinphoneProxyConfig { protected final long nativePtr; + + private native int getState(long nativePtr); + private native void setExpires(long nativePtr, int delay); + boolean ownPtr = false; protected LinphoneProxyConfigImpl(String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException { nativePtr = newLinphoneProxyConfig(); @@ -121,4 +127,11 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { throw new LinphoneCoreException("cannot set route ["+routeUri+"]"); } } + public RegistrationState getState() { + return RegistrationState.fromInt(getState(nativePtr)); + } + + public void setExpires(int delay) { + setExpires(nativePtr, delay); + } } diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java index d87446140..820360294 100644 --- a/tutorials/TutorialRegistrationActivity.java +++ b/tutorials/TutorialRegistrationActivity.java @@ -42,6 +42,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { private TutorialRegistration tutorial; private Button buttonCall; private Handler mHandler = new Handler(); + private TextView outputText; @Override @@ -55,7 +56,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { sipPasswordWidget.setText(defaultSipPassword); // Output text to the outputText widget - final TextView outputText = (TextView) findViewById(R.id.OutputText); + outputText = (TextView) findViewById(R.id.OutputText); final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); @@ -66,6 +67,7 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { // Assign call action to call button buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setText("Register"); buttonCall.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TutorialLaunchingThread thread = new TutorialLaunchingThread(); @@ -74,7 +76,6 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { } }); - // Assign stop action to stop button Button buttonStop = (Button) findViewById(R.id.ButtonStop); buttonStop.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { @@ -92,13 +93,9 @@ public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { tutorial.launchTutorial( sipAddressWidget.getText().toString(), sipPasswordWidget.getText().toString()); - mHandler.post(new Runnable() { - public void run() { - buttonCall.setEnabled(true); - } - }); } catch (LinphoneCoreException e) { e.printStackTrace(); + outputText.setText(e.getMessage() +"\n"+outputText.getText()); } } } From 276874bf64419eb59df7bb9c71fa52364058e982 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 14 Dec 2010 12:58:28 +0100 Subject: [PATCH 075/288] Landscape preview in landscape orientation on sdk>=8 --- AndroidCameraRecord.java | 3 ++- ...fferedImpl.java => AndroidCameraRecordAPI8Impl.java | 10 ++++++---- AndroidCameraRecordManager.java | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) rename AndroidCameraRecordBufferedImpl.java => AndroidCameraRecordAPI8Impl.java (86%) diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 84ad452ef..1696efbc7 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -167,7 +167,8 @@ public abstract class AndroidCameraRecord { public void setDisplayOrientation(int rotation) { displayOrientation = rotation; } - + protected int getDisplayOrientation() {return displayOrientation;} + protected int rotateCapturedFrame() { if (params.videoDimensionsInverted) { return 1; // always rotate 90° diff --git a/AndroidCameraRecordBufferedImpl.java b/AndroidCameraRecordAPI8Impl.java similarity index 86% rename from AndroidCameraRecordBufferedImpl.java rename to AndroidCameraRecordAPI8Impl.java index ad54341c3..9655428db 100644 --- a/AndroidCameraRecordBufferedImpl.java +++ b/AndroidCameraRecordAPI8Impl.java @@ -30,10 +30,10 @@ import android.util.Log; * @author Guillaume Beraudo * */ -public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 { +public class AndroidCameraRecordAPI8Impl extends AndroidCameraRecordImplAPI5 { - public AndroidCameraRecordBufferedImpl(RecorderParams parameters) { + public AndroidCameraRecordAPI8Impl(RecorderParams parameters) { super(parameters); } @@ -66,8 +66,10 @@ public class AndroidCameraRecordBufferedImpl extends AndroidCameraRecordImplAPI5 protected void onSettingCameraParameters(Parameters parameters) { super.onSettingCameraParameters(parameters); // Only on v8 hardware - camera.setDisplayOrientation(90 * rotateCapturedFrame()); + camera.setDisplayOrientation(90 * getPreviewCaptureRotation()); } - + private int getPreviewCaptureRotation() { + return (4 + 1 - displayOrientation) % 4; + } } diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 023dcffa4..42a57806d 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -155,7 +155,7 @@ public class AndroidCameraRecordManager { parameters.rotation = rotation; parameters.surfaceView = surfaceView; if (version >= 8) { - recorder = new AndroidCameraRecordBufferedImpl(parameters); + recorder = new AndroidCameraRecordAPI8Impl(parameters); } else if (version >= 5) { recorder = new AndroidCameraRecordImplAPI5(parameters); } else { From df734bfc9e9525bef6a85877f6667f27f47c2f56 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 14 Dec 2010 15:11:24 +0100 Subject: [PATCH 076/288] decline calls while incall because multi call not supported yet --- LinphoneCallImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 74c701a72..e2aad29a1 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -31,6 +31,7 @@ class LinphoneCallImpl implements LinphoneCall { native private int getState(long nativePtr); private native long getCurrentParamsCopy(long nativePtr); private native void enableCamera(long nativePtr, boolean enabled); + protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -68,4 +69,7 @@ class LinphoneCallImpl implements LinphoneCall { public void enableCamera(boolean enabled) { enableCamera(nativePtr, enabled); } + public boolean equals(Object call) { + return nativePtr == ((LinphoneCallImpl)call).nativePtr; + } } From 02ac3962b99bd5d710161126d6720e772cb89e6d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 29 Dec 2010 08:15:12 +0100 Subject: [PATCH 077/288] Removed getter/setter to access video height/width directly. --- AndroidCameraRecordManager.java | 4 ++-- LinphoneCoreImpl.java | 6 +++--- tutorials/TestVideoActivity.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 42a57806d..a6c38d76d 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -32,7 +32,7 @@ import android.view.SurfaceHolder.Callback; /** - * Manage the video capture, only on for all cameras. + * Manage the video capture, only one for all cameras. * * @author Guillaume Beraudo * @@ -231,7 +231,7 @@ public class AndroidCameraRecordManager { VideoSize testSize = vSize.isPortrait() ? vSize.createInverted() : vSize; for (Size s : AndroidCameraRecordManager.getInstance().supportedVideoSizes()) { - if (s.height == testSize.getHeight() && s.width == testSize.getWidth()) { + if (s.height == testSize.height && s.width == testSize.width) { return vSize; } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 929403c9d..b49856e91 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -395,15 +395,15 @@ class LinphoneCoreImpl implements LinphoneCore { } public void setPreferredVideoSize(VideoSize vSize) { - setPreferredVideoSize(nativePtr, vSize.getWidth(), vSize.getHeight()); + setPreferredVideoSize(nativePtr, vSize.width, vSize.height); } public VideoSize getPreferredVideoSize() { int[] nativeSize = getPreferredVideoSize(nativePtr); VideoSize vSize = new VideoSize(); - vSize.setWidth(nativeSize[0]); - vSize.setHeight(nativeSize[1]); + vSize.width = nativeSize[0]; + vSize.height = nativeSize[1]; return vSize; } public void setRing(String path) { diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index 971b8f73f..6bbdab517 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -139,7 +139,7 @@ public class TestVideoActivity extends Activity implements Callback, OnClickList } VideoSize size = videoSizes.pop(); - changeSurfaceViewLayout(size.getWidth(), size.getHeight()); + changeSurfaceViewLayout(size.width, size.height); // on surface changed the recorder will be restarted with new values // and the surface will be resized From 6dad6a315496600c8a180a39d43e3e86e8ed8360 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 3 Jan 2011 14:14:22 +0100 Subject: [PATCH 078/288] Captured video always sent in correct orientation. Temporarily blocked rotation of phone in video call activity. --- AndroidCameraRecord.java | 30 +-- ...API5.java => AndroidCameraRecord5Impl.java | 4 +- ...Impl.java => AndroidCameraRecord8Impl.java | 10 +- AndroidCameraRecord9Impl.java | 40 ++++ AndroidCameraRecordImpl.java | 12 +- AndroidCameraRecordManager.java | 206 +++++++++++++----- Version.java | 41 ++++ 7 files changed, 249 insertions(+), 94 deletions(-) rename AndroidCameraRecordImplAPI5.java => AndroidCameraRecord5Impl.java (93%) rename AndroidCameraRecordAPI8Impl.java => AndroidCameraRecord8Impl.java (86%) create mode 100644 AndroidCameraRecord9Impl.java create mode 100644 Version.java diff --git a/AndroidCameraRecord.java b/AndroidCameraRecord.java index 1696efbc7..6feafc322 100644 --- a/AndroidCameraRecord.java +++ b/AndroidCameraRecord.java @@ -39,14 +39,12 @@ public abstract class AndroidCameraRecord { private PreviewCallback storedPreviewCallback; private boolean previewStarted; - protected int displayOrientation; protected static final String tag="Linphone"; private List supportedVideoSizes; private Size currentPreviewSize; public AndroidCameraRecord(RecorderParams parameters) { this.params = parameters; - setDisplayOrientation(parameters.rotation); } protected List getSupportedPreviewSizes(Camera.Parameters parameters) { @@ -67,7 +65,7 @@ public abstract class AndroidCameraRecord { } - camera=Camera.open(); + camera = openCamera(params.cameraId); camera.setErrorCallback(new ErrorCallback() { public void onError(int error, Camera camera) { Log.e(tag, "Camera error : " + error); @@ -84,9 +82,10 @@ public abstract class AndroidCameraRecord { } - if (!params.videoDimensionsInverted) { + if (params.width >= params.height) { parameters.setPreviewSize(params.width, params.height); } else { + // invert height and width parameters.setPreviewSize(params.height, params.width); } parameters.setPreviewFrameRate(Math.round(params.fps)); @@ -126,6 +125,10 @@ public abstract class AndroidCameraRecord { + protected Camera openCamera(int cameraId) { + return Camera.open(); + } + protected void onSettingCameraParameters(Parameters parameters) {} /** @@ -164,24 +167,8 @@ public abstract class AndroidCameraRecord { protected abstract void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb); - public void setDisplayOrientation(int rotation) { - displayOrientation = rotation; - } - protected int getDisplayOrientation() {return displayOrientation;} - - protected int rotateCapturedFrame() { - if (params.videoDimensionsInverted) { - return 1; // always rotate 90° - } else if (params.cameraId == 2) { - return 0; - } else { - return (4 + 1 - displayOrientation) % 4; - } - } - - public static class RecorderParams { public float fps; public int height; @@ -191,7 +178,6 @@ public abstract class AndroidCameraRecord { public int cameraId; public int rotation; public SurfaceView surfaceView; - public boolean videoDimensionsInverted; public RecorderParams(long ptr) { filterDataNativePtr = ptr; @@ -200,7 +186,6 @@ public abstract class AndroidCameraRecord { - public boolean isStarted() { return previewStarted; } @@ -215,4 +200,5 @@ public abstract class AndroidCameraRecord { return currentPreviewSize.width * currentPreviewSize.height * 3 /2; } + } diff --git a/AndroidCameraRecordImplAPI5.java b/AndroidCameraRecord5Impl.java similarity index 93% rename from AndroidCameraRecordImplAPI5.java rename to AndroidCameraRecord5Impl.java index 7ff307d03..18e487d12 100644 --- a/AndroidCameraRecordImplAPI5.java +++ b/AndroidCameraRecord5Impl.java @@ -26,9 +26,9 @@ import android.hardware.Camera.Size; import android.util.Log; -public class AndroidCameraRecordImplAPI5 extends AndroidCameraRecordImpl { +public class AndroidCameraRecord5Impl extends AndroidCameraRecordImpl { - public AndroidCameraRecordImplAPI5(RecorderParams parameters) { + public AndroidCameraRecord5Impl(RecorderParams parameters) { super(parameters); } diff --git a/AndroidCameraRecordAPI8Impl.java b/AndroidCameraRecord8Impl.java similarity index 86% rename from AndroidCameraRecordAPI8Impl.java rename to AndroidCameraRecord8Impl.java index 9655428db..490d9ad97 100644 --- a/AndroidCameraRecordAPI8Impl.java +++ b/AndroidCameraRecord8Impl.java @@ -30,10 +30,10 @@ import android.util.Log; * @author Guillaume Beraudo * */ -public class AndroidCameraRecordAPI8Impl extends AndroidCameraRecordImplAPI5 { +public class AndroidCameraRecord8Impl extends AndroidCameraRecord5Impl { - public AndroidCameraRecordAPI8Impl(RecorderParams parameters) { + public AndroidCameraRecord8Impl(RecorderParams parameters) { super(parameters); } @@ -66,10 +66,6 @@ public class AndroidCameraRecordAPI8Impl extends AndroidCameraRecordImplAPI5 { protected void onSettingCameraParameters(Parameters parameters) { super.onSettingCameraParameters(parameters); // Only on v8 hardware - camera.setDisplayOrientation(90 * getPreviewCaptureRotation()); - } - - private int getPreviewCaptureRotation() { - return (4 + 1 - displayOrientation) % 4; + camera.setDisplayOrientation(rotation); } } diff --git a/AndroidCameraRecord9Impl.java b/AndroidCameraRecord9Impl.java new file mode 100644 index 000000000..0ddb283d2 --- /dev/null +++ b/AndroidCameraRecord9Impl.java @@ -0,0 +1,40 @@ +/* +AndroidCameraRecord9Impl.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; + +import android.hardware.Camera; + +/** + * + * Android >= 9 (2.3) version. + * @author Guillaume Beraudo + * + */ +public class AndroidCameraRecord9Impl extends AndroidCameraRecord8Impl { + + + public AndroidCameraRecord9Impl(RecorderParams parameters) { + super(parameters); + } + + @Override + protected Camera openCamera(int cameraId) { + return Camera.open(cameraId); + } +} diff --git a/AndroidCameraRecordImpl.java b/AndroidCameraRecordImpl.java index daf26ea4e..f1a4f4844 100644 --- a/AndroidCameraRecordImpl.java +++ b/AndroidCameraRecordImpl.java @@ -34,19 +34,19 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev private double timeElapsedBetweenFrames = 0; private long lastFrameTime = 0; private final double expectedTimeBetweenFrames; - private boolean sizesInverted; + protected final int rotation; public AndroidCameraRecordImpl(RecorderParams parameters) { super(parameters); expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; - sizesInverted = parameters.videoDimensionsInverted; + rotation = parameters.rotation; storePreviewCallBack(this); } - private native void putImage(long filterCtxPtr, byte[] buffer, int rotate, boolean sizesInverted); + private native void putImage(long filterCtxPtr, byte[] buffer, int rotate); public void onPreviewFrame(byte[] data, Camera camera) { @@ -69,7 +69,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; - putImage(filterCtxPtr, data, rotateCapturedFrame(), sizesInverted); + putImage(filterCtxPtr, data, rotation); return; } @@ -82,7 +82,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev timeElapsedBetweenFrames = currentTimeElapsed; // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data, rotateCapturedFrame(), sizesInverted); + putImage(filterCtxPtr, data, rotation); } @@ -92,6 +92,4 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev camera.setPreviewCallback(cb); } - - } diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index a6c38d76d..5c9f4d7c8 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -22,6 +22,7 @@ import java.util.List; import org.linphone.core.AndroidCameraRecord.RecorderParams; +import android.hardware.Camera; import android.hardware.Camera.Size; import android.os.Build; import android.util.Log; @@ -38,14 +39,9 @@ import android.view.SurfaceHolder.Callback; * */ public class AndroidCameraRecordManager { - private static final int version = Integer.parseInt(Build.VERSION.SDK); private static final String tag = "Linphone"; private static AndroidCameraRecordManager instance; - // singleton - private AndroidCameraRecordManager() {} - - /** * @return instance */ @@ -59,31 +55,76 @@ public class AndroidCameraRecordManager { private AndroidCameraRecord.RecorderParams parameters; private SurfaceView surfaceView; private boolean muted; - + private int cameraId; private AndroidCameraRecord recorder; - - private List supportedVideoSizes; - private int rotation; + private int phoneOrientation; + public int getPhoneOrientation() {return phoneOrientation;} + public void setPhoneOrientation(int degrees) {this.phoneOrientation = degrees;} - private boolean useFrontCamera; + private int frontCameraId; + private int rearCameraId; + + // singleton + private AndroidCameraRecordManager() { + findFrontAndRearCameraIds(); + } + + + private void findFrontAndRearCameraIds() { + if (Version.sdkAbove(9)) { + findFrontAndRearCameraIds9(); + return; + } + + if (Build.DEVICE.startsWith("GT-I9000")) { + // Galaxy S has 2 cameras + frontCameraId = 2; + rearCameraId = 1; + cameraId = rearCameraId; + return; + } + + // default to 0/0 + } + + private void findFrontAndRearCameraIds9() { + for (int id=0; id < getNumberOfCameras9(); id++) { + if (isFrontCamera9(id)) { + frontCameraId = id; + } else { + rearCameraId = id; + } + } + } + + public boolean hasSeveralCameras() { + return frontCameraId != rearCameraId; + } + + public void setUseFrontCamera(boolean value) { - if (useFrontCamera == value) return; - this.useFrontCamera = value; - + if (isFrontCamera() == value) return; // already OK + + toggleUseFrontCamera(); + } + + public boolean isUseFrontCamera() {return isFrontCamera();} + public boolean toggleUseFrontCamera() { + boolean previousUseFront = isFrontCamera(); + + cameraId = previousUseFront ? rearCameraId : frontCameraId; + if (parameters != null) { - parameters.cameraId = cameraId(); + parameters.cameraId = cameraId; if (isRecording()) { stopVideoRecording(); tryToStartVideoRecording(); } } - } - public boolean isUseFrontCamera() {return useFrontCamera;} - public boolean toggleUseFrontCamera() { - setUseFrontCamera(!useFrontCamera); - return useFrontCamera; + + return !previousUseFront; } @@ -94,16 +135,14 @@ public class AndroidCameraRecordManager { p.fps = fps; p.width = width; p.height = height; - p.cameraId = cameraId(); - p.videoDimensionsInverted = width < height; - // width and height will be inverted in Recorder on startPreview + p.cameraId = cameraId; parameters = p; tryToStartVideoRecording(); } - public final void setSurfaceView(final SurfaceView sv, final int rotation) { - this.rotation = useFrontCamera ? 1 : rotation; + public final void setSurfaceView(final SurfaceView sv, final int phoneOrientation) { + this.phoneOrientation = phoneOrientation; SurfaceHolder holder = sv.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); @@ -152,12 +191,15 @@ public class AndroidCameraRecordManager { private void tryToStartVideoRecording() { if (muted || surfaceView == null || parameters == null) return; - parameters.rotation = rotation; + parameters.rotation = bufferRotationForCorrectImageOrientation(); + parameters.surfaceView = surfaceView; - if (version >= 8) { - recorder = new AndroidCameraRecordAPI8Impl(parameters); - } else if (version >= 5) { - recorder = new AndroidCameraRecordImplAPI5(parameters); + if (Version.sdkAbove(9)) { + recorder = new AndroidCameraRecord9Impl(parameters); + } else if (Version.sdkAbove(8)) { + recorder = new AndroidCameraRecord8Impl(parameters); + } else if (Version.sdkAbove(5)) { + recorder = new AndroidCameraRecord5Impl(parameters); } else { recorder = new AndroidCameraRecordImpl(parameters); } @@ -188,8 +230,8 @@ public class AndroidCameraRecordManager { if (supportedVideoSizes != null) return supportedVideoSizes; } - if (version >= 5) { - supportedVideoSizes = AndroidCameraRecordImplAPI5.oneShotSupportedVideoSizes(); + if (Version.sdkAbove(5)) { + supportedVideoSizes = AndroidCameraRecord5Impl.oneShotSupportedVideoSizes(); } // eventually null @@ -212,34 +254,86 @@ public class AndroidCameraRecordManager { parameters = null; } - /** - * Naive simple version. - * @param askedSize - * @return - */ - public VideoSize doYouSupportThisVideoSize(VideoSize askedSize) { - Log.d(tag, "Asking camera if it supports size "+askedSize); - if (useFrontCamera && askedSize.isPortrait()) { - return askedSize.createInverted(); // only landscape supported - } else { - return askedSize; - } + public boolean outputIsPortrait() { + final int rotation = bufferRotationForCorrectImageOrientation(); + final boolean isPortrait = (rotation % 180) == 90; + + Log.d(tag, "Camera sensor in portrait orientation ?" + isPortrait); + return isPortrait; } - private VideoSize closestVideoSize(VideoSize vSize, int defaultSizeCode, boolean defaultIsPortrait) { - VideoSize testSize = vSize.isPortrait() ? vSize.createInverted() : vSize; - - for (Size s : AndroidCameraRecordManager.getInstance().supportedVideoSizes()) { - if (s.height == testSize.height && s.width == testSize.width) { - return vSize; - } - } - - return VideoSize.createStandard(defaultSizeCode, defaultIsPortrait); + + + public static int getNumberOfCameras() { + if (Version.sdkAbove(9)) return getNumberOfCameras9(); + + // Use hacks to guess the number of cameras + if (Build.DEVICE.startsWith("GT-I9000")) { + // Galaxy S has 2 cameras + return 2; + } else + return 1; } - private static final int rearCamId() {return 1;} - private static final int frontCamId() {return 2;} - private final int cameraId() {return useFrontCamera? frontCamId() : rearCamId(); } + private static int getNumberOfCameras9() { + return Camera.getNumberOfCameras(); + } + + public boolean isCameraOrientationPortrait() { + return (getCameraOrientation() % 180) == 90; + } + + public int getCameraOrientation() { + if (Version.sdkAbove(9)) return getCameraOrientation9(); + + // Use hacks to guess orientation of the camera + if (cameraId == 2 && Build.DEVICE.startsWith("GT-I9000")) { + // Galaxy S rear camera + // mounted in landscape for a portrait phone orientation + return 90; + } + return 0; + } + + + private int getCameraOrientation9() { + android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); + Camera.getCameraInfo(cameraId, info); + return info.orientation; + } + + public boolean isFrontCamera() { + if (Version.sdkAbove(9)) return isFrontCamera9(); + + // Use hacks to guess facing of the camera + + if (cameraId == 2 && Build.DEVICE.startsWith("GT-I9000")) { + return true; + } + + return false; + } + + private boolean isFrontCamera9() { + return isFrontCamera9(cameraId); + } + + + private boolean isFrontCamera9(int cameraId) { + android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); + Camera.getCameraInfo(cameraId, info); + return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; + } + + private int bufferRotationForCorrectImageOrientation() { + final int cameraOrientation = getCameraOrientation(); + final int rotation = Version.sdkAbove(8) ? + (360 - cameraOrientation + 90 - phoneOrientation) % 360 + : 0; + Log.d(tag, "Capture video buffer will need a rotation of " + rotation + + " degrees : camera " + cameraOrientation + + ", phone " + phoneOrientation); + return rotation; + } } diff --git a/Version.java b/Version.java new file mode 100644 index 000000000..0ec07fc25 --- /dev/null +++ b/Version.java @@ -0,0 +1,41 @@ +/* +Version.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; + +import android.os.Build; + +/** + * Centralize version access and allow simulation of lower versions. + * @author Guillaume Beraudo + */ +public class Version { + + private static final int buildVersion = +// Integer.parseInt(Build.VERSION.SDK); + 7; // 2.1 + + public static final boolean sdkAbove(int value) { + return buildVersion >= value; + } + + public static final boolean sdkBelow(int value) { + return buildVersion < value; + } + +} From e161f668e5f83bc3d741d23c28de8fe0788c1ab1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 18 Jan 2011 16:19:27 +0100 Subject: [PATCH 079/288] change sent video orientation when phone is rotated --- LinphoneCoreImpl.java | 2 +- Version.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b49856e91..3c21fe0f6 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -382,7 +382,7 @@ class LinphoneCoreImpl implements LinphoneCore { public int updateCall(LinphoneCall call, LinphoneCallParams params) { long ptrCall = ((LinphoneCallImpl) call).nativePtr; - long ptrParams = ((LinphoneCallParamsImpl)params).nativePtr; + long ptrParams = params!=null ? ((LinphoneCallParamsImpl)params).nativePtr : 0; return updateCall(nativePtr, ptrCall, ptrParams); } diff --git a/Version.java b/Version.java index 0ec07fc25..b094e31d7 100644 --- a/Version.java +++ b/Version.java @@ -27,8 +27,8 @@ import android.os.Build; public class Version { private static final int buildVersion = -// Integer.parseInt(Build.VERSION.SDK); - 7; // 2.1 + Integer.parseInt(Build.VERSION.SDK); +// 7; // 2.1 public static final boolean sdkAbove(int value) { return buildVersion >= value; @@ -38,4 +38,4 @@ public class Version { return buildVersion < value; } -} +} \ No newline at end of file From ed6a5bf8413f62d154f4e6bb9dfe76816f13786a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 24 Jan 2011 10:45:40 +0100 Subject: [PATCH 080/288] disable EC while in speaker mode --- LinphoneCallImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index e2aad29a1..001443492 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -31,7 +31,10 @@ class LinphoneCallImpl implements LinphoneCall { native private int getState(long nativePtr); private native long getCurrentParamsCopy(long nativePtr); private native void enableCamera(long nativePtr, boolean enabled); - + private native void enableEchoCancellation(long nativePtr,boolean enable); + private native boolean isEchoCancellationEnabled(long nativePtr) ; + private native void enableEchoLimiter(long nativePtr,boolean enable); + private native boolean isEchoLimiterEnabled(long nativePtr) ; protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -72,4 +75,17 @@ class LinphoneCallImpl implements LinphoneCall { public boolean equals(Object call) { return nativePtr == ((LinphoneCallImpl)call).nativePtr; } + public void enableEchoCancellation(boolean enable) { + enableEchoCancellation(nativePtr,enable); + + } + public boolean isEchoCancellationEnabled() { + return isEchoCancellationEnabled(nativePtr); + } + public void enableEchoLimiter(boolean enable) { + enableEchoLimiter(nativePtr,enable); + } + public boolean isEchoLimiterEnabled() { + return isEchoLimiterEnabled(nativePtr); + } } From 7f43336078404630e72c09f5c76c5313a1d64cfa Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 25 Jan 2011 15:45:15 +0100 Subject: [PATCH 081/288] Fix cameraID=0 on Galaxy tab GT-P1000. Move sdk9 code from Video manager to dedicated class to avoid dalvik errors. Add phone information dump at Linphone startup. Add "Hack" class to centralize call to hackish code. --- AndroidCameraConf.java | 77 +++++++++++++++++++++++++ AndroidCameraConf9.java | 50 +++++++++++++++++ AndroidCameraRecordManager.java | 99 ++++----------------------------- LinphoneCoreImpl.java | 2 - 4 files changed, 139 insertions(+), 89 deletions(-) create mode 100644 AndroidCameraConf.java create mode 100644 AndroidCameraConf9.java diff --git a/AndroidCameraConf.java b/AndroidCameraConf.java new file mode 100644 index 000000000..242000dc7 --- /dev/null +++ b/AndroidCameraConf.java @@ -0,0 +1,77 @@ +/* +AndroidCameraConf.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; + +import org.linphone.Hacks; + +import android.util.Log; + +public class AndroidCameraConf { + private static final String tag = "Linphone"; + + public void findFrontAndRearCameraIds(Integer frontCameraId, Integer rearCameraId, Integer cameraId) { + + if (Hacks.isGalaxyS()) { + Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); + frontCameraId = 2; + rearCameraId = 1; + cameraId = rearCameraId; + return; + } + + // default to 0/0 + } + + public int getNumberOfCameras() { + // Use hacks to guess the number of cameras + if (Hacks.isGalaxyS()) { + Log.d(tag, "Hack Galaxy S : has 2 cameras"); + return 2; + } else + return 1; + } + + + + public int getCameraOrientation(int cameraId) { + // Use hacks to guess orientation of the camera + if (cameraId == 2 && Hacks.isGalaxyS()) { + Log.d(tag, "Hack Galaxy S : rear camera id=2 ; mounted landscape"); + // mounted in landscape for a portrait phone orientation + return 90; + } + return 0; + } + + + + + public boolean isFrontCamera(int cameraId) { + // Use hacks to guess facing of the camera + if (cameraId == 2 && Hacks.isGalaxyS()) { + Log.d(tag, "Hack Galaxy S : front camera has id=2"); + return true; + } + + return false; + } + + + +} diff --git a/AndroidCameraConf9.java b/AndroidCameraConf9.java new file mode 100644 index 000000000..07e49bab0 --- /dev/null +++ b/AndroidCameraConf9.java @@ -0,0 +1,50 @@ +/* +AndroidCameraConf9.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; + +import android.hardware.Camera; + +public class AndroidCameraConf9 extends AndroidCameraConf { + + public void findFrontAndRearCameraIds9(Integer frontCameraId, Integer rearCameraId, Integer cameraId) { + for (int id=0; id < getNumberOfCameras(); id++) { + if (isFrontCamera(id)) { + frontCameraId = id; + } else { + rearCameraId = id; + } + } + } + + public int getNumberOfCameras() { + return Camera.getNumberOfCameras(); + } + + public int getCameraOrientation(int cameraId) { + android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); + Camera.getCameraInfo(cameraId, info); + return info.orientation; + } + + public boolean isFrontCamera(int cameraId) { + android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); + Camera.getCameraInfo(cameraId, info); + return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; + } +} diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 5c9f4d7c8..ffdcc3eea 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -22,9 +22,7 @@ import java.util.List; import org.linphone.core.AndroidCameraRecord.RecorderParams; -import android.hardware.Camera; import android.hardware.Camera.Size; -import android.os.Build; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -53,6 +51,7 @@ public class AndroidCameraRecordManager { } private AndroidCameraRecord.RecorderParams parameters; + private final AndroidCameraConf cc; private SurfaceView surfaceView; private boolean muted; private int cameraId; @@ -68,36 +67,15 @@ public class AndroidCameraRecordManager { // singleton private AndroidCameraRecordManager() { - findFrontAndRearCameraIds(); + cc = Version.sdkAbove(9) ? new AndroidCameraConf9() : new AndroidCameraConf(); + + Integer fId = -1;Integer rId = -1;Integer cId = -1; + cc.findFrontAndRearCameraIds(fId, rId, cId); + frontCameraId=fId;rearCameraId=rId;cameraId=cId; } - private void findFrontAndRearCameraIds() { - if (Version.sdkAbove(9)) { - findFrontAndRearCameraIds9(); - return; - } - if (Build.DEVICE.startsWith("GT-I9000")) { - // Galaxy S has 2 cameras - frontCameraId = 2; - rearCameraId = 1; - cameraId = rearCameraId; - return; - } - - // default to 0/0 - } - - private void findFrontAndRearCameraIds9() { - for (int id=0; id < getNumberOfCameras9(); id++) { - if (isFrontCamera9(id)) { - frontCameraId = id; - } else { - rearCameraId = id; - } - } - } public boolean hasSeveralCameras() { return frontCameraId != rearCameraId; @@ -105,14 +83,14 @@ public class AndroidCameraRecordManager { public void setUseFrontCamera(boolean value) { - if (isFrontCamera() == value) return; // already OK + if (cc.isFrontCamera(cameraId) == value) return; // already OK toggleUseFrontCamera(); } - public boolean isUseFrontCamera() {return isFrontCamera();} + public boolean isUseFrontCamera() {return cc.isFrontCamera(cameraId);} public boolean toggleUseFrontCamera() { - boolean previousUseFront = isFrontCamera(); + boolean previousUseFront = cc.isFrontCamera(cameraId); cameraId = previousUseFront ? rearCameraId : frontCameraId; @@ -265,69 +243,16 @@ public class AndroidCameraRecordManager { - public static int getNumberOfCameras() { - if (Version.sdkAbove(9)) return getNumberOfCameras9(); - - // Use hacks to guess the number of cameras - if (Build.DEVICE.startsWith("GT-I9000")) { - // Galaxy S has 2 cameras - return 2; - } else - return 1; - } - - private static int getNumberOfCameras9() { - return Camera.getNumberOfCameras(); - } + public boolean isCameraOrientationPortrait() { - return (getCameraOrientation() % 180) == 90; - } - - public int getCameraOrientation() { - if (Version.sdkAbove(9)) return getCameraOrientation9(); - - // Use hacks to guess orientation of the camera - if (cameraId == 2 && Build.DEVICE.startsWith("GT-I9000")) { - // Galaxy S rear camera - // mounted in landscape for a portrait phone orientation - return 90; - } - return 0; + return (cc.getCameraOrientation(cameraId) % 180) == 90; } - private int getCameraOrientation9() { - android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); - Camera.getCameraInfo(cameraId, info); - return info.orientation; - } - - public boolean isFrontCamera() { - if (Version.sdkAbove(9)) return isFrontCamera9(); - - // Use hacks to guess facing of the camera - - if (cameraId == 2 && Build.DEVICE.startsWith("GT-I9000")) { - return true; - } - - return false; - } - - private boolean isFrontCamera9() { - return isFrontCamera9(cameraId); - } - - - private boolean isFrontCamera9(int cameraId) { - android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); - Camera.getCameraInfo(cameraId, info); - return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; - } private int bufferRotationForCorrectImageOrientation() { - final int cameraOrientation = getCameraOrientation(); + final int cameraOrientation = cc.getCameraOrientation(cameraId); final int rotation = Version.sdkAbove(8) ? (360 - cameraOrientation + 90 - phoneOrientation) % 360 : 0; diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 3c21fe0f6..01ba4e652 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -90,8 +90,6 @@ class LinphoneCoreImpl implements LinphoneCore { private native long[] listVideoPayloadTypes(long nativePtr); - private static final String TAG = "LinphoneCore"; - LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); From 6714bdbe1e53544f929c2282a2a0be0c61e82376 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 25 Jan 2011 15:45:36 +0100 Subject: [PATCH 082/288] add ec calibrator --- LinphoneCoreImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 3c21fe0f6..2f33278f9 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -88,6 +88,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); private native long[] listVideoPayloadTypes(long nativePtr); + private native void enableKeepAlive(long nativePtr,boolean enable); + private native boolean isKeepAliveEnabled(long nativePtr); + private native int startEchoCalibration(long nativePtr,Object data); private static final String TAG = "LinphoneCore"; @@ -428,4 +431,14 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isNetworkReachable() { throw new RuntimeException("Not implemented"); } + public void enableKeepAlive(boolean enable) { + enableKeepAlive(nativePtr,enable); + + } + public boolean isKeepAliveEnabled() { + return isKeepAliveEnabled(nativePtr); + } + public void startEchoCalibration(Object data) throws LinphoneCoreException { + startEchoCalibration(nativePtr, data); + } } From ddfd680240a32ed53d192f15a3d8f1943f22eb8d Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 26 Jan 2011 14:29:36 +0100 Subject: [PATCH 083/288] fix Galaxy S detection --- AndroidCameraConf.java | 10 +++++----- AndroidCameraRecordManager.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AndroidCameraConf.java b/AndroidCameraConf.java index 242000dc7..523f249b0 100644 --- a/AndroidCameraConf.java +++ b/AndroidCameraConf.java @@ -25,13 +25,13 @@ import android.util.Log; public class AndroidCameraConf { private static final String tag = "Linphone"; - public void findFrontAndRearCameraIds(Integer frontCameraId, Integer rearCameraId, Integer cameraId) { - + public void findFrontAndRearCameraIds(int[] frontCameraId, int[] rearCameraId, int[] cameraId) { + Log.i(tag, "Detecting cameras"); if (Hacks.isGalaxyS()) { Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); - frontCameraId = 2; - rearCameraId = 1; - cameraId = rearCameraId; + frontCameraId[0] = 2; + rearCameraId[0] = 1; + cameraId[0] = rearCameraId[0]; return; } diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index ffdcc3eea..2ca3d70aa 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -69,9 +69,9 @@ public class AndroidCameraRecordManager { private AndroidCameraRecordManager() { cc = Version.sdkAbove(9) ? new AndroidCameraConf9() : new AndroidCameraConf(); - Integer fId = -1;Integer rId = -1;Integer cId = -1; + int[] fId = {-1};int[] rId = {-1};int[] cId = {-1}; cc.findFrontAndRearCameraIds(fId, rId, cId); - frontCameraId=fId;rearCameraId=rId;cameraId=cId; + frontCameraId=fId[0];rearCameraId=rId[0];cameraId=cId[0]; } From 05c6be619ecddfffe3ffeef7c5c4b551cdd78962 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 2 Feb 2011 22:25:50 +0100 Subject: [PATCH 084/288] allow auto replacement of calls and update ffmpeg commit id due to forced update --- LinphoneCallImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 001443492..a7104ffef 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -34,7 +34,8 @@ class LinphoneCallImpl implements LinphoneCall { private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr) ; 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); protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -88,4 +89,12 @@ class LinphoneCallImpl implements LinphoneCall { public boolean isEchoLimiterEnabled() { return isEchoLimiterEnabled(nativePtr); } + public LinphoneCall getReplacedCall(){ + long callptr=getReplacedCall(nativePtr); + if (callptr!=0){ + return new LinphoneCallImpl(callptr); + } + return null; + } + } From 3c760cd68d24b0ceb3142acb08419c4dbc78500b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 14 Feb 2011 15:58:09 +0100 Subject: [PATCH 085/288] Make phones with sdk >=9 report they use SDK 8. --- Version.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Version.java b/Version.java index b094e31d7..2b938dbea 100644 --- a/Version.java +++ b/Version.java @@ -26,8 +26,8 @@ import android.os.Build; */ public class Version { - private static final int buildVersion = - Integer.parseInt(Build.VERSION.SDK); + private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK) >= 9? + 8 : Integer.parseInt(Build.VERSION.SDK); // Force versions above 9 to 8 // 7; // 2.1 public static final boolean sdkAbove(int value) { From 099907b8ee1d12eb26034ffec75d5c45618f63ad Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 22 Feb 2011 14:41:27 +0100 Subject: [PATCH 086/288] Several enhancements: - Fix errors in start/stop linphoneManager - Fix calls to guiListener().xx when null - Fix restart of linphoneManager - Cleanup some useless code - Work on outgoingCallReceiver - Intent CALL_PRIVILEDGED --- AndroidCameraRecordManager.java | 12 ++++++------ LinphoneCoreImpl.java | 6 +++--- Version.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AndroidCameraRecordManager.java b/AndroidCameraRecordManager.java index 2ca3d70aa..ecf12c597 100644 --- a/AndroidCameraRecordManager.java +++ b/AndroidCameraRecordManager.java @@ -67,7 +67,7 @@ public class AndroidCameraRecordManager { // singleton private AndroidCameraRecordManager() { - cc = Version.sdkAbove(9) ? new AndroidCameraConf9() : new AndroidCameraConf(); + cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf(); int[] fId = {-1};int[] rId = {-1};int[] cId = {-1}; cc.findFrontAndRearCameraIds(fId, rId, cId); @@ -172,11 +172,11 @@ public class AndroidCameraRecordManager { parameters.rotation = bufferRotationForCorrectImageOrientation(); parameters.surfaceView = surfaceView; - if (Version.sdkAbove(9)) { + if (Version.sdkAboveOrEqual(9)) { recorder = new AndroidCameraRecord9Impl(parameters); - } else if (Version.sdkAbove(8)) { + } else if (Version.sdkAboveOrEqual(8)) { recorder = new AndroidCameraRecord8Impl(parameters); - } else if (Version.sdkAbove(5)) { + } else if (Version.sdkAboveOrEqual(5)) { recorder = new AndroidCameraRecord5Impl(parameters); } else { recorder = new AndroidCameraRecordImpl(parameters); @@ -208,7 +208,7 @@ public class AndroidCameraRecordManager { if (supportedVideoSizes != null) return supportedVideoSizes; } - if (Version.sdkAbove(5)) { + if (Version.sdkAboveOrEqual(5)) { supportedVideoSizes = AndroidCameraRecord5Impl.oneShotSupportedVideoSizes(); } @@ -253,7 +253,7 @@ public class AndroidCameraRecordManager { private int bufferRotationForCorrectImageOrientation() { final int cameraOrientation = cc.getCameraOrientation(cameraId); - final int rotation = Version.sdkAbove(8) ? + final int rotation = Version.sdkAboveOrEqual(8) ? (360 - cameraOrientation + 90 - phoneOrientation) % 360 : 0; Log.d(tag, "Capture video buffer will need a rotation of " + rotation diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 1a9fc67a7..533ee8b97 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -64,7 +64,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr); private native long getCurrentCall(long nativePtr) ; - private native void playDtmf(long nativePtr,char dtmf,int duration); + private native void playDtmf(long nativePtr,char dtmf,int duration, boolean speaker); private native void stopDtmf(long nativePtr); private native void setVideoWindowId(long nativePtr, Object wid); private native void setPreviewWindowId(long nativePtr, Object wid); @@ -298,8 +298,8 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } - public void playDtmf(char number, int duration) { - playDtmf(nativePtr,number, duration); + public void playDtmf(char number, int duration, boolean speaker) { + playDtmf(nativePtr,number, duration, speaker); } public void stopDtmf() { diff --git a/Version.java b/Version.java index 2b938dbea..057fb53a3 100644 --- a/Version.java +++ b/Version.java @@ -30,11 +30,11 @@ public class Version { 8 : Integer.parseInt(Build.VERSION.SDK); // Force versions above 9 to 8 // 7; // 2.1 - public static final boolean sdkAbove(int value) { + public static final boolean sdkAboveOrEqual(int value) { return buildVersion >= value; } - public static final boolean sdkBelow(int value) { + public static final boolean sdkStrictlyBelow(int value) { return buildVersion < value; } From 5ffaf9c434bfe173bfd1a1a83d868df4cba04f1c Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 23 Feb 2011 15:37:28 +0100 Subject: [PATCH 087/288] Enhancements: - Numpad component factorizing setAddressWidget - Digit uses style - No more NewOutgoingCallReceiver and the associated magic Now uses CALL_PRIVILEDGED - Move Video classes to core.video package and lower visibility - Merged AndroidCameraRecord5Impl and AndroidCameraRecordImpl --- AndroidCameraRecord5Impl.java | 64 ------------------- Version.java | 4 ++ tutorials/AndroidTutorialNotifier.java | 3 +- tutorials/JavaCameraRecordImpl.java | 10 ++- tutorials/TestVideoActivity.java | 2 +- .../AndroidCameraConf.java | 7 +- .../AndroidCameraConf9.java | 4 +- .../AndroidCameraRecord.java | 2 +- .../AndroidCameraRecord8.java | 6 +- .../AndroidCameraRecord9.java | 6 +- .../AndroidCameraRecordImpl.java | 37 ++++++++++- .../AndroidCameraRecordManager.java | 15 +++-- 12 files changed, 71 insertions(+), 89 deletions(-) delete mode 100644 AndroidCameraRecord5Impl.java rename AndroidCameraConf.java => video/AndroidCameraConf.java (94%) rename AndroidCameraConf9.java => video/AndroidCameraConf9.java (94%) rename AndroidCameraRecord.java => video/AndroidCameraRecord.java (99%) rename AndroidCameraRecord8Impl.java => video/AndroidCameraRecord8.java (92%) rename AndroidCameraRecord9Impl.java => video/AndroidCameraRecord9.java (86%) rename AndroidCameraRecordImpl.java => video/AndroidCameraRecordImpl.java (67%) rename AndroidCameraRecordManager.java => video/AndroidCameraRecordManager.java (94%) diff --git a/AndroidCameraRecord5Impl.java b/AndroidCameraRecord5Impl.java deleted file mode 100644 index 18e487d12..000000000 --- a/AndroidCameraRecord5Impl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* -AndroidCameraRecordImplAPI5.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; - -import java.util.List; - -import android.hardware.Camera; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.Size; -import android.util.Log; - - -public class AndroidCameraRecord5Impl extends AndroidCameraRecordImpl { - - public AndroidCameraRecord5Impl(RecorderParams parameters) { - super(parameters); - } - - @Override - protected void onSettingCameraParameters(Parameters parameters) { - super.onSettingCameraParameters(parameters); - - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { - Log.w(tag, "Auto Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); - } else { - Log.w(tag, "Auto Focus not supported by camera device"); - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { - Log.w(tag, "Infinity Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); - } else { - Log.w(tag, "Infinity Focus not supported by camera device"); - } - } - } - - public static List oneShotSupportedVideoSizes() { - Camera camera = Camera.open(); - List supportedVideoSizes =camera.getParameters().getSupportedPreviewSizes(); - camera.release(); - return supportedVideoSizes; - } - - @Override - protected List getSupportedPreviewSizes(Parameters parameters) { - return parameters.getSupportedPreviewSizes(); - } -} diff --git a/Version.java b/Version.java index 057fb53a3..c06a2efea 100644 --- a/Version.java +++ b/Version.java @@ -38,4 +38,8 @@ public class Version { return buildVersion < value; } + public static int sdk() { + return buildVersion; + } + } \ No newline at end of file diff --git a/tutorials/AndroidTutorialNotifier.java b/tutorials/AndroidTutorialNotifier.java index 01e0555e2..7721f7dc1 100644 --- a/tutorials/AndroidTutorialNotifier.java +++ b/tutorials/AndroidTutorialNotifier.java @@ -23,11 +23,12 @@ import android.widget.TextView; /** * Write notifications to a TextView widget. + * This is an helper class, not a test activity. * * @author Guillaume Beraudo * */ -public class AndroidTutorialNotifier extends TutorialNotifier { +class AndroidTutorialNotifier extends TutorialNotifier { private Handler mHandler; private TextView outputTextView; diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index 33cc6b22e..a40bee238 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.tutorials; -import org.linphone.core.AndroidCameraRecord; +import org.linphone.core.video.AndroidCameraRecord; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; @@ -26,7 +26,13 @@ import android.hardware.Camera.Size; import android.util.Log; import android.widget.TextView; -public class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { +/** + * This is an helper class, not a test activity. + * + * @author Guillaume Beraudo + * + */ +class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { private TextView debug; private long count = 0; diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index 6bbdab517..ce3a9185b 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -21,8 +21,8 @@ package org.linphone.core.tutorials; import java.util.Stack; import org.linphone.R; -import org.linphone.core.AndroidCameraRecord; import org.linphone.core.VideoSize; +import org.linphone.core.video.AndroidCameraRecord; import android.app.Activity; import android.os.Bundle; diff --git a/AndroidCameraConf.java b/video/AndroidCameraConf.java similarity index 94% rename from AndroidCameraConf.java rename to video/AndroidCameraConf.java index 523f249b0..1d430082e 100644 --- a/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -16,13 +16,13 @@ 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; +package org.linphone.core.video; import org.linphone.Hacks; import android.util.Log; -public class AndroidCameraConf { +class AndroidCameraConf { private static final String tag = "Linphone"; public void findFrontAndRearCameraIds(int[] frontCameraId, int[] rearCameraId, int[] cameraId) { @@ -39,6 +39,7 @@ public class AndroidCameraConf { } public int getNumberOfCameras() { + Log.i(tag, "Detecting the number of cameras"); // Use hacks to guess the number of cameras if (Hacks.isGalaxyS()) { Log.d(tag, "Hack Galaxy S : has 2 cameras"); @@ -46,7 +47,7 @@ public class AndroidCameraConf { } else return 1; } - + public int getCameraOrientation(int cameraId) { diff --git a/AndroidCameraConf9.java b/video/AndroidCameraConf9.java similarity index 94% rename from AndroidCameraConf9.java rename to video/AndroidCameraConf9.java index 07e49bab0..4c3713b83 100644 --- a/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -16,11 +16,11 @@ 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; +package org.linphone.core.video; import android.hardware.Camera; -public class AndroidCameraConf9 extends AndroidCameraConf { +class AndroidCameraConf9 extends AndroidCameraConf { public void findFrontAndRearCameraIds9(Integer frontCameraId, Integer rearCameraId, Integer cameraId) { for (int id=0; id < getNumberOfCameras(); id++) { diff --git a/AndroidCameraRecord.java b/video/AndroidCameraRecord.java similarity index 99% rename from AndroidCameraRecord.java rename to video/AndroidCameraRecord.java index 6feafc322..64af664f5 100644 --- a/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -16,7 +16,7 @@ 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; +package org.linphone.core.video; import java.util.ArrayList; import java.util.Collections; diff --git a/AndroidCameraRecord8Impl.java b/video/AndroidCameraRecord8.java similarity index 92% rename from AndroidCameraRecord8Impl.java rename to video/AndroidCameraRecord8.java index 490d9ad97..20805bd64 100644 --- a/AndroidCameraRecord8Impl.java +++ b/video/AndroidCameraRecord8.java @@ -16,7 +16,7 @@ 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; +package org.linphone.core.video; import android.hardware.Camera; import android.hardware.Camera.Parameters; @@ -30,10 +30,10 @@ import android.util.Log; * @author Guillaume Beraudo * */ -public class AndroidCameraRecord8Impl extends AndroidCameraRecord5Impl { +class AndroidCameraRecord8 extends AndroidCameraRecordImpl { - public AndroidCameraRecord8Impl(RecorderParams parameters) { + public AndroidCameraRecord8(RecorderParams parameters) { super(parameters); } diff --git a/AndroidCameraRecord9Impl.java b/video/AndroidCameraRecord9.java similarity index 86% rename from AndroidCameraRecord9Impl.java rename to video/AndroidCameraRecord9.java index 0ddb283d2..d81e8103e 100644 --- a/AndroidCameraRecord9Impl.java +++ b/video/AndroidCameraRecord9.java @@ -16,7 +16,7 @@ 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; +package org.linphone.core.video; import android.hardware.Camera; @@ -26,10 +26,10 @@ import android.hardware.Camera; * @author Guillaume Beraudo * */ -public class AndroidCameraRecord9Impl extends AndroidCameraRecord8Impl { +class AndroidCameraRecord9 extends AndroidCameraRecord8 { - public AndroidCameraRecord9Impl(RecorderParams parameters) { + public AndroidCameraRecord9(RecorderParams parameters) { super(parameters); } diff --git a/AndroidCameraRecordImpl.java b/video/AndroidCameraRecordImpl.java similarity index 67% rename from AndroidCameraRecordImpl.java rename to video/AndroidCameraRecordImpl.java index f1a4f4844..9e30cca07 100644 --- a/AndroidCameraRecordImpl.java +++ b/video/AndroidCameraRecordImpl.java @@ -16,19 +16,24 @@ 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; +package org.linphone.core.video; + +import java.util.List; import android.hardware.Camera; +import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.Size; import android.util.Log; /** * Record from Android camera. + * Android >= 5 (2.0) version. * * @author Guillaume Beraudo * */ -public class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { +class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { private long filterCtxPtr; private double timeElapsedBetweenFrames = 0; @@ -85,7 +90,35 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev putImage(filterCtxPtr, data, rotation); } + @Override + protected void onSettingCameraParameters(Parameters parameters) { + super.onSettingCameraParameters(parameters); + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { + Log.w(tag, "Auto Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); + } else { + Log.w(tag, "Auto Focus not supported by camera device"); + if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { + Log.w(tag, "Infinity Focus supported by camera device"); + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); + } else { + Log.w(tag, "Infinity Focus not supported by camera device"); + } + } + } + + public static List oneShotSupportedVideoSizes() { + Camera camera = Camera.open(); + List supportedVideoSizes =camera.getParameters().getSupportedPreviewSizes(); + camera.release(); + return supportedVideoSizes; + } + + @Override + protected List getSupportedPreviewSizes(Parameters parameters) { + return parameters.getSupportedPreviewSizes(); + } @Override protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { diff --git a/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java similarity index 94% rename from AndroidCameraRecordManager.java rename to video/AndroidCameraRecordManager.java index ecf12c597..87c4f53ac 100644 --- a/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -16,11 +16,12 @@ 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; +package org.linphone.core.video; import java.util.List; -import org.linphone.core.AndroidCameraRecord.RecorderParams; +import org.linphone.core.Version; +import org.linphone.core.video.AndroidCameraRecord.RecorderParams; import android.hardware.Camera.Size; import android.util.Log; @@ -173,13 +174,13 @@ public class AndroidCameraRecordManager { parameters.surfaceView = surfaceView; if (Version.sdkAboveOrEqual(9)) { - recorder = new AndroidCameraRecord9Impl(parameters); + recorder = new AndroidCameraRecord9(parameters); } else if (Version.sdkAboveOrEqual(8)) { - recorder = new AndroidCameraRecord8Impl(parameters); + recorder = new AndroidCameraRecord8(parameters); } else if (Version.sdkAboveOrEqual(5)) { - recorder = new AndroidCameraRecord5Impl(parameters); - } else { recorder = new AndroidCameraRecordImpl(parameters); + } else { + throw new RuntimeException("SDK version unsupported " + Version.sdk()); } recorder.startPreview(); @@ -209,7 +210,7 @@ public class AndroidCameraRecordManager { } if (Version.sdkAboveOrEqual(5)) { - supportedVideoSizes = AndroidCameraRecord5Impl.oneShotSupportedVideoSizes(); + supportedVideoSizes = AndroidCameraRecordImpl.oneShotSupportedVideoSizes(); } // eventually null From 2b84ac3ee4cd69a6b0e2c5e4daa0fea9150da04b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 28 Feb 2011 11:55:52 +0100 Subject: [PATCH 088/288] Incall view. Hack for Audio with Galaxy S --- Hacks.java | 75 ++++++++++++++++++++++++++++++++++++ LinphoneCallImpl.java | 5 +++ LinphoneCoreImpl.java | 9 +++-- video/AndroidCameraConf.java | 2 +- 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 Hacks.java diff --git a/Hacks.java b/Hacks.java new file mode 100644 index 000000000..49c3125ae --- /dev/null +++ b/Hacks.java @@ -0,0 +1,75 @@ +/* +Hacks.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; + +import android.media.AudioManager; +import android.os.Build; +import android.util.Log; + +public class Hacks { + + private Hacks() {} + + public static boolean isGalaxyS() { + return Build.DEVICE.startsWith("GT-I9000") || Build.DEVICE.startsWith("GT-P1000"); + } + +/* private static final boolean log(final String msg) { + Log.d("Linphone", msg); + return true; + }*/ + + /* Not working as now + * Calling from Galaxy S to PC is "usable" even with no hack; other side is not even with this one*/ + public static void galaxySSwitchToCallStreamUnMuteLowerVolume(AudioManager am) { + // Switch to call audio channel (Galaxy S) + am.setSpeakerphoneOn(false); + sleep(200); + + // Lower volume + am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 1, 0); + + // Another way to select call channel + am.setMode(AudioManager.MODE_NORMAL); + sleep(200); + + // Mic is muted if not doing this + am.setMicrophoneMute(true); + sleep(200); + am.setMicrophoneMute(false); + sleep(200); + } + + private static final void sleep(int time) { + try { + Thread.sleep(time); + } catch(InterruptedException ie){} + } + + public static void dumpDeviceInformation() { + StringBuilder sb = new StringBuilder(" ==== Phone information dump ====\n"); + sb.append("DEVICE=").append(Build.DEVICE).append("\n"); + sb.append("MODEL=").append(Build.MODEL).append("\n"); + //MANUFACTURER doesn't exist in android 1.5. + //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); + sb.append("SDK=").append(Build.VERSION.SDK); + + Log.d("Linphone", sb.toString()); + } +} diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index a7104ffef..b60d92fda 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -36,6 +36,7 @@ class LinphoneCallImpl implements LinphoneCall { private native void enableEchoLimiter(long nativePtr,boolean enable); private native boolean isEchoLimiterEnabled(long nativePtr); private native long getReplacedCall(long nativePtr); + private native int getDuration(long nativePtr); protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -96,5 +97,9 @@ class LinphoneCallImpl implements LinphoneCall { } return null; } + + public int getDuration() { + return getDuration(nativePtr); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 533ee8b97..61afcd5d0 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -64,7 +64,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr); private native long getCurrentCall(long nativePtr) ; - private native void playDtmf(long nativePtr,char dtmf,int duration, boolean speaker); + private native void playDtmf(long nativePtr,char dtmf,int duration); private native void stopDtmf(long nativePtr); private native void setVideoWindowId(long nativePtr, Object wid); private native void setPreviewWindowId(long nativePtr, Object wid); @@ -298,8 +298,8 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } - public void playDtmf(char number, int duration, boolean speaker) { - playDtmf(nativePtr,number, duration, speaker); + public void playDtmf(char number, int duration) { + playDtmf(nativePtr,number, duration); } public void stopDtmf() { @@ -439,4 +439,7 @@ class LinphoneCoreImpl implements LinphoneCore { public void startEchoCalibration(Object data) throws LinphoneCoreException { startEchoCalibration(nativePtr, data); } + public Transport getSignalingTransport() { + throw new RuntimeException("Not implemented"); + } } diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index 1d430082e..065ea22af 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; -import org.linphone.Hacks; +import org.linphone.core.Hacks; import android.util.Log; From 5ee4ee4dba59b8932e9e4c4bc628d3c2394e0789 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 1 Mar 2011 18:39:03 +0100 Subject: [PATCH 089/288] Galaxy tab doesn't require Galaxy S speaker hack. --- Hacks.java | 12 ++++++++++-- video/AndroidCameraConf.java | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Hacks.java b/Hacks.java index 49c3125ae..01f6d401d 100644 --- a/Hacks.java +++ b/Hacks.java @@ -22,12 +22,20 @@ import android.media.AudioManager; import android.os.Build; import android.util.Log; -public class Hacks { +public final class Hacks { private Hacks() {} public static boolean isGalaxyS() { - return Build.DEVICE.startsWith("GT-I9000") || Build.DEVICE.startsWith("GT-P1000"); + return Build.DEVICE.startsWith("GT-I9000"); + } + + public static boolean isGalaxySOrTab() { + return isGalaxyS() || isGalaxyTab(); + } + + public static boolean isGalaxyTab() { + return Build.DEVICE.startsWith("GT-P1000"); } /* private static final boolean log(final String msg) { diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index 065ea22af..a86e45787 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -27,7 +27,7 @@ class AndroidCameraConf { public void findFrontAndRearCameraIds(int[] frontCameraId, int[] rearCameraId, int[] cameraId) { Log.i(tag, "Detecting cameras"); - if (Hacks.isGalaxyS()) { + if (Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); frontCameraId[0] = 2; rearCameraId[0] = 1; @@ -41,7 +41,7 @@ class AndroidCameraConf { public int getNumberOfCameras() { Log.i(tag, "Detecting the number of cameras"); // Use hacks to guess the number of cameras - if (Hacks.isGalaxyS()) { + if (Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : has 2 cameras"); return 2; } else @@ -52,7 +52,7 @@ class AndroidCameraConf { public int getCameraOrientation(int cameraId) { // Use hacks to guess orientation of the camera - if (cameraId == 2 && Hacks.isGalaxyS()) { + if (cameraId == 2 && Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : rear camera id=2 ; mounted landscape"); // mounted in landscape for a portrait phone orientation return 90; @@ -65,7 +65,7 @@ class AndroidCameraConf { public boolean isFrontCamera(int cameraId) { // Use hacks to guess facing of the camera - if (cameraId == 2 && Hacks.isGalaxyS()) { + if (cameraId == 2 && Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : front camera has id=2"); return true; } From ce0d804023a8e8a68b2c1e67744d236f5473b581 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 10 Mar 2011 15:51:46 +0100 Subject: [PATCH 090/288] Transport selection (UDP, TCP, TLS);standard ports. --- LinphoneCoreImpl.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 61afcd5d0..8be2008f3 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -91,7 +91,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void enableKeepAlive(long nativePtr,boolean enable); private native boolean isKeepAliveEnabled(long nativePtr); private native int startEchoCalibration(long nativePtr,Object data); - + private native int getSignalingTransportPort(long nativePtr, int code); + private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -285,10 +286,6 @@ class LinphoneCoreImpl implements LinphoneCore { public void setPlayLevel(int level) { // TODO Auto-generated method stub - } - public void setSignalingTransport(Transport aTransport) { - // TODO Auto-generated method stub - } public void enableSpeaker(boolean value) { // TODO Auto-generated method stub @@ -439,7 +436,19 @@ class LinphoneCoreImpl implements LinphoneCore { public void startEchoCalibration(Object data) throws LinphoneCoreException { startEchoCalibration(nativePtr, data); } - public Transport getSignalingTransport() { - throw new RuntimeException("Not implemented"); + + public Transports getSignalingTransportPorts() { + Transports transports = new Transports(); + transports.udp = getSignalingTransportPort(nativePtr, 0); + transports.tcp = getSignalingTransportPort(nativePtr, 1); + transports.tls = getSignalingTransportPort(nativePtr, 3); + // See C struct LCSipTransports in linphonecore.h + // Code is the index in the structure + return transports; } + public void setSignalingTransportPorts(Transports transports) { + setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls); + } + + } From d18561cea4c5f0ea2143ebc611bb5bf4b6b49c7a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 11 Mar 2011 11:36:48 +0100 Subject: [PATCH 091/288] payload init, data paths, armv7 detection, typos Fix: payload initialization in PreferenceActivity Fix: paths to application data by using Android facilities Detect ARMv7 by looking at Build.CPU_ABI through reflection Fix: crash on registration change after LinphoneActivity was killed by Android --- Version.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Version.java b/Version.java index c06a2efea..65d5370d6 100644 --- a/Version.java +++ b/Version.java @@ -42,4 +42,13 @@ public class Version { return buildVersion; } + public static boolean isArmv7() { + try { + return sdkAboveOrEqual(4) + && Build.class.getField("CPU_ABI").get(null).toString().startsWith("armeabi-v7"); + } catch (Throwable e) {} + return false; + } + + } \ No newline at end of file From 56e955319a2aaf73867ed5ae8d19ec833c042f54 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 11 Mar 2011 15:37:18 +0100 Subject: [PATCH 092/288] Fix hardcoded log tags. --- Hacks.java | 4 +++- tutorials/JavaCameraRecordImpl.java | 2 +- video/AndroidCameraRecord8.java | 2 +- video/AndroidCameraRecordImpl.java | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Hacks.java b/Hacks.java index 01f6d401d..d90588130 100644 --- a/Hacks.java +++ b/Hacks.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.LinphoneManager; + import android.media.AudioManager; import android.os.Build; import android.util.Log; @@ -78,6 +80,6 @@ public final class Hacks { //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); sb.append("SDK=").append(Build.VERSION.SDK); - Log.d("Linphone", sb.toString()); + Log.d(LinphoneManager.TAG, sb.toString()); } } diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index a40bee238..341bd28cc 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -59,7 +59,7 @@ class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallbac Size s = camera.getParameters().getPreviewSize(); int expectedBuffLength = s.width * s.height * 3 /2; if (expectedBuffLength != data.length) { - Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length + " whereas expected is " + expectedBuffLength + " don't calling putImage"); return; } diff --git a/video/AndroidCameraRecord8.java b/video/AndroidCameraRecord8.java index 20805bd64..ef8425d7e 100644 --- a/video/AndroidCameraRecord8.java +++ b/video/AndroidCameraRecord8.java @@ -40,7 +40,7 @@ class AndroidCameraRecord8 extends AndroidCameraRecordImpl { @Override protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { if (cb != null) { - Log.d("Linphone", "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); + Log.d(tag, "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); } camera.setPreviewCallbackWithBuffer(cb); } diff --git a/video/AndroidCameraRecordImpl.java b/video/AndroidCameraRecordImpl.java index 9e30cca07..84c22a0e4 100644 --- a/video/AndroidCameraRecordImpl.java +++ b/video/AndroidCameraRecordImpl.java @@ -56,17 +56,17 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall public void onPreviewFrame(byte[] data, Camera camera) { if (data == null) { - Log.e("Linphone", "onPreviewFrame Called with null buffer"); + Log.e(tag, "onPreviewFrame Called with null buffer"); return; } if (filterCtxPtr == 0l) { - Log.e("Linphone", "onPreviewFrame Called with no filterCtxPtr set"); + Log.e(tag, "onPreviewFrame Called with no filterCtxPtr set"); return; } int expectedBuffLength = getExpectedBufferLength(); if (expectedBuffLength != data.length) { - Log.e("Linphone", "onPreviewFrame called with bad buffer length " + data.length + Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length + " whereas expected is " + expectedBuffLength + " don't calling putImage"); return; } @@ -80,7 +80,7 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; if (currentTimeElapsed < expectedTimeBetweenFrames) { -// Log.d("Linphone", "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); +// Log.d(tag, "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); return; } lastFrameTime = curTime; From 592ce55c2dc72c104d945c8bb76d01fdeee2272c Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 11 Mar 2011 15:54:43 +0100 Subject: [PATCH 093/288] Fix hardcoded log tags --- AndroidVideoWindowImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index ec7eb2cbb..243afb472 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -34,11 +34,11 @@ public class AndroidVideoWindowImpl { mSurface=holder.getSurface(); } if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); - Log.w("Linphone", "Video display surface changed"); + Log.w(TAG, "Video display surface changed"); } public void surfaceCreated(SurfaceHolder holder) { - Log.w("Linphone", "Video display surface created"); + Log.w(TAG, "Video display surface created"); } public void surfaceDestroyed(SurfaceHolder holder) { @@ -48,7 +48,7 @@ public class AndroidVideoWindowImpl { } if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); - Log.d("Linphone", "Video display surface destroyed"); + Log.d(TAG, "Video display surface destroyed"); } }); } From 4ac9d2148b638699c91c63a4e21f3eda144db181 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 18 Mar 2011 10:52:52 +0100 Subject: [PATCH 094/288] When muting video, return if mute state changed. --- video/AndroidCameraRecordManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 87c4f53ac..bf64b615a 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -145,14 +145,19 @@ public class AndroidCameraRecordManager { }); } - public void setMuted(boolean muteState) { - if (muteState == muted) return; + /** + * @param muteState + * @return true if mute state changed + */ + public boolean setMuted(boolean muteState) { + if (muteState == muted) return false; muted = muteState; if (muted) { stopVideoRecording(); } else { tryToStartVideoRecording(); } + return true; } public boolean toggleMute() { setMuted(!muted); From 173b47ff1ad165aed481151e81b556bd0e15ed9a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 28 Mar 2011 15:59:55 +0200 Subject: [PATCH 095/288] ffmpeg as shared library. --- LinphoneCoreFactoryImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 1b4e9aaf0..b676ccd61 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -21,9 +21,25 @@ package org.linphone.core; import java.io.File; import java.io.IOException; +import org.linphone.LinphoneManager; + +import android.util.Log; + public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { + private static void loadOptionalLibrary(String s) { + try { + System.loadLibrary(s); + } catch (Throwable e) { + Log.w(LinphoneManager.TAG, "Unable to load optional library lib" + s); + } + } + static { + loadOptionalLibrary("avutil"); + loadOptionalLibrary("swscale"); + loadOptionalLibrary("avcore"); + loadOptionalLibrary("avcodec"); System.loadLibrary("linphone"); } @Override From ae591fb01a4e1bfca4473bb2b5ee6429e78347d7 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 31 Mar 2011 11:09:19 +0200 Subject: [PATCH 096/288] Potentially fix crash when network goes down. --- LinphoneCoreImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 8be2008f3..0ca1d2a06 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -203,7 +203,7 @@ class LinphoneCoreImpl implements LinphoneCore { throw new RuntimeException("object already destroyed"); } } - public void setNetworkReachable(boolean isReachable) { + public synchronized void setNetworkReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } public void setPlaybackGain(float gain) { From 61604d00fd7a8c974adbf670166c2616492668ab Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 6 Apr 2011 10:41:01 +0200 Subject: [PATCH 097/288] Merge ms2. Fix i18n in ms2. Activate 2.3 in Version. --- Version.java | 3 +- video/AndroidCameraConf.java | 77 +++++++---------------- video/AndroidCameraConf5.java | 88 +++++++++++++++++++++++++++ video/AndroidCameraConf9.java | 18 ++++-- video/AndroidCameraRecordManager.java | 13 ++-- 5 files changed, 128 insertions(+), 71 deletions(-) create mode 100644 video/AndroidCameraConf5.java diff --git a/Version.java b/Version.java index 65d5370d6..dccdaf833 100644 --- a/Version.java +++ b/Version.java @@ -26,8 +26,7 @@ import android.os.Build; */ public class Version { - private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK) >= 9? - 8 : Integer.parseInt(Build.VERSION.SDK); // Force versions above 9 to 8 + private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK); // 7; // 2.1 public static final boolean sdkAboveOrEqual(int value) { diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index a86e45787..3d7a7bcad 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -1,6 +1,6 @@ /* AndroidCameraConf.java -Copyright (C) 2010 Belledonne Communications, Grenoble, France +Copyright (C) 2011 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 @@ -15,64 +15,31 @@ 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.video; -import org.linphone.core.Hacks; -import android.util.Log; +/** + * @author Guillaume Beraudo + * + */ +interface AndroidCameraConf { -class AndroidCameraConf { - private static final String tag = "Linphone"; + AndroidCameras getFoundCameras(); - public void findFrontAndRearCameraIds(int[] frontCameraId, int[] rearCameraId, int[] cameraId) { - Log.i(tag, "Detecting cameras"); - if (Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); - frontCameraId[0] = 2; - rearCameraId[0] = 1; - cameraId[0] = rearCameraId[0]; - return; - } + int getNumberOfCameras(); - // default to 0/0 + int getCameraOrientation(int cameraId); + + boolean isFrontCamera(int cameraId); + + class AndroidCameras { + Integer front; + Integer rear; + Integer defaultC; + + boolean hasFrontCamera() { return front != null; } + boolean hasRearCamera() { return rear != null; } + boolean hasSeveralCameras() { return front != rear && front != null; } } - - public int getNumberOfCameras() { - Log.i(tag, "Detecting the number of cameras"); - // Use hacks to guess the number of cameras - if (Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : has 2 cameras"); - return 2; - } else - return 1; - } - - - - public int getCameraOrientation(int cameraId) { - // Use hacks to guess orientation of the camera - if (cameraId == 2 && Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : rear camera id=2 ; mounted landscape"); - // mounted in landscape for a portrait phone orientation - return 90; - } - return 0; - } - - - - - public boolean isFrontCamera(int cameraId) { - // Use hacks to guess facing of the camera - if (cameraId == 2 && Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : front camera has id=2"); - return true; - } - - return false; - } - - - -} +} \ No newline at end of file diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java new file mode 100644 index 000000000..3c010180d --- /dev/null +++ b/video/AndroidCameraConf5.java @@ -0,0 +1,88 @@ +/* +AndroidCameraConf.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.video; + +import org.linphone.core.Hacks; + +import android.util.Log; + +class AndroidCameraConf5 implements AndroidCameraConf { + private static final String tag = "Linphone"; + private AndroidCameras foundCameras; + public AndroidCameras getFoundCameras() {return foundCameras;} + + public AndroidCameraConf5() { + Log.i(tag, "Detecting cameras"); + + // Defaults 0/0/0 + foundCameras = new AndroidCameras(); + + if (Hacks.isGalaxySOrTab()) { + Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); + foundCameras.front = 2; + foundCameras.rear = 1; + foundCameras.defaultC = foundCameras.rear; + } + + } + + public int getNumberOfCameras() { + Log.i(tag, "Detecting the number of cameras"); + if (Hacks.isGalaxySOrTab()) { + Log.d(tag, "Hack Galaxy S : has 2 cameras"); + return 2; + } else + return 1; + } + + + + public int getCameraOrientation(int cameraId) { + // Use hacks to guess orientation of the camera + if (Hacks.isGalaxySOrTab() && !isFrontCamera(cameraId)) { + Log.d(tag, "Hack Galaxy S : rear camera mounted landscape"); + // mounted in landscape for a portrait phone orientation + // |^^^^^^^^| + // | ____ | + // | |____| | + // | | + // | | + // | Phone | + // |________| + return 90; + } + return 0; + } + + + + + public boolean isFrontCamera(int cameraId) { + // Use hacks to guess facing of the camera + if (cameraId == 2 && Hacks.isGalaxySOrTab()) { + Log.d(tag, "Hack Galaxy S : front camera has id=2"); + return true; + } + + return false; + } + + + +} diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index 4c3713b83..ad6e50e90 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -20,14 +20,21 @@ package org.linphone.core.video; import android.hardware.Camera; -class AndroidCameraConf9 extends AndroidCameraConf { +class AndroidCameraConf9 implements AndroidCameraConf { + private AndroidCameras foundCameras; + public AndroidCameras getFoundCameras() {return foundCameras;} + + public AndroidCameraConf9() { + foundCameras = new AndroidCameras(); - public void findFrontAndRearCameraIds9(Integer frontCameraId, Integer rearCameraId, Integer cameraId) { for (int id=0; id < getNumberOfCameras(); id++) { + if (foundCameras.defaultC == null) + foundCameras.defaultC = id; + if (isFrontCamera(id)) { - frontCameraId = id; + foundCameras.front = id; } else { - rearCameraId = id; + foundCameras.rear = id; } } } @@ -39,7 +46,7 @@ class AndroidCameraConf9 extends AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); - return info.orientation; + return (info.orientation - 90) %360; } public boolean isFrontCamera(int cameraId) { @@ -47,4 +54,5 @@ class AndroidCameraConf9 extends AndroidCameraConf { Camera.getCameraInfo(cameraId, info); return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; } + } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index bf64b615a..5fa1b37e2 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -63,23 +63,18 @@ public class AndroidCameraRecordManager { public int getPhoneOrientation() {return phoneOrientation;} public void setPhoneOrientation(int degrees) {this.phoneOrientation = degrees;} - private int frontCameraId; - private int rearCameraId; // singleton private AndroidCameraRecordManager() { - cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf(); - - int[] fId = {-1};int[] rId = {-1};int[] cId = {-1}; - cc.findFrontAndRearCameraIds(fId, rId, cId); - frontCameraId=fId[0];rearCameraId=rId[0];cameraId=cId[0]; + cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5(); + cameraId = cc.getFoundCameras().defaultC; } public boolean hasSeveralCameras() { - return frontCameraId != rearCameraId; + return cc.getFoundCameras().hasSeveralCameras(); } @@ -93,7 +88,7 @@ public class AndroidCameraRecordManager { public boolean toggleUseFrontCamera() { boolean previousUseFront = cc.isFrontCamera(cameraId); - cameraId = previousUseFront ? rearCameraId : frontCameraId; + cameraId = previousUseFront ? cc.getFoundCameras().rear : cc.getFoundCameras().front; if (parameters != null) { parameters.cameraId = cameraId; From 4dd30dcf60e4c9da854abec5a4ef0b2a4d9c863e Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 6 Apr 2011 12:26:57 +0200 Subject: [PATCH 098/288] Support GalaxyS SC-02B. --- Hacks.java | 19 +++++++++++++++++-- Version.java | 4 +++- video/AndroidCameraConf.java | 9 +++++++-- video/AndroidCameraConf5.java | 18 +++++++++++------- video/AndroidCameraRecordManager.java | 8 +++++++- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Hacks.java b/Hacks.java index d90588130..1f96da119 100644 --- a/Hacks.java +++ b/Hacks.java @@ -29,7 +29,15 @@ public final class Hacks { private Hacks() {} public static boolean isGalaxyS() { - return Build.DEVICE.startsWith("GT-I9000"); + return isGT9000() || isSC02B(); + } + + public static boolean needGalaxySAudioHack() { + return isGalaxySOrTab(); + } + + public static boolean isGalaxySOrTabWithFrontCamera() { + return isGalaxySOrTab() && !isGalaxySOrTabWithoutFrontCamera(); } public static boolean isGalaxySOrTab() { @@ -37,7 +45,14 @@ public final class Hacks { } public static boolean isGalaxyTab() { - return Build.DEVICE.startsWith("GT-P1000"); + return isGTP1000(); + } + + private static boolean isGT9000() {return Build.DEVICE.startsWith("GT-I9000");} + private static boolean isSC02B() {return Build.DEVICE.startsWith("SC-02B");} + private static boolean isGTP1000() {return Build.DEVICE.startsWith("GT-P1000");} + private static boolean isGalaxySOrTabWithoutFrontCamera() { + return isSC02B(); } /* private static final boolean log(final String msg) { diff --git a/Version.java b/Version.java index dccdaf833..8064cb176 100644 --- a/Version.java +++ b/Version.java @@ -26,7 +26,9 @@ import android.os.Build; */ public class Version { - private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK); + private static final int buildVersion = + Integer.parseInt(Build.VERSION.SDK); +// 8; // 2.2 // 7; // 2.1 public static final boolean sdkAboveOrEqual(int value) { diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index 3d7a7bcad..85bbe4526 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -33,10 +33,15 @@ interface AndroidCameraConf { boolean isFrontCamera(int cameraId); + /** + * Default: no front; rear=0; default=rear + * @author Guillaume Beraudo + * + */ class AndroidCameras { Integer front; - Integer rear; - Integer defaultC; + Integer rear = 0; + Integer defaultC = rear; boolean hasFrontCamera() { return front != null; } boolean hasRearCamera() { return rear != null; } diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index 3c010180d..c3298d1c7 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -30,12 +30,17 @@ class AndroidCameraConf5 implements AndroidCameraConf { public AndroidCameraConf5() { Log.i(tag, "Detecting cameras"); - // Defaults 0/0/0 + // Defaults foundCameras = new AndroidCameras(); if (Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); - foundCameras.front = 2; + Log.d(tag, "Hack Galaxy S : has one or more cameras"); + if (Hacks.isGalaxySOrTabWithFrontCamera()) { + Log.d(tag, "Hack Galaxy S : HAVE a front camera"); + foundCameras.front = 2; + } else { + Log.d(tag, "Hack Galaxy S : NO front camera"); + } foundCameras.rear = 1; foundCameras.defaultC = foundCameras.rear; } @@ -44,7 +49,7 @@ class AndroidCameraConf5 implements AndroidCameraConf { public int getNumberOfCameras() { Log.i(tag, "Detecting the number of cameras"); - if (Hacks.isGalaxySOrTab()) { + if (Hacks.isGalaxySOrTabWithFrontCamera()) { Log.d(tag, "Hack Galaxy S : has 2 cameras"); return 2; } else @@ -55,8 +60,8 @@ class AndroidCameraConf5 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { // Use hacks to guess orientation of the camera - if (Hacks.isGalaxySOrTab() && !isFrontCamera(cameraId)) { - Log.d(tag, "Hack Galaxy S : rear camera mounted landscape"); + if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) { + Log.d(tag, "Hack Galaxy S : front camera mounted landscape"); // mounted in landscape for a portrait phone orientation // |^^^^^^^^| // | ____ | @@ -72,7 +77,6 @@ class AndroidCameraConf5 implements AndroidCameraConf { - public boolean isFrontCamera(int cameraId) { // Use hacks to guess facing of the camera if (cameraId == 2 && Hacks.isGalaxySOrTab()) { diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 5fa1b37e2..4649fe0b2 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -76,11 +76,17 @@ public class AndroidCameraRecordManager { public boolean hasSeveralCameras() { return cc.getFoundCameras().hasSeveralCameras(); } + public boolean hasFrontCamera() { + return cc.getFoundCameras().front != null; + } public void setUseFrontCamera(boolean value) { + if (!hasFrontCamera()) { + Log.e(tag, "setUseFrontCamera(true) while no front camera detected on device: using rear"); + value = false; + } if (cc.isFrontCamera(cameraId) == value) return; // already OK - toggleUseFrontCamera(); } From f596a19ad553cf00643d10fb9c70a8dbdc4542c0 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 6 Apr 2011 15:16:20 +0200 Subject: [PATCH 099/288] Enable ipv6 support for Android. --- LinphoneCoreImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0ca1d2a06..81885d13a 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -93,7 +93,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native int startEchoCalibration(long nativePtr,Object data); private native int getSignalingTransportPort(long nativePtr, int code); private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls); - + private native void enableIpv6(long nativePtr,boolean enable); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -450,5 +451,8 @@ class LinphoneCoreImpl implements LinphoneCore { setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls); } + public void enableIpv6(boolean enable) { + enableIpv6(nativePtr,enable); + } } From 1e2a21ea2aceaca503c79b9fe80a781f7b22b6b1 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 11 Apr 2011 12:18:47 +0200 Subject: [PATCH 100/288] Initial support to softvolume. --- LinphoneCoreImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 81885d13a..f90812fc4 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -94,6 +94,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getSignalingTransportPort(long nativePtr, int code); private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls); private native void enableIpv6(long nativePtr,boolean enable); + private native void adjustSoftwareVolume(long nativePtr,int db); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -454,5 +455,8 @@ class LinphoneCoreImpl implements LinphoneCore { public void enableIpv6(boolean enable) { enableIpv6(nativePtr,enable); } + public void adjustSoftwareVolume(int i) { + adjustSoftwareVolume(nativePtr, i); + } } From 9aa95c08cc798333594c23d2e195a196d4f3fa89 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 15 Apr 2011 23:56:32 +0200 Subject: [PATCH 101/288] add amr support to linphone-android --- LinphoneCoreImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f90812fc4..9b374c0f8 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -88,6 +88,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); private native long[] listVideoPayloadTypes(long nativePtr); + private native long[] listAudioPayloadTypes(long nativePtr); private native void enableKeepAlive(long nativePtr,boolean enable); private native boolean isKeepAliveEnabled(long nativePtr); private native int startEchoCalibration(long nativePtr,Object data); @@ -413,7 +414,7 @@ class LinphoneCoreImpl implements LinphoneCore { return getRing(nativePtr); } - public PayloadType[] listVideoCodecs() { + public PayloadType[] getVideoCodecs() { long[] typesPtr = listVideoPayloadTypes(nativePtr); if (typesPtr == null) return null; @@ -425,6 +426,18 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } + public PayloadType[] getAudioCodecs() { + long[] typesPtr = listAudioPayloadTypes(nativePtr); + if (typesPtr == null) return null; + + PayloadType[] codecs = new PayloadType[typesPtr.length]; + + for (int i=0; i < codecs.length; i++) { + codecs[i] = new PayloadTypeImpl(typesPtr[i]); + } + + return codecs; + } public boolean isNetworkReachable() { throw new RuntimeException("Not implemented"); } From 857dd1503e82e8a2b9645b52a889396f582c0aef Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 18 Apr 2011 15:18:00 +0200 Subject: [PATCH 102/288] Soft volume. Forced for galaxy S. Pref. access mgr. --- Hacks.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Hacks.java b/Hacks.java index 1f96da119..23ebcb487 100644 --- a/Hacks.java +++ b/Hacks.java @@ -97,4 +97,8 @@ public final class Hacks { Log.d(LinphoneManager.TAG, sb.toString()); } + + public static boolean needSoftvolume() { + return isGalaxySOrTab(); + } } From d78b0760407c29f58c778bb4dc601c56f2a6e1d4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 19 Apr 2011 09:05:28 +0200 Subject: [PATCH 103/288] Fix deliver script. Move TAG to core Version.java --- Hacks.java | 6 ++---- LinphoneCoreFactoryImpl.java | 4 +--- Version.java | 2 ++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Hacks.java b/Hacks.java index 23ebcb487..0eea6a814 100644 --- a/Hacks.java +++ b/Hacks.java @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import org.linphone.LinphoneManager; - import android.media.AudioManager; import android.os.Build; import android.util.Log; @@ -94,8 +92,8 @@ public final class Hacks { //MANUFACTURER doesn't exist in android 1.5. //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); sb.append("SDK=").append(Build.VERSION.SDK); - - Log.d(LinphoneManager.TAG, sb.toString()); + + Log.d(Version.TAG, sb.toString()); } public static boolean needSoftvolume() { diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index b676ccd61..0a9ba7a76 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -21,8 +21,6 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import org.linphone.LinphoneManager; - import android.util.Log; public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { @@ -31,7 +29,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { try { System.loadLibrary(s); } catch (Throwable e) { - Log.w(LinphoneManager.TAG, "Unable to load optional library lib" + s); + Log.w(Version.TAG, "Unable to load optional library lib" + s); } } diff --git a/Version.java b/Version.java index 8064cb176..350189eea 100644 --- a/Version.java +++ b/Version.java @@ -26,6 +26,8 @@ import android.os.Build; */ public class Version { + public static final String TAG="Linphone"; + private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK); // 8; // 2.2 From 5b9a6d1123a9f34ca5f4a6da6e92f5e32b9d7f6a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 19 Apr 2011 10:54:37 +0200 Subject: [PATCH 104/288] detect when processor doesn't have ARM NEON instructions and disable video then --- Version.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Version.java b/Version.java index 8064cb176..9701b75c3 100644 --- a/Version.java +++ b/Version.java @@ -25,7 +25,7 @@ import android.os.Build; * @author Guillaume Beraudo */ public class Version { - + private static native boolean nativeHasNeon(); private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK); // 8; // 2.2 @@ -50,6 +50,8 @@ public class Version { } catch (Throwable e) {} return false; } + public static boolean hasNeon(){ + return nativeHasNeon(); + } - -} \ No newline at end of file +} From 4404fea296da048f07b2c51e09d301d509999663 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 19 Apr 2011 14:11:25 +0200 Subject: [PATCH 105/288] Add debugs to trace detected and used camera id. --- video/AndroidCameraConf.java | 12 +++++++++++- video/AndroidCameraRecord.java | 12 +++++++++--- video/AndroidCameraRecordManager.java | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index 85bbe4526..9796ba12b 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -45,6 +45,16 @@ interface AndroidCameraConf { boolean hasFrontCamera() { return front != null; } boolean hasRearCamera() { return rear != null; } - boolean hasSeveralCameras() { return front != rear && front != null; } + boolean hasSeveralCameras() { return front != rear && front != null; } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Cameras :"); + if (rear != null) sb.append(" rear=").append(rear); + if (front != null) sb.append(" front=").append(front); + if (defaultC != null) sb.append(" default=").append(defaultC); + return sb.toString(); + } } } \ No newline at end of file diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index 64af664f5..d807a30cc 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.linphone.core.Version; + import android.hardware.Camera; import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; @@ -65,6 +67,7 @@ public abstract class AndroidCameraRecord { } + Log.d(tag, "Trying to open camera with id " + params.cameraId); camera = openCamera(params.cameraId); camera.setErrorCallback(new ErrorCallback() { public void onError(int error, Camera camera) { @@ -74,9 +77,12 @@ public abstract class AndroidCameraRecord { Camera.Parameters parameters=camera.getParameters(); - parameters.set("camera-id",params.cameraId); - camera.setParameters(parameters); - parameters = camera.getParameters(); + if (Version.sdkStrictlyBelow(9)) { + parameters.set("camera-id",params.cameraId); + camera.setParameters(parameters); + parameters = camera.getParameters(); + } + if (supportedVideoSizes == null) { supportedVideoSizes = new ArrayList(getSupportedPreviewSizes(parameters)); } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 4649fe0b2..f86e82bf9 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -67,6 +67,7 @@ public class AndroidCameraRecordManager { // singleton private AndroidCameraRecordManager() { cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5(); + Log.i(tag, "=== Detected " + cc.getFoundCameras()+ " ==="); cameraId = cc.getFoundCameras().defaultC; } From a66eb9aee50ec8c17b97fb576587e9e14ab865c6 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 20 Apr 2011 15:41:52 +0200 Subject: [PATCH 106/288] Improve Galaxy S support. Add hack preferences. - Switching to earpiece/speaker shouldn't mute the mic anymore - Enable hidden audio hacks by removing "android:layout="@layout/hidden" from "pref_audio_hacks_title" PreferenceScreen. --- Hacks.java | 18 ++++++++++++++---- LinphoneCoreImpl.java | 13 ++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Hacks.java b/Hacks.java index 0eea6a814..5459bbd4b 100644 --- a/Hacks.java +++ b/Hacks.java @@ -30,9 +30,6 @@ public final class Hacks { return isGT9000() || isSC02B(); } - public static boolean needGalaxySAudioHack() { - return isGalaxySOrTab(); - } public static boolean isGalaxySOrTabWithFrontCamera() { return isGalaxySOrTab() && !isGalaxySOrTabWithoutFrontCamera(); @@ -93,10 +90,23 @@ public final class Hacks { //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); sb.append("SDK=").append(Build.VERSION.SDK); - Log.d(Version.TAG, sb.toString()); + Log.i(Version.TAG, sb.toString()); } public static boolean needSoftvolume() { return isGalaxySOrTab(); } + + public static boolean needRoutingAPI() { + return Version.sdkStrictlyBelow(5) /* Date: Fri, 20 May 2011 12:55:40 +0200 Subject: [PATCH 107/288] Video hacks + disabled mirroring of capture. --- Hacks.java | 37 +++++++++++++++++++-------- video/AndroidCameraConf5.java | 13 +++++++--- video/AndroidCameraConf9.java | 7 +++++ video/AndroidCameraRecord.java | 27 ++++++++++++------- video/AndroidCameraRecordImpl.java | 10 +++++--- video/AndroidCameraRecordManager.java | 36 ++++++++++++++++++-------- 6 files changed, 94 insertions(+), 36 deletions(-) diff --git a/Hacks.java b/Hacks.java index 5459bbd4b..38a578769 100644 --- a/Hacks.java +++ b/Hacks.java @@ -26,14 +26,14 @@ public final class Hacks { private Hacks() {} - public static boolean isGalaxyS() { - return isGT9000() || isSC02B(); - } - public static boolean isGalaxySOrTabWithFrontCamera() { return isGalaxySOrTab() && !isGalaxySOrTabWithoutFrontCamera(); } + private static boolean isGalaxySOrTabWithoutFrontCamera() { + return isSC02B() || isSGHI896(); + } + public static boolean isGalaxySOrTab() { return isGalaxyS() || isGalaxyTab(); @@ -42,13 +42,26 @@ public final class Hacks { public static boolean isGalaxyTab() { return isGTP1000(); } - - private static boolean isGT9000() {return Build.DEVICE.startsWith("GT-I9000");} - private static boolean isSC02B() {return Build.DEVICE.startsWith("SC-02B");} - private static boolean isGTP1000() {return Build.DEVICE.startsWith("GT-P1000");} - private static boolean isGalaxySOrTabWithoutFrontCamera() { - return isSC02B(); + private static boolean isGalaxyS() { + return isGT9000() || isSC02B() || isSGHI896() || isSPHD700(); } + + public static final boolean hasTwoCamerasRear0Front1() { + return isSPHD700() || isADR6400(); + } + + // HTC + private static final boolean isADR6400() { + return Build.MODEL.startsWith("ADR6400") || Build.DEVICE.startsWith("ADR6400"); + } // HTC Thunderbolt + + // Galaxy S variants + private static final boolean isSPHD700() {return Build.DEVICE.startsWith("SPH-D700");} // Epic + private static boolean isSGHI896() {return Build.DEVICE.startsWith("SGH-I896");} // Captivate + private static boolean isGT9000() {return Build.DEVICE.startsWith("GT-I9000");} // Galaxy S + private static boolean isSC02B() {return Build.DEVICE.startsWith("SC-02B");} // Docomo + private static boolean isGTP1000() {return Build.DEVICE.startsWith("GT-P1000");} // Tab + /* private static final boolean log(final String msg) { Log.d("Linphone", msg); @@ -109,4 +122,8 @@ public final class Hacks { // return false; return isGalaxySOrTab() && !isSC02B(); } + + public static boolean hasTwoCameras() { + return isSPHD700() || isGalaxySOrTabWithFrontCamera(); + } } diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index c3298d1c7..8f9bab996 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -36,21 +36,25 @@ class AndroidCameraConf5 implements AndroidCameraConf { if (Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : has one or more cameras"); if (Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d(tag, "Hack Galaxy S : HAVE a front camera"); + Log.d(tag, "Hack Galaxy S : HAS a front camera with id=2"); foundCameras.front = 2; } else { Log.d(tag, "Hack Galaxy S : NO front camera"); } + Log.d(tag, "Hack Galaxy S : HAS a rear camera with id=1"); foundCameras.rear = 1; foundCameras.defaultC = foundCameras.rear; + } else if (Hacks.hasTwoCamerasRear0Front1()) { + Log.d(tag, "Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1"); + foundCameras.front = 1; } } public int getNumberOfCameras() { Log.i(tag, "Detecting the number of cameras"); - if (Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d(tag, "Hack Galaxy S : has 2 cameras"); + if (Hacks.hasTwoCamerasRear0Front1() || Hacks.isGalaxySOrTabWithFrontCamera()) { + Log.d(tag, "Hack: we know this model has 2 cameras"); return 2; } else return 1; @@ -82,6 +86,9 @@ class AndroidCameraConf5 implements AndroidCameraConf { if (cameraId == 2 && Hacks.isGalaxySOrTab()) { Log.d(tag, "Hack Galaxy S : front camera has id=2"); return true; + } else if (cameraId == 1 && Hacks.hasTwoCamerasRear0Front1()) { + Log.d(tag, "Hack SPHD700 : front camera has id=1"); + return true; } return false; diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index ad6e50e90..c53e7fce4 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import org.linphone.LinphoneManager; + import android.hardware.Camera; +import android.util.Log; class AndroidCameraConf9 implements AndroidCameraConf { private AndroidCameras foundCameras; @@ -46,6 +49,10 @@ class AndroidCameraConf9 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); + Log.d(LinphoneManager.TAG, String.format("Camera info for %i: orientation=%i returned=%i ", + cameraId, + info.orientation, + (info.orientation - 90) %360)); return (info.orientation - 90) %360; } diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index d807a30cc..27bd02c63 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -53,7 +53,7 @@ public abstract class AndroidCameraRecord { return Collections.emptyList(); } - public void startPreview() { // FIXME throws exception? + public synchronized void startPreview() { // FIXME throws exception? if (previewStarted) { Log.w(tag, "Already started"); throw new RuntimeException("Video recorder already started"); @@ -68,6 +68,10 @@ public abstract class AndroidCameraRecord { Log.d(tag, "Trying to open camera with id " + params.cameraId); + if (camera != null) { + Log.e(tag, "Camera is not null, ?already open? : aborting"); + return; + } camera = openCamera(params.cameraId); camera.setErrorCallback(new ErrorCallback() { public void onError(int error, Camera camera) { @@ -79,8 +83,6 @@ public abstract class AndroidCameraRecord { Camera.Parameters parameters=camera.getParameters(); if (Version.sdkStrictlyBelow(9)) { parameters.set("camera-id",params.cameraId); - camera.setParameters(parameters); - parameters = camera.getParameters(); } if (supportedVideoSizes == null) { @@ -94,14 +96,15 @@ public abstract class AndroidCameraRecord { // invert height and width parameters.setPreviewSize(params.height, params.width); } + // should setParameters and get again to have the real one?? + currentPreviewSize = parameters.getPreviewSize(); + parameters.setPreviewFrameRate(Math.round(params.fps)); onSettingCameraParameters(parameters); camera.setParameters(parameters); - currentPreviewSize = camera.getParameters().getPreviewSize(); - SurfaceHolder holder = params.surfaceView.getHolder(); try { camera.setPreviewDisplay(holder); @@ -113,9 +116,11 @@ public abstract class AndroidCameraRecord { try { camera.startPreview(); - previewStarted = true; } catch (Throwable e) { - Log.e(tag, "Can't start camera preview"); + Log.e(tag, "Error, can't start camera preview. Releasing camera!"); + camera.release(); + camera = null; + return; } previewStarted = true; @@ -160,7 +165,7 @@ public abstract class AndroidCameraRecord { camera.stopPreview(); camera.release(); camera=null; - if (currentPreviewSize != null) currentPreviewSize = null; + currentPreviewSize = null; previewStarted = false; } @@ -176,6 +181,8 @@ public abstract class AndroidCameraRecord { public static class RecorderParams { + public static enum MirrorType {NO, HORIZONTAL, CENTRAL, VERTICAL}; + public float fps; public int height; public int width; @@ -184,7 +191,9 @@ public abstract class AndroidCameraRecord { public int cameraId; public int rotation; public SurfaceView surfaceView; - + + public MirrorType mirror = MirrorType.NO; + public RecorderParams(long ptr) { filterDataNativePtr = ptr; } diff --git a/video/AndroidCameraRecordImpl.java b/video/AndroidCameraRecordImpl.java index 84c22a0e4..3e68ab921 100644 --- a/video/AndroidCameraRecordImpl.java +++ b/video/AndroidCameraRecordImpl.java @@ -20,6 +20,8 @@ package org.linphone.core.video; import java.util.List; +import org.linphone.core.video.AndroidCameraRecord.RecorderParams.MirrorType; + import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; @@ -40,18 +42,20 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall private long lastFrameTime = 0; private final double expectedTimeBetweenFrames; protected final int rotation; + private MirrorType mirror; public AndroidCameraRecordImpl(RecorderParams parameters) { super(parameters); expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; rotation = parameters.rotation; + mirror = parameters.mirror; storePreviewCallBack(this); } - private native void putImage(long filterCtxPtr, byte[] buffer, int rotate); + private native void putImage(long filterCtxPtr, byte[] buffer, int rotate, int mirror); public void onPreviewFrame(byte[] data, Camera camera) { @@ -74,7 +78,7 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; - putImage(filterCtxPtr, data, rotation); + putImage(filterCtxPtr, data, rotation, mirror.ordinal()); return; } @@ -87,7 +91,7 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall timeElapsedBetweenFrames = currentTimeElapsed; // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data, rotation); + putImage(filterCtxPtr, data, rotation, mirror.ordinal()); } @Override diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index f86e82bf9..d3c75f98f 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -118,6 +118,17 @@ public class AndroidCameraRecordManager { p.height = height; p.cameraId = cameraId; parameters = p; + + /* Need first a working camera to test + if (isUseFrontCamera()) { + if (isCameraOrientationPortrait()) { + p.mirror = RecorderParams.MirrorType.CENTRAL; + } else { + p.mirror = RecorderParams.MirrorType.HORIZONTAL; + } + } // else no mirror + */ + tryToStartVideoRecording(); } @@ -174,7 +185,7 @@ public class AndroidCameraRecordManager { tryToStartVideoRecording(); } - private void tryToStartVideoRecording() { + private synchronized void tryToStartVideoRecording() { if (muted || surfaceView == null || parameters == null) return; parameters.rotation = bufferRotationForCorrectImageOrientation(); @@ -193,7 +204,7 @@ public class AndroidCameraRecordManager { recorder.startPreview(); } - public void stopVideoRecording() { + public synchronized void stopVideoRecording() { if (recorder != null) { recorder.stopPreview(); recorder = null; @@ -244,7 +255,7 @@ public class AndroidCameraRecordManager { final int rotation = bufferRotationForCorrectImageOrientation(); final boolean isPortrait = (rotation % 180) == 90; - Log.d(tag, "Camera sensor in portrait orientation ?" + isPortrait); + Log.d(tag, "Camera sensor in portrait orientation? " + isPortrait); return isPortrait; } @@ -260,13 +271,16 @@ public class AndroidCameraRecordManager { private int bufferRotationForCorrectImageOrientation() { - final int cameraOrientation = cc.getCameraOrientation(cameraId); - final int rotation = Version.sdkAboveOrEqual(8) ? - (360 - cameraOrientation + 90 - phoneOrientation) % 360 - : 0; - Log.d(tag, "Capture video buffer will need a rotation of " + rotation - + " degrees : camera " + cameraOrientation - + ", phone " + phoneOrientation); - return rotation; + if (Version.sdkAboveOrEqual(8)) { + final int cameraOrientation = cc.getCameraOrientation(cameraId); + final int rotation = (360 - cameraOrientation + 90 - phoneOrientation) % 360; + Log.d(tag, String.format( + "Capture video buffer of cameraId=%d will need a rotation of " + + "%d degrees: camera_orientation=%d, phone_orientation=%d", + cameraId, rotation, cameraOrientation, phoneOrientation)); + return rotation; + } + + return 0; } } From 3b88d0c151c0beeb656da0dbb9562a9653f6fd0a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 25 May 2011 11:31:18 +0200 Subject: [PATCH 108/288] Fix bad pattern --- video/AndroidCameraConf9.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index c53e7fce4..683c0c5b5 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -49,7 +49,7 @@ class AndroidCameraConf9 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); - Log.d(LinphoneManager.TAG, String.format("Camera info for %i: orientation=%i returned=%i ", + Log.d(LinphoneManager.TAG, String.format("Camera info for %d: orientation=%d returned=%d ", cameraId, info.orientation, (info.orientation - 90) %360)); From 4284ff4dc957895fb67f46fcf41eaad8447a5c9a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Jun 2011 12:23:39 +0200 Subject: [PATCH 109/288] Fix non existing Android API calls from old sdk. --- ...AndroidCameraRecordImpl.java => AndroidCameraRecord5.java} | 4 ++-- video/AndroidCameraRecord8.java | 2 +- video/AndroidCameraRecordManager.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename video/{AndroidCameraRecordImpl.java => AndroidCameraRecord5.java} (96%) diff --git a/video/AndroidCameraRecordImpl.java b/video/AndroidCameraRecord5.java similarity index 96% rename from video/AndroidCameraRecordImpl.java rename to video/AndroidCameraRecord5.java index 3e68ab921..62af64b9f 100644 --- a/video/AndroidCameraRecordImpl.java +++ b/video/AndroidCameraRecord5.java @@ -35,7 +35,7 @@ import android.util.Log; * @author Guillaume Beraudo * */ -class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { +class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallback { private long filterCtxPtr; private double timeElapsedBetweenFrames = 0; @@ -44,7 +44,7 @@ class AndroidCameraRecordImpl extends AndroidCameraRecord implements PreviewCall protected final int rotation; private MirrorType mirror; - public AndroidCameraRecordImpl(RecorderParams parameters) { + public AndroidCameraRecord5(RecorderParams parameters) { super(parameters); expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); filterCtxPtr = parameters.filterDataNativePtr; diff --git a/video/AndroidCameraRecord8.java b/video/AndroidCameraRecord8.java index ef8425d7e..b62c63e97 100644 --- a/video/AndroidCameraRecord8.java +++ b/video/AndroidCameraRecord8.java @@ -30,7 +30,7 @@ import android.util.Log; * @author Guillaume Beraudo * */ -class AndroidCameraRecord8 extends AndroidCameraRecordImpl { +class AndroidCameraRecord8 extends AndroidCameraRecord5 { public AndroidCameraRecord8(RecorderParams parameters) { diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index d3c75f98f..8b4f1fc6d 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -196,7 +196,7 @@ public class AndroidCameraRecordManager { } else if (Version.sdkAboveOrEqual(8)) { recorder = new AndroidCameraRecord8(parameters); } else if (Version.sdkAboveOrEqual(5)) { - recorder = new AndroidCameraRecordImpl(parameters); + recorder = new AndroidCameraRecord5(parameters); } else { throw new RuntimeException("SDK version unsupported " + Version.sdk()); } @@ -228,7 +228,7 @@ public class AndroidCameraRecordManager { } if (Version.sdkAboveOrEqual(5)) { - supportedVideoSizes = AndroidCameraRecordImpl.oneShotSupportedVideoSizes(); + supportedVideoSizes = AndroidCameraRecord5.oneShotSupportedVideoSizes(); } // eventually null From 55d7aee36c0f2443a594edfb7abd89bdecd0d531 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Jun 2011 16:18:40 +0200 Subject: [PATCH 110/288] Front camera mirror. Shouldn't work for Nexus S. --- video/AndroidCameraRecordManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 8b4f1fc6d..df884583d 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -119,15 +119,15 @@ public class AndroidCameraRecordManager { p.cameraId = cameraId; parameters = p; - /* Need first a working camera to test if (isUseFrontCamera()) { - if (isCameraOrientationPortrait()) { + if (!isCameraOrientationPortrait()) { + // Code for Nexus S: to be tested p.mirror = RecorderParams.MirrorType.CENTRAL; } else { + // Code for Galaxy S like: camera mounted landscape when phone hold portrait p.mirror = RecorderParams.MirrorType.HORIZONTAL; } - } // else no mirror - */ + } tryToStartVideoRecording(); } From 069c31c2dd1b4589939a421a5c9fbe21c3b34bb7 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Jun 2011 15:32:29 +0200 Subject: [PATCH 111/288] Fix log tag. --- video/AndroidCameraConf9.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index 683c0c5b5..6b6f8a1ba 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; -import org.linphone.LinphoneManager; +import org.linphone.core.Version; import android.hardware.Camera; import android.util.Log; @@ -49,7 +49,7 @@ class AndroidCameraConf9 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); - Log.d(LinphoneManager.TAG, String.format("Camera info for %d: orientation=%d returned=%d ", + Log.d(Version.TAG, String.format("Camera info for %d: orientation=%d returned=%d ", cameraId, info.orientation, (info.orientation - 90) %360)); From 39caf85271b2c5dbc23aff26690c24e243f4ff30 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Jun 2011 15:40:01 +0200 Subject: [PATCH 112/288] Removed camera testing on startup. --- Hacks.java | 18 ++++++++++++++++++ Version.java | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/Hacks.java b/Hacks.java index 38a578769..7ddf63d56 100644 --- a/Hacks.java +++ b/Hacks.java @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import android.hardware.Camera; import android.media.AudioManager; import android.os.Build; import android.util.Log; @@ -126,4 +127,21 @@ public final class Hacks { public static boolean hasTwoCameras() { return isSPHD700() || isGalaxySOrTabWithFrontCamera(); } + + public static boolean hasCamera() { + if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) { + int nb = 0; + try { + nb = (Integer) Camera.class.getMethod("getNumberOfCameras", (Class[])null).invoke(null); + } catch (Exception e) { + Log.wtf(Version.TAG, "Error getting number of cameras"); + } + return nb > 0; + } + + Log.i(Version.TAG, "Hack: considering there IS a camera.\n" + + "If it is not the case, report DEVICE and MODEL to linphone-users@nongnu.org"); + return true; + } + } diff --git a/Version.java b/Version.java index 924217a26..37fbfd877 100644 --- a/Version.java +++ b/Version.java @@ -28,6 +28,14 @@ public class Version { public static final String TAG="Linphone"; + public static final int API03_CUPCAKE_15 = 3; + public static final int API04_DONUT_16 = 4; + public static final int API06_ECLAIR_20 = 6; + public static final int API07_ECLAIR_21 = 7; + public static final int API08_FROYO_22 = 8; + public static final int API09_GINGERBREAD_23 = 9; + public static final int API11_HONEYCOMB_30 = 11; + private static native boolean nativeHasNeon(); private static Boolean hasNeon; From 2e8a69679b7e6204af21a894462cbd08a4c70b1d Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Jun 2011 15:40:56 +0200 Subject: [PATCH 113/288] Capture focus (continuous or click preview for auto focus) --- video/AndroidCameraRecord.java | 28 ++++++++++++++++-- video/AndroidCameraRecord5.java | 42 +++++++++++++++------------ video/AndroidCameraRecord8.java | 10 +++++++ video/AndroidCameraRecord9.java | 10 +++++++ video/AndroidCameraRecordManager.java | 8 ++--- 5 files changed, 72 insertions(+), 26 deletions(-) diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index 27bd02c63..ae477302e 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -25,6 +25,7 @@ import java.util.List; import org.linphone.core.Version; import android.hardware.Camera; +import android.hardware.Camera.AutoFocusCallback; import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; @@ -32,9 +33,11 @@ import android.hardware.Camera.Size; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.View; +import android.view.View.OnClickListener; -public abstract class AndroidCameraRecord { +public abstract class AndroidCameraRecord implements AutoFocusCallback { protected Camera camera; private RecorderParams params; @@ -125,6 +128,19 @@ public abstract class AndroidCameraRecord { previewStarted = true; + // Activate autofocus + if (Camera.Parameters.FOCUS_MODE_AUTO.equals(parameters.getFocusMode())) { + OnClickListener svClickListener = new OnClickListener() { + public void onClick(View v) { + Log.i(tag, "Auto focus requested"); + camera.autoFocus(AndroidCameraRecord.this); + } + }; + params.surfaceView.setOnClickListener(svClickListener); + // svClickListener.onClick(null); + } else { + params.surfaceView.setOnClickListener(null); + } // Register callback to get capture buffer lowLevelSetPreviewCallback(camera, storedPreviewCallback); @@ -151,7 +167,7 @@ public abstract class AndroidCameraRecord { public void storePreviewCallBack(PreviewCallback cb) { this.storedPreviewCallback = cb; if (camera == null) { - Log.w(tag, "Capture camera not ready, storing callback"); + Log.w(tag, "Capture camera not ready, storing preview callback"); return; } @@ -165,6 +181,7 @@ public abstract class AndroidCameraRecord { camera.stopPreview(); camera.release(); camera=null; + Log.d(tag, "Camera released"); currentPreviewSize = null; previewStarted = false; } @@ -189,6 +206,7 @@ public abstract class AndroidCameraRecord { final long filterDataNativePtr; public int cameraId; + public boolean isFrontCamera; public int rotation; public SurfaceView surfaceView; @@ -215,5 +233,9 @@ public abstract class AndroidCameraRecord { return currentPreviewSize.width * currentPreviewSize.height * 3 /2; } - + + public void onAutoFocus(boolean success, Camera camera) { + if (success) Log.i(tag, "Autofocus success"); + else Log.i(tag, "Autofocus failure"); + } } diff --git a/video/AndroidCameraRecord5.java b/video/AndroidCameraRecord5.java index 62af64b9f..90ca02d05 100644 --- a/video/AndroidCameraRecord5.java +++ b/video/AndroidCameraRecord5.java @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.Arrays; import java.util.List; import org.linphone.core.video.AndroidCameraRecord.RecorderParams.MirrorType; @@ -43,6 +44,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac private final double expectedTimeBetweenFrames; protected final int rotation; private MirrorType mirror; +// private boolean isUsingFrontCamera; public AndroidCameraRecord5(RecorderParams parameters) { super(parameters); @@ -50,6 +52,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac filterCtxPtr = parameters.filterDataNativePtr; rotation = parameters.rotation; mirror = parameters.mirror; +// isUsingFrontCamera = parameters.isFrontCamera; storePreviewCallBack(this); } @@ -94,31 +97,34 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac putImage(filterCtxPtr, data, rotation, mirror.ordinal()); } + protected String selectFocusMode(final List supportedFocusModes) {/* + if (isUsingFrontCamera && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) { + return Camera.Parameters.FOCUS_MODE_FIXED; + } + if (!isUsingFrontCamera && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { + return Camera.Parameters.FOCUS_MODE_INFINITY; + }*/ + + if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) { + return Camera.Parameters.FOCUS_MODE_AUTO; + } + + return null; // Should not occur? + } + @Override protected void onSettingCameraParameters(Parameters parameters) { super.onSettingCameraParameters(parameters); - - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) { - Log.w(tag, "Auto Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); + List supportedFocusModes = parameters.getSupportedFocusModes(); + String focusMode = selectFocusMode(supportedFocusModes); + if (focusMode != null) { + Log.w(tag, "Selected focus mode: " + focusMode); + parameters.setFocusMode(focusMode); } else { - Log.w(tag, "Auto Focus not supported by camera device"); - if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { - Log.w(tag, "Infinity Focus supported by camera device"); - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); - } else { - Log.w(tag, "Infinity Focus not supported by camera device"); - } + Log.i(tag, "No suitable focus mode found in : " + Arrays.toString(supportedFocusModes.toArray())); } } - public static List oneShotSupportedVideoSizes() { - Camera camera = Camera.open(); - List supportedVideoSizes =camera.getParameters().getSupportedPreviewSizes(); - camera.release(); - return supportedVideoSizes; - } - @Override protected List getSupportedPreviewSizes(Parameters parameters) { return parameters.getSupportedPreviewSizes(); diff --git a/video/AndroidCameraRecord8.java b/video/AndroidCameraRecord8.java index b62c63e97..ad776475b 100644 --- a/video/AndroidCameraRecord8.java +++ b/video/AndroidCameraRecord8.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.List; + import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; @@ -68,4 +70,12 @@ class AndroidCameraRecord8 extends AndroidCameraRecord5 { // Only on v8 hardware camera.setDisplayOrientation(rotation); } + + @Override + protected String selectFocusMode(final List supportedFocusModes) { + if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_EDOF)) { + return Camera.Parameters.FOCUS_MODE_EDOF; + } else + return super.selectFocusMode(supportedFocusModes); + } } diff --git a/video/AndroidCameraRecord9.java b/video/AndroidCameraRecord9.java index d81e8103e..f0023ef57 100644 --- a/video/AndroidCameraRecord9.java +++ b/video/AndroidCameraRecord9.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.List; + import android.hardware.Camera; /** @@ -37,4 +39,12 @@ class AndroidCameraRecord9 extends AndroidCameraRecord8 { protected Camera openCamera(int cameraId) { return Camera.open(cameraId); } + + @Override + protected String selectFocusMode(final List supportedFocusModes) { + if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) { + return Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO; + } else + return super.selectFocusMode(supportedFocusModes); + } } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index df884583d..a78550a42 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -99,6 +99,7 @@ public class AndroidCameraRecordManager { if (parameters != null) { parameters.cameraId = cameraId; + parameters.isFrontCamera = !previousUseFront; if (isRecording()) { stopVideoRecording(); tryToStartVideoRecording(); @@ -117,9 +118,10 @@ public class AndroidCameraRecordManager { p.width = width; p.height = height; p.cameraId = cameraId; + p.isFrontCamera = isUseFrontCamera(); parameters = p; - if (isUseFrontCamera()) { + if (p.isFrontCamera) { if (!isCameraOrientationPortrait()) { // Code for Nexus S: to be tested p.mirror = RecorderParams.MirrorType.CENTRAL; @@ -227,10 +229,6 @@ public class AndroidCameraRecordManager { if (supportedVideoSizes != null) return supportedVideoSizes; } - if (Version.sdkAboveOrEqual(5)) { - supportedVideoSizes = AndroidCameraRecord5.oneShotSupportedVideoSizes(); - } - // eventually null return supportedVideoSizes; From 3c6d4b89d0d86ae993498477de07c7cb6a1ed8e1 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 6 Jun 2011 15:04:16 +0200 Subject: [PATCH 114/288] Fix Log.wtf didn't exist on earlier Android versiosn. --- Hacks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hacks.java b/Hacks.java index 7ddf63d56..7628632be 100644 --- a/Hacks.java +++ b/Hacks.java @@ -134,7 +134,7 @@ public final class Hacks { try { nb = (Integer) Camera.class.getMethod("getNumberOfCameras", (Class[])null).invoke(null); } catch (Exception e) { - Log.wtf(Version.TAG, "Error getting number of cameras"); + Log.e(Version.TAG, "Error getting number of cameras"); } return nb > 0; } From bd0745ecc33e04327087b409b8a7b7c091bc1e37 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Jun 2011 19:04:53 +0200 Subject: [PATCH 115/288] implement quality indicators methods --- LinphoneCallImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index b60d92fda..653bd157e 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -37,6 +37,8 @@ class LinphoneCallImpl implements LinphoneCall { private native boolean isEchoLimiterEnabled(long nativePtr); private native long getReplacedCall(long nativePtr); private native int getDuration(long nativePtr); + private native float getCurrentQuality(long nativePtr); + private native float getAverageQuality(long nativePtr); protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -101,5 +103,11 @@ class LinphoneCallImpl implements LinphoneCall { public int getDuration() { return getDuration(nativePtr); } + public float getAverageQuality() { + return getAverageQuality(nativePtr); + } + public float getCurrentQuality() { + return getCurrentQuality(nativePtr); + } } From 1ac48c525da85ef50a8bf524df7784cabb63843f Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 17 Jun 2011 11:10:08 +0200 Subject: [PATCH 116/288] Efficient log class. --- Log.java | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 Log.java diff --git a/Log.java b/Log.java new file mode 100644 index 000000000..f223e6100 --- /dev/null +++ b/Log.java @@ -0,0 +1,102 @@ +/* +Log.java +Copyright (C) 2011 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; + + +/** + * Convenient wrapper for Android logs. + * + * @author Guillaume Beraudo + */ +public final class Log { + + public static final String TAG = "Linphone"; + + public static void i(Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) { + android.util.Log.i(TAG, toString(objects)); + } + } + public static void i(Throwable t, Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) { + android.util.Log.i(TAG, toString(objects), t); + } + } + + + public static void d(Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) { + android.util.Log.d(TAG, toString(objects)); + } + } + public static void d(Throwable t, Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) { + android.util.Log.d(TAG, toString(objects), t); + } + } + + public static void w(Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) { + android.util.Log.w(TAG, toString(objects)); + } + } + public static void w(Throwable t, Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) { + android.util.Log.w(TAG, toString(objects), t); + } + } + + public static void e(Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + android.util.Log.e(TAG, toString(objects)); + } + } + public static void e(Throwable t, Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + android.util.Log.e(TAG, toString(objects), t); + } + } + + /** + * @throws RuntimeException always throw after logging the error message. + */ + public static void f(Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + android.util.Log.e(TAG, toString(objects)); + throw new RuntimeException("Fatal error : " + toString(objects)); + } + } + /** + * @throws RuntimeException always throw after logging the error message. + */ + public static void f(Throwable t, Object...objects) { + if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + android.util.Log.e(TAG, toString(objects), t); + throw new RuntimeException("Fatal error : " + toString(objects), t); + } + } + + private static String toString(Object...objects) { + StringBuilder sb = new StringBuilder(); + for (Object o : objects) { + sb.append(o); + } + return sb.toString(); + } +} From 3698ea0b736d94fdaf78b158a0b02e884018e8fe Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 17 Jun 2011 16:02:53 +0200 Subject: [PATCH 117/288] Fix crashes on network change. --- video/AndroidCameraRecord5.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/AndroidCameraRecord5.java b/video/AndroidCameraRecord5.java index 90ca02d05..8ee2c8303 100644 --- a/video/AndroidCameraRecord5.java +++ b/video/AndroidCameraRecord5.java @@ -77,7 +77,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac + " whereas expected is " + expectedBuffLength + " don't calling putImage"); return; } - + long curTime = System.currentTimeMillis(); if (lastFrameTime == 0) { lastFrameTime = curTime; From 64ae9ce334ca90758730f9674aa62386562c31cd Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 20 Jun 2011 13:47:46 +0200 Subject: [PATCH 118/288] Rework video capture. Fix high/low resolution switch. --- video/AndroidCameraConf5.java | 4 +- video/AndroidCameraConf9.java | 7 +- video/AndroidCameraRecord.java | 5 + video/AndroidCameraRecordManager.java | 126 ++++++++++++++++++++------ 4 files changed, 109 insertions(+), 33 deletions(-) diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index 8f9bab996..3deda1c69 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -74,9 +74,9 @@ class AndroidCameraConf5 implements AndroidCameraConf { // | | // | Phone | // |________| - return 90; + return 180; } - return 0; + return 90; } diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index 6b6f8a1ba..b32c80303 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -49,11 +49,10 @@ class AndroidCameraConf9 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); - Log.d(Version.TAG, String.format("Camera info for %d: orientation=%d returned=%d ", + Log.d(Version.TAG, String.format("Camera info for %d: orientation=%d", cameraId, - info.orientation, - (info.orientation - 90) %360)); - return (info.orientation - 90) %360; + info.orientation)); + return info.orientation; } public boolean isFrontCamera(int cameraId) { diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index ae477302e..1fa12b86f 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -211,6 +211,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { public SurfaceView surfaceView; public MirrorType mirror = MirrorType.NO; + public int phoneOrientation; public RecorderParams(long ptr) { filterDataNativePtr = ptr; @@ -238,4 +239,8 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { if (success) Log.i(tag, "Autofocus success"); else Log.i(tag, "Autofocus failure"); } + + public int getStoredPhoneOrientation() { + return params.phoneOrientation; + } } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index a78550a42..f30f23e96 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -20,11 +20,14 @@ package org.linphone.core.video; import java.util.List; +import org.linphone.LinphoneManager; import org.linphone.core.Version; import org.linphone.core.video.AndroidCameraRecord.RecorderParams; +import android.content.Context; import android.hardware.Camera.Size; import android.util.Log; +import android.view.OrientationEventListener; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.SurfaceHolder.Callback; @@ -40,6 +43,8 @@ import android.view.SurfaceHolder.Callback; public class AndroidCameraRecordManager { private static final String tag = "Linphone"; private static AndroidCameraRecordManager instance; + private OrientationEventListener orientationEventListener; + private OnCapturingStateChangedListener capturingStateChangedListener; /** * @return instance @@ -59,9 +64,7 @@ public class AndroidCameraRecordManager { private AndroidCameraRecord recorder; private List supportedVideoSizes; - private int phoneOrientation; - public int getPhoneOrientation() {return phoneOrientation;} - public void setPhoneOrientation(int degrees) {this.phoneOrientation = degrees;} + private int mAlwaysChangingPhoneOrientation=0; // singleton @@ -112,7 +115,10 @@ public class AndroidCameraRecordManager { public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { - stopVideoRecording(); + if (recorder != null) { + Log.w(tag, "Recorder should not be running"); + stopVideoRecording(); + } RecorderParams p = new RecorderParams(filterDataPtr); p.fps = fps; p.width = width; @@ -135,8 +141,7 @@ public class AndroidCameraRecordManager { } - public final void setSurfaceView(final SurfaceView sv, final int phoneOrientation) { - this.phoneOrientation = phoneOrientation; + public final void setSurfaceView(final SurfaceView sv) { SurfaceHolder holder = sv.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); @@ -186,11 +191,20 @@ public class AndroidCameraRecordManager { if (isRecording()) return; tryToStartVideoRecording(); } - + private synchronized void tryToStartVideoRecording() { + if (orientationEventListener == null) { + throw new RuntimeException("startOrientationSensor was not called"); + } + if (muted || surfaceView == null || parameters == null) return; - - parameters.rotation = bufferRotationForCorrectImageOrientation(); + + if (recorder != null) { + Log.e(tag, "Recorder already present"); + stopVideoRecording(); + } + + parameters.rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); parameters.surfaceView = surfaceView; if (Version.sdkAboveOrEqual(9)) { @@ -204,20 +218,26 @@ public class AndroidCameraRecordManager { } recorder.startPreview(); + + if (capturingStateChangedListener != null) { + capturingStateChangedListener.captureStarted(); + } } public synchronized void stopVideoRecording() { if (recorder != null) { recorder.stopPreview(); recorder = null; + if (capturingStateChangedListener != null) { + capturingStateChangedListener.captureStopped(); + } } } - // FIXME select right camera + /** - * Eventually null if API < 5. - * + * FIXME select right camera */ public List supportedVideoSizes() { if (supportedVideoSizes != null) { @@ -229,8 +249,6 @@ public class AndroidCameraRecordManager { if (supportedVideoSizes != null) return supportedVideoSizes; } - // eventually null - return supportedVideoSizes; } @@ -249,11 +267,11 @@ public class AndroidCameraRecordManager { parameters = null; } - public boolean outputIsPortrait() { - final int rotation = bufferRotationForCorrectImageOrientation(); + public boolean isOutputPortraitDependingOnCameraAndPhoneOrientations() { + final int rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); final boolean isPortrait = (rotation % 180) == 90; - Log.d(tag, "Camera sensor in portrait orientation? " + isPortrait); + Log.d(tag, "Camera sensor in " + (isPortrait? "portrait":"landscape") + " orientation."); return isPortrait; } @@ -263,22 +281,76 @@ public class AndroidCameraRecordManager { public boolean isCameraOrientationPortrait() { - return (cc.getCameraOrientation(cameraId) % 180) == 90; + return (cc.getCameraOrientation(cameraId) % 180) == 0; } - private int bufferRotationForCorrectImageOrientation() { - if (Version.sdkAboveOrEqual(8)) { - final int cameraOrientation = cc.getCameraOrientation(cameraId); - final int rotation = (360 - cameraOrientation + 90 - phoneOrientation) % 360; - Log.d(tag, String.format( + private int bufferRotationToCompensateCameraAndPhoneOrientations() { + if (Version.sdkStrictlyBelow(Version.API08_FROYO_22)) { + // Don't perform any rotation + // Phone screen should use fitting orientation + return 0; + } + + final int phoneOrientation = mAlwaysChangingPhoneOrientation; + final int cameraOrientation = cc.getCameraOrientation(cameraId); + final int rotation = (cameraOrientation + phoneOrientation) % 360; + Log.d(tag, String.format( "Capture video buffer of cameraId=%d will need a rotation of " + "%d degrees: camera_orientation=%d, phone_orientation=%d", cameraId, rotation, cameraOrientation, phoneOrientation)); - return rotation; - } - - return 0; + return rotation; } + + + /** + * Register a sensor to track phoneOrientation changes + */ + public void startOrientationSensor(Context c) { + if (orientationEventListener == null) { + orientationEventListener = new LocalOrientationEventListener(c); + orientationEventListener.enable(); + } + } + + private class LocalOrientationEventListener extends OrientationEventListener { + public LocalOrientationEventListener(Context context) { + super(context); + } + @Override + public void onOrientationChanged(final int o) { + if (o == OrientationEventListener.ORIENTATION_UNKNOWN) return; + + int degrees=270; + if (o < 45 || o >315) degrees=0; + else if (o<135) degrees=90; + else if (o<225) degrees=180; + + if (mAlwaysChangingPhoneOrientation == degrees) return; + + Log.i(tag, "Phone orientation changed to " + degrees); + mAlwaysChangingPhoneOrientation = degrees; + } + } + + /** + * @return true if linphone core configured to send a A buffer while phone orientation induces !A buffer (A=landscape or portrait) + */ + public boolean isOutputOrientationMismatch() { + final boolean currentlyPortrait = LinphoneManager.getLc().getPreferredVideoSize().isPortrait(); + final boolean shouldBePortrait = isOutputPortraitDependingOnCameraAndPhoneOrientations(); + return currentlyPortrait ^ shouldBePortrait; + } + + public void setOnCapturingStateChanged(OnCapturingStateChangedListener listener) { + this.capturingStateChangedListener=listener; + } + + public static interface OnCapturingStateChangedListener { + void captureStarted(); + void captureStopped(); + } + + } From f5b18a690957971522fa0d6705e9aade6f7ae6a9 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 20 Jun 2011 14:44:50 +0200 Subject: [PATCH 119/288] Convert Logs to new system. No more "tags" remaining. --- AndroidVideoWindowImpl.java | 12 +++++------ Hacks.java | 9 ++++----- LinphoneCoreFactoryImpl.java | 4 +--- Log.java | 1 + Version.java | 2 -- tutorials/JavaCameraRecordImpl.java | 6 +++--- tutorials/TestVideoActivity.java | 13 +++++++----- video/AndroidCameraConf5.java | 25 +++++++++++------------ video/AndroidCameraConf9.java | 7 ++----- video/AndroidCameraRecord.java | 27 ++++++++++++------------- video/AndroidCameraRecord5.java | 16 +++++++-------- video/AndroidCameraRecord8.java | 5 +++-- video/AndroidCameraRecordManager.java | 29 +++++++++++++-------------- 13 files changed, 74 insertions(+), 82 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 243afb472..254efb379 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -3,7 +3,6 @@ package org.linphone.core; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Bitmap.Config; -import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -15,7 +14,6 @@ public class AndroidVideoWindowImpl { private SurfaceView mView; private Surface mSurface; private VideoWindowListener mListener; - static private String TAG = "Linphone"; public static interface VideoWindowListener{ void onSurfaceReady(AndroidVideoWindowImpl vw); void onSurfaceDestroyed(AndroidVideoWindowImpl vw); @@ -28,17 +26,17 @@ public class AndroidVideoWindowImpl { view.getHolder().addCallback(new Callback(){ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.i(TAG,"Surface is being changed."); + Log.i("Surface is being changed."); synchronized(AndroidVideoWindowImpl.this){ mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); mSurface=holder.getSurface(); } if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); - Log.w(TAG, "Video display surface changed"); + Log.w("Video display surface changed"); } public void surfaceCreated(SurfaceHolder holder) { - Log.w(TAG, "Video display surface created"); + Log.w("Video display surface created"); } public void surfaceDestroyed(SurfaceHolder holder) { @@ -48,7 +46,7 @@ public class AndroidVideoWindowImpl { } if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); - Log.d(TAG, "Video display surface destroyed"); + Log.d("Video display surface destroyed"); } }); } @@ -56,7 +54,7 @@ public class AndroidVideoWindowImpl { static final int PORTRAIT=1; public void requestOrientation(int orientation){ //Surface.setOrientation(0, orientation==LANDSCAPE ? 1 : 0); - //Log.d("Linphone", "Orientation changed."); + //Log.d("Orientation changed."); } public void setListener(VideoWindowListener l){ mListener=l; diff --git a/Hacks.java b/Hacks.java index 7628632be..fd9342827 100644 --- a/Hacks.java +++ b/Hacks.java @@ -21,7 +21,6 @@ package org.linphone.core; import android.hardware.Camera; import android.media.AudioManager; import android.os.Build; -import android.util.Log; public final class Hacks { @@ -65,7 +64,7 @@ public final class Hacks { /* private static final boolean log(final String msg) { - Log.d("Linphone", msg); + Log.d(msg); return true; }*/ @@ -104,7 +103,7 @@ public final class Hacks { //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); sb.append("SDK=").append(Build.VERSION.SDK); - Log.i(Version.TAG, sb.toString()); + Log.i(sb.toString()); } public static boolean needSoftvolume() { @@ -134,12 +133,12 @@ public final class Hacks { try { nb = (Integer) Camera.class.getMethod("getNumberOfCameras", (Class[])null).invoke(null); } catch (Exception e) { - Log.e(Version.TAG, "Error getting number of cameras"); + Log.e("Error getting number of cameras"); } return nb > 0; } - Log.i(Version.TAG, "Hack: considering there IS a camera.\n" + Log.i("Hack: considering there IS a camera.\n" + "If it is not the case, report DEVICE and MODEL to linphone-users@nongnu.org"); return true; } diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 0a9ba7a76..a2800be92 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -21,15 +21,13 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import android.util.Log; - public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { private static void loadOptionalLibrary(String s) { try { System.loadLibrary(s); } catch (Throwable e) { - Log.w(Version.TAG, "Unable to load optional library lib" + s); + Log.w("Unable to load optional library lib", s); } } diff --git a/Log.java b/Log.java index f223e6100..c341fa68e 100644 --- a/Log.java +++ b/Log.java @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; + /** * Convenient wrapper for Android logs. * diff --git a/Version.java b/Version.java index 37fbfd877..6bf12be45 100644 --- a/Version.java +++ b/Version.java @@ -26,8 +26,6 @@ import android.os.Build; */ public class Version { - public static final String TAG="Linphone"; - public static final int API03_CUPCAKE_15 = 3; public static final int API04_DONUT_16 = 4; public static final int API06_ECLAIR_20 = 6; diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java index 341bd28cc..4772c7a5b 100644 --- a/tutorials/JavaCameraRecordImpl.java +++ b/tutorials/JavaCameraRecordImpl.java @@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.tutorials; +import org.linphone.core.Log; import org.linphone.core.video.AndroidCameraRecord; import android.hardware.Camera; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; -import android.util.Log; import android.widget.TextView; /** @@ -59,8 +59,8 @@ class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallbac Size s = camera.getParameters().getPreviewSize(); int expectedBuffLength = s.width * s.height * 3 /2; if (expectedBuffLength != data.length) { - Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length - + " whereas expected is " + expectedBuffLength + " don't calling putImage"); + Log.e("onPreviewFrame called with bad buffer length ", data.length, + " whereas expected is ", expectedBuffLength, " don't calling putImage"); return; } diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java index ce3a9185b..7523cb0ff 100644 --- a/tutorials/TestVideoActivity.java +++ b/tutorials/TestVideoActivity.java @@ -18,15 +18,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.tutorials; +import static org.linphone.core.VideoSize.CIF; +import static org.linphone.core.VideoSize.HVGA; +import static org.linphone.core.VideoSize.QCIF; +import static org.linphone.core.VideoSize.QVGA; + import java.util.Stack; import org.linphone.R; +import org.linphone.core.Log; import org.linphone.core.VideoSize; import org.linphone.core.video.AndroidCameraRecord; import android.app.Activity; import android.os.Bundle; -import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; @@ -35,7 +40,6 @@ import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.TextView; -import static org.linphone.core.VideoSize.*; /** * Activity for displaying and starting the HelloWorld example on Android phone. @@ -48,7 +52,6 @@ public class TestVideoActivity extends Activity implements Callback, OnClickList private SurfaceView surfaceView; private static final int rate = 7; private JavaCameraRecordImpl recorder; - private static String tag = "Linphone"; private TextView debugView; private Button nextSize; private Button changeCamera; @@ -171,12 +174,12 @@ public class TestVideoActivity extends Activity implements Callback, OnClickList public void surfaceDestroyed(SurfaceHolder holder) { surfaceView = null; - Log.d(tag , "Video capture surface destroyed"); + Log.d("Video capture surface destroyed"); if (recorder != null) recorder.stopPreview(); } public void surfaceCreated(SurfaceHolder holder) { - Log.d(tag , "Video capture surface created"); + Log.d("Video capture surface created"); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index 3deda1c69..f8dbe56cb 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -19,42 +19,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core.video; import org.linphone.core.Hacks; +import org.linphone.core.Log; -import android.util.Log; class AndroidCameraConf5 implements AndroidCameraConf { - private static final String tag = "Linphone"; private AndroidCameras foundCameras; public AndroidCameras getFoundCameras() {return foundCameras;} public AndroidCameraConf5() { - Log.i(tag, "Detecting cameras"); + Log.i("Detecting cameras"); // Defaults foundCameras = new AndroidCameras(); if (Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : has one or more cameras"); + Log.d("Hack Galaxy S : has one or more cameras"); if (Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d(tag, "Hack Galaxy S : HAS a front camera with id=2"); + Log.d("Hack Galaxy S : HAS a front camera with id=2"); foundCameras.front = 2; } else { - Log.d(tag, "Hack Galaxy S : NO front camera"); + Log.d("Hack Galaxy S : NO front camera"); } - Log.d(tag, "Hack Galaxy S : HAS a rear camera with id=1"); + Log.d("Hack Galaxy S : HAS a rear camera with id=1"); foundCameras.rear = 1; foundCameras.defaultC = foundCameras.rear; } else if (Hacks.hasTwoCamerasRear0Front1()) { - Log.d(tag, "Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1"); + Log.d("Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1"); foundCameras.front = 1; } } public int getNumberOfCameras() { - Log.i(tag, "Detecting the number of cameras"); + Log.i("Detecting the number of cameras"); if (Hacks.hasTwoCamerasRear0Front1() || Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d(tag, "Hack: we know this model has 2 cameras"); + Log.d("Hack: we know this model has 2 cameras"); return 2; } else return 1; @@ -65,7 +64,7 @@ class AndroidCameraConf5 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { // Use hacks to guess orientation of the camera if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) { - Log.d(tag, "Hack Galaxy S : front camera mounted landscape"); + Log.d("Hack Galaxy S : front camera mounted landscape"); // mounted in landscape for a portrait phone orientation // |^^^^^^^^| // | ____ | @@ -84,10 +83,10 @@ class AndroidCameraConf5 implements AndroidCameraConf { public boolean isFrontCamera(int cameraId) { // Use hacks to guess facing of the camera if (cameraId == 2 && Hacks.isGalaxySOrTab()) { - Log.d(tag, "Hack Galaxy S : front camera has id=2"); + Log.d("Hack Galaxy S : front camera has id=2"); return true; } else if (cameraId == 1 && Hacks.hasTwoCamerasRear0Front1()) { - Log.d(tag, "Hack SPHD700 : front camera has id=1"); + Log.d("Hack SPHD700 : front camera has id=1"); return true; } diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index b32c80303..d0ef0faa5 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -18,10 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; -import org.linphone.core.Version; +import org.linphone.core.Log; import android.hardware.Camera; -import android.util.Log; class AndroidCameraConf9 implements AndroidCameraConf { private AndroidCameras foundCameras; @@ -49,9 +48,7 @@ class AndroidCameraConf9 implements AndroidCameraConf { public int getCameraOrientation(int cameraId) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); - Log.d(Version.TAG, String.format("Camera info for %d: orientation=%d", - cameraId, - info.orientation)); + Log.d("Camera info for ",cameraId,": orientation=",info.orientation); return info.orientation; } diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index 1fa12b86f..dec9338b2 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.linphone.core.Log; import org.linphone.core.Version; import android.hardware.Camera; @@ -30,7 +31,6 @@ import android.hardware.Camera.ErrorCallback; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; -import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; @@ -44,7 +44,6 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { private PreviewCallback storedPreviewCallback; private boolean previewStarted; - protected static final String tag="Linphone"; private List supportedVideoSizes; private Size currentPreviewSize; @@ -58,27 +57,27 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { public synchronized void startPreview() { // FIXME throws exception? if (previewStarted) { - Log.w(tag, "Already started"); + Log.w("Already started"); throw new RuntimeException("Video recorder already started"); // return } if (params.surfaceView.getVisibility() != SurfaceView.VISIBLE) { // Illegal state - Log.e(tag, "Illegal state: video capture surface view is not visible"); + Log.e("Illegal state: video capture surface view is not visible"); return; } - Log.d(tag, "Trying to open camera with id " + params.cameraId); + Log.d("Trying to open camera with id ", params.cameraId); if (camera != null) { - Log.e(tag, "Camera is not null, ?already open? : aborting"); + Log.e("Camera is not null, ?already open? : aborting"); return; } camera = openCamera(params.cameraId); camera.setErrorCallback(new ErrorCallback() { public void onError(int error, Camera camera) { - Log.e(tag, "Camera error : " + error); + Log.e("Camera error : ", error); } }); @@ -113,14 +112,14 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { camera.setPreviewDisplay(holder); } catch (Throwable t) { - Log.e(tag, "Exception in Video capture setPreviewDisplay()", t); + Log.e(t,"Exception in Video capture setPreviewDisplay()"); } try { camera.startPreview(); } catch (Throwable e) { - Log.e(tag, "Error, can't start camera preview. Releasing camera!"); + Log.e("Error, can't start camera preview. Releasing camera!"); camera.release(); camera = null; return; @@ -132,7 +131,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { if (Camera.Parameters.FOCUS_MODE_AUTO.equals(parameters.getFocusMode())) { OnClickListener svClickListener = new OnClickListener() { public void onClick(View v) { - Log.i(tag, "Auto focus requested"); + Log.i("Auto focus requested"); camera.autoFocus(AndroidCameraRecord.this); } }; @@ -167,7 +166,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { public void storePreviewCallBack(PreviewCallback cb) { this.storedPreviewCallback = cb; if (camera == null) { - Log.w(tag, "Capture camera not ready, storing preview callback"); + Log.w("Capture camera not ready, storing preview callback"); return; } @@ -181,7 +180,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { camera.stopPreview(); camera.release(); camera=null; - Log.d(tag, "Camera released"); + Log.d("Camera released"); currentPreviewSize = null; previewStarted = false; } @@ -236,8 +235,8 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { } public void onAutoFocus(boolean success, Camera camera) { - if (success) Log.i(tag, "Autofocus success"); - else Log.i(tag, "Autofocus failure"); + if (success) Log.i("Autofocus success"); + else Log.i("Autofocus failure"); } public int getStoredPhoneOrientation() { diff --git a/video/AndroidCameraRecord5.java b/video/AndroidCameraRecord5.java index 8ee2c8303..03f9123db 100644 --- a/video/AndroidCameraRecord5.java +++ b/video/AndroidCameraRecord5.java @@ -21,13 +21,13 @@ package org.linphone.core.video; import java.util.Arrays; import java.util.List; +import org.linphone.core.Log; import org.linphone.core.video.AndroidCameraRecord.RecorderParams.MirrorType; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; -import android.util.Log; /** * Record from Android camera. @@ -63,18 +63,18 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac public void onPreviewFrame(byte[] data, Camera camera) { if (data == null) { - Log.e(tag, "onPreviewFrame Called with null buffer"); + Log.e("onPreviewFrame Called with null buffer"); return; } if (filterCtxPtr == 0l) { - Log.e(tag, "onPreviewFrame Called with no filterCtxPtr set"); + Log.e("onPreviewFrame Called with no filterCtxPtr set"); return; } int expectedBuffLength = getExpectedBufferLength(); if (expectedBuffLength != data.length) { - Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length - + " whereas expected is " + expectedBuffLength + " don't calling putImage"); + Log.e("onPreviewFrame called with bad buffer length ", data.length, + " whereas expected is ", expectedBuffLength, " don't calling putImage"); return; } @@ -87,7 +87,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; if (currentTimeElapsed < expectedTimeBetweenFrames) { -// Log.d(tag, "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps); +// Log.d("Clipping frame ", Math.round(1 / currentTimeElapsed), " > ", fps); return; } lastFrameTime = curTime; @@ -118,10 +118,10 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac List supportedFocusModes = parameters.getSupportedFocusModes(); String focusMode = selectFocusMode(supportedFocusModes); if (focusMode != null) { - Log.w(tag, "Selected focus mode: " + focusMode); + Log.w("Selected focus mode: ", focusMode); parameters.setFocusMode(focusMode); } else { - Log.i(tag, "No suitable focus mode found in : " + Arrays.toString(supportedFocusModes.toArray())); + Log.i("No suitable focus mode found in : ", Arrays.toString(supportedFocusModes.toArray())); } } diff --git a/video/AndroidCameraRecord8.java b/video/AndroidCameraRecord8.java index ad776475b..c5fda6774 100644 --- a/video/AndroidCameraRecord8.java +++ b/video/AndroidCameraRecord8.java @@ -20,11 +20,12 @@ package org.linphone.core.video; import java.util.List; +import org.linphone.core.Log; + import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.Size; -import android.util.Log; /** * @@ -42,7 +43,7 @@ class AndroidCameraRecord8 extends AndroidCameraRecord5 { @Override protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { if (cb != null) { - Log.d(tag, "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); + Log.d("Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); } camera.setPreviewCallbackWithBuffer(cb); } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index f30f23e96..beb8fecb0 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -21,12 +21,12 @@ package org.linphone.core.video; import java.util.List; import org.linphone.LinphoneManager; +import org.linphone.core.Log; import org.linphone.core.Version; import org.linphone.core.video.AndroidCameraRecord.RecorderParams; import android.content.Context; import android.hardware.Camera.Size; -import android.util.Log; import android.view.OrientationEventListener; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -41,7 +41,6 @@ import android.view.SurfaceHolder.Callback; * */ public class AndroidCameraRecordManager { - private static final String tag = "Linphone"; private static AndroidCameraRecordManager instance; private OrientationEventListener orientationEventListener; private OnCapturingStateChangedListener capturingStateChangedListener; @@ -70,7 +69,7 @@ public class AndroidCameraRecordManager { // singleton private AndroidCameraRecordManager() { cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5(); - Log.i(tag, "=== Detected " + cc.getFoundCameras()+ " ==="); + Log.i("=== Detected " + cc.getFoundCameras()+ " ==="); cameraId = cc.getFoundCameras().defaultC; } @@ -87,7 +86,7 @@ public class AndroidCameraRecordManager { public void setUseFrontCamera(boolean value) { if (!hasFrontCamera()) { - Log.e(tag, "setUseFrontCamera(true) while no front camera detected on device: using rear"); + Log.e("setUseFrontCamera(true) while no front camera detected on device: using rear"); value = false; } if (cc.isFrontCamera(cameraId) == value) return; // already OK @@ -116,7 +115,7 @@ public class AndroidCameraRecordManager { public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { if (recorder != null) { - Log.w(tag, "Recorder should not be running"); + Log.w("Recorder should not be running"); stopVideoRecording(); } RecorderParams p = new RecorderParams(filterDataPtr); @@ -148,19 +147,19 @@ public class AndroidCameraRecordManager { holder.addCallback(new Callback() { public void surfaceDestroyed(SurfaceHolder holder) { surfaceView = null; - Log.d(tag , "Video capture surface destroyed"); + Log.d("Video capture surface destroyed"); stopVideoRecording(); } public void surfaceCreated(SurfaceHolder holder) { surfaceView = sv; - Log.d(tag , "Video capture surface created"); + Log.d("Video capture surface created"); tryToStartVideoRecording(); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.d(tag , "Video capture surface changed"); + Log.d("Video capture surface changed"); } }); } @@ -200,7 +199,7 @@ public class AndroidCameraRecordManager { if (muted || surfaceView == null || parameters == null) return; if (recorder != null) { - Log.e(tag, "Recorder already present"); + Log.e("Recorder already present"); stopVideoRecording(); } @@ -271,7 +270,7 @@ public class AndroidCameraRecordManager { final int rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); final boolean isPortrait = (rotation % 180) == 90; - Log.d(tag, "Camera sensor in " + (isPortrait? "portrait":"landscape") + " orientation."); + Log.d("Camera sensor in ", isPortrait? "portrait":"landscape"," orientation."); return isPortrait; } @@ -296,10 +295,10 @@ public class AndroidCameraRecordManager { final int phoneOrientation = mAlwaysChangingPhoneOrientation; final int cameraOrientation = cc.getCameraOrientation(cameraId); final int rotation = (cameraOrientation + phoneOrientation) % 360; - Log.d(tag, String.format( - "Capture video buffer of cameraId=%d will need a rotation of " - + "%d degrees: camera_orientation=%d, phone_orientation=%d", - cameraId, rotation, cameraOrientation, phoneOrientation)); + Log.d("Capture video buffer of cameraId=",cameraId, + " will need a rotation of ",rotation, + " degrees: camera_orientation=",cameraOrientation, + " phone_orientation=", phoneOrientation); return rotation; } @@ -329,7 +328,7 @@ public class AndroidCameraRecordManager { if (mAlwaysChangingPhoneOrientation == degrees) return; - Log.i(tag, "Phone orientation changed to " + degrees); + Log.i("Phone orientation changed to ", degrees); mAlwaysChangingPhoneOrientation = degrees; } } From 94d58ce1e6336ed050e2b08671ea481ccf8632d7 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 21 Jun 2011 15:33:33 +0200 Subject: [PATCH 120/288] Fix regression video with Galaxy S. --- video/AndroidCameraRecordManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index beb8fecb0..6ad9a78de 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -294,7 +294,10 @@ public class AndroidCameraRecordManager { final int phoneOrientation = mAlwaysChangingPhoneOrientation; final int cameraOrientation = cc.getCameraOrientation(cameraId); - final int rotation = (cameraOrientation + phoneOrientation) % 360; + int frontCameraCorrection = 0; + if (cc.isFrontCamera(cameraId)) // TODO: check with other phones (Nexus S, ...) + frontCameraCorrection=180; // hack that "just works" on Galaxy S. + final int rotation = (cameraOrientation + phoneOrientation + frontCameraCorrection) % 360; Log.d("Capture video buffer of cameraId=",cameraId, " will need a rotation of ",rotation, " degrees: camera_orientation=",cameraOrientation, From 03c280a21665044ed510a2e598399a5263b494dd Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 22 Jun 2011 13:06:47 +0200 Subject: [PATCH 121/288] add missing ptime setters --- LinphoneCoreImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 32052f143..b68d9c676 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -99,6 +99,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native int pauseCall(long nativePtr, long callPtr); private native int pauseAllCalls(long nativePtr); private native int resumeCall(long nativePtr, long callPtr); + private native void setUploadPtime(long nativePtr, int ptime); + private native void setDownloadPtime(long nativePtr, int ptime); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -483,4 +486,11 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized boolean pauseAllCalls() { return 0 == pauseAllCalls(nativePtr); } + public void setDownloadPtime(int ptime) { + setDownloadPtime(nativePtr,ptime); + + } + public void setUploadPtime(int ptime) { + setUploadPtime(nativePtr,ptime); + } } From f91c9b4805a7050b1f192b28c848b4aac39ae713 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 1 Jul 2011 18:08:04 +0200 Subject: [PATCH 122/288] disable video on non capable hardware --- Version.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Version.java b/Version.java index 6bf12be45..61a92b40b 100644 --- a/Version.java +++ b/Version.java @@ -65,5 +65,8 @@ public class Version { if (hasNeon == null) hasNeon = nativeHasNeon(); return hasNeon; } + public static boolean isVideoCapable() { + return !Version.sdkStrictlyBelow(5) && Version.hasNeon() && Hacks.hasCamera(); + } } From d9333176bf4b03cc1c585f12a4ecc52294a05340 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 15 Jul 2011 22:08:36 +0200 Subject: [PATCH 123/288] Rename openssl libs. ZRTP API and makefiles. --- LinphoneCallImpl.java | 14 +++++++++++++- LinphoneCoreFactoryImpl.java | 12 ++++++++++++ LinphoneCoreImpl.java | 7 ++++++- Version.java | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 653bd157e..55d3baedf 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -39,6 +39,9 @@ class LinphoneCallImpl implements LinphoneCall { private native int getDuration(long nativePtr); private native float getCurrentQuality(long nativePtr); private native float getAverageQuality(long nativePtr); + private native String getAuthenticationToken(long nativePtr); + private native boolean isAuthenticationTokenVerified(long nativePtr); + private native boolean areStreamsEncrypted(long nativePtr); protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -109,5 +112,14 @@ class LinphoneCallImpl implements LinphoneCall { public float getCurrentQuality() { return getCurrentQuality(nativePtr); } - + + public String getAuthenticationToken(){ + return getAuthenticationToken(nativePtr); + } + public boolean isAuthenticationTokenVerified(){ + return isAuthenticationTokenVerified(nativePtr); + } + public boolean areStreamsEncrypted() { + return areStreamsEncrypted(nativePtr); + } } diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index a2800be92..6301c5c70 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -32,10 +32,22 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } static { + // FFMPEG (audio/video) loadOptionalLibrary("avutil"); loadOptionalLibrary("swscale"); loadOptionalLibrary("avcore"); loadOptionalLibrary("avcodec"); + + // OPENSSL (cryptography) + // lin prefix avoids collision with libs in /system/lib + loadOptionalLibrary("lincrypto"); + loadOptionalLibrary("linssl"); + + // Secure RTP and key negotiation + loadOptionalLibrary("srtp"); + loadOptionalLibrary("zrtpcpp"); // GPLv3+ + + //Main library System.loadLibrary("linphone"); } @Override diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b68d9c676..b8fddda20 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -101,7 +101,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native int resumeCall(long nativePtr, long callPtr); private native void setUploadPtime(long nativePtr, int ptime); private native void setDownloadPtime(long nativePtr, int ptime); - + private native void setZrtpSecretsCache(long nativePtr, String file); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -493,4 +494,8 @@ class LinphoneCoreImpl implements LinphoneCore { public void setUploadPtime(int ptime) { setUploadPtime(nativePtr,ptime); } + + public void setZrtpSecretsCache(String file) { + setZrtpSecretsCache(nativePtr,file); + } } diff --git a/Version.java b/Version.java index 61a92b40b..14dff0c27 100644 --- a/Version.java +++ b/Version.java @@ -34,6 +34,7 @@ public class Version { public static final int API09_GINGERBREAD_23 = 9; public static final int API11_HONEYCOMB_30 = 11; + private static native boolean nativeHasZrtp(); private static native boolean nativeHasNeon(); private static Boolean hasNeon; @@ -69,4 +70,7 @@ public class Version { return !Version.sdkStrictlyBelow(5) && Version.hasNeon() && Hacks.hasCamera(); } + public static boolean hasZrtp(){ + return nativeHasZrtp(); + } } From efdfe92b18348a8234f01a7874bc504ebc18476a Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 20 Jul 2011 11:52:09 +0200 Subject: [PATCH 124/288] Enable TLS option --- LinphoneCoreFactoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 6301c5c70..7e8f6e5de 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -37,7 +37,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { loadOptionalLibrary("swscale"); loadOptionalLibrary("avcore"); loadOptionalLibrary("avcodec"); - + // OPENSSL (cryptography) // lin prefix avoids collision with libs in /system/lib loadOptionalLibrary("lincrypto"); From 4eb83bcf13d2d9a25709d6f5887f14388c9c98f0 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 22 Jul 2011 11:43:05 +0200 Subject: [PATCH 125/288] Updated Android implementation to support new trusted root CA option --- LinphoneCoreFactoryImpl.java | 14 ++++++++++++++ LinphoneCoreImpl.java | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 7e8f6e5de..f92dd6c86 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -19,7 +19,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.PKIXParameters; +import java.security.cert.TrustAnchor; +import java.security.cert.X509Certificate; +import java.util.Iterator; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b8fddda20..f09c5f9ee 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -87,6 +87,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native int[] getPreferredVideoSize(long nativePtr); private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); + private native void setRootCA(long nativePtr, String path); private native long[] listVideoPayloadTypes(long nativePtr); private native long[] listAudioPayloadTypes(long nativePtr); private native void enableKeepAlive(long nativePtr,boolean enable); @@ -420,6 +421,10 @@ class LinphoneCoreImpl implements LinphoneCore { return getRing(nativePtr); } + public void setRootCA(String path) { + setRootCA(nativePtr, path); + } + public PayloadType[] getVideoCodecs() { long[] typesPtr = listVideoPayloadTypes(nativePtr); if (typesPtr == null) return null; From 69f71d9bc81ed27c65031c6c6b4fe142272c85ee Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 22 Jul 2011 12:44:41 +0200 Subject: [PATCH 126/288] clean up sdk deps --- video/AndroidCameraRecordManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 6ad9a78de..86d12fffa 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -20,7 +20,8 @@ package org.linphone.core.video; import java.util.List; -import org.linphone.LinphoneManager; + +import org.linphone.core.LinphoneCore; import org.linphone.core.Log; import org.linphone.core.Version; import org.linphone.core.video.AndroidCameraRecord.RecorderParams; @@ -339,8 +340,8 @@ public class AndroidCameraRecordManager { /** * @return true if linphone core configured to send a A buffer while phone orientation induces !A buffer (A=landscape or portrait) */ - public boolean isOutputOrientationMismatch() { - final boolean currentlyPortrait = LinphoneManager.getLc().getPreferredVideoSize().isPortrait(); + public boolean isOutputOrientationMismatch(LinphoneCore lc) { + final boolean currentlyPortrait = lc.getPreferredVideoSize().isPortrait(); final boolean shouldBePortrait = isOutputPortraitDependingOnCameraAndPhoneOrientations(); return currentlyPortrait ^ shouldBePortrait; } From 748ad2f38529f74468daa217e4b8fbf80d777401 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 1 Aug 2011 10:09:11 +0200 Subject: [PATCH 127/288] ZRTP on old arm devices. --- LinphoneCoreFactoryImpl.java | 2 ++ Version.java | 7 +++++++ video/AndroidCameraConf5.java | 2 -- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index f92dd6c86..674b62450 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -63,6 +63,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library System.loadLibrary("linphone"); + + Version.dumpCapabilities(); } @Override public LinphoneAuthInfo createAuthInfo(String username, String password, diff --git a/Version.java b/Version.java index 14dff0c27..53ae2e05f 100644 --- a/Version.java +++ b/Version.java @@ -73,4 +73,11 @@ public class Version { public static boolean hasZrtp(){ return nativeHasZrtp(); } + + public static void dumpCapabilities(){ + StringBuilder sb = new StringBuilder(" ==== Capabilities dump ====\n"); + sb.append("Has neon: ").append(Boolean.toString(hasNeon())).append("\n"); + sb.append("Has ZRTP: ").append(Boolean.toString(hasZrtp())).append("\n"); + Log.i(sb.toString()); + } } diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index f8dbe56cb..c9c3a1ade 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -27,8 +27,6 @@ class AndroidCameraConf5 implements AndroidCameraConf { public AndroidCameras getFoundCameras() {return foundCameras;} public AndroidCameraConf5() { - Log.i("Detecting cameras"); - // Defaults foundCameras = new AndroidCameras(); From 8b09455f817acd6c02f0b01fb602fc1d76d0bb06 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 4 Aug 2011 10:04:31 +0200 Subject: [PATCH 128/288] Fix Android logs from java. Some levels where hidden due to the use of isLoggable. --- Log.java | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/Log.java b/Log.java index c341fa68e..b70b65931 100644 --- a/Log.java +++ b/Log.java @@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; - +import static android.util.Log.DEBUG; +import static android.util.Log.ERROR; +import static android.util.Log.INFO; +import static android.util.Log.WARN; /** * Convenient wrapper for Android logs. @@ -28,48 +31,54 @@ package org.linphone.core; public final class Log { public static final String TAG = "Linphone"; - + private static final boolean useIsLoggable = false; + + @SuppressWarnings(value="all") + private static boolean isLoggable(int level) { + return !useIsLoggable || android.util.Log.isLoggable(TAG, level); + } + public static void i(Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) { + if (isLoggable(INFO)) { android.util.Log.i(TAG, toString(objects)); } } public static void i(Throwable t, Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) { + if (isLoggable(INFO)) { android.util.Log.i(TAG, toString(objects), t); } } public static void d(Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) { + if (isLoggable(DEBUG)) { android.util.Log.d(TAG, toString(objects)); } } public static void d(Throwable t, Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) { + if (isLoggable(DEBUG)) { android.util.Log.d(TAG, toString(objects), t); } } public static void w(Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) { + if (isLoggable(WARN)) { android.util.Log.w(TAG, toString(objects)); } } public static void w(Throwable t, Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) { + if (isLoggable(WARN)) { android.util.Log.w(TAG, toString(objects), t); } } public static void e(Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + if (isLoggable(ERROR)) { android.util.Log.e(TAG, toString(objects)); } } public static void e(Throwable t, Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + if (isLoggable(ERROR)) { android.util.Log.e(TAG, toString(objects), t); } } @@ -78,7 +87,7 @@ public final class Log { * @throws RuntimeException always throw after logging the error message. */ public static void f(Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + if (isLoggable(ERROR)) { android.util.Log.e(TAG, toString(objects)); throw new RuntimeException("Fatal error : " + toString(objects)); } @@ -87,7 +96,7 @@ public final class Log { * @throws RuntimeException always throw after logging the error message. */ public static void f(Throwable t, Object...objects) { - if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) { + if (isLoggable(ERROR)) { android.util.Log.e(TAG, toString(objects), t); throw new RuntimeException("Fatal error : " + toString(objects), t); } From c635198a64da7563e3f5782383d61c56d5db0ec0 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 4 Aug 2011 11:26:19 +0200 Subject: [PATCH 129/288] Fix video on Nexus S. --- video/AndroidCameraConf.java | 6 +++ video/AndroidCameraConf5.java | 17 ++++++++ video/AndroidCameraConf9.java | 20 +++++++++ video/AndroidCameraRecord.java | 37 +++++++++++++--- video/AndroidCameraRecord5.java | 1 + video/AndroidCameraRecordManager.java | 62 +++++++++++++-------------- video/VideoUtil.java | 42 ++++++++++++++++++ 7 files changed, 147 insertions(+), 38 deletions(-) create mode 100644 video/VideoUtil.java diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java index 9796ba12b..874a6d2da 100644 --- a/video/AndroidCameraConf.java +++ b/video/AndroidCameraConf.java @@ -18,6 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.List; + +import org.linphone.core.VideoSize; + /** * @author Guillaume Beraudo @@ -33,6 +37,8 @@ interface AndroidCameraConf { boolean isFrontCamera(int cameraId); + List getSupportedPreviewSizes(int cameraId); + /** * Default: no front; rear=0; default=rear * @author Guillaume Beraudo diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java index c9c3a1ade..06c266d7a 100644 --- a/video/AndroidCameraConf5.java +++ b/video/AndroidCameraConf5.java @@ -18,8 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.List; + import org.linphone.core.Hacks; import org.linphone.core.Log; +import org.linphone.core.VideoSize; + +import android.hardware.Camera; class AndroidCameraConf5 implements AndroidCameraConf { @@ -90,6 +95,18 @@ class AndroidCameraConf5 implements AndroidCameraConf { return false; } + + public List getSupportedPreviewSizes(int cameraId) { + if (getNumberOfCameras() >1) { + Log.w("Hack: on older devices, using video formats supported by default camera"); + } + Log.i("Opening camera to retrieve supported video sizes"); + Camera c = Camera.open(); + List sizes=VideoUtil.createList(c.getParameters().getSupportedPreviewSizes()); + c.release(); + Log.i("Camera opened to retrieve supported video sizes released"); + return sizes; + } diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java index d0ef0faa5..02e909895 100644 --- a/video/AndroidCameraConf9.java +++ b/video/AndroidCameraConf9.java @@ -18,12 +18,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.linphone.core.Log; +import org.linphone.core.VideoSize; import android.hardware.Camera; class AndroidCameraConf9 implements AndroidCameraConf { private AndroidCameras foundCameras; + private Map> supportedSizes = new HashMap>(); public AndroidCameras getFoundCameras() {return foundCameras;} public AndroidCameraConf9() { @@ -38,9 +44,19 @@ class AndroidCameraConf9 implements AndroidCameraConf { } else { foundCameras.rear = id; } + supportedSizes.put(id, findSupportedVideoSizes(id)); } } + private List findSupportedVideoSizes(int id) { + Log.i("Opening camera ",id," to retrieve supported video sizes"); + Camera c = Camera.open(id); + List sizes=VideoUtil.createList(c.getParameters().getSupportedPreviewSizes()); + c.release(); + Log.i("Camera ",id," opened to retrieve supported video sizes released"); + return sizes; + } + public int getNumberOfCameras() { return Camera.getNumberOfCameras(); } @@ -58,4 +74,8 @@ class AndroidCameraConf9 implements AndroidCameraConf { return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; } + public List getSupportedPreviewSizes(int cameraId) { + return supportedSizes.get(cameraId); + } + } diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index dec9338b2..bb9fd9786 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core.video; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.linphone.core.Log; import org.linphone.core.Version; +import org.linphone.core.VideoSize; import android.hardware.Camera; import android.hardware.Camera.AutoFocusCallback; @@ -44,7 +44,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { private PreviewCallback storedPreviewCallback; private boolean previewStarted; - private List supportedVideoSizes; + private List supportedVideoSizes; private Size currentPreviewSize; public AndroidCameraRecord(RecorderParams parameters) { @@ -55,6 +55,23 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { return Collections.emptyList(); } + private int[] findClosestFpsRange(int expectedFps, List fpsRanges) { + Log.d("Searching for closest fps range from ",expectedFps); + int measure = Integer.MAX_VALUE; + int[] closestRange = {expectedFps,expectedFps}; + for (int[] curRange : fpsRanges) { + if (curRange[0] > expectedFps || curRange[1] < expectedFps) continue; + int curMeasure = Math.abs(curRange[0] - expectedFps) + + Math.abs(curRange[1] - expectedFps); + if (curMeasure < measure) { + closestRange=curRange; + Log.d("a better range has been found: w=",closestRange[0],",h=",closestRange[1]); + } + } + Log.d("The closest fps range is w=",closestRange[0],",h=",closestRange[1]); + return closestRange; + } + public synchronized void startPreview() { // FIXME throws exception? if (previewStarted) { Log.w("Already started"); @@ -83,12 +100,12 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { Camera.Parameters parameters=camera.getParameters(); - if (Version.sdkStrictlyBelow(9)) { + if (Version.sdkStrictlyBelow(Version.API09_GINGERBREAD_23)) { parameters.set("camera-id",params.cameraId); } if (supportedVideoSizes == null) { - supportedVideoSizes = new ArrayList(getSupportedPreviewSizes(parameters)); + supportedVideoSizes = VideoUtil.createList(getSupportedPreviewSizes(parameters)); } @@ -101,7 +118,13 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { // should setParameters and get again to have the real one?? currentPreviewSize = parameters.getPreviewSize(); - parameters.setPreviewFrameRate(Math.round(params.fps)); + // Frame rate + if (Version.sdkStrictlyBelow(Version.API09_GINGERBREAD_23)) { + parameters.setPreviewFrameRate(Math.round(params.fps)); + } else { + int[] range=findClosestFpsRange((int)(1000*params.fps), parameters.getSupportedPreviewFpsRange()); + parameters.setPreviewFpsRange(range[0], range[1]); + } onSettingCameraParameters(parameters); @@ -223,8 +246,8 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { return previewStarted; } - public List getSupportedVideoSizes() { - return new ArrayList(supportedVideoSizes); + public List getSupportedVideoSizes() { + return supportedVideoSizes; } diff --git a/video/AndroidCameraRecord5.java b/video/AndroidCameraRecord5.java index 03f9123db..45f94cd29 100644 --- a/video/AndroidCameraRecord5.java +++ b/video/AndroidCameraRecord5.java @@ -135,4 +135,5 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac camera.setPreviewCallback(cb); } + } diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 86d12fffa..22f437d21 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -20,14 +20,13 @@ package org.linphone.core.video; import java.util.List; - import org.linphone.core.LinphoneCore; import org.linphone.core.Log; import org.linphone.core.Version; +import org.linphone.core.VideoSize; import org.linphone.core.video.AndroidCameraRecord.RecorderParams; import android.content.Context; -import android.hardware.Camera.Size; import android.view.OrientationEventListener; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -63,7 +62,6 @@ public class AndroidCameraRecordManager { private int cameraId; private AndroidCameraRecord recorder; - private List supportedVideoSizes; private int mAlwaysChangingPhoneOrientation=0; @@ -126,11 +124,14 @@ public class AndroidCameraRecordManager { p.cameraId = cameraId; p.isFrontCamera = isUseFrontCamera(); parameters = p; - + + // Mirror the sent frames in order to make them readable + // (otherwise it is mirrored and thus unreadable) if (p.isFrontCamera) { - if (!isCameraOrientationPortrait()) { - // Code for Nexus S: to be tested - p.mirror = RecorderParams.MirrorType.CENTRAL; + if (!isCameraMountedPortrait()) { + // Code for Nexus S + if (isFrameToBeShownPortrait()) + p.mirror = RecorderParams.MirrorType.CENTRAL; } else { // Code for Galaxy S like: camera mounted landscape when phone hold portrait p.mirror = RecorderParams.MirrorType.HORIZONTAL; @@ -236,20 +237,9 @@ public class AndroidCameraRecordManager { - /** - * FIXME select right camera - */ - public List supportedVideoSizes() { - if (supportedVideoSizes != null) { - return supportedVideoSizes; - } - - if (recorder != null) { - supportedVideoSizes = recorder.getSupportedVideoSizes(); - if (supportedVideoSizes != null) return supportedVideoSizes; - } - - return supportedVideoSizes; + public List supportedVideoSizes() { + Log.d("Using supportedVideoSizes of camera ",cameraId); + return cc.getSupportedPreviewSizes(cameraId); } @@ -267,20 +257,28 @@ public class AndroidCameraRecordManager { parameters = null; } - public boolean isOutputPortraitDependingOnCameraAndPhoneOrientations() { + /** Depends on currently selected camera, camera mounted portrait/landscape, current phone orientation */ + public boolean isFrameToBeShownPortrait() { final int rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); - final boolean isPortrait = (rotation % 180) == 90; - - Log.d("Camera sensor in ", isPortrait? "portrait":"landscape"," orientation."); + + boolean isPortrait; + if (isCameraMountedPortrait()) { + // Nexus S + isPortrait = (rotation % 180) == 0; + } else { + isPortrait = (rotation % 180) == 90; + } + + Log.d("The frame to be shown and sent to remote is ", isPortrait? "portrait":"landscape"," orientation."); return isPortrait; } - - - public boolean isCameraOrientationPortrait() { + + + public boolean isCameraMountedPortrait() { return (cc.getCameraOrientation(cameraId) % 180) == 0; } @@ -296,8 +294,10 @@ public class AndroidCameraRecordManager { final int phoneOrientation = mAlwaysChangingPhoneOrientation; final int cameraOrientation = cc.getCameraOrientation(cameraId); int frontCameraCorrection = 0; - if (cc.isFrontCamera(cameraId)) // TODO: check with other phones (Nexus S, ...) - frontCameraCorrection=180; // hack that "just works" on Galaxy S. + if (cc.isFrontCamera(cameraId)) { + frontCameraCorrection=180; // hack that "just works" on Galaxy S and Nexus S. + // See also magic with mirrors in setParametersFromFilter + } final int rotation = (cameraOrientation + phoneOrientation + frontCameraCorrection) % 360; Log.d("Capture video buffer of cameraId=",cameraId, " will need a rotation of ",rotation, @@ -342,7 +342,7 @@ public class AndroidCameraRecordManager { */ public boolean isOutputOrientationMismatch(LinphoneCore lc) { final boolean currentlyPortrait = lc.getPreferredVideoSize().isPortrait(); - final boolean shouldBePortrait = isOutputPortraitDependingOnCameraAndPhoneOrientations(); + final boolean shouldBePortrait = isFrameToBeShownPortrait(); return currentlyPortrait ^ shouldBePortrait; } diff --git a/video/VideoUtil.java b/video/VideoUtil.java new file mode 100644 index 000000000..065557b77 --- /dev/null +++ b/video/VideoUtil.java @@ -0,0 +1,42 @@ +/* +VideoUtil.java +Copyright (C) 2011 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.video; + +import java.util.ArrayList; +import java.util.List; + +import org.linphone.core.VideoSize; + +import android.hardware.Camera.Size; + +/** + * @author Guillaume Beraudo + */ +final class VideoUtil { + + private VideoUtil() {} + + public static List createList(List supportedVideoSizes) { + List converted = new ArrayList(supportedVideoSizes.size()); + for (Size s : supportedVideoSizes) { + converted.add(new VideoSize(s.width, s.height)); + } + return converted; + } +} From 6eb200df4a908a29646dcf9ee04e76a19da108b2 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 4 Aug 2011 16:13:16 +0200 Subject: [PATCH 130/288] Don't load Camera Manager on video uncapable devices. --- video/AndroidCameraRecordManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java index 22f437d21..7e8e8b613 100644 --- a/video/AndroidCameraRecordManager.java +++ b/video/AndroidCameraRecordManager.java @@ -67,6 +67,9 @@ public class AndroidCameraRecordManager { // singleton private AndroidCameraRecordManager() { + if (!Version.isVideoCapable()) { // imply sdk>=5 + throw new RuntimeException("AndroidCameraRecordManager: hardware is not video capable"); + } cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5(); Log.i("=== Detected " + cc.getFoundCameras()+ " ==="); cameraId = cc.getFoundCameras().defaultC; From 83390c8351c467e7e53538cceca1304ed2261f11 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 5 Aug 2011 16:15:24 +0200 Subject: [PATCH 131/288] Conventien method to sleep. --- Hacks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hacks.java b/Hacks.java index fd9342827..ceca9ee80 100644 --- a/Hacks.java +++ b/Hacks.java @@ -89,7 +89,7 @@ public final class Hacks { sleep(200); } - private static final void sleep(int time) { + public static final void sleep(int time) { try { Thread.sleep(time); } catch(InterruptedException ie){} From 2b19e7cf75e5df1777d5610f65076d38ddc883ec Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 12 Aug 2011 16:21:22 +0200 Subject: [PATCH 132/288] android: add opengl support for video display --- AndroidVideoWindowImpl.java | 98 +++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 14 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 254efb379..2fd27b424 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -1,8 +1,14 @@ package org.linphone.core; +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + +import org.linphone.OpenGLESDisplay; + import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Bitmap.Config; +import android.opengl.GLSurfaceView; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -10,15 +16,18 @@ import android.view.Surface.OutOfResourcesException; import android.view.SurfaceHolder.Callback; public class AndroidVideoWindowImpl { - private Bitmap mBitmap; + private boolean useGLrendering; + private Bitmap mBitmap; private SurfaceView mView; - private Surface mSurface; + private Surface mSurface; private VideoWindowListener mListener; + private Renderer renderer; public static interface VideoWindowListener{ void onSurfaceReady(AndroidVideoWindowImpl vw); void onSurfaceDestroyed(AndroidVideoWindowImpl vw); }; public AndroidVideoWindowImpl(SurfaceView view){ + useGLrendering = (view instanceof GLSurfaceView); mView=view; mBitmap=null; mSurface=null; @@ -27,9 +36,11 @@ public class AndroidVideoWindowImpl { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.i("Surface is being changed."); - synchronized(AndroidVideoWindowImpl.this){ - mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); - mSurface=holder.getSurface(); + if (!useGLrendering) { + synchronized(AndroidVideoWindowImpl.this){ + mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); + mSurface=holder.getSurface(); + } } if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); Log.w("Video display surface changed"); @@ -40,15 +51,23 @@ public class AndroidVideoWindowImpl { } public void surfaceDestroyed(SurfaceHolder holder) { - synchronized(AndroidVideoWindowImpl.this){ - mSurface=null; - mBitmap=null; + if (!useGLrendering) { + synchronized(AndroidVideoWindowImpl.this){ + mSurface=null; + mBitmap=null; + } } if (mListener!=null) mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); Log.d("Video display surface destroyed"); } }); + + if (useGLrendering) { + renderer = new Renderer(); + ((GLSurfaceView)mView).setRenderer(renderer); + ((GLSurfaceView)mView).setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); + } } static final int LANDSCAPE=0; static final int PORTRAIT=1; @@ -57,31 +76,82 @@ public class AndroidVideoWindowImpl { //Log.d("Orientation changed."); } public void setListener(VideoWindowListener l){ - mListener=l; + mListener=l; } public Surface getSurface(){ + if (useGLrendering) + Log.e("View class does not match Video display filter used (you must use a non-GL View)"); return mView.getHolder().getSurface(); } public Bitmap getBitmap(){ + if (useGLrendering) + Log.e("View class does not match Video display filter used (you must use a non-GL View)"); return mBitmap; } - //Called by the mediastreamer2 android display filter + + public void setOpenGLESDisplay(int ptr) { + if (!useGLrendering) + Log.e("View class does not match Video display filter used (you must use a GL View)"); + renderer.setOpenGLESDisplay(ptr); + } + + public void requestRender() { + ((GLSurfaceView)mView).requestRender(); + } + + //Called by the mediastreamer2 android display filter public synchronized void update(){ if (mSurface!=null){ try { - Canvas canvas=mSurface.lockCanvas(null); + Canvas canvas=mSurface.lockCanvas(null); canvas.drawBitmap(mBitmap, 0, 0, null); mSurface.unlockCanvasAndPost(canvas); - + } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (OutOfResourcesException e) { // TODO Auto-generated catch block e.printStackTrace(); - } - } + } + } } + + private static class Renderer implements GLSurfaceView.Renderer { + int ptr; + boolean initPending; + int width, height; + + public Renderer() { + ptr = 0; + initPending = false; + } + + public void setOpenGLESDisplay(int ptr) { + this.ptr = ptr; + } + + public void onDrawFrame(GL10 gl) { + if (ptr == 0) + return; + if (initPending) { + OpenGLESDisplay.init(ptr, width, height); + initPending = false; + } + OpenGLESDisplay.render(ptr); + } + + public void onSurfaceChanged(GL10 gl, int width, int height) { + /* delay init until ptr is set */ + this.width = width; + this.height = height; + initPending = true; + } + + public void onSurfaceCreated(GL10 gl, EGLConfig config) { + + } + } } From 524c8e4919638aabfe3db0ca5a243327e80de32b Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 12 Aug 2011 09:37:22 +0200 Subject: [PATCH 133/288] video: initialize fps range using first value given by the hardware --- video/AndroidCameraRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index bb9fd9786..fe787f317 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -58,7 +58,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { private int[] findClosestFpsRange(int expectedFps, List fpsRanges) { Log.d("Searching for closest fps range from ",expectedFps); int measure = Integer.MAX_VALUE; - int[] closestRange = {expectedFps,expectedFps}; + int[] closestRange = fpsRanges.get(0); for (int[] curRange : fpsRanges) { if (curRange[0] > expectedFps || curRange[1] < expectedFps) continue; int curMeasure = Math.abs(curRange[0] - expectedFps) From b60a44a59eb1b5deafcc91ca6a3880ebfa34b47b Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 16 Aug 2011 09:48:36 +0200 Subject: [PATCH 134/288] android: 'synchronized' native calls to liblinphone Avoids dead locks in exosip. --- LinphoneCoreImpl.java | 96 +++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f09c5f9ee..99a2e194a 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -216,17 +216,17 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setNetworkReachable(boolean isReachable) { setNetworkStateReachable(nativePtr,isReachable); } - public void setPlaybackGain(float gain) { + public synchronized void setPlaybackGain(float gain) { setPlaybackGain(nativePtr,gain); } - public float getPlaybackGain() { + public synchronized float getPlaybackGain() { return getPlaybackGain(nativePtr); } - public void muteMic(boolean isMuted) { + public synchronized void muteMic(boolean isMuted) { muteMic(nativePtr,isMuted); } - public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException { + public synchronized LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException { long lAddress = interpretUrl(nativePtr,destination); if (lAddress != 0) { return new LinphoneAddressImpl(lAddress,true); @@ -234,7 +234,7 @@ class LinphoneCoreImpl implements LinphoneCore { throw new LinphoneCoreException("Cannot interpret ["+destination+"]"); } } - public LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { + public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); if (lNativePtr!=0) { return new LinphoneCallImpl(lNativePtr); @@ -243,16 +243,16 @@ class LinphoneCoreImpl implements LinphoneCore { } } - public void sendDtmf(char number) { + public synchronized void sendDtmf(char number) { sendDtmf(nativePtr,number); } - public void clearCallLogs() { + public synchronized void clearCallLogs() { clearCallLogs(nativePtr); } - public boolean isMicMuted() { + public synchronized boolean isMicMuted() { return isMicMuted(nativePtr); } - public PayloadType findPayloadType(String mime, int clockRate) { + public synchronized PayloadType findPayloadType(String mime, int clockRate) { isValid(); long playLoadType = findPayloadType(nativePtr, mime, clockRate); if (playLoadType == 0) { @@ -261,7 +261,7 @@ class LinphoneCoreImpl implements LinphoneCore { return new PayloadTypeImpl(playLoadType); } } - public void enablePayloadType(PayloadType pt, boolean enable) + public synchronized void enablePayloadType(PayloadType pt, boolean enable) throws LinphoneCoreException { isValid(); if (enablePayloadType(nativePtr,((PayloadTypeImpl)pt).nativePtr,enable) != 0) { @@ -269,11 +269,11 @@ class LinphoneCoreImpl implements LinphoneCore { } } - public void enableEchoCancellation(boolean enable) { + public synchronized void enableEchoCancellation(boolean enable) { isValid(); enableEchoCancellation(nativePtr, enable); } - public boolean isEchoCancellationEnabled() { + public synchronized boolean isEchoCancellationEnabled() { isValid(); return isEchoCancellationEnabled(nativePtr); @@ -305,27 +305,27 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } - public void playDtmf(char number, int duration) { + public synchronized void playDtmf(char number, int duration) { playDtmf(nativePtr,number, duration); } - public void stopDtmf() { + public synchronized void stopDtmf() { stopDtmf(nativePtr); } - public void addFriend(LinphoneFriend lf) throws LinphoneCoreException { + public synchronized void addFriend(LinphoneFriend lf) throws LinphoneCoreException { addFriend(nativePtr,((LinphoneFriendImpl)lf).nativePtr); } - public void setPresenceInfo(int minute_away, String alternative_contact, + public synchronized void setPresenceInfo(int minute_away, String alternative_contact, OnlineStatus status) { setPresenceInfo(nativePtr,minute_away,alternative_contact,status.mValue); } - public LinphoneChatRoom createChatRoom(String to) { + public synchronized LinphoneChatRoom createChatRoom(String to) { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } - public void setPreviewWindow(Object w) { + public synchronized void setPreviewWindow(Object w) { if (mPreviewWindow!=null) mPreviewWindow.setListener(null); mPreviewWindow=new AndroidVideoWindowImpl((SurfaceView)w); @@ -339,7 +339,7 @@ class LinphoneCoreImpl implements LinphoneCore { } }); } - public void setVideoWindow(Object w) { + public synchronized void setVideoWindow(Object w) { if (mVideoWindow!=null) mVideoWindow.setListener(null); mVideoWindow=new AndroidVideoWindowImpl((SurfaceView) w); @@ -353,30 +353,30 @@ class LinphoneCoreImpl implements LinphoneCore { } }); } - public void enableVideo(boolean vcap_enabled, boolean display_enabled) { + public synchronized void enableVideo(boolean vcap_enabled, boolean display_enabled) { enableVideo(nativePtr,vcap_enabled, display_enabled); } - public boolean isVideoEnabled() { + public synchronized boolean isVideoEnabled() { return isVideoEnabled(nativePtr); } - public FirewallPolicy getFirewallPolicy() { + public synchronized FirewallPolicy getFirewallPolicy() { return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr)); } - public String getStunServer() { + public synchronized String getStunServer() { return getStunServer(nativePtr); } - public void setFirewallPolicy(FirewallPolicy pol) { + public synchronized void setFirewallPolicy(FirewallPolicy pol) { setFirewallPolicy(nativePtr,pol.value()); } - public void setStunServer(String stunServer) { + public synchronized void setStunServer(String stunServer) { setStunServer(nativePtr,stunServer); } - public LinphoneCallParams createDefaultCallParameters() { + public synchronized LinphoneCallParams createDefaultCallParameters() { return new LinphoneCallParamsImpl(createDefaultCallParams(nativePtr)); } - public LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException { + public synchronized LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException { long ptrDestination = ((LinphoneAddressImpl)to).nativePtr; long ptrParams =((LinphoneCallParamsImpl)params).nativePtr; @@ -388,25 +388,25 @@ class LinphoneCoreImpl implements LinphoneCore { } } - public int updateCall(LinphoneCall call, LinphoneCallParams params) { + public synchronized int updateCall(LinphoneCall call, LinphoneCallParams params) { long ptrCall = ((LinphoneCallImpl) call).nativePtr; long ptrParams = params!=null ? ((LinphoneCallParamsImpl)params).nativePtr : 0; return updateCall(nativePtr, ptrCall, ptrParams); } - public void setUploadBandwidth(int bw) { + public synchronized void setUploadBandwidth(int bw) { setUploadBandwidth(nativePtr, bw); } - public void setDownloadBandwidth(int bw) { + public synchronized void setDownloadBandwidth(int bw) { setDownloadBandwidth(nativePtr, bw); } - public void setPreferredVideoSize(VideoSize vSize) { + public synchronized void setPreferredVideoSize(VideoSize vSize) { setPreferredVideoSize(nativePtr, vSize.width, vSize.height); } - public VideoSize getPreferredVideoSize() { + public synchronized VideoSize getPreferredVideoSize() { int[] nativeSize = getPreferredVideoSize(nativePtr); VideoSize vSize = new VideoSize(); @@ -414,18 +414,18 @@ class LinphoneCoreImpl implements LinphoneCore { vSize.height = nativeSize[1]; return vSize; } - public void setRing(String path) { + public synchronized void setRing(String path) { setRing(nativePtr, path); } - public String getRing() { + public synchronized String getRing() { return getRing(nativePtr); } - public void setRootCA(String path) { + public synchronized void setRootCA(String path) { setRootCA(nativePtr, path); } - public PayloadType[] getVideoCodecs() { + public synchronized PayloadType[] getVideoCodecs() { long[] typesPtr = listVideoPayloadTypes(nativePtr); if (typesPtr == null) return null; @@ -437,7 +437,7 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } - public PayloadType[] getAudioCodecs() { + public synchronized PayloadType[] getAudioCodecs() { long[] typesPtr = listAudioPayloadTypes(nativePtr); if (typesPtr == null) return null; @@ -449,21 +449,21 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } - public boolean isNetworkReachable() { + public synchronized boolean isNetworkReachable() { throw new RuntimeException("Not implemented"); } - public void enableKeepAlive(boolean enable) { + public synchronized void enableKeepAlive(boolean enable) { enableKeepAlive(nativePtr,enable); } - public boolean isKeepAliveEnabled() { + public synchronized boolean isKeepAliveEnabled() { return isKeepAliveEnabled(nativePtr); } - public void startEchoCalibration(Object data) throws LinphoneCoreException { + public synchronized void startEchoCalibration(Object data) throws LinphoneCoreException { startEchoCalibration(nativePtr, data); } - public Transports getSignalingTransportPorts() { + public synchronized Transports getSignalingTransportPorts() { Transports transports = new Transports(); transports.udp = getSignalingTransportPort(nativePtr, 0); transports.tcp = getSignalingTransportPort(nativePtr, 1); @@ -472,14 +472,14 @@ class LinphoneCoreImpl implements LinphoneCore { // Code is the index in the structure return transports; } - public void setSignalingTransportPorts(Transports transports) { + public synchronized void setSignalingTransportPorts(Transports transports) { setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls); } - public void enableIpv6(boolean enable) { + public synchronized void enableIpv6(boolean enable) { enableIpv6(nativePtr,enable); } - public void adjustSoftwareVolume(int i) { + public synchronized void adjustSoftwareVolume(int i) { adjustSoftwareVolume(nativePtr, i); } @@ -492,15 +492,15 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized boolean pauseAllCalls() { return 0 == pauseAllCalls(nativePtr); } - public void setDownloadPtime(int ptime) { + public synchronized void setDownloadPtime(int ptime) { setDownloadPtime(nativePtr,ptime); } - public void setUploadPtime(int ptime) { + public synchronized void setUploadPtime(int ptime) { setUploadPtime(nativePtr,ptime); } - public void setZrtpSecretsCache(String file) { + public synchronized void setZrtpSecretsCache(String file) { setZrtpSecretsCache(nativePtr,file); } } From 878f0238f7b4137653b40f4fe12d42261bd7cd5f Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 18 Aug 2011 09:36:31 +0200 Subject: [PATCH 135/288] Fix use of unsupported video capture frame rate. --- video/AndroidCameraRecord.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java index fe787f317..9d4dd29fe 100644 --- a/video/AndroidCameraRecord.java +++ b/video/AndroidCameraRecord.java @@ -55,7 +55,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { return Collections.emptyList(); } - private int[] findClosestFpsRange(int expectedFps, List fpsRanges) { + private int[] findClosestEnclosingFpsRange(int expectedFps, List fpsRanges) { Log.d("Searching for closest fps range from ",expectedFps); int measure = Integer.MAX_VALUE; int[] closestRange = fpsRanges.get(0); @@ -120,9 +120,20 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback { // Frame rate if (Version.sdkStrictlyBelow(Version.API09_GINGERBREAD_23)) { - parameters.setPreviewFrameRate(Math.round(params.fps)); + // Select the supported fps just faster than the target rate + List supportedFrameRates=parameters.getSupportedPreviewFrameRates(); + if (supportedFrameRates != null && supportedFrameRates.size() > 0) { + Collections.sort(supportedFrameRates); + int selectedRate = -1; + for (Integer rate : supportedFrameRates) { + selectedRate=rate; + if (rate >= params.fps) break; + } + parameters.setPreviewFrameRate(selectedRate); + } } else { - int[] range=findClosestFpsRange((int)(1000*params.fps), parameters.getSupportedPreviewFpsRange()); + List supportedRanges = parameters.getSupportedPreviewFpsRange(); + int[] range=findClosestEnclosingFpsRange((int)(1000*params.fps), supportedRanges); parameters.setPreviewFpsRange(range[0], range[1]); } From 954beb9c3df3a616960cce1a38004f4022cb28bb Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 5 Sep 2011 16:40:47 +0200 Subject: [PATCH 136/288] echo cancellation improvemnents: - use echo limiter always on !armv7 - enable echo cancellation by default - toggle speaker mode on during video calls --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 99a2e194a..23a8d3914 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -103,6 +103,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setUploadPtime(long nativePtr, int ptime); private native void setDownloadPtime(long nativePtr, int ptime); private native void setZrtpSecretsCache(long nativePtr, String file); + private native void enableEchoLimiter(long nativePtr2, boolean val); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -503,4 +504,8 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setZrtpSecretsCache(String file) { setZrtpSecretsCache(nativePtr,file); } + public void enableEchoLimiter(boolean val) { + enableEchoLimiter(nativePtr,val); + } + } From b923fd19d6847b1617c359fb2cb354af04cfef7a Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 13 Sep 2011 11:21:31 +0200 Subject: [PATCH 137/288] android: fix video rendering bug when changing resolution during call --- AndroidVideoWindowImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java index 2fd27b424..4fc213f5f 100644 --- a/AndroidVideoWindowImpl.java +++ b/AndroidVideoWindowImpl.java @@ -120,15 +120,20 @@ public class AndroidVideoWindowImpl { private static class Renderer implements GLSurfaceView.Renderer { int ptr; boolean initPending; - int width, height; + int width=-1, height=-1; public Renderer() { - ptr = 0; + ptr = 0; initPending = false; } public void setOpenGLESDisplay(int ptr) { this.ptr = ptr; + // if dimension are set, we are recreating MS2 graph without + // recreating the surface => need to force init + if (width > 0 && height > 0) { + initPending = true; + } } public void onDrawFrame(GL10 gl) { From b0357a9dddad99ffd6ce5cedf1944133e06fa539 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 14 Sep 2011 17:41:17 +0200 Subject: [PATCH 138/288] New Mediastreamer Android Camera filter integration android: new mediastreamer integration android: new ms2 integration Video calls minor corrections --- AndroidVideoWindowImpl.java | 162 ------------ Hacks.java | 146 ----------- LinphoneCallImpl.java | 9 +- LinphoneCoreImpl.java | 49 ++-- Version.java | 2 + tutorials/JavaCameraRecordImpl.java | 87 ------- tutorials/TestVideoActivity.java | 194 -------------- video/AndroidCameraConf.java | 66 ----- video/AndroidCameraConf5.java | 113 -------- video/AndroidCameraConf9.java | 81 ------ video/AndroidCameraRecord.java | 279 -------------------- video/AndroidCameraRecord5.java | 139 ---------- video/AndroidCameraRecord8.java | 82 ------ video/AndroidCameraRecord9.java | 50 ---- video/AndroidCameraRecordManager.java | 362 -------------------------- 15 files changed, 31 insertions(+), 1790 deletions(-) delete mode 100644 AndroidVideoWindowImpl.java delete mode 100644 Hacks.java delete mode 100644 tutorials/JavaCameraRecordImpl.java delete mode 100644 tutorials/TestVideoActivity.java delete mode 100644 video/AndroidCameraConf.java delete mode 100644 video/AndroidCameraConf5.java delete mode 100644 video/AndroidCameraConf9.java delete mode 100644 video/AndroidCameraRecord.java delete mode 100644 video/AndroidCameraRecord5.java delete mode 100644 video/AndroidCameraRecord8.java delete mode 100644 video/AndroidCameraRecord9.java delete mode 100644 video/AndroidCameraRecordManager.java diff --git a/AndroidVideoWindowImpl.java b/AndroidVideoWindowImpl.java deleted file mode 100644 index 4fc213f5f..000000000 --- a/AndroidVideoWindowImpl.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.linphone.core; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import org.linphone.OpenGLESDisplay; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Bitmap.Config; -import android.opengl.GLSurfaceView; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.Surface.OutOfResourcesException; -import android.view.SurfaceHolder.Callback; - -public class AndroidVideoWindowImpl { - private boolean useGLrendering; - private Bitmap mBitmap; - private SurfaceView mView; - private Surface mSurface; - private VideoWindowListener mListener; - private Renderer renderer; - public static interface VideoWindowListener{ - void onSurfaceReady(AndroidVideoWindowImpl vw); - void onSurfaceDestroyed(AndroidVideoWindowImpl vw); - }; - public AndroidVideoWindowImpl(SurfaceView view){ - useGLrendering = (view instanceof GLSurfaceView); - mView=view; - mBitmap=null; - mSurface=null; - mListener=null; - view.getHolder().addCallback(new Callback(){ - public void surfaceChanged(SurfaceHolder holder, int format, - int width, int height) { - Log.i("Surface is being changed."); - if (!useGLrendering) { - synchronized(AndroidVideoWindowImpl.this){ - mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565); - mSurface=holder.getSurface(); - } - } - if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this); - Log.w("Video display surface changed"); - } - - public void surfaceCreated(SurfaceHolder holder) { - Log.w("Video display surface created"); - } - - public void surfaceDestroyed(SurfaceHolder holder) { - if (!useGLrendering) { - synchronized(AndroidVideoWindowImpl.this){ - mSurface=null; - mBitmap=null; - } - } - if (mListener!=null) - mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this); - Log.d("Video display surface destroyed"); - } - }); - - if (useGLrendering) { - renderer = new Renderer(); - ((GLSurfaceView)mView).setRenderer(renderer); - ((GLSurfaceView)mView).setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); - } - } - static final int LANDSCAPE=0; - static final int PORTRAIT=1; - public void requestOrientation(int orientation){ - //Surface.setOrientation(0, orientation==LANDSCAPE ? 1 : 0); - //Log.d("Orientation changed."); - } - public void setListener(VideoWindowListener l){ - mListener=l; - } - public Surface getSurface(){ - if (useGLrendering) - Log.e("View class does not match Video display filter used (you must use a non-GL View)"); - return mView.getHolder().getSurface(); - } - public Bitmap getBitmap(){ - if (useGLrendering) - Log.e("View class does not match Video display filter used (you must use a non-GL View)"); - return mBitmap; - } - - public void setOpenGLESDisplay(int ptr) { - if (!useGLrendering) - Log.e("View class does not match Video display filter used (you must use a GL View)"); - renderer.setOpenGLESDisplay(ptr); - } - - public void requestRender() { - ((GLSurfaceView)mView).requestRender(); - } - - //Called by the mediastreamer2 android display filter - public synchronized void update(){ - if (mSurface!=null){ - try { - Canvas canvas=mSurface.lockCanvas(null); - canvas.drawBitmap(mBitmap, 0, 0, null); - mSurface.unlockCanvasAndPost(canvas); - - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (OutOfResourcesException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - private static class Renderer implements GLSurfaceView.Renderer { - int ptr; - boolean initPending; - int width=-1, height=-1; - - public Renderer() { - ptr = 0; - initPending = false; - } - - public void setOpenGLESDisplay(int ptr) { - this.ptr = ptr; - // if dimension are set, we are recreating MS2 graph without - // recreating the surface => need to force init - if (width > 0 && height > 0) { - initPending = true; - } - } - - public void onDrawFrame(GL10 gl) { - if (ptr == 0) - return; - if (initPending) { - OpenGLESDisplay.init(ptr, width, height); - initPending = false; - } - OpenGLESDisplay.render(ptr); - } - - public void onSurfaceChanged(GL10 gl, int width, int height) { - /* delay init until ptr is set */ - this.width = width; - this.height = height; - initPending = true; - } - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - - } - } -} - - diff --git a/Hacks.java b/Hacks.java deleted file mode 100644 index ceca9ee80..000000000 --- a/Hacks.java +++ /dev/null @@ -1,146 +0,0 @@ -/* -Hacks.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; - -import android.hardware.Camera; -import android.media.AudioManager; -import android.os.Build; - -public final class Hacks { - - private Hacks() {} - - - public static boolean isGalaxySOrTabWithFrontCamera() { - return isGalaxySOrTab() && !isGalaxySOrTabWithoutFrontCamera(); - } - private static boolean isGalaxySOrTabWithoutFrontCamera() { - return isSC02B() || isSGHI896(); - } - - - public static boolean isGalaxySOrTab() { - return isGalaxyS() || isGalaxyTab(); - } - - public static boolean isGalaxyTab() { - return isGTP1000(); - } - private static boolean isGalaxyS() { - return isGT9000() || isSC02B() || isSGHI896() || isSPHD700(); - } - - public static final boolean hasTwoCamerasRear0Front1() { - return isSPHD700() || isADR6400(); - } - - // HTC - private static final boolean isADR6400() { - return Build.MODEL.startsWith("ADR6400") || Build.DEVICE.startsWith("ADR6400"); - } // HTC Thunderbolt - - // Galaxy S variants - private static final boolean isSPHD700() {return Build.DEVICE.startsWith("SPH-D700");} // Epic - private static boolean isSGHI896() {return Build.DEVICE.startsWith("SGH-I896");} // Captivate - private static boolean isGT9000() {return Build.DEVICE.startsWith("GT-I9000");} // Galaxy S - private static boolean isSC02B() {return Build.DEVICE.startsWith("SC-02B");} // Docomo - private static boolean isGTP1000() {return Build.DEVICE.startsWith("GT-P1000");} // Tab - - -/* private static final boolean log(final String msg) { - Log.d(msg); - return true; - }*/ - - /* Not working as now - * Calling from Galaxy S to PC is "usable" even with no hack; other side is not even with this one*/ - public static void galaxySSwitchToCallStreamUnMuteLowerVolume(AudioManager am) { - // Switch to call audio channel (Galaxy S) - am.setSpeakerphoneOn(false); - sleep(200); - - // Lower volume - am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 1, 0); - - // Another way to select call channel - am.setMode(AudioManager.MODE_NORMAL); - sleep(200); - - // Mic is muted if not doing this - am.setMicrophoneMute(true); - sleep(200); - am.setMicrophoneMute(false); - sleep(200); - } - - public static final void sleep(int time) { - try { - Thread.sleep(time); - } catch(InterruptedException ie){} - } - - public static void dumpDeviceInformation() { - StringBuilder sb = new StringBuilder(" ==== Phone information dump ====\n"); - sb.append("DEVICE=").append(Build.DEVICE).append("\n"); - sb.append("MODEL=").append(Build.MODEL).append("\n"); - //MANUFACTURER doesn't exist in android 1.5. - //sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n"); - sb.append("SDK=").append(Build.VERSION.SDK); - - Log.i(sb.toString()); - } - - public static boolean needSoftvolume() { - return isGalaxySOrTab(); - } - - public static boolean needRoutingAPI() { - return Version.sdkStrictlyBelow(5) /* 0; - } - - Log.i("Hack: considering there IS a camera.\n" - + "If it is not the case, report DEVICE and MODEL to linphone-users@nongnu.org"); - return true; - } - -} diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 55d3baedf..b027e2170 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -20,7 +20,7 @@ package org.linphone.core; class LinphoneCallImpl implements LinphoneCall { - + protected final long nativePtr; boolean ownPtr = false; native private void ref(long ownPtr); @@ -31,6 +31,7 @@ class LinphoneCallImpl implements LinphoneCall { native private int getState(long nativePtr); private native long getCurrentParamsCopy(long nativePtr); private native void enableCamera(long nativePtr, boolean enabled); + private native boolean cameraEnabled(long nativePtr); private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr) ; private native void enableEchoLimiter(long nativePtr,boolean enable); @@ -48,7 +49,7 @@ class LinphoneCallImpl implements LinphoneCall { ref(nativePtr); } protected void finalize() throws Throwable { - unref(nativePtr); + unref(nativePtr); } public LinphoneCallLog getCallLog() { long lNativePtr = getCallLog(nativePtr); @@ -79,6 +80,10 @@ class LinphoneCallImpl implements LinphoneCall { public void enableCamera(boolean enabled) { enableCamera(nativePtr, enabled); } + @Override + public boolean cameraEnabled() { + return cameraEnabled(nativePtr); + } public boolean equals(Object call) { return nativePtr == ((LinphoneCallImpl)call).nativePtr; } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 23a8d3914..d4b54b663 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -22,7 +22,8 @@ import java.io.File; import java.io.IOException; import java.util.Vector; -import android.view.SurfaceView; +import org.linphone.LinphoneManager; +import org.linphone.mediastream.video.AndroidVideoWindowImpl; class LinphoneCoreImpl implements LinphoneCore { @@ -68,8 +69,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void stopDtmf(long nativePtr); private native void setVideoWindowId(long nativePtr, Object wid); private native void setPreviewWindowId(long nativePtr, Object wid); - private AndroidVideoWindowImpl mVideoWindow; - private AndroidVideoWindowImpl mPreviewWindow; + private native void setDeviceRotation(long nativePtr, int rotation); private native void addFriend(long nativePtr,long friend); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); private native long createChatRoom(long nativePtr,String to); @@ -104,6 +104,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setDownloadPtime(long nativePtr, int ptime); private native void setZrtpSecretsCache(long nativePtr, String file); private native void enableEchoLimiter(long nativePtr2, boolean val); + private native int setVideoDevice(long nativePtr2, int id); + private native int getVideoDevice(long nativePtr2); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -327,33 +329,15 @@ class LinphoneCoreImpl implements LinphoneCore { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } public synchronized void setPreviewWindow(Object w) { - if (mPreviewWindow!=null) - mPreviewWindow.setListener(null); - mPreviewWindow=new AndroidVideoWindowImpl((SurfaceView)w); - mPreviewWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ - public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { - setPreviewWindowId(nativePtr,null); - } - - public void onSurfaceReady(AndroidVideoWindowImpl vw) { - setPreviewWindowId(nativePtr,vw); - } - }); + setPreviewWindowId(nativePtr,w); } public synchronized void setVideoWindow(Object w) { - if (mVideoWindow!=null) - mVideoWindow.setListener(null); - mVideoWindow=new AndroidVideoWindowImpl((SurfaceView) w); - mVideoWindow.setListener(new AndroidVideoWindowImpl.VideoWindowListener(){ - public void onSurfaceDestroyed(AndroidVideoWindowImpl vw) { - setVideoWindowId(nativePtr,null); - } - - public void onSurfaceReady(AndroidVideoWindowImpl vw) { - setVideoWindowId(nativePtr,vw); - } - }); + setVideoWindowId(nativePtr, w); } + public synchronized void setDeviceRotation(int rotation) { + setDeviceRotation(nativePtr, rotation); + } + public synchronized void enableVideo(boolean vcap_enabled, boolean display_enabled) { enableVideo(nativePtr,vcap_enabled, display_enabled); } @@ -507,5 +491,16 @@ class LinphoneCoreImpl implements LinphoneCore { public void enableEchoLimiter(boolean val) { enableEchoLimiter(nativePtr,val); } + @Override + public void setVideoDevice(int id) { + Log.i("Setting camera id :", id); + if (setVideoDevice(nativePtr, id) != 0) { + Log.e("Failed to set video device to id:", id); + } + } + @Override + public int getVideoDevice() { + return getVideoDevice(nativePtr); + } } diff --git a/Version.java b/Version.java index 53ae2e05f..edbb25e8e 100644 --- a/Version.java +++ b/Version.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.mediastream.video.capture.hwconf.Hacks; + import android.os.Build; /** diff --git a/tutorials/JavaCameraRecordImpl.java b/tutorials/JavaCameraRecordImpl.java deleted file mode 100644 index 4772c7a5b..000000000 --- a/tutorials/JavaCameraRecordImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/* -JavaCameraRecordImpl.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.tutorials; - -import org.linphone.core.Log; -import org.linphone.core.video.AndroidCameraRecord; - -import android.hardware.Camera; -import android.hardware.Camera.PreviewCallback; -import android.hardware.Camera.Size; -import android.widget.TextView; - -/** - * This is an helper class, not a test activity. - * - * @author Guillaume Beraudo - * - */ -class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallback { - - private TextView debug; - private long count = 0; - private float averageCalledRate; - - private long startTime; - private long endTime; - private int fps; - - - public JavaCameraRecordImpl(AndroidCameraRecord.RecorderParams parameters) { - super(parameters); - storePreviewCallBack(this); - fps = Math.round(parameters.fps); - } - - - public void setDebug(TextView debug) { - this.debug = debug; - } - - public void onPreviewFrame(byte[] data, Camera camera) { - - Size s = camera.getParameters().getPreviewSize(); - int expectedBuffLength = s.width * s.height * 3 /2; - if (expectedBuffLength != data.length) { - Log.e("onPreviewFrame called with bad buffer length ", data.length, - " whereas expected is ", expectedBuffLength, " don't calling putImage"); - return; - } - - if ((count % 2 * fps) == 0) { - endTime = System.currentTimeMillis(); - averageCalledRate = (100000 * 2 * fps) / (endTime - startTime); - averageCalledRate /= 100f; - startTime = endTime; - } - - count++; - - String msg = "Frame " + count + ": " + data.length + "bytes (avg="+averageCalledRate+"frames/s)"; - if (debug != null) debug.setText(msg); - Log.d("onPreviewFrame:", msg); - } - - - @Override - protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { - camera.setPreviewCallback(cb); - } - -} diff --git a/tutorials/TestVideoActivity.java b/tutorials/TestVideoActivity.java deleted file mode 100644 index 7523cb0ff..000000000 --- a/tutorials/TestVideoActivity.java +++ /dev/null @@ -1,194 +0,0 @@ -/* -TutorialHelloWorldActivity.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.tutorials; - -import static org.linphone.core.VideoSize.CIF; -import static org.linphone.core.VideoSize.HVGA; -import static org.linphone.core.VideoSize.QCIF; -import static org.linphone.core.VideoSize.QVGA; - -import java.util.Stack; - -import org.linphone.R; -import org.linphone.core.Log; -import org.linphone.core.VideoSize; -import org.linphone.core.video.AndroidCameraRecord; - -import android.app.Activity; -import android.os.Bundle; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import android.view.SurfaceHolder.Callback; -import android.view.View.OnClickListener; -import android.view.ViewGroup.LayoutParams; -import android.widget.Button; -import android.widget.TextView; - -/** - * Activity for displaying and starting the HelloWorld example on Android phone. - * - * @author Guillaume Beraudo - * - */ -public class TestVideoActivity extends Activity implements Callback, OnClickListener { - - private SurfaceView surfaceView; - private static final int rate = 7; - private JavaCameraRecordImpl recorder; - private TextView debugView; - private Button nextSize; - private Button changeCamera; - private Button changeOrientation; - private AndroidCameraRecord.RecorderParams params; - - private Stack videoSizes = createSizesToTest(); - private int currentCameraId = 2; - private boolean currentOrientationIsPortrait = false; - private int width; - private int height; - private boolean started; - - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.videotest); - - surfaceView=(SurfaceView)findViewById(R.id.videotest_surfaceView); - - nextSize = (Button) findViewById(R.id.test_video_size); - nextSize.setOnClickListener(this); - - changeCamera = (Button) findViewById(R.id.test_video_camera); - changeCamera.setText("Cam"+otherCameraId(currentCameraId)); - changeCamera.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - changeCamera.setText("Cam"+currentCameraId); - currentCameraId = otherCameraId(currentCameraId); - updateRecording(); - } - }); - - changeOrientation = (Button) findViewById(R.id.test_video_orientation); - changeOrientation.setText(orientationToString(!currentOrientationIsPortrait)); - changeOrientation.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - currentOrientationIsPortrait = !currentOrientationIsPortrait; - changeOrientation.setText(orientationToString(!currentOrientationIsPortrait)); - - if (width == 0 || height == 0) return; - int newWidth = currentOrientationIsPortrait? Math.min(height, width) : Math.max(height, width); - int newHeight = currentOrientationIsPortrait? Math.max(height, width) : Math.min(height, width); - changeSurfaceViewLayout(newWidth, newHeight); // will change width and height on surfaceChanged - } - }); - - SurfaceHolder holder = surfaceView.getHolder(); - holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - holder.addCallback(this); - - - debugView = (TextView) findViewById(R.id.videotest_debug); - } - - protected void updateRecording() { - if (width == 0 || height == 0) return; - if (recorder != null) recorder.stopPreview(); - - params = new AndroidCameraRecord.RecorderParams(0); - params.surfaceView = surfaceView; - params.width = width; - params.height = height; - params.fps = rate; - params.cameraId = currentCameraId; - - recorder = new JavaCameraRecordImpl(params); -// recorder.setDebug(debugView); - debugView.setText(orientationToString(currentOrientationIsPortrait) - + " w="+width + " h="+height+ " cam"+currentCameraId); - recorder.startPreview(); - - } - - private String orientationToString(boolean orientationIsPortrait) { - return orientationIsPortrait? "Por" : "Lan"; - } - private int otherCameraId(int currentId) { - return (currentId == 2) ? 1 : 2; - } - public void onClick(View v) { - nextSize.setText("Next"); - started=true; - if (videoSizes.isEmpty()) { - videoSizes = createSizesToTest(); - } - - VideoSize size = videoSizes.pop(); - changeSurfaceViewLayout(size.width, size.height); - - // on surface changed the recorder will be restarted with new values - // and the surface will be resized - } - - - private void changeSurfaceViewLayout(int width, int height) { - LayoutParams params = surfaceView.getLayoutParams(); - params.height = height; - params.width = width; - surfaceView.setLayoutParams(params); - - } - - private Stack createSizesToTest() { - Stack stack = new Stack(); - - stack.push(VideoSize.createStandard(QCIF, false)); - stack.push(VideoSize.createStandard(CIF, false)); - stack.push(VideoSize.createStandard(QVGA, false)); - stack.push(VideoSize.createStandard(HVGA, false)); - stack.push(new VideoSize(640,480)); - stack.push(new VideoSize(800,480)); - return stack; - } - - - - - public void surfaceDestroyed(SurfaceHolder holder) { - surfaceView = null; - Log.d("Video capture surface destroyed"); - if (recorder != null) recorder.stopPreview(); - } - - public void surfaceCreated(SurfaceHolder holder) { - Log.d("Video capture surface created"); - } - - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - if (!started) return; - if (recorder != null) recorder.stopPreview(); - - this.width = width; - this.height = height; - - updateRecording(); - } -} diff --git a/video/AndroidCameraConf.java b/video/AndroidCameraConf.java deleted file mode 100644 index 874a6d2da..000000000 --- a/video/AndroidCameraConf.java +++ /dev/null @@ -1,66 +0,0 @@ -/* -AndroidCameraConf.java -Copyright (C) 2011 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.video; - -import java.util.List; - -import org.linphone.core.VideoSize; - - -/** - * @author Guillaume Beraudo - * - */ -interface AndroidCameraConf { - - AndroidCameras getFoundCameras(); - - int getNumberOfCameras(); - - int getCameraOrientation(int cameraId); - - boolean isFrontCamera(int cameraId); - - List getSupportedPreviewSizes(int cameraId); - - /** - * Default: no front; rear=0; default=rear - * @author Guillaume Beraudo - * - */ - class AndroidCameras { - Integer front; - Integer rear = 0; - Integer defaultC = rear; - - boolean hasFrontCamera() { return front != null; } - boolean hasRearCamera() { return rear != null; } - boolean hasSeveralCameras() { return front != rear && front != null; } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Cameras :"); - if (rear != null) sb.append(" rear=").append(rear); - if (front != null) sb.append(" front=").append(front); - if (defaultC != null) sb.append(" default=").append(defaultC); - return sb.toString(); - } - } -} \ No newline at end of file diff --git a/video/AndroidCameraConf5.java b/video/AndroidCameraConf5.java deleted file mode 100644 index 06c266d7a..000000000 --- a/video/AndroidCameraConf5.java +++ /dev/null @@ -1,113 +0,0 @@ -/* -AndroidCameraConf.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.video; - -import java.util.List; - -import org.linphone.core.Hacks; -import org.linphone.core.Log; -import org.linphone.core.VideoSize; - -import android.hardware.Camera; - - -class AndroidCameraConf5 implements AndroidCameraConf { - private AndroidCameras foundCameras; - public AndroidCameras getFoundCameras() {return foundCameras;} - - public AndroidCameraConf5() { - // Defaults - foundCameras = new AndroidCameras(); - - if (Hacks.isGalaxySOrTab()) { - Log.d("Hack Galaxy S : has one or more cameras"); - if (Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d("Hack Galaxy S : HAS a front camera with id=2"); - foundCameras.front = 2; - } else { - Log.d("Hack Galaxy S : NO front camera"); - } - Log.d("Hack Galaxy S : HAS a rear camera with id=1"); - foundCameras.rear = 1; - foundCameras.defaultC = foundCameras.rear; - } else if (Hacks.hasTwoCamerasRear0Front1()) { - Log.d("Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1"); - foundCameras.front = 1; - } - - } - - public int getNumberOfCameras() { - Log.i("Detecting the number of cameras"); - if (Hacks.hasTwoCamerasRear0Front1() || Hacks.isGalaxySOrTabWithFrontCamera()) { - Log.d("Hack: we know this model has 2 cameras"); - return 2; - } else - return 1; - } - - - - public int getCameraOrientation(int cameraId) { - // Use hacks to guess orientation of the camera - if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) { - Log.d("Hack Galaxy S : front camera mounted landscape"); - // mounted in landscape for a portrait phone orientation - // |^^^^^^^^| - // | ____ | - // | |____| | - // | | - // | | - // | Phone | - // |________| - return 180; - } - return 90; - } - - - - public boolean isFrontCamera(int cameraId) { - // Use hacks to guess facing of the camera - if (cameraId == 2 && Hacks.isGalaxySOrTab()) { - Log.d("Hack Galaxy S : front camera has id=2"); - return true; - } else if (cameraId == 1 && Hacks.hasTwoCamerasRear0Front1()) { - Log.d("Hack SPHD700 : front camera has id=1"); - return true; - } - - return false; - } - - public List getSupportedPreviewSizes(int cameraId) { - if (getNumberOfCameras() >1) { - Log.w("Hack: on older devices, using video formats supported by default camera"); - } - Log.i("Opening camera to retrieve supported video sizes"); - Camera c = Camera.open(); - List sizes=VideoUtil.createList(c.getParameters().getSupportedPreviewSizes()); - c.release(); - Log.i("Camera opened to retrieve supported video sizes released"); - return sizes; - } - - - -} diff --git a/video/AndroidCameraConf9.java b/video/AndroidCameraConf9.java deleted file mode 100644 index 02e909895..000000000 --- a/video/AndroidCameraConf9.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -AndroidCameraConf9.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.video; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.linphone.core.Log; -import org.linphone.core.VideoSize; - -import android.hardware.Camera; - -class AndroidCameraConf9 implements AndroidCameraConf { - private AndroidCameras foundCameras; - private Map> supportedSizes = new HashMap>(); - public AndroidCameras getFoundCameras() {return foundCameras;} - - public AndroidCameraConf9() { - foundCameras = new AndroidCameras(); - - for (int id=0; id < getNumberOfCameras(); id++) { - if (foundCameras.defaultC == null) - foundCameras.defaultC = id; - - if (isFrontCamera(id)) { - foundCameras.front = id; - } else { - foundCameras.rear = id; - } - supportedSizes.put(id, findSupportedVideoSizes(id)); - } - } - - private List findSupportedVideoSizes(int id) { - Log.i("Opening camera ",id," to retrieve supported video sizes"); - Camera c = Camera.open(id); - List sizes=VideoUtil.createList(c.getParameters().getSupportedPreviewSizes()); - c.release(); - Log.i("Camera ",id," opened to retrieve supported video sizes released"); - return sizes; - } - - public int getNumberOfCameras() { - return Camera.getNumberOfCameras(); - } - - public int getCameraOrientation(int cameraId) { - android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); - Camera.getCameraInfo(cameraId, info); - Log.d("Camera info for ",cameraId,": orientation=",info.orientation); - return info.orientation; - } - - public boolean isFrontCamera(int cameraId) { - android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); - Camera.getCameraInfo(cameraId, info); - return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? true : false; - } - - public List getSupportedPreviewSizes(int cameraId) { - return supportedSizes.get(cameraId); - } - -} diff --git a/video/AndroidCameraRecord.java b/video/AndroidCameraRecord.java deleted file mode 100644 index 9d4dd29fe..000000000 --- a/video/AndroidCameraRecord.java +++ /dev/null @@ -1,279 +0,0 @@ -/* -AndroidCameraRecordImpl.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.video; - -import java.util.Collections; -import java.util.List; - -import org.linphone.core.Log; -import org.linphone.core.Version; -import org.linphone.core.VideoSize; - -import android.hardware.Camera; -import android.hardware.Camera.AutoFocusCallback; -import android.hardware.Camera.ErrorCallback; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.PreviewCallback; -import android.hardware.Camera.Size; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import android.view.View.OnClickListener; - - -public abstract class AndroidCameraRecord implements AutoFocusCallback { - - protected Camera camera; - private RecorderParams params; - - private PreviewCallback storedPreviewCallback; - private boolean previewStarted; - private List supportedVideoSizes; - private Size currentPreviewSize; - - public AndroidCameraRecord(RecorderParams parameters) { - this.params = parameters; - } - - protected List getSupportedPreviewSizes(Camera.Parameters parameters) { - return Collections.emptyList(); - } - - private int[] findClosestEnclosingFpsRange(int expectedFps, List fpsRanges) { - Log.d("Searching for closest fps range from ",expectedFps); - int measure = Integer.MAX_VALUE; - int[] closestRange = fpsRanges.get(0); - for (int[] curRange : fpsRanges) { - if (curRange[0] > expectedFps || curRange[1] < expectedFps) continue; - int curMeasure = Math.abs(curRange[0] - expectedFps) - + Math.abs(curRange[1] - expectedFps); - if (curMeasure < measure) { - closestRange=curRange; - Log.d("a better range has been found: w=",closestRange[0],",h=",closestRange[1]); - } - } - Log.d("The closest fps range is w=",closestRange[0],",h=",closestRange[1]); - return closestRange; - } - - public synchronized void startPreview() { // FIXME throws exception? - if (previewStarted) { - Log.w("Already started"); - throw new RuntimeException("Video recorder already started"); - // return - } - - if (params.surfaceView.getVisibility() != SurfaceView.VISIBLE) { - // Illegal state - Log.e("Illegal state: video capture surface view is not visible"); - return; - } - - - Log.d("Trying to open camera with id ", params.cameraId); - if (camera != null) { - Log.e("Camera is not null, ?already open? : aborting"); - return; - } - camera = openCamera(params.cameraId); - camera.setErrorCallback(new ErrorCallback() { - public void onError(int error, Camera camera) { - Log.e("Camera error : ", error); - } - }); - - - Camera.Parameters parameters=camera.getParameters(); - if (Version.sdkStrictlyBelow(Version.API09_GINGERBREAD_23)) { - parameters.set("camera-id",params.cameraId); - } - - if (supportedVideoSizes == null) { - supportedVideoSizes = VideoUtil.createList(getSupportedPreviewSizes(parameters)); - } - - - if (params.width >= params.height) { - parameters.setPreviewSize(params.width, params.height); - } else { - // invert height and width - parameters.setPreviewSize(params.height, params.width); - } - // should setParameters and get again to have the real one?? - currentPreviewSize = parameters.getPreviewSize(); - - // Frame rate - if (Version.sdkStrictlyBelow(Version.API09_GINGERBREAD_23)) { - // Select the supported fps just faster than the target rate - List supportedFrameRates=parameters.getSupportedPreviewFrameRates(); - if (supportedFrameRates != null && supportedFrameRates.size() > 0) { - Collections.sort(supportedFrameRates); - int selectedRate = -1; - for (Integer rate : supportedFrameRates) { - selectedRate=rate; - if (rate >= params.fps) break; - } - parameters.setPreviewFrameRate(selectedRate); - } - } else { - List supportedRanges = parameters.getSupportedPreviewFpsRange(); - int[] range=findClosestEnclosingFpsRange((int)(1000*params.fps), supportedRanges); - parameters.setPreviewFpsRange(range[0], range[1]); - } - - - onSettingCameraParameters(parameters); - camera.setParameters(parameters); - - SurfaceHolder holder = params.surfaceView.getHolder(); - try { - camera.setPreviewDisplay(holder); - } - catch (Throwable t) { - Log.e(t,"Exception in Video capture setPreviewDisplay()"); - } - - - try { - camera.startPreview(); - } catch (Throwable e) { - Log.e("Error, can't start camera preview. Releasing camera!"); - camera.release(); - camera = null; - return; - } - - previewStarted = true; - - // Activate autofocus - if (Camera.Parameters.FOCUS_MODE_AUTO.equals(parameters.getFocusMode())) { - OnClickListener svClickListener = new OnClickListener() { - public void onClick(View v) { - Log.i("Auto focus requested"); - camera.autoFocus(AndroidCameraRecord.this); - } - }; - params.surfaceView.setOnClickListener(svClickListener); - // svClickListener.onClick(null); - } else { - params.surfaceView.setOnClickListener(null); - } - - // Register callback to get capture buffer - lowLevelSetPreviewCallback(camera, storedPreviewCallback); - - - onPreviewStarted(camera); - } - - - - - protected Camera openCamera(int cameraId) { - return Camera.open(); - } - - protected void onSettingCameraParameters(Parameters parameters) {} - - /** - * Hook. - * @param camera - */ - public void onPreviewStarted(Camera camera) {} - - public void storePreviewCallBack(PreviewCallback cb) { - this.storedPreviewCallback = cb; - if (camera == null) { - Log.w("Capture camera not ready, storing preview callback"); - return; - } - - lowLevelSetPreviewCallback(camera, cb); - } - - - public void stopPreview() { - if (!previewStarted) return; - lowLevelSetPreviewCallback(camera, null); - camera.stopPreview(); - camera.release(); - camera=null; - Log.d("Camera released"); - currentPreviewSize = null; - previewStarted = false; - } - - - public void stopCaptureCallback() { - if (camera != null) { - lowLevelSetPreviewCallback(camera, null); - } - } - - protected abstract void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb); - - - - public static class RecorderParams { - public static enum MirrorType {NO, HORIZONTAL, CENTRAL, VERTICAL}; - - public float fps; - public int height; - public int width; - - final long filterDataNativePtr; - public int cameraId; - public boolean isFrontCamera; - public int rotation; - public SurfaceView surfaceView; - - public MirrorType mirror = MirrorType.NO; - public int phoneOrientation; - - public RecorderParams(long ptr) { - filterDataNativePtr = ptr; - } - } - - - - public boolean isStarted() { - return previewStarted; - } - - public List getSupportedVideoSizes() { - return supportedVideoSizes; - } - - - protected int getExpectedBufferLength() { - if (currentPreviewSize == null) return -1; - - return currentPreviewSize.width * currentPreviewSize.height * 3 /2; - } - - public void onAutoFocus(boolean success, Camera camera) { - if (success) Log.i("Autofocus success"); - else Log.i("Autofocus failure"); - } - - public int getStoredPhoneOrientation() { - return params.phoneOrientation; - } -} diff --git a/video/AndroidCameraRecord5.java b/video/AndroidCameraRecord5.java deleted file mode 100644 index 45f94cd29..000000000 --- a/video/AndroidCameraRecord5.java +++ /dev/null @@ -1,139 +0,0 @@ -/* -AndroidCameraRecordImpl.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.video; - -import java.util.Arrays; -import java.util.List; - -import org.linphone.core.Log; -import org.linphone.core.video.AndroidCameraRecord.RecorderParams.MirrorType; - -import android.hardware.Camera; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.PreviewCallback; -import android.hardware.Camera.Size; - -/** - * Record from Android camera. - * Android >= 5 (2.0) version. - * - * @author Guillaume Beraudo - * - */ -class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallback { - - private long filterCtxPtr; - private double timeElapsedBetweenFrames = 0; - private long lastFrameTime = 0; - private final double expectedTimeBetweenFrames; - protected final int rotation; - private MirrorType mirror; -// private boolean isUsingFrontCamera; - - public AndroidCameraRecord5(RecorderParams parameters) { - super(parameters); - expectedTimeBetweenFrames = 1d / Math.round(parameters.fps); - filterCtxPtr = parameters.filterDataNativePtr; - rotation = parameters.rotation; - mirror = parameters.mirror; -// isUsingFrontCamera = parameters.isFrontCamera; - - storePreviewCallBack(this); - } - - - private native void putImage(long filterCtxPtr, byte[] buffer, int rotate, int mirror); - - - public void onPreviewFrame(byte[] data, Camera camera) { - if (data == null) { - Log.e("onPreviewFrame Called with null buffer"); - return; - } - if (filterCtxPtr == 0l) { - Log.e("onPreviewFrame Called with no filterCtxPtr set"); - return; - } - - int expectedBuffLength = getExpectedBufferLength(); - if (expectedBuffLength != data.length) { - Log.e("onPreviewFrame called with bad buffer length ", data.length, - " whereas expected is ", expectedBuffLength, " don't calling putImage"); - return; - } - - long curTime = System.currentTimeMillis(); - if (lastFrameTime == 0) { - lastFrameTime = curTime; - putImage(filterCtxPtr, data, rotation, mirror.ordinal()); - return; - } - - double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames; - if (currentTimeElapsed < expectedTimeBetweenFrames) { -// Log.d("Clipping frame ", Math.round(1 / currentTimeElapsed), " > ", fps); - return; - } - lastFrameTime = curTime; - timeElapsedBetweenFrames = currentTimeElapsed; - - // Log.d("onPreviewFrame: ", Integer.toString(data.length)); - putImage(filterCtxPtr, data, rotation, mirror.ordinal()); - } - - protected String selectFocusMode(final List supportedFocusModes) {/* - if (isUsingFrontCamera && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) { - return Camera.Parameters.FOCUS_MODE_FIXED; - } - if (!isUsingFrontCamera && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { - return Camera.Parameters.FOCUS_MODE_INFINITY; - }*/ - - if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) { - return Camera.Parameters.FOCUS_MODE_AUTO; - } - - return null; // Should not occur? - } - - @Override - protected void onSettingCameraParameters(Parameters parameters) { - super.onSettingCameraParameters(parameters); - List supportedFocusModes = parameters.getSupportedFocusModes(); - String focusMode = selectFocusMode(supportedFocusModes); - if (focusMode != null) { - Log.w("Selected focus mode: ", focusMode); - parameters.setFocusMode(focusMode); - } else { - Log.i("No suitable focus mode found in : ", Arrays.toString(supportedFocusModes.toArray())); - } - } - - @Override - protected List getSupportedPreviewSizes(Parameters parameters) { - return parameters.getSupportedPreviewSizes(); - } - - @Override - protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { - camera.setPreviewCallback(cb); - } - - -} diff --git a/video/AndroidCameraRecord8.java b/video/AndroidCameraRecord8.java deleted file mode 100644 index c5fda6774..000000000 --- a/video/AndroidCameraRecord8.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -AndroidCameraRecord8Impl.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.video; - -import java.util.List; - -import org.linphone.core.Log; - -import android.hardware.Camera; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.PreviewCallback; -import android.hardware.Camera.Size; - -/** - * - * Android >= 8 (2.2) version. - * @author Guillaume Beraudo - * - */ -class AndroidCameraRecord8 extends AndroidCameraRecord5 { - - - public AndroidCameraRecord8(RecorderParams parameters) { - super(parameters); - } - - @Override - protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) { - if (cb != null) { - Log.d("Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!"); - } - camera.setPreviewCallbackWithBuffer(cb); - } - - @Override - public void onPreviewStarted(Camera camera) { - super.onPreviewStarted(camera); - - Size s = camera.getParameters().getPreviewSize(); - int wishedBufferSize = s.height * s.width * 3 / 2; - - camera.addCallbackBuffer(new byte[wishedBufferSize]); - camera.addCallbackBuffer(new byte[wishedBufferSize]); - } - - @Override - public void onPreviewFrame(byte[] data, Camera camera) { - super.onPreviewFrame(data, camera); - camera.addCallbackBuffer(data); - } - - @Override - protected void onSettingCameraParameters(Parameters parameters) { - super.onSettingCameraParameters(parameters); - // Only on v8 hardware - camera.setDisplayOrientation(rotation); - } - - @Override - protected String selectFocusMode(final List supportedFocusModes) { - if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_EDOF)) { - return Camera.Parameters.FOCUS_MODE_EDOF; - } else - return super.selectFocusMode(supportedFocusModes); - } -} diff --git a/video/AndroidCameraRecord9.java b/video/AndroidCameraRecord9.java deleted file mode 100644 index f0023ef57..000000000 --- a/video/AndroidCameraRecord9.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -AndroidCameraRecord9Impl.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.video; - -import java.util.List; - -import android.hardware.Camera; - -/** - * - * Android >= 9 (2.3) version. - * @author Guillaume Beraudo - * - */ -class AndroidCameraRecord9 extends AndroidCameraRecord8 { - - - public AndroidCameraRecord9(RecorderParams parameters) { - super(parameters); - } - - @Override - protected Camera openCamera(int cameraId) { - return Camera.open(cameraId); - } - - @Override - protected String selectFocusMode(final List supportedFocusModes) { - if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) { - return Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO; - } else - return super.selectFocusMode(supportedFocusModes); - } -} diff --git a/video/AndroidCameraRecordManager.java b/video/AndroidCameraRecordManager.java deleted file mode 100644 index 7e8e8b613..000000000 --- a/video/AndroidCameraRecordManager.java +++ /dev/null @@ -1,362 +0,0 @@ -/* -AndroidCameraRecordManager.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.video; - -import java.util.List; - -import org.linphone.core.LinphoneCore; -import org.linphone.core.Log; -import org.linphone.core.Version; -import org.linphone.core.VideoSize; -import org.linphone.core.video.AndroidCameraRecord.RecorderParams; - -import android.content.Context; -import android.view.OrientationEventListener; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.SurfaceHolder.Callback; - - - -/** - * Manage the video capture, only one for all cameras. - * - * @author Guillaume Beraudo - * - */ -public class AndroidCameraRecordManager { - private static AndroidCameraRecordManager instance; - private OrientationEventListener orientationEventListener; - private OnCapturingStateChangedListener capturingStateChangedListener; - - /** - * @return instance - */ - public static final synchronized AndroidCameraRecordManager getInstance() { - if (instance == null) { - instance = new AndroidCameraRecordManager(); - } - return instance; - } - - private AndroidCameraRecord.RecorderParams parameters; - private final AndroidCameraConf cc; - private SurfaceView surfaceView; - private boolean muted; - private int cameraId; - - private AndroidCameraRecord recorder; - private int mAlwaysChangingPhoneOrientation=0; - - - // singleton - private AndroidCameraRecordManager() { - if (!Version.isVideoCapable()) { // imply sdk>=5 - throw new RuntimeException("AndroidCameraRecordManager: hardware is not video capable"); - } - cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5(); - Log.i("=== Detected " + cc.getFoundCameras()+ " ==="); - cameraId = cc.getFoundCameras().defaultC; - } - - - - - public boolean hasSeveralCameras() { - return cc.getFoundCameras().hasSeveralCameras(); - } - public boolean hasFrontCamera() { - return cc.getFoundCameras().front != null; - } - - - public void setUseFrontCamera(boolean value) { - if (!hasFrontCamera()) { - Log.e("setUseFrontCamera(true) while no front camera detected on device: using rear"); - value = false; - } - if (cc.isFrontCamera(cameraId) == value) return; // already OK - toggleUseFrontCamera(); - } - - public boolean isUseFrontCamera() {return cc.isFrontCamera(cameraId);} - public boolean toggleUseFrontCamera() { - boolean previousUseFront = cc.isFrontCamera(cameraId); - - cameraId = previousUseFront ? cc.getFoundCameras().rear : cc.getFoundCameras().front; - - if (parameters != null) { - parameters.cameraId = cameraId; - parameters.isFrontCamera = !previousUseFront; - if (isRecording()) { - stopVideoRecording(); - tryToStartVideoRecording(); - } - } - - return !previousUseFront; - } - - - - public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) { - if (recorder != null) { - Log.w("Recorder should not be running"); - stopVideoRecording(); - } - RecorderParams p = new RecorderParams(filterDataPtr); - p.fps = fps; - p.width = width; - p.height = height; - p.cameraId = cameraId; - p.isFrontCamera = isUseFrontCamera(); - parameters = p; - - // Mirror the sent frames in order to make them readable - // (otherwise it is mirrored and thus unreadable) - if (p.isFrontCamera) { - if (!isCameraMountedPortrait()) { - // Code for Nexus S - if (isFrameToBeShownPortrait()) - p.mirror = RecorderParams.MirrorType.CENTRAL; - } else { - // Code for Galaxy S like: camera mounted landscape when phone hold portrait - p.mirror = RecorderParams.MirrorType.HORIZONTAL; - } - } - - tryToStartVideoRecording(); - } - - - public final void setSurfaceView(final SurfaceView sv) { - SurfaceHolder holder = sv.getHolder(); - holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - - holder.addCallback(new Callback() { - public void surfaceDestroyed(SurfaceHolder holder) { - surfaceView = null; - Log.d("Video capture surface destroyed"); - stopVideoRecording(); - } - - public void surfaceCreated(SurfaceHolder holder) { - surfaceView = sv; - Log.d("Video capture surface created"); - tryToStartVideoRecording(); - } - - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - Log.d("Video capture surface changed"); - } - }); - } - - /** - * @param muteState - * @return true if mute state changed - */ - public boolean setMuted(boolean muteState) { - if (muteState == muted) return false; - muted = muteState; - if (muted) { - stopVideoRecording(); - } else { - tryToStartVideoRecording(); - } - return true; - } - public boolean toggleMute() { - setMuted(!muted); - return muted; - } - public boolean isMuted() { - return muted; - } - - public void tryResumingVideoRecording() { - if (isRecording()) return; - tryToStartVideoRecording(); - } - - private synchronized void tryToStartVideoRecording() { - if (orientationEventListener == null) { - throw new RuntimeException("startOrientationSensor was not called"); - } - - if (muted || surfaceView == null || parameters == null) return; - - if (recorder != null) { - Log.e("Recorder already present"); - stopVideoRecording(); - } - - parameters.rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); - - parameters.surfaceView = surfaceView; - if (Version.sdkAboveOrEqual(9)) { - recorder = new AndroidCameraRecord9(parameters); - } else if (Version.sdkAboveOrEqual(8)) { - recorder = new AndroidCameraRecord8(parameters); - } else if (Version.sdkAboveOrEqual(5)) { - recorder = new AndroidCameraRecord5(parameters); - } else { - throw new RuntimeException("SDK version unsupported " + Version.sdk()); - } - - recorder.startPreview(); - - if (capturingStateChangedListener != null) { - capturingStateChangedListener.captureStarted(); - } - } - - public synchronized void stopVideoRecording() { - if (recorder != null) { - recorder.stopPreview(); - recorder = null; - if (capturingStateChangedListener != null) { - capturingStateChangedListener.captureStopped(); - } - } - } - - - - public List supportedVideoSizes() { - Log.d("Using supportedVideoSizes of camera ",cameraId); - return cc.getSupportedPreviewSizes(cameraId); - } - - - public boolean isRecording() { - if (recorder != null) { - return recorder.isStarted(); - } - - return false; - } - - - public void invalidateParameters() { - stopVideoRecording(); - parameters = null; - } - - /** Depends on currently selected camera, camera mounted portrait/landscape, current phone orientation */ - public boolean isFrameToBeShownPortrait() { - final int rotation = bufferRotationToCompensateCameraAndPhoneOrientations(); - - boolean isPortrait; - if (isCameraMountedPortrait()) { - // Nexus S - isPortrait = (rotation % 180) == 0; - } else { - isPortrait = (rotation % 180) == 90; - } - - Log.d("The frame to be shown and sent to remote is ", isPortrait? "portrait":"landscape"," orientation."); - return isPortrait; - } - - - - - - - public boolean isCameraMountedPortrait() { - return (cc.getCameraOrientation(cameraId) % 180) == 0; - } - - - - private int bufferRotationToCompensateCameraAndPhoneOrientations() { - if (Version.sdkStrictlyBelow(Version.API08_FROYO_22)) { - // Don't perform any rotation - // Phone screen should use fitting orientation - return 0; - } - - final int phoneOrientation = mAlwaysChangingPhoneOrientation; - final int cameraOrientation = cc.getCameraOrientation(cameraId); - int frontCameraCorrection = 0; - if (cc.isFrontCamera(cameraId)) { - frontCameraCorrection=180; // hack that "just works" on Galaxy S and Nexus S. - // See also magic with mirrors in setParametersFromFilter - } - final int rotation = (cameraOrientation + phoneOrientation + frontCameraCorrection) % 360; - Log.d("Capture video buffer of cameraId=",cameraId, - " will need a rotation of ",rotation, - " degrees: camera_orientation=",cameraOrientation, - " phone_orientation=", phoneOrientation); - return rotation; - } - - - /** - * Register a sensor to track phoneOrientation changes - */ - public void startOrientationSensor(Context c) { - if (orientationEventListener == null) { - orientationEventListener = new LocalOrientationEventListener(c); - orientationEventListener.enable(); - } - } - - private class LocalOrientationEventListener extends OrientationEventListener { - public LocalOrientationEventListener(Context context) { - super(context); - } - @Override - public void onOrientationChanged(final int o) { - if (o == OrientationEventListener.ORIENTATION_UNKNOWN) return; - - int degrees=270; - if (o < 45 || o >315) degrees=0; - else if (o<135) degrees=90; - else if (o<225) degrees=180; - - if (mAlwaysChangingPhoneOrientation == degrees) return; - - Log.i("Phone orientation changed to ", degrees); - mAlwaysChangingPhoneOrientation = degrees; - } - } - - /** - * @return true if linphone core configured to send a A buffer while phone orientation induces !A buffer (A=landscape or portrait) - */ - public boolean isOutputOrientationMismatch(LinphoneCore lc) { - final boolean currentlyPortrait = lc.getPreferredVideoSize().isPortrait(); - final boolean shouldBePortrait = isFrameToBeShownPortrait(); - return currentlyPortrait ^ shouldBePortrait; - } - - public void setOnCapturingStateChanged(OnCapturingStateChangedListener listener) { - this.capturingStateChangedListener=listener; - } - - public static interface OnCapturingStateChangedListener { - void captureStarted(); - void captureStopped(); - } - - -} From 9bf7e93992de78603d48abcb4024efcb918dbf1f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 19 Sep 2011 12:44:22 +0200 Subject: [PATCH 139/288] fix broken compilation and update linphone submodule --- LinphoneCallImpl.java | 5 ++++- LinphoneCoreImpl.java | 47 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index b027e2170..db8b3f733 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -80,7 +80,6 @@ class LinphoneCallImpl implements LinphoneCall { public void enableCamera(boolean enabled) { enableCamera(nativePtr, enabled); } - @Override public boolean cameraEnabled() { return cameraEnabled(nativePtr); } @@ -127,4 +126,8 @@ class LinphoneCallImpl implements LinphoneCall { public boolean areStreamsEncrypted() { return areStreamsEncrypted(nativePtr); } + public boolean isInConference() { + // TODO Auto-generated method stub + return false; + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index d4b54b663..20d18e90e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,6 +20,7 @@ package org.linphone.core; import java.io.File; import java.io.IOException; +import java.util.List; import java.util.Vector; import org.linphone.LinphoneManager; @@ -491,16 +492,58 @@ class LinphoneCoreImpl implements LinphoneCore { public void enableEchoLimiter(boolean val) { enableEchoLimiter(nativePtr,val); } - @Override public void setVideoDevice(int id) { Log.i("Setting camera id :", id); if (setVideoDevice(nativePtr, id) != 0) { Log.e("Failed to set video device to id:", id); } } - @Override public int getVideoDevice() { return getVideoDevice(nativePtr); } + public void addAllToConference() { + // TODO Auto-generated method stub + + } + public void addToConference(LinphoneCall call) { + // TODO Auto-generated method stub + + } + public void enterConference() { + // TODO Auto-generated method stub + + } + public List getCalls() { + // TODO Auto-generated method stub + return null; + } + public int getCallsNb() { + // TODO Auto-generated method stub + return 0; + } + public int getConferenceSize() { + // TODO Auto-generated method stub + return 0; + } + public boolean isInConference() { + // TODO Auto-generated method stub + return false; + } + public void leaveConference() { + // TODO Auto-generated method stub + + } + public void removeFromConference(LinphoneCall call) { + // TODO Auto-generated method stub + + } + public void terminateAllCalls() { + // TODO Auto-generated method stub + + } + public void terminateConference() { + // TODO Auto-generated method stub + + } } From 698e7ac2b253083b6ed088e89e1df6d8f0fefd61 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 20 Sep 2011 21:33:05 +0200 Subject: [PATCH 140/288] update linphone submodule, fix compilation issue --- LinphoneCoreImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 20d18e90e..01517762d 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -545,5 +545,14 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub } + public void transferCall(LinphoneCall call, String referTo) { + // TODO Auto-generated method stub + + } + public void transferCallToAnother(LinphoneCall callToTransfer, + LinphoneCall destination) { + // TODO Auto-generated method stub + + } } From d97eeee7f51d06b760053aca902c532d6b432358 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 22 Sep 2011 10:50:35 +0200 Subject: [PATCH 141/288] Fix errors with different Android SDK (3, 5) --- LinphoneCoreFactoryImpl.java | 2 + Version.java | 85 ------------------------------------ 2 files changed, 2 insertions(+), 85 deletions(-) delete mode 100644 Version.java diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 674b62450..19b0282f3 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -35,6 +35,8 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; +import org.linphone.mediastream.Version; + public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { private static void loadOptionalLibrary(String s) { diff --git a/Version.java b/Version.java deleted file mode 100644 index edbb25e8e..000000000 --- a/Version.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -Version.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; - -import org.linphone.mediastream.video.capture.hwconf.Hacks; - -import android.os.Build; - -/** - * Centralize version access and allow simulation of lower versions. - * @author Guillaume Beraudo - */ -public class Version { - - public static final int API03_CUPCAKE_15 = 3; - public static final int API04_DONUT_16 = 4; - public static final int API06_ECLAIR_20 = 6; - public static final int API07_ECLAIR_21 = 7; - public static final int API08_FROYO_22 = 8; - public static final int API09_GINGERBREAD_23 = 9; - public static final int API11_HONEYCOMB_30 = 11; - - private static native boolean nativeHasZrtp(); - private static native boolean nativeHasNeon(); - private static Boolean hasNeon; - - private static final int buildVersion = - Integer.parseInt(Build.VERSION.SDK); -// 8; // 2.2 -// 7; // 2.1 - - public static final boolean sdkAboveOrEqual(int value) { - return buildVersion >= value; - } - - public static final boolean sdkStrictlyBelow(int value) { - return buildVersion < value; - } - - public static int sdk() { - return buildVersion; - } - - public static boolean isArmv7() { - try { - return sdkAboveOrEqual(4) - && Build.class.getField("CPU_ABI").get(null).toString().startsWith("armeabi-v7"); - } catch (Throwable e) {} - return false; - } - public static boolean hasNeon(){ - if (hasNeon == null) hasNeon = nativeHasNeon(); - return hasNeon; - } - public static boolean isVideoCapable() { - return !Version.sdkStrictlyBelow(5) && Version.hasNeon() && Hacks.hasCamera(); - } - - public static boolean hasZrtp(){ - return nativeHasZrtp(); - } - - public static void dumpCapabilities(){ - StringBuilder sb = new StringBuilder(" ==== Capabilities dump ====\n"); - sb.append("Has neon: ").append(Boolean.toString(hasNeon())).append("\n"); - sb.append("Has ZRTP: ").append(Boolean.toString(hasZrtp())).append("\n"); - Log.i(sb.toString()); - } -} From d5b7321a657bf0fce20771d0e6af8a5476cc8c0c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 22 Sep 2011 10:55:47 +0200 Subject: [PATCH 142/288] fix inconsistency when a second call arrives --- LinphoneCallImpl.java | 6 ++---- LinphoneCoreImpl.java | 10 ++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index db8b3f733..ceb541ed0 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -23,8 +23,7 @@ class LinphoneCallImpl implements LinphoneCall { protected final long nativePtr; boolean ownPtr = false; - native private void ref(long ownPtr); - native private void unref(long ownPtr); + native private void finalize(long nativePtr); native private long getCallLog(long nativePtr); private native boolean isIncoming(long nativePtr); native private long getRemoteAddress(long nativePtr); @@ -46,10 +45,9 @@ class LinphoneCallImpl implements LinphoneCall { protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; - ref(nativePtr); } protected void finalize() throws Throwable { - unref(nativePtr); + finalize(nativePtr); } public LinphoneCallLog getCallLog() { long lNativePtr = getCallLog(nativePtr); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 01517762d..52019f96b 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -65,7 +65,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native int enablePayloadType(long nativePtr, long payloadType, boolean enable); private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr); - private native long getCurrentCall(long nativePtr) ; + private native Object getCurrentCall(long nativePtr) ; private native void playDtmf(long nativePtr,char dtmf,int duration); private native void stopDtmf(long nativePtr); private native void setVideoWindowId(long nativePtr, Object wid); @@ -285,12 +285,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized LinphoneCall getCurrentCall() { isValid(); - long lNativePtr = getCurrentCall(nativePtr); - if (lNativePtr!=0) { - return new LinphoneCallImpl(lNativePtr); - } else { - return null; - } + return (LinphoneCall)getCurrentCall(nativePtr); } public int getPlayLevel() { @@ -554,5 +549,4 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub } - } From 98ea21e21fb80198e3d5bf007017a5075da7aaf6 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 22 Sep 2011 17:11:35 +0200 Subject: [PATCH 143/288] fix for unique LinphoneCalls again --- LinphoneCallImpl.java | 13 ++++++------- LinphoneCoreImpl.java | 25 ++++++++++--------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index ceb541ed0..70968e79d 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -35,14 +35,17 @@ class LinphoneCallImpl implements LinphoneCall { private native boolean isEchoCancellationEnabled(long nativePtr) ; private native void enableEchoLimiter(long nativePtr,boolean enable); 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 float getCurrentQuality(long nativePtr); private native float getAverageQuality(long nativePtr); private native String getAuthenticationToken(long nativePtr); private native boolean isAuthenticationTokenVerified(long nativePtr); private native boolean areStreamsEncrypted(long nativePtr); - + + /* + * This method must always be called from JNI, nothing else. + */ protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; } @@ -98,11 +101,7 @@ class LinphoneCallImpl implements LinphoneCall { return isEchoLimiterEnabled(nativePtr); } public LinphoneCall getReplacedCall(){ - long callptr=getReplacedCall(nativePtr); - if (callptr!=0){ - return new LinphoneCallImpl(callptr); - } - return null; + return (LinphoneCall)getReplacedCall(nativePtr); } public int getDuration() { diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 52019f96b..a45bad1c7 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -42,7 +42,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void clearProxyConfigs(long nativePtr); 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 long getRemoteAddress(long nativePtr); private native boolean isInCall(long nativePtr); @@ -56,8 +56,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native float getPlaybackGain(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); - private native long inviteAddress(long nativePtr,long to); - private native long inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); + private native Object inviteAddress(long nativePtr,long to); + private native Object inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); private native void sendDtmf(long nativePtr,char dtmf); private native void clearCallLogs(long nativePtr); private native boolean isMicMuted(long nativePtr); @@ -140,12 +140,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized LinphoneCall invite(String uri) { isValid(); - long lNativePtr = invite(nativePtr,uri); - if (lNativePtr!=0) { - return new LinphoneCallImpl(lNativePtr); - } else { - return null; - } + return (LinphoneCall)invite(nativePtr,uri); } public synchronized void iterate() { @@ -239,9 +234,9 @@ class LinphoneCoreImpl implements LinphoneCore { } } public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { - long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); - if (lNativePtr!=0) { - return new LinphoneCallImpl(lNativePtr); + LinphoneCall call = (LinphoneCall)inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); + if (call!=null) { + return call; } else { throw new LinphoneCoreException("Unable to invite address " + to.asString()); } @@ -361,9 +356,9 @@ class LinphoneCoreImpl implements LinphoneCore { long ptrDestination = ((LinphoneAddressImpl)to).nativePtr; long ptrParams =((LinphoneCallParamsImpl)params).nativePtr; - long lcNativePtr = inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); - if (lcNativePtr!=0) { - return new LinphoneCallImpl(lcNativePtr); + LinphoneCall call = (LinphoneCall)inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); + if (call!=null) { + return call; } else { throw new LinphoneCoreException("Unable to invite with params " + to.asString()); } From dfdd63a2ed80b193dca5e6aab6ccafd20093e139 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 26 Sep 2011 09:18:48 +0200 Subject: [PATCH 144/288] Report bug button in about activity when debug on. --- LinphoneCoreFactoryImpl.java | 14 -------------- LinphoneCoreImpl.java | 3 --- 2 files changed, 17 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 19b0282f3..1591a8b4e 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -19,21 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.cert.PKIXParameters; -import java.security.cert.TrustAnchor; -import java.security.cert.X509Certificate; -import java.util.Iterator; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; import org.linphone.mediastream.Version; diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index a45bad1c7..92eb4a43c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -23,9 +23,6 @@ import java.io.IOException; import java.util.List; import java.util.Vector; -import org.linphone.LinphoneManager; -import org.linphone.mediastream.video.AndroidVideoWindowImpl; - class LinphoneCoreImpl implements LinphoneCore { From 79965f6d156c1412a1cf3764765f27bf88b5f978 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 14 Sep 2011 11:04:14 +0200 Subject: [PATCH 145/288] Preliminary code for conferencing support. --- LinphoneCallImpl.java | 5 +- LinphoneCallParamsImpl.java | 5 ++ LinphoneCoreImpl.java | 93 ++++++++++++++++++++++--------------- 3 files changed, 64 insertions(+), 39 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 70968e79d..acad5a09f 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -123,8 +123,9 @@ class LinphoneCallImpl implements LinphoneCall { public boolean areStreamsEncrypted() { return areStreamsEncrypted(nativePtr); } + public boolean isInConference() { - // TODO Auto-generated method stub - return false; + LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); + return params.localConferenceMode(); } } diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index ef05eb228..d9c490ae1 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -48,4 +48,9 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { public void setAudioBandwidth(int value) { audioBandwidth(nativePtr, value); } + + private native boolean localConferenceMode(long nativePtr); + public boolean localConferenceMode() { + return localConferenceMode(nativePtr); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 92eb4a43c..ab87a17b2 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,6 +20,7 @@ package org.linphone.core; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Vector; @@ -488,50 +489,68 @@ class LinphoneCoreImpl implements LinphoneCore { public int getVideoDevice() { return getVideoDevice(nativePtr); } - public void addAllToConference() { - // TODO Auto-generated method stub - - } - public void addToConference(LinphoneCall call) { - // TODO Auto-generated method stub - - } - public void enterConference() { - // TODO Auto-generated method stub - - } - public List getCalls() { - // TODO Auto-generated method stub - return null; - } - public int getCallsNb() { - // TODO Auto-generated method stub - return 0; - } - public int getConferenceSize() { - // TODO Auto-generated method stub - return 0; - } - public boolean isInConference() { - // TODO Auto-generated method stub - return false; - } + + + private native void leaveConference(long nativePtr); public void leaveConference() { - // TODO Auto-generated method stub - + leaveConference(nativePtr); } - public void removeFromConference(LinphoneCall call) { - // TODO Auto-generated method stub - + + private native void enterConference(long nativePtr); + public void enterConference() { + enterConference(nativePtr); } - public void terminateAllCalls() { - // TODO Auto-generated method stub - + + private native boolean isInConference(long nativePtr); + public boolean isInConference() { + return isInConference(nativePtr); } + + private native void addToConference(long nativePtr, long nativePtrLcall); + public void addToConference(LinphoneCall call, boolean addOthersToNewConference) { + addToConference(nativePtr, ((LinphoneCallImpl)call).nativePtr); + } + + private native void terminateConference(long nativePtr); public void terminateConference() { - // TODO Auto-generated method stub + terminateConference(nativePtr); + } + private native int getConferenceSize(long nativePtr); + public int getConferenceSize() { + return getConferenceSize(nativePtr); + } + private native int getCallsNb(long nativePtr); + public int getCallsNb() { + return getCallsNb(nativePtr); + } + private native void terminateAllCalls(long nativePtr); + public void terminateAllCalls() { + terminateAllCalls(nativePtr); + } + private native long getCall(long nativePtr, int position); + @SuppressWarnings("unchecked") public List getCalls() { + int size = getCallsNb(nativePtr); + List calls = new ArrayList(size); + for (int i=0; i < size; i++) { + calls.add(new LinphoneCallImpl(getCall(nativePtr, i))); + } + return calls; + } + private native void addAllToConference(long nativePtr); + public void addAllToConference() { + addAllToConference(nativePtr); } + private native void addToConference(long nativePtr); + public void addToConference(LinphoneCall call) { + addToConference(nativePtr); + + } + private native void removeFromConference(long nativePtr); + public void removeFromConference(LinphoneCall call) { + removeFromConference(nativePtr); + } + public void transferCall(LinphoneCall call, String referTo) { // TODO Auto-generated method stub From eb6fe80e62d12bfb574864f34c2f8f923cd1807b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 14 Sep 2011 11:37:54 +0200 Subject: [PATCH 146/288] Fix mediastreamer2 build. --- LinphoneCallImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index acad5a09f..c96593d63 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -128,4 +128,9 @@ class LinphoneCallImpl implements LinphoneCall { LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); return params.localConferenceMode(); } + + @Override + public String toString() { + return "Call " + nativePtr; + } } From b44d51a5b17da9973c35729386c41a8b085eea17 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 20 Sep 2011 14:36:15 +0200 Subject: [PATCH 147/288] Initial support for conferencing. --- LinphoneCoreImpl.java | 53 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index ab87a17b2..a5b4b718c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -477,7 +477,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setZrtpSecretsCache(String file) { setZrtpSecretsCache(nativePtr,file); } - public void enableEchoLimiter(boolean val) { + public synchronized void enableEchoLimiter(boolean val) { enableEchoLimiter(nativePtr,val); } public void setVideoDevice(int id) { @@ -492,43 +492,38 @@ class LinphoneCoreImpl implements LinphoneCore { private native void leaveConference(long nativePtr); - public void leaveConference() { + public synchronized void leaveConference() { leaveConference(nativePtr); } private native void enterConference(long nativePtr); - public void enterConference() { + public synchronized void enterConference() { enterConference(nativePtr); } private native boolean isInConference(long nativePtr); - public boolean isInConference() { + public synchronized boolean isInConference() { return isInConference(nativePtr); } - private native void addToConference(long nativePtr, long nativePtrLcall); - public void addToConference(LinphoneCall call, boolean addOthersToNewConference) { - addToConference(nativePtr, ((LinphoneCallImpl)call).nativePtr); - } - private native void terminateConference(long nativePtr); - public void terminateConference() { + public synchronized void terminateConference() { terminateConference(nativePtr); } private native int getConferenceSize(long nativePtr); - public int getConferenceSize() { + public synchronized int getConferenceSize() { return getConferenceSize(nativePtr); } private native int getCallsNb(long nativePtr); - public int getCallsNb() { + public synchronized int getCallsNb() { return getCallsNb(nativePtr); } private native void terminateAllCalls(long nativePtr); - public void terminateAllCalls() { + public synchronized void terminateAllCalls() { terminateAllCalls(nativePtr); } private native long getCall(long nativePtr, int position); - @SuppressWarnings("unchecked") public List getCalls() { + @SuppressWarnings("unchecked") public synchronized List getCalls() { int size = getCallsNb(nativePtr); List calls = new ArrayList(size); for (int i=0; i < size; i++) { @@ -537,27 +532,31 @@ class LinphoneCoreImpl implements LinphoneCore { return calls; } private native void addAllToConference(long nativePtr); - public void addAllToConference() { + public synchronized void addAllToConference() { addAllToConference(nativePtr); } - private native void addToConference(long nativePtr); - public void addToConference(LinphoneCall call) { - addToConference(nativePtr); + private native void addToConference(long nativePtr, long nativePtrLcall); + public synchronized void addToConference(LinphoneCall call) { + addToConference(nativePtr, getCallPtr(call)); } private native void removeFromConference(long nativePtr); - public void removeFromConference(LinphoneCall call) { - removeFromConference(nativePtr); + public synchronized void removeFromConference(LinphoneCall call) { + removeFromConference(getCallPtr(call)); } - public void transferCall(LinphoneCall call, String referTo) { - // TODO Auto-generated method stub - + private long getCallPtr(LinphoneCall call) { + return ((LinphoneCallImpl)call).nativePtr; } - public void transferCallToAnother(LinphoneCall callToTransfer, - LinphoneCall destination) { - // TODO Auto-generated method stub - + + private native int transferCall(long nativePtr, long callPtr, String referTo); + public synchronized void transferCall(LinphoneCall call, String referTo) { + transferCall(nativePtr, getCallPtr(call), referTo); + } + + private native int transferCallToAnother(long nativePtr, long callPtr, long destPtr); + public synchronized void transferCallToAnother(LinphoneCall call, LinphoneCall dest) { + transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest)); } } From 8a89467629e7ee95d375a96bc59937f9f46253b3 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 29 Sep 2011 16:36:40 +0200 Subject: [PATCH 148/288] improved incoming activity + back to conference button. --- LinphoneCallImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index c96593d63..3f153e0fc 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -84,9 +84,21 @@ class LinphoneCallImpl implements LinphoneCall { public boolean cameraEnabled() { return cameraEnabled(nativePtr); } + + @Override public boolean equals(Object call) { + if (this == call) return true; + if (call == null) return false; + if (!(call instanceof LinphoneCallImpl)) return false; return nativePtr == ((LinphoneCallImpl)call).nativePtr; } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + (int) (nativePtr ^ (nativePtr >>> 32)); + return result; + } public void enableEchoCancellation(boolean enable) { enableEchoCancellation(nativePtr,enable); From f57826fb231936c82760c12f5cdb3dcc230843de Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 30 Sep 2011 13:51:46 +0200 Subject: [PATCH 149/288] Fix second incoming call from same uri crash. --- LinphoneCoreImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index a5b4b718c..8a40cdb9f 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -559,4 +559,11 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void transferCallToAnother(LinphoneCall call, LinphoneCall dest) { transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest)); } + + private native long findCallFromUri(long nativePtr, String uri); + @Override + public synchronized LinphoneCall findCallFromUri(String uri) { + long callPtr = findCallFromUri(nativePtr, uri); + return callPtr != 0 ? new LinphoneCallImpl(callPtr) : null; + } } From 17df23f74ac47e3c7ee263a918b9bfba850ddee7 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 7 Oct 2011 08:48:12 +0200 Subject: [PATCH 150/288] Add missing LinphoneCore function impl --- LinphoneCoreImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 92eb4a43c..4b3f9e99c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -541,4 +541,8 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub } + public LinphoneCall findCallFromUri(String uri) { + // TODO Auto-generated method stub + return null; + } } From 70f96ce8e9e871140d938d3c8d05fcccfc130a1c Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Oct 2011 14:50:38 +0200 Subject: [PATCH 151/288] Enable srtp --- LinphoneCoreImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 4b3f9e99c..902ea9f4f 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -515,7 +515,7 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isInConference() { // TODO Auto-generated method stub return false; - } + } public void leaveConference() { // TODO Auto-generated method stub From d8f8b821037fddb489f0325520f0b7ba51f341d0 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 7 Oct 2011 09:52:59 +0200 Subject: [PATCH 152/288] Enhance conference activity style + permute calls. --- LinphoneCoreImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 8a40cdb9f..0f91922d7 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -522,12 +522,12 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void terminateAllCalls() { terminateAllCalls(nativePtr); } - private native long getCall(long nativePtr, int position); + private native Object getCall(long nativePtr, int position); @SuppressWarnings("unchecked") public synchronized List getCalls() { int size = getCallsNb(nativePtr); List calls = new ArrayList(size); for (int i=0; i < size; i++) { - calls.add(new LinphoneCallImpl(getCall(nativePtr, i))); + calls.add((LinphoneCall)getCall(nativePtr, i)); } return calls; } From 382b6f480a1286aab7711a3f767321c186c57b66 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 7 Oct 2011 14:43:32 +0200 Subject: [PATCH 153/288] Hide LinphonecallImpl constructor. linphonecalls should not be created from java. --- LinphoneCallImpl.java | 2 +- LinphoneCoreImpl.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 3f153e0fc..6370dce17 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -46,7 +46,7 @@ class LinphoneCallImpl implements LinphoneCall { /* * This method must always be called from JNI, nothing else. */ - protected LinphoneCallImpl(long aNativePtr) { + private LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; } protected void finalize() throws Throwable { diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0f91922d7..bf5e5de9c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -560,10 +560,9 @@ class LinphoneCoreImpl implements LinphoneCore { transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest)); } - private native long findCallFromUri(long nativePtr, String uri); + private native Object findCallFromUri(long nativePtr, String uri); @Override public synchronized LinphoneCall findCallFromUri(String uri) { - long callPtr = findCallFromUri(nativePtr, uri); - return callPtr != 0 ? new LinphoneCallImpl(callPtr) : null; + return (LinphoneCall) findCallFromUri(nativePtr, uri); } } From 641354c50f65f6dbb94d7888fb3ae0c65ae066fc Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 10 Oct 2011 09:26:14 +0200 Subject: [PATCH 154/288] srtp: add Java impl --- LinphoneCallParamsImpl.java | 10 ++++++++++ LinphoneCoreImpl.java | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index ef05eb228..c346dcd1f 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -28,6 +28,8 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { private native void enableVideo(long nativePtr, boolean b); private native boolean getVideoEnabled(long nativePtr); private native void audioBandwidth(long nativePtr, int bw); + private native void setMediaEncryption(long nativePtr, String menc); + private native String getMediaEncryption(long nativePtr); private native void destroy(long nativePtr); @@ -48,4 +50,12 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { public void setAudioBandwidth(int value) { audioBandwidth(nativePtr, value); } + + public String getMediaEncryption() { + return getMediaEncryption(nativePtr); + } + + public void setMediaEnctyption(String menc) { + setMediaEncryption(nativePtr, menc); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 902ea9f4f..355523d59 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -104,7 +104,12 @@ class LinphoneCoreImpl implements LinphoneCore { private native void enableEchoLimiter(long nativePtr2, boolean val); private native int setVideoDevice(long nativePtr2, int id); private native int getVideoDevice(long nativePtr2); - + private native String getMediaEncryption(long nativePtr); + private native void setMediaEncryption(long nativePtr, String menc); + private native boolean isMediaEncryptionMandatory(long nativePtr); + private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno); + + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -545,4 +550,17 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return null; } + + public String getMediaEncryption() { + return getMediaEncryption(nativePtr); + } + public boolean isMediaEncryptionMandatory() { + return isMediaEncryptionMandatory(nativePtr); + } + public void setMediaEncryption(String menc) { + setMediaEncryption(nativePtr, menc); + } + public void setMediaEncryptionMandatory(boolean yesno) { + setMediaEncryptionMandatory(nativePtr, yesno); + } } From ebaa5f460d1388cba04063cf7b660ffa2636b5b8 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 18 Oct 2011 15:44:35 +0200 Subject: [PATCH 155/288] Ability to limit number of calls / hide transfers. --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 139e1a30f..b2a26a976 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -583,4 +583,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void setMediaEncryptionMandatory(boolean yesno) { setMediaEncryptionMandatory(nativePtr, yesno); } + + private native int getMaxCalls(long nativePtr); + public int getMaxCalls() { + return getMaxCalls(nativePtr); + } } From 5d05c296465e1009888c7011d6007433809d1c46 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 26 Oct 2011 13:14:39 +0200 Subject: [PATCH 156/288] Reject incoming and outgoing calls to incall people. --- LinphoneCoreImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b2a26a976..0e5cfbdb5 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -588,4 +588,8 @@ class LinphoneCoreImpl implements LinphoneCore { public int getMaxCalls() { return getMaxCalls(nativePtr); } + @Override + public boolean isMyself(String uri) { + return uri.equals(getDefaultProxyConfig().getIdentity()); + } } From 9fa4af5159134fd7d9bbc82b880017d5d95ff365 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 27 Oct 2011 10:43:15 +0200 Subject: [PATCH 157/288] Better add call, callee actions dialog, dtmf numpad. Prevent situations where several calls use the sound resources at the same time. --- LinphoneCoreImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0e5cfbdb5..7c1f6d905 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -590,6 +590,13 @@ class LinphoneCoreImpl implements LinphoneCore { } @Override public boolean isMyself(String uri) { - return uri.equals(getDefaultProxyConfig().getIdentity()); + LinphoneProxyConfig lpc = getDefaultProxyConfig(); + if (lpc == null) return false; + return uri.equals(lpc.getIdentity()); + } + + private native boolean soundResourcesLocked(long nativePtr); + public boolean soundResourcesLocked() { + return soundResourcesLocked(nativePtr); } } From ab036c5fe0f8510d2557177a7f6ae3c2834275b5 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 3 Nov 2011 16:12:38 +0100 Subject: [PATCH 158/288] Fix rejection of SIP calls while in GSM call. Audio was messed up. --- LinphoneCoreImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 7c1f6d905..5d9d634db 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -599,4 +599,10 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean soundResourcesLocked() { return soundResourcesLocked(nativePtr); } + + private native void setMaxCalls(long nativePtr, int max); + @Override + public void setMaxCalls(int max) { + setMaxCalls(nativePtr, max); + } } From 6fe2f65ab0729447299643b0602141a746bc82bd Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 8 Nov 2011 16:23:21 +0100 Subject: [PATCH 159/288] fix for silk 24khz on Galaxy S --- LinphoneCallImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 6370dce17..2550367cb 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -132,9 +132,6 @@ class LinphoneCallImpl implements LinphoneCall { public boolean isAuthenticationTokenVerified(){ return isAuthenticationTokenVerified(nativePtr); } - public boolean areStreamsEncrypted() { - return areStreamsEncrypted(nativePtr); - } public boolean isInConference() { LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); From 453e6a5319d2dfc98d511718251b3e873735aefd Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Nov 2011 17:28:51 +0100 Subject: [PATCH 160/288] add option to enable echo limiter, and fallback to it when echo limiter failed --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 5d9d634db..7f63f0cb3 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -605,4 +605,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void setMaxCalls(int max) { setMaxCalls(nativePtr, max); } + private native boolean isEchoLimiterEnabled(long nativePtr); + @Override + public boolean isEchoLimiterEnabled() { + return isEchoLimiterEnabled(nativePtr); + } } From b15cee59b3e442673c4a7182db24cf6a857b63cc Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 14 Nov 2011 15:37:03 +0100 Subject: [PATCH 161/288] Improve ZRTP GUI + setAuthenticationVerified --- LinphoneCallImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 2550367cb..802801155 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -39,9 +39,6 @@ class LinphoneCallImpl implements LinphoneCall { private native int getDuration(long nativePtr); private native float getCurrentQuality(long nativePtr); private native float getAverageQuality(long nativePtr); - private native String getAuthenticationToken(long nativePtr); - private native boolean isAuthenticationTokenVerified(long nativePtr); - private native boolean areStreamsEncrypted(long nativePtr); /* * This method must always be called from JNI, nothing else. @@ -126,13 +123,21 @@ class LinphoneCallImpl implements LinphoneCall { return getCurrentQuality(nativePtr); } + private native String getAuthenticationToken(long nativePtr); public String getAuthenticationToken(){ return getAuthenticationToken(nativePtr); } + + private native boolean isAuthenticationTokenVerified(long nativePtr); public boolean isAuthenticationTokenVerified(){ return isAuthenticationTokenVerified(nativePtr); } + private native boolean setAuthenticationTokenVerified(long nativePtr, boolean verified); + public void setAuthenticationTokenVerified(boolean verified){ + setAuthenticationTokenVerified(nativePtr, verified); + } + public boolean isInConference() { LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); return params.localConferenceMode(); From 34a0b4eb5e8aa963fdac5d47ffebed764b18a36a Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 22 Nov 2011 11:12:57 +0100 Subject: [PATCH 162/288] Fundamental incall UI changes. - single click for resuming/pausing call; - long click for advanced call/conference interaction; - terminate call action according to situation; - conference details activity; - cleanings. --- LinphoneCoreImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 7f63f0cb3..363ac8ac4 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -501,9 +501,9 @@ class LinphoneCoreImpl implements LinphoneCore { leaveConference(nativePtr); } - private native void enterConference(long nativePtr); - public synchronized void enterConference() { - enterConference(nativePtr); + private native boolean enterConference(long nativePtr); + public synchronized boolean enterConference() { + return enterConference(nativePtr); } private native boolean isInConference(long nativePtr); From cc90b960f10487b3f39ddcce290699681dcd77eb Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 23 Nov 2011 22:20:00 +0100 Subject: [PATCH 163/288] media encryption API enhancements add preference for media encryption selection. --- LinphoneCallParamsImpl.java | 14 ++++++++------ LinphoneCoreImpl.java | 23 ++++++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index 8a7fba15c..bb7e9b1ab 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.core.LinphoneCore.MediaEncryption; + public class LinphoneCallParamsImpl implements LinphoneCallParams { protected final long nativePtr; @@ -28,8 +30,8 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { private native void enableVideo(long nativePtr, boolean b); private native boolean getVideoEnabled(long nativePtr); private native void audioBandwidth(long nativePtr, int bw); - private native void setMediaEncryption(long nativePtr, String menc); - private native String getMediaEncryption(long nativePtr); + private native void setMediaEncryption(long nativePtr, int menc); + private native int getMediaEncryption(long nativePtr); private native void destroy(long nativePtr); @@ -51,12 +53,12 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { audioBandwidth(nativePtr, value); } - public String getMediaEncryption() { - return getMediaEncryption(nativePtr); + public MediaEncryption getMediaEncryption() { + return MediaEncryption.fromInt(getMediaEncryption(nativePtr)); } - public void setMediaEnctyption(String menc) { - setMediaEncryption(nativePtr, menc); + public void setMediaEnctyption(MediaEncryption menc) { + setMediaEncryption(nativePtr, menc.mValue); } private native boolean localConferenceMode(long nativePtr); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 7f63f0cb3..eeb082dca 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -105,8 +105,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void enableEchoLimiter(long nativePtr2, boolean val); private native int setVideoDevice(long nativePtr2, int id); private native int getVideoDevice(long nativePtr2); - private native String getMediaEncryption(long nativePtr); - private native void setMediaEncryption(long nativePtr, String menc); + private native int getMediaEncryption(long nativePtr); + private native void setMediaEncryption(long nativePtr, int menc); private native boolean isMediaEncryptionMandatory(long nativePtr); private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno); @@ -501,9 +501,9 @@ class LinphoneCoreImpl implements LinphoneCore { leaveConference(nativePtr); } - private native void enterConference(long nativePtr); - public synchronized void enterConference() { - enterConference(nativePtr); + private native boolean enterConference(long nativePtr); + public synchronized boolean enterConference() { + return enterConference(nativePtr); } private native boolean isInConference(long nativePtr); @@ -571,14 +571,14 @@ class LinphoneCoreImpl implements LinphoneCore { return (LinphoneCall) findCallFromUri(nativePtr, uri); } - public String getMediaEncryption() { - return getMediaEncryption(nativePtr); + public MediaEncryption getMediaEncryption() { + return MediaEncryption.fromInt(getMediaEncryption(nativePtr)); } public boolean isMediaEncryptionMandatory() { return isMediaEncryptionMandatory(nativePtr); } - public void setMediaEncryption(String menc) { - setMediaEncryption(nativePtr, menc); + public void setMediaEncryption(MediaEncryption menc) { + setMediaEncryption(nativePtr, menc.mValue); } public void setMediaEncryptionMandatory(boolean yesno) { setMediaEncryptionMandatory(nativePtr, yesno); @@ -610,4 +610,9 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isEchoLimiterEnabled() { return isEchoLimiterEnabled(nativePtr); } + private native boolean mediaEncryptionSupported(long nativePtr, int menc); + @Override + public boolean mediaEncryptionSupported(MediaEncryption menc) { + return mediaEncryptionSupported(nativePtr,menc.mValue); + } } From a829a84f6dae73a5dc7e6c867f265913570eac65 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 1 Dec 2011 08:51:48 +0100 Subject: [PATCH 164/288] Play sound to other part when holding call. --- LinphoneCoreImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index eeb082dca..b9d15299c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -615,4 +615,10 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean mediaEncryptionSupported(MediaEncryption menc) { return mediaEncryptionSupported(nativePtr,menc.mValue); } + + private native void setPlayFile(long nativePtr, String path); + @Override + public void setPlayFile(String path) { + setPlayFile(nativePtr, path); + } } From d6b568905f8bc89eb267981764e96d7d3630e897 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 6 Dec 2011 14:03:25 +0100 Subject: [PATCH 165/288] fix bad JNI interface for removeFromConf() and update linphone submodule for conferencing fixes --- LinphoneCoreImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b9d15299c..61ddbd4d6 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -546,9 +546,9 @@ class LinphoneCoreImpl implements LinphoneCore { addToConference(nativePtr, getCallPtr(call)); } - private native void removeFromConference(long nativePtr); + private native void removeFromConference(long nativePtr, long nativeCallPtr); public synchronized void removeFromConference(LinphoneCall call) { - removeFromConference(getCallPtr(call)); + removeFromConference(nativePtr,getCallPtr(call)); } private long getCallPtr(LinphoneCall call) { From b8e9569e5d497c1ff1a029cedc73a96baa2d5f01 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 16 Dec 2011 10:59:32 +0100 Subject: [PATCH 166/288] Optional tunnel plugin. Requires a tunnel implementation with Android.mk in submodules/linphone/tunnel --- LinphoneCoreFactoryImpl.java | 3 +++ LinphoneCoreImpl.java | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 1591a8b4e..39fbeee54 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -49,6 +49,9 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { loadOptionalLibrary("srtp"); loadOptionalLibrary("zrtpcpp"); // GPLv3+ + // Tunnel + loadOptionalLibrary("tunnelclient"); + //Main library System.loadLibrary("linphone"); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 61ddbd4d6..5d04d745c 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -617,8 +617,43 @@ class LinphoneCoreImpl implements LinphoneCore { } private native void setPlayFile(long nativePtr, String path); + @Override public void setPlayFile(String path) { setPlayFile(nativePtr, path); } + + + private native void tunnelAddServerAndMirror(long nativePtr, String host, int port, int mirror, int ms); + @Override + public void tunnelAddServerAndMirror(String host, int port, int mirror, int ms) { + tunnelAddServerAndMirror(nativePtr, host, port, mirror, ms); + } + + private native void tunnelAutoDetect(long nativePtr); + @Override + public void tunnelAutoDetect() { + tunnelAutoDetect(nativePtr); + } + + private native void tunnelCleanServers(long nativePtr); + @Override + public void tunnelCleanServers() { + tunnelCleanServers(nativePtr); + } + + private native void tunnelEnable(long nativePtr, boolean enable); + @Override + public void tunnelEnable(boolean enable) { + tunnelEnable(nativePtr, enable); + } + + private native void tunnelEnableLogs(long nativePtr, boolean enable); + @Override + public void tunnelEnableLogs(boolean enable) { + tunnelEnableLogs(nativePtr, enable); + } + + @Override + public native boolean isTunnelAvailable(); } From 7e81d189d0ba19670d6e8a2d36b70934d8b71745 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 30 Dec 2011 17:00:28 +0100 Subject: [PATCH 167/288] Show who is talking in conf view --- LinphoneCallImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 802801155..b2b71dcb5 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -147,4 +147,9 @@ class LinphoneCallImpl implements LinphoneCall { public String toString() { return "Call " + nativePtr; } + + private native float getPlayVolume(long nativePtr); + public float getPlayVolume() { + return getPlayVolume(nativePtr); + } } From 757b973a8d0dab62a4852646c402fb37cfe5f8cf Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 2 Feb 2012 11:30:26 +0100 Subject: [PATCH 168/288] Linphone submodule updated for JNI --- LinphoneCoreImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 5d04d745c..ee91f4f5d 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -88,6 +88,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native String getRing(long nativePtr); private native void setRootCA(long nativePtr, String path); private native long[] listVideoPayloadTypes(long nativePtr); + private native long[] getProxyConfigList(long nativePtr); private native long[] listAudioPayloadTypes(long nativePtr); private native void enableKeepAlive(long nativePtr,boolean enable); private native boolean isKeepAliveEnabled(long nativePtr); @@ -404,6 +405,19 @@ class LinphoneCoreImpl implements LinphoneCore { setRootCA(nativePtr, path); } + public synchronized LinphoneProxyConfig[] getProxyConfigList() { + long[] typesPtr = getProxyConfigList(nativePtr); + if (typesPtr == null) return null; + + LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length]; + + for (int i=0; i < proxies.length; i++) { + proxies[i] = new LinphoneProxyConfigImpl(typesPtr[i]); + } + + return proxies; + } + public synchronized PayloadType[] getVideoCodecs() { long[] typesPtr = listVideoPayloadTypes(nativePtr); if (typesPtr == null) return null; From 9db10616e2d3d4faa7be6ce08d0b788d12c81708 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 17 Feb 2012 11:30:39 +0100 Subject: [PATCH 169/288] add g729 integration --- LinphoneCoreFactoryImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 39fbeee54..a5ae7805f 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -51,9 +51,12 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { // Tunnel loadOptionalLibrary("tunnelclient"); + + // g729 A implementation + loadOptionalLibrary("bcg729"); //Main library - System.loadLibrary("linphone"); + System.loadLibrary("linphone"); Version.dumpCapabilities(); } From 139e7a49a8f733e112ce60fd645b55ffccb4bef6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 29 Feb 2012 16:55:17 +0100 Subject: [PATCH 170/288] End of JNI export for getRemoteParams, acceptCallWithParams, acceptCallUpdate and deferCallUpdate --- LinphoneCallImpl.java | 5 ++++- LinphoneCoreImpl.java | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index b2b71dcb5..008b19df4 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -29,6 +29,7 @@ class LinphoneCallImpl implements LinphoneCall { native private long getRemoteAddress(long nativePtr); native private int getState(long nativePtr); private native long getCurrentParamsCopy(long nativePtr); + private native long getRemoteParams(long nativePtr); private native void enableCamera(long nativePtr, boolean enabled); private native boolean cameraEnabled(long nativePtr); private native void enableEchoCancellation(long nativePtr,boolean enable); @@ -74,7 +75,9 @@ class LinphoneCallImpl implements LinphoneCall { public LinphoneCallParams getCurrentParamsCopy() { return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); } - + public LinphoneCallParams getRemoteParams() { + return new LinphoneCallParamsImpl(getRemoteParams(nativePtr)); + } public void enableCamera(boolean enabled) { enableCamera(nativePtr, enabled); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index ee91f4f5d..f6ee3c835 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -670,4 +670,26 @@ class LinphoneCoreImpl implements LinphoneCore { @Override public native boolean isTunnelAvailable(); + + private native void acceptCallWithParams(long nativePtr, LinphoneCall aCall, + LinphoneCallParams params); + @Override + public void acceptCallWithParams(LinphoneCall aCall, + LinphoneCallParams params) throws LinphoneCoreException { + acceptCallWithParams(nativePtr, aCall, params); + } + + private native void acceptCallUpdate(long nativePtr, LinphoneCall aCall, LinphoneCallParams params); + @Override + public void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params) + throws LinphoneCoreException { + acceptCallUpdate(nativePtr, aCall, params); + } + + private native void deferCallUpdate(long nativePtr, LinphoneCall aCall, LinphoneCallParams params); + @Override + public void deferCallUpdate(LinphoneCall aCall, LinphoneCallParams params) + throws LinphoneCoreException { + deferCallUpdate(nativePtr, aCall, params); + } } From 5904cfcc49793e8f5576e6e5ab5bd9a8f3cd85d8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 1 Mar 2012 12:14:15 +0100 Subject: [PATCH 171/288] Update exosip & linphone submodule + using setVideoPolicy --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f6ee3c835..2e79fde95 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -692,4 +692,9 @@ class LinphoneCoreImpl implements LinphoneCore { throws LinphoneCoreException { deferCallUpdate(nativePtr, aCall, params); } + + private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept); + public void setVideoPolicy(boolean autoInitiate, boolean autoAccept) { + setVideoPolicy(nativePtr, autoInitiate, autoAccept); + } } From 19df41ad738aa1c7b6e8ddcfca7359f67403c7de Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 1 Mar 2012 14:20:21 +0100 Subject: [PATCH 172/288] Updated linphone to match JNI exports --- LinphoneCoreImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 2e79fde95..f58247591 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -686,11 +686,11 @@ class LinphoneCoreImpl implements LinphoneCore { acceptCallUpdate(nativePtr, aCall, params); } - private native void deferCallUpdate(long nativePtr, LinphoneCall aCall, LinphoneCallParams params); + private native void deferCallUpdate(long nativePtr, LinphoneCall aCall); @Override - public void deferCallUpdate(LinphoneCall aCall, LinphoneCallParams params) + public void deferCallUpdate(LinphoneCall aCall) throws LinphoneCoreException { - deferCallUpdate(nativePtr, aCall, params); + deferCallUpdate(nativePtr, aCall); } private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept); From f2d47eda42438d65c8d248d20e6e2429106b9630 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 7 Mar 2012 13:49:16 +0100 Subject: [PATCH 173/288] Fixed JNI pointers --- LinphoneCoreImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f58247591..8e2a83008 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -568,6 +568,10 @@ class LinphoneCoreImpl implements LinphoneCore { private long getCallPtr(LinphoneCall call) { return ((LinphoneCallImpl)call).nativePtr; } + + private long getCallParamsPtr(LinphoneCallParams callParams) { + return ((LinphoneCallParamsImpl)callParams).nativePtr; + } private native int transferCall(long nativePtr, long callPtr, String referTo); public synchronized void transferCall(LinphoneCall call, String referTo) { @@ -671,26 +675,26 @@ class LinphoneCoreImpl implements LinphoneCore { @Override public native boolean isTunnelAvailable(); - private native void acceptCallWithParams(long nativePtr, LinphoneCall aCall, - LinphoneCallParams params); + private native void acceptCallWithParams(long nativePtr, long aCall, + long params); @Override public void acceptCallWithParams(LinphoneCall aCall, LinphoneCallParams params) throws LinphoneCoreException { - acceptCallWithParams(nativePtr, aCall, params); + acceptCallWithParams(nativePtr, getCallPtr(aCall), getCallParamsPtr(params)); } - private native void acceptCallUpdate(long nativePtr, LinphoneCall aCall, LinphoneCallParams params); + private native void acceptCallUpdate(long nativePtr, long aCall, long params); @Override public void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params) throws LinphoneCoreException { - acceptCallUpdate(nativePtr, aCall, params); + acceptCallUpdate(nativePtr, getCallPtr(aCall), getCallParamsPtr(params)); } - private native void deferCallUpdate(long nativePtr, LinphoneCall aCall); + private native void deferCallUpdate(long nativePtr, long aCall); @Override public void deferCallUpdate(LinphoneCall aCall) throws LinphoneCoreException { - deferCallUpdate(nativePtr, aCall); + deferCallUpdate(nativePtr, getCallPtr(aCall)); } private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept); From 571948eb7d11f318ff8d158658889daab4cb932a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 8 Mar 2012 16:04:20 +0100 Subject: [PATCH 174/288] Dynamic video with asking dependings on the settings + linphone submodule updated --- LinphoneCoreImpl.java | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 8e2a83008..b79d19306 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -589,21 +589,21 @@ class LinphoneCoreImpl implements LinphoneCore { return (LinphoneCall) findCallFromUri(nativePtr, uri); } - public MediaEncryption getMediaEncryption() { + public synchronized MediaEncryption getMediaEncryption() { return MediaEncryption.fromInt(getMediaEncryption(nativePtr)); } - public boolean isMediaEncryptionMandatory() { + public synchronized boolean isMediaEncryptionMandatory() { return isMediaEncryptionMandatory(nativePtr); } - public void setMediaEncryption(MediaEncryption menc) { + public synchronized void setMediaEncryption(MediaEncryption menc) { setMediaEncryption(nativePtr, menc.mValue); } - public void setMediaEncryptionMandatory(boolean yesno) { + public synchronized void setMediaEncryptionMandatory(boolean yesno) { setMediaEncryptionMandatory(nativePtr, yesno); } private native int getMaxCalls(long nativePtr); - public int getMaxCalls() { + public synchronized int getMaxCalls() { return getMaxCalls(nativePtr); } @Override @@ -614,61 +614,61 @@ class LinphoneCoreImpl implements LinphoneCore { } private native boolean soundResourcesLocked(long nativePtr); - public boolean soundResourcesLocked() { + public synchronized boolean soundResourcesLocked() { return soundResourcesLocked(nativePtr); } private native void setMaxCalls(long nativePtr, int max); @Override - public void setMaxCalls(int max) { + public synchronized void setMaxCalls(int max) { setMaxCalls(nativePtr, max); } private native boolean isEchoLimiterEnabled(long nativePtr); @Override - public boolean isEchoLimiterEnabled() { + public synchronized boolean isEchoLimiterEnabled() { return isEchoLimiterEnabled(nativePtr); } private native boolean mediaEncryptionSupported(long nativePtr, int menc); @Override - public boolean mediaEncryptionSupported(MediaEncryption menc) { + public synchronized boolean mediaEncryptionSupported(MediaEncryption menc) { return mediaEncryptionSupported(nativePtr,menc.mValue); } private native void setPlayFile(long nativePtr, String path); @Override - public void setPlayFile(String path) { + public synchronized void setPlayFile(String path) { setPlayFile(nativePtr, path); } private native void tunnelAddServerAndMirror(long nativePtr, String host, int port, int mirror, int ms); @Override - public void tunnelAddServerAndMirror(String host, int port, int mirror, int ms) { + public synchronized void tunnelAddServerAndMirror(String host, int port, int mirror, int ms) { tunnelAddServerAndMirror(nativePtr, host, port, mirror, ms); } private native void tunnelAutoDetect(long nativePtr); @Override - public void tunnelAutoDetect() { + public synchronized void tunnelAutoDetect() { tunnelAutoDetect(nativePtr); } private native void tunnelCleanServers(long nativePtr); @Override - public void tunnelCleanServers() { + public synchronized void tunnelCleanServers() { tunnelCleanServers(nativePtr); } private native void tunnelEnable(long nativePtr, boolean enable); @Override - public void tunnelEnable(boolean enable) { + public synchronized void tunnelEnable(boolean enable) { tunnelEnable(nativePtr, enable); } private native void tunnelEnableLogs(long nativePtr, boolean enable); @Override - public void tunnelEnableLogs(boolean enable) { + public synchronized void tunnelEnableLogs(boolean enable) { tunnelEnableLogs(nativePtr, enable); } @@ -678,27 +678,27 @@ class LinphoneCoreImpl implements LinphoneCore { private native void acceptCallWithParams(long nativePtr, long aCall, long params); @Override - public void acceptCallWithParams(LinphoneCall aCall, + public synchronized void acceptCallWithParams(LinphoneCall aCall, LinphoneCallParams params) throws LinphoneCoreException { acceptCallWithParams(nativePtr, getCallPtr(aCall), getCallParamsPtr(params)); } private native void acceptCallUpdate(long nativePtr, long aCall, long params); @Override - public void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params) + public synchronized void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params) throws LinphoneCoreException { acceptCallUpdate(nativePtr, getCallPtr(aCall), getCallParamsPtr(params)); } private native void deferCallUpdate(long nativePtr, long aCall); @Override - public void deferCallUpdate(LinphoneCall aCall) + public synchronized void deferCallUpdate(LinphoneCall aCall) throws LinphoneCoreException { deferCallUpdate(nativePtr, getCallPtr(aCall)); } private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept); - public void setVideoPolicy(boolean autoInitiate, boolean autoAccept) { + public synchronized void setVideoPolicy(boolean autoInitiate, boolean autoAccept) { setVideoPolicy(nativePtr, autoInitiate, autoAccept); } } From 623c8c7ef8ff9b5297762fbbaef0b3e5676e93e9 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 13 Mar 2012 22:05:41 +0100 Subject: [PATCH 175/288] add setUserAgent() method. --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index b79d19306..939a022d2 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -701,4 +701,9 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setVideoPolicy(boolean autoInitiate, boolean autoAccept) { setVideoPolicy(nativePtr, autoInitiate, autoAccept); } + private native void setUserAgent(long nativePtr, String name, String version); + @Override + public void setUserAgent(String name, String version) { + setUserAgent(nativePtr,name,version); + } } From 849f5c75d09b1df37d4420c62c2d562d2c56e14e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 22 Mar 2012 16:50:42 +0100 Subject: [PATCH 176/288] Added multicore option for MS --- LinphoneCoreImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 939a022d2..92faacc55 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -706,4 +706,10 @@ class LinphoneCoreImpl implements LinphoneCore { public void setUserAgent(String name, String version) { setUserAgent(nativePtr,name,version); } + + private native void setCpuCountNative(int count); + public void setCpuCount(int count) + { + setCpuCountNative(count); + } } From b24e3aba5f625e20f64dc43d21e0d2a4ac852882 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 17 Apr 2012 16:57:37 +0200 Subject: [PATCH 177/288] Fix last issue with pause + fix shared libs without neon problem --- LinphoneCoreFactoryImpl.java | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index a5ae7805f..3dedd06d0 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -20,9 +20,12 @@ package org.linphone.core; import java.io.File; import java.io.IOException; +import java.io.InputStream; import org.linphone.mediastream.Version; +import android.util.Log; + public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { private static void loadOptionalLibrary(String s) { @@ -35,10 +38,17 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { static { // FFMPEG (audio/video) - loadOptionalLibrary("avutil"); - loadOptionalLibrary("swscale"); - loadOptionalLibrary("avcore"); - loadOptionalLibrary("avcodec"); + if (!hasNeonInCpuFeatures()) { + loadOptionalLibrary("avutilnoneon"); + loadOptionalLibrary("swscalenoneon"); + loadOptionalLibrary("avcorenoneon"); + loadOptionalLibrary("avcodecnoneon"); + } else { + loadOptionalLibrary("avutil"); + loadOptionalLibrary("swscale"); + loadOptionalLibrary("avcore"); + loadOptionalLibrary("avcodec"); + } // OPENSSL (cryptography) // lin prefix avoids collision with libs in /system/lib @@ -56,7 +66,11 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { loadOptionalLibrary("bcg729"); //Main library - System.loadLibrary("linphone"); + if (!hasNeonInCpuFeatures()) { + System.loadLibrary("linphonenoneon"); + } else { + System.loadLibrary("linphone"); + } Version.dumpCapabilities(); } @@ -121,4 +135,28 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { public LinphoneFriend createLinphoneFriend() { return createLinphoneFriend(null); } + + public static boolean hasNeonInCpuFeatures() + { + ProcessBuilder cmd; + boolean result = false; + + try { + String[] args = {"/system/bin/cat", "/proc/cpuinfo"}; + cmd = new ProcessBuilder(args); + + Process process = cmd.start(); + InputStream in = process.getInputStream(); + byte[] re = new byte[1024]; + while(in.read(re) != -1){ + String line = new String(re); + if (line.startsWith("Features")) + result = line.contains("neon"); + } + in.close(); + } catch(IOException ex){ + ex.printStackTrace(); + } + return result; + } } From d0501c8328f9008b65091ee106e91d95b4ffb1f6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 19 Apr 2012 16:35:29 +0200 Subject: [PATCH 178/288] Fix video preferences issue --- LinphoneCoreFactoryImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 3dedd06d0..29f1c58ca 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -150,8 +150,10 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { byte[] re = new byte[1024]; while(in.read(re) != -1){ String line = new String(re); - if (line.startsWith("Features")) + if (line.startsWith("Features")) { result = line.contains("neon"); + break; + } } in.close(); } catch(IOException ex){ From cae534589d206da63b708757aaee80602662bf14 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 25 Apr 2012 14:29:28 +0200 Subject: [PATCH 179/288] Important ms2 update + Java 1.3 compatible --- LinphoneCoreImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 92faacc55..597f647f3 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -542,9 +542,9 @@ class LinphoneCoreImpl implements LinphoneCore { terminateAllCalls(nativePtr); } private native Object getCall(long nativePtr, int position); - @SuppressWarnings("unchecked") public synchronized List getCalls() { + @SuppressWarnings("unchecked") public synchronized Vector getCalls() { int size = getCallsNb(nativePtr); - List calls = new ArrayList(size); + Vector calls = new Vector(size); for (int i=0; i < size; i++) { calls.add((LinphoneCall)getCall(nativePtr, i)); } From 058e011ce1f33e2b2d5c60ac2668730753a95fd4 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 27 Apr 2012 15:42:35 +0200 Subject: [PATCH 180/288] Fix issues/behaviour on smartphones + update linphone/ms2/ortp --- LinphoneCoreImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 92faacc55..0dd655fcd 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,8 +20,6 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import java.util.Vector; @@ -542,9 +540,9 @@ class LinphoneCoreImpl implements LinphoneCore { terminateAllCalls(nativePtr); } private native Object getCall(long nativePtr, int position); - @SuppressWarnings("unchecked") public synchronized List getCalls() { + @SuppressWarnings("unchecked") public synchronized Vector getCalls() { int size = getCallsNb(nativePtr); - List calls = new ArrayList(size); + Vector calls = new Vector(size); for (int i=0; i < size; i++) { calls.add((LinphoneCall)getCall(nativePtr, i)); } From fb7cab25589abcbcc52099ffd8a621bbcb1ff1b6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 27 Apr 2012 16:53:03 +0200 Subject: [PATCH 181/288] Fixes for smartphones --- LinphoneCoreFactoryImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 29f1c58ca..99c880e37 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -68,6 +68,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library if (!hasNeonInCpuFeatures()) { System.loadLibrary("linphonenoneon"); + Log.w("linphone", "No-neon liblinphone loaded"); } else { System.loadLibrary("linphone"); } @@ -150,7 +151,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { byte[] re = new byte[1024]; while(in.read(re) != -1){ String line = new String(re); - if (line.startsWith("Features")) { + if (line.contains("Features")) { result = line.contains("neon"); break; } From 4f108428984e0e32a2deb69caa2374b6b6e7eccd Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 2 May 2012 10:12:08 +0200 Subject: [PATCH 182/288] replace vectores by arrays in linphone core api --- LinphoneCoreImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0dd655fcd..0b2996a03 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -195,11 +195,11 @@ class LinphoneCoreImpl implements LinphoneCore { acceptCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr); } - public synchronized Vector getCallLogs() { + public synchronized LinphoneCallLog[] getCallLogs() { isValid(); - Vector logs = new Vector(); + LinphoneCallLog[] logs = new LinphoneCallLog[getNumberOfCallLogs(nativePtr)]; for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) { - logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i))); + logs[i] = new LinphoneCallLogImpl(getCallLog(nativePtr, i)); } return logs; } @@ -540,11 +540,11 @@ class LinphoneCoreImpl implements LinphoneCore { terminateAllCalls(nativePtr); } private native Object getCall(long nativePtr, int position); - @SuppressWarnings("unchecked") public synchronized Vector getCalls() { + public synchronized LinphoneCall[] getCalls() { int size = getCallsNb(nativePtr); - Vector calls = new Vector(size); + LinphoneCall[] calls = new LinphoneCall[size]; for (int i=0; i < size; i++) { - calls.add((LinphoneCall)getCall(nativePtr, i)); + calls[i]=((LinphoneCall)getCall(nativePtr, i)); } return calls; } From bbde983c9bb2209ded4d121ec25674370ac31799 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 May 2012 10:46:41 +0200 Subject: [PATCH 183/288] Load neon liblinphone if fails to load no-neon liblinphone --- LinphoneCoreFactoryImpl.java | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 99c880e37..8cc721e90 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -28,21 +28,30 @@ import android.util.Log; public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { - private static void loadOptionalLibrary(String s) { + private static boolean loadOptionalLibrary(String s) { try { System.loadLibrary(s); + return true; } catch (Throwable e) { Log.w("Unable to load optional library lib", s); } + return false; } static { // FFMPEG (audio/video) if (!hasNeonInCpuFeatures()) { - loadOptionalLibrary("avutilnoneon"); - loadOptionalLibrary("swscalenoneon"); - loadOptionalLibrary("avcorenoneon"); - loadOptionalLibrary("avcodecnoneon"); + boolean noNeonLibrariesLoaded = true; + noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avutilnoneon"); + noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("swscalenoneon"); + noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avcorenoneon"); + noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avcodecnoneon"); + if (!noNeonLibrariesLoaded) { + loadOptionalLibrary("avutil"); + loadOptionalLibrary("swscale"); + loadOptionalLibrary("avcore"); + loadOptionalLibrary("avcodec"); + } } else { loadOptionalLibrary("avutil"); loadOptionalLibrary("swscale"); @@ -67,8 +76,13 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library if (!hasNeonInCpuFeatures()) { - System.loadLibrary("linphonenoneon"); - Log.w("linphone", "No-neon liblinphone loaded"); + try { + System.loadLibrary("linphonenoneon"); + Log.w("linphone", "No-neon liblinphone loaded"); + } catch (UnsatisfiedLinkError ule) { + Log.w("linphone", "Failed to load no-neon liblinphone, loading neon liblinphone"); + System.loadLibrary("linphone"); + } } else { System.loadLibrary("linphone"); } From 8fd5f5b9f068b3ac4efd059c76029d7f7136acc6 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 23 May 2012 11:53:10 +0200 Subject: [PATCH 184/288] update linphone for ms2 bugfix for phones having more than 2 cameras --- LinphoneCoreImpl.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0b2996a03..54f6383a0 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -664,12 +664,6 @@ class LinphoneCoreImpl implements LinphoneCore { tunnelEnable(nativePtr, enable); } - private native void tunnelEnableLogs(long nativePtr, boolean enable); - @Override - public synchronized void tunnelEnableLogs(boolean enable) { - tunnelEnableLogs(nativePtr, enable); - } - @Override public native boolean isTunnelAvailable(); From 9806cc6b5d0d76accbb2b91e9f104d321dc99f9f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 23 May 2012 17:38:16 +0200 Subject: [PATCH 185/288] Updated libs compilation --- LinphoneCoreFactoryImpl.java | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 8cc721e90..baed45873 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -40,22 +40,16 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { static { // FFMPEG (audio/video) + loadOptionalLibrary("avutil"); + loadOptionalLibrary("swscale"); + loadOptionalLibrary("avcore"); + if (!hasNeonInCpuFeatures()) { - boolean noNeonLibrariesLoaded = true; - noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avutilnoneon"); - noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("swscalenoneon"); - noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avcorenoneon"); - noNeonLibrariesLoaded = noNeonLibrariesLoaded && loadOptionalLibrary("avcodecnoneon"); + boolean noNeonLibrariesLoaded = loadOptionalLibrary("avcodecnoneon"); if (!noNeonLibrariesLoaded) { - loadOptionalLibrary("avutil"); - loadOptionalLibrary("swscale"); - loadOptionalLibrary("avcore"); loadOptionalLibrary("avcodec"); } } else { - loadOptionalLibrary("avutil"); - loadOptionalLibrary("swscale"); - loadOptionalLibrary("avcore"); loadOptionalLibrary("avcodec"); } @@ -77,7 +71,11 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library if (!hasNeonInCpuFeatures()) { try { - System.loadLibrary("linphonenoneon"); + if (isArmv5()) { + System.loadLibrary("linphonearmv5"); + } else { + System.loadLibrary("linphonenoneon"); + } Log.w("linphone", "No-neon liblinphone loaded"); } catch (UnsatisfiedLinkError ule) { Log.w("linphone", "Failed to load no-neon liblinphone, loading neon liblinphone"); @@ -176,4 +174,9 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } return result; } + + public static boolean isArmv5() + { + return System.getProperty("os.arch").contains("armv5"); + } } From 99ace7d2fd1a0f57bc1a562374ea0bc7bf71dea4 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 1 Jun 2012 09:45:47 +0200 Subject: [PATCH 186/288] Fix armv6 loadling liblinphone issue --- LinphoneCoreFactoryImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index baed45873..7d0be46e3 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -71,7 +71,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library if (!hasNeonInCpuFeatures()) { try { - if (isArmv5()) { + if (!isArmv7()) { System.loadLibrary("linphonearmv5"); } else { System.loadLibrary("linphonenoneon"); @@ -175,8 +175,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { return result; } - public static boolean isArmv5() + public static boolean isArmv7() { - return System.getProperty("os.arch").contains("armv5"); + return System.getProperty("os.arch").contains("armv7"); } } From 7db25e2e318a591c0c175782e244af18fab44915 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 18 Jun 2012 17:00:26 +0200 Subject: [PATCH 187/288] add tunnelSetHttpProxy() --- LinphoneCallLogImpl.java | 10 ++++++++++ LinphoneCoreImpl.java | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index 1bdb84720..895e27a38 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -45,5 +45,15 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public CallStatus getStatus() { throw new RuntimeException("not implemented yet"); } + @Override + public String getStartDate() { + // TODO Auto-generated method stub + return null; + } + @Override + public int getCallDuration() { + // TODO Auto-generated method stub + return 0; + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 54f6383a0..d02f69cfb 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -704,4 +704,25 @@ class LinphoneCoreImpl implements LinphoneCore { { setCpuCountNative(count); } + private native void tunnelSetHttpProxyNative(long nativePtr, String proxy_host, int port, String username, String password); + @Override + public void tunnelSetHttpProxy(String proxy_host, int port, + String username, String password) { + tunnelSetHttpProxyNative(nativePtr,proxy_host, port, username, password); + } + @Override + public void removeCallLog(LinphoneCallLog log) { + // TODO Auto-generated method stub + + } + @Override + public int getMissedCallsCount() { + // TODO Auto-generated method stub + return 0; + } + @Override + public void resetMissedCallsCount() { + // TODO Auto-generated method stub + + } } From d5a3e7b345d894a1fc40691d1cd7c242947ebe11 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 21 Jun 2012 10:05:25 +0200 Subject: [PATCH 188/288] First changes for the new UI --- LinphoneCallLogImpl.java | 18 +++- LinphoneCoreImpl.java | 18 +++- tutorials/AndroidTutorialNotifier.java | 50 --------- tutorials/TutorialBuddyStatusActivity.java | 109 -------------------- tutorials/TutorialChatRoomActivity.java | 98 ------------------ tutorials/TutorialHelloWorldActivity.java | 98 ------------------ tutorials/TutorialRegistrationActivity.java | 103 ------------------ 7 files changed, 31 insertions(+), 463 deletions(-) delete mode 100644 tutorials/AndroidTutorialNotifier.java delete mode 100644 tutorials/TutorialBuddyStatusActivity.java delete mode 100644 tutorials/TutorialChatRoomActivity.java delete mode 100644 tutorials/TutorialHelloWorldActivity.java delete mode 100644 tutorials/TutorialRegistrationActivity.java diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index 1bdb84720..996b51c10 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -26,11 +26,14 @@ class LinphoneCallLogImpl implements LinphoneCallLog { private native long getFrom(long nativePtr); private native long getTo(long nativePtr); private native boolean isIncoming(long nativePtr); + private native int getStatus(long nativePtr); + private native String getStartDate(long nativePtr); + private native int getCallDuration(long nativePtr); + LinphoneCallLogImpl(long aNativePtr) { nativePtr = aNativePtr; } - public CallDirection getDirection() { return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing; } @@ -43,7 +46,18 @@ class LinphoneCallLogImpl implements LinphoneCallLog { return new LinphoneAddressImpl(getTo(nativePtr)); } public CallStatus getStatus() { - throw new RuntimeException("not implemented yet"); + return LinphoneCallLog.CallStatus.fromInt(getStatus(nativePtr)); } + public long getNativePtr() { + return nativePtr; + } + + public String getStartDate() { + return getStartDate(nativePtr); + } + + public int getCallDuration() { + return getCallDuration(nativePtr); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 54f6383a0..75e885253 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,12 +20,10 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import java.util.Vector; class LinphoneCoreImpl implements LinphoneCore { - @SuppressWarnings("unused") private final LinphoneCoreListener mListener; //to make sure to keep a reference on this object private long nativePtr = 0; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); @@ -108,7 +106,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setMediaEncryption(long nativePtr, int menc); private native boolean isMediaEncryptionMandatory(long nativePtr); private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno); - + private native void removeCallLog(long nativePtr, long callLogPtr); + private native int getMissedCallsCount(long nativePtr); + private native void resetMissedCallsCount(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -704,4 +704,16 @@ class LinphoneCoreImpl implements LinphoneCore { { setCpuCountNative(count); } + + public int getMissedCallsCount() { + return getMissedCallsCount(nativePtr); + } + + public void removeCallLog(LinphoneCallLog log) { + removeCallLog(nativePtr, log.getNativePtr()); + } + + public void resetMissedCallsCount() { + resetMissedCallsCount(nativePtr); + } } diff --git a/tutorials/AndroidTutorialNotifier.java b/tutorials/AndroidTutorialNotifier.java deleted file mode 100644 index 7721f7dc1..000000000 --- a/tutorials/AndroidTutorialNotifier.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -AndroidTutorialNotifier.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.tutorials; - -import android.os.Handler; -import android.widget.TextView; - -/** - * Write notifications to a TextView widget. - * This is an helper class, not a test activity. - * - * @author Guillaume Beraudo - * - */ -class AndroidTutorialNotifier extends TutorialNotifier { - - private Handler mHandler; - private TextView outputTextView; - - public AndroidTutorialNotifier(Handler mHandler, final TextView outputTextView) { - this.mHandler = mHandler; - this.outputTextView = outputTextView; - } - - - @Override - public void notify(final String s) { - mHandler.post(new Runnable() { - public void run() { - outputTextView.setText(s + "\n" + outputTextView.getText()); - } - }); - } -} diff --git a/tutorials/TutorialBuddyStatusActivity.java b/tutorials/TutorialBuddyStatusActivity.java deleted file mode 100644 index 1bf4f981f..000000000 --- a/tutorials/TutorialBuddyStatusActivity.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -TutorialBuddyStatusActivity.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.tutorials; - -import org.linphone.R; -import org.linphone.core.LinphoneCoreException; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -/** - * Activity for displaying and starting the BuddyStatus example on Android phone. - * - * @author Guillaume Beraudo - * - */ -public class TutorialBuddyStatusActivity extends Activity { - - private static final String defaultSipAddress = "sip:"; - private TextView sipAddressWidget; - private TextView mySipAddressWidget; - private TextView mySipPasswordWidget; - - private TutorialBuddyStatus tutorial; - private Handler mHandler = new Handler() ; - private Button buttonCall; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.hello_world); - sipAddressWidget = (TextView) findViewById(R.id.AddressId); - sipAddressWidget.setText(defaultSipAddress); - - mySipAddressWidget = (TextView) findViewById(R.id.MyAddressId); - mySipAddressWidget.setVisibility(View.VISIBLE); - mySipPasswordWidget = (TextView) findViewById(R.id.Password); - mySipPasswordWidget.setVisibility(TextView.VISIBLE); - - - // Output text to the outputText widget - final TextView outputText = (TextView) findViewById(R.id.OutputText); - final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); - - - // Create BuddyStatus object - tutorial = new TutorialBuddyStatus(notifier); - - - - // Assign call action to call button - buttonCall = (Button) findViewById(R.id.CallButton); - buttonCall.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - TutorialLaunchingThread thread = new TutorialLaunchingThread(); - buttonCall.setEnabled(false); - thread.start(); - } - }); - - // Assign stop action to stop button - Button buttonStop = (Button) findViewById(R.id.ButtonStop); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - tutorial.stopMainLoop(); - } - }); - } - - - private class TutorialLaunchingThread extends Thread { - @Override - public void run() { - super.run(); - try { - String myIdentity = mySipAddressWidget.getText().length()>0?mySipAddressWidget.getText().toString():null; - String myPassword = mySipPasswordWidget.getText().length()>0?mySipPasswordWidget.getText().toString():null; - tutorial.launchTutorial(sipAddressWidget.getText().toString(), myIdentity, myPassword); - mHandler.post(new Runnable() { - public void run() { - buttonCall.setEnabled(true); - } - }); - } catch (LinphoneCoreException e) { - e.printStackTrace(); - } - } - } -} diff --git a/tutorials/TutorialChatRoomActivity.java b/tutorials/TutorialChatRoomActivity.java deleted file mode 100644 index f7dab4ce7..000000000 --- a/tutorials/TutorialChatRoomActivity.java +++ /dev/null @@ -1,98 +0,0 @@ -/* -TutorialChatRoomActivity.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.tutorials; - -import org.linphone.R; -import org.linphone.core.LinphoneCoreException; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -/** - * Activity for displaying and starting the chatroom example on Android phone. - * - * @author Guillaume Beraudo - * - */ -public class TutorialChatRoomActivity extends Activity { - - private static final String defaultSipAddress = "sip:"; - private TextView sipAddressWidget; - private TutorialChatRoom tutorial; - private Handler mHandler = new Handler() ; - private Button buttonCall; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.hello_world); - sipAddressWidget = (TextView) findViewById(R.id.AddressId); - sipAddressWidget.setText(defaultSipAddress); - - // Output text to the outputText widget - final TextView outputText = (TextView) findViewById(R.id.OutputText); - final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); - - - // Create HelloWorld object - tutorial = new TutorialChatRoom(notifier); - - - - // Assign call action to call button - buttonCall = (Button) findViewById(R.id.CallButton); - buttonCall.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - TutorialLaunchingThread thread = new TutorialLaunchingThread(); - buttonCall.setEnabled(false); - thread.start(); - } - }); - - // Assign stop action to stop button - Button buttonStop = (Button) findViewById(R.id.ButtonStop); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - tutorial.stopMainLoop(); - } - }); - } - - - private class TutorialLaunchingThread extends Thread { - @Override - public void run() { - super.run(); - try { - tutorial.launchTutorial(sipAddressWidget.getText().toString()); - mHandler.post(new Runnable() { - public void run() { - buttonCall.setEnabled(true); - } - }); - } catch (LinphoneCoreException e) { - e.printStackTrace(); - } - } - } -} diff --git a/tutorials/TutorialHelloWorldActivity.java b/tutorials/TutorialHelloWorldActivity.java deleted file mode 100644 index 60bd872c7..000000000 --- a/tutorials/TutorialHelloWorldActivity.java +++ /dev/null @@ -1,98 +0,0 @@ -/* -TutorialHelloWorldActivity.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.tutorials; - -import org.linphone.R; -import org.linphone.core.LinphoneCoreException; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -/** - * Activity for displaying and starting the HelloWorld example on Android phone. - * - * @author Guillaume Beraudo - * - */ -public class TutorialHelloWorldActivity extends Activity { - - private static final String defaultSipAddress = "sip:"; - private TextView sipAddressWidget; - private TutorialHelloWorld tutorial; - private Handler mHandler = new Handler() ; - private Button buttonCall; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.hello_world); - sipAddressWidget = (TextView) findViewById(R.id.AddressId); - sipAddressWidget.setText(defaultSipAddress); - - // Output text to the outputText widget - final TextView outputText = (TextView) findViewById(R.id.OutputText); - final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); - - - // Create HelloWorld object - tutorial = new TutorialHelloWorld(notifier); - - - - // Assign call action to call button - buttonCall = (Button) findViewById(R.id.CallButton); - buttonCall.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - TutorialLaunchingThread thread = new TutorialLaunchingThread(); - buttonCall.setEnabled(false); - thread.start(); - } - }); - - // Assign stop action to stop button - Button buttonStop = (Button) findViewById(R.id.ButtonStop); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - tutorial.stopMainLoop(); - } - }); - } - - - private class TutorialLaunchingThread extends Thread { - @Override - public void run() { - super.run(); - try { - tutorial.launchTutorial(sipAddressWidget.getText().toString()); - mHandler.post(new Runnable() { - public void run() { - buttonCall.setEnabled(true); - } - }); - } catch (LinphoneCoreException e) { - e.printStackTrace(); - } - } - } -} diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java deleted file mode 100644 index 94670480c..000000000 --- a/tutorials/TutorialRegistrationActivity.java +++ /dev/null @@ -1,103 +0,0 @@ -/* -TutorialRegistrationActivity.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.tutorials; - -import org.linphone.R; -import org.linphone.core.LinphoneCoreException; - -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -/** - * Activity for displaying and starting the registration example on Android phone. - * - * @author Guillaume Beraudo - * - */ -public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { - - private static final String defaultSipAddress = "sip:"; - private static final String defaultSipPassword = ""; - private TextView sipAddressWidget; - private TextView sipPasswordWidget; - private TutorialRegistration tutorial; - private Button buttonCall; - private Handler mHandler = new Handler(); - private TextView outputText; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.hello_world); - sipAddressWidget = (TextView) findViewById(R.id.AddressId); - sipAddressWidget.setText(defaultSipAddress); - sipPasswordWidget = (TextView) findViewById(R.id.Password); - sipPasswordWidget.setVisibility(TextView.VISIBLE); - sipPasswordWidget.setText(defaultSipPassword); - - // Output text to the outputText widget - outputText = (TextView) findViewById(R.id.OutputText); - final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); - - - // Create Tutorial object - tutorial = new TutorialRegistration(notifier); - - - - // Assign call action to call button - buttonCall = (Button) findViewById(R.id.CallButton); - buttonCall.setText("Register"); - buttonCall.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - TutorialLaunchingThread thread = new TutorialLaunchingThread(); - buttonCall.setEnabled(false); - thread.start(); - } - }); - - - Button buttonStop = (Button) findViewById(R.id.ButtonStop); - buttonStop.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - tutorial.stopMainLoop(); - } - }); - } - - - private class TutorialLaunchingThread extends Thread { - @Override - public void run() { - super.run(); - try { - tutorial.launchTutorial( - sipAddressWidget.getText().toString(), - sipPasswordWidget.getText().toString()); - } catch (LinphoneCoreException e) { - e.printStackTrace(); - outputText.setText(e.getMessage() +"\n"+outputText.getText()); - } - } - } -} From 93d8702c4acf5db01ba95cacfbc9bcb2d41d27c2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 21 Jun 2012 16:44:23 +0200 Subject: [PATCH 189/288] Some issues fixed + chat notification + account assistant started --- LinphoneCoreImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 75e885253..f732782d9 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -710,10 +710,18 @@ class LinphoneCoreImpl implements LinphoneCore { } public void removeCallLog(LinphoneCallLog log) { - removeCallLog(nativePtr, log.getNativePtr()); + removeCallLog(nativePtr, ((LinphoneCallLogImpl) log).getNativePtr()); } public void resetMissedCallsCount() { resetMissedCallsCount(nativePtr); } + + private native void tunnelSetHttpProxy(long nativePtr, String proxy_host, int port, + String username, String password); + @Override + public void tunnelSetHttpProxy(String proxy_host, int port, + String username, String password) { + tunnelSetHttpProxy(nativePtr, proxy_host, port, username, password); + } } From f2d72a7e63909af11f5e87b0f268252e0efc83d3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 27 Jun 2012 10:19:59 +0200 Subject: [PATCH 190/288] linphone updated + takeSnapshot and zoomVideo implementation added --- LinphoneCallImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 008b19df4..27ed253ef 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -155,4 +155,14 @@ class LinphoneCallImpl implements LinphoneCall { public float getPlayVolume() { return getPlayVolume(nativePtr); } + + private native void takeSnapshot(long nativePtr, String path); + public void takeSnapshot(String path) { + takeSnapshot(nativePtr, path); + } + + private native void zoomVideo(long nativePtr, float factor, float cx, float cy); + public void zoomVideo(float factor, float cx, float cy) { + zoomVideo(nativePtr, factor, cx, cy); + } } From f37b38d9e558cc91290c80b37556d7f4fb06b809 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 28 Jun 2012 13:36:54 +0200 Subject: [PATCH 191/288] Linphone submodule updated --- LinphoneCoreImpl.java | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index d02f69cfb..4a962e52e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -20,7 +20,6 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -import java.util.Vector; class LinphoneCoreImpl implements LinphoneCore { @@ -710,19 +709,24 @@ class LinphoneCoreImpl implements LinphoneCore { String username, String password) { tunnelSetHttpProxyNative(nativePtr,proxy_host, port, username, password); } - @Override + + private native void removeCallLog(long nativePtr, LinphoneCallLog log); public void removeCallLog(LinphoneCallLog log) { - // TODO Auto-generated method stub - + removeCallLog(nativePtr, log); } - @Override + + private native int getMissedCallsCount(long nativePtr); public int getMissedCallsCount() { - // TODO Auto-generated method stub - return 0; + return getMissedCallsCount(nativePtr); } - @Override + + private native void resetMissedCallsCount(long nativePtr); public void resetMissedCallsCount() { - // TODO Auto-generated method stub - + resetMissedCallsCount(nativePtr); + } + + private native void refreshRegisters(long nativePtr); + public void refreshRegisters() { + refreshRegisters(nativePtr); } } From cff354ab3cf2fc2311862af6bf1bcff1967f3760 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 29 Jun 2012 10:46:46 +0200 Subject: [PATCH 192/288] Linphone submodule updated + mjpeg encoder build added --- LinphoneCallImpl.java | 10 ++++++++++ LinphoneCoreImpl.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 008b19df4..5d886d43e 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -155,4 +155,14 @@ class LinphoneCallImpl implements LinphoneCall { public float getPlayVolume() { return getPlayVolume(nativePtr); } + + private native void takeSnapshot(long nativePtr, String path); + public void takeSnapshot(String path) { + takeSnapshot(nativePtr, path); + } + + private native void zoomVideo(long nativePtr, float factor, float cx, float cy); + public void zoomVideo(float factor, float cx, float cy) { + zoomVideo(nativePtr, factor, cx, cy); + } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index f732782d9..88084d237 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -724,4 +724,9 @@ class LinphoneCoreImpl implements LinphoneCore { String username, String password) { tunnelSetHttpProxy(nativePtr, proxy_host, port, username, password); } + + private native void refreshRegisters(long nativePtr); + public void refreshRegisters() { + refreshRegisters(nativePtr); + } } From 36d15495a07322de2ed4103263128218aeeaf50d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 1 Aug 2012 17:14:02 +0200 Subject: [PATCH 193/288] Drawable hdpi and mdpi + rotation issue fixed + memory leak fixed --- LinphoneCoreImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 88084d237..6f3683745 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -109,6 +109,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void removeCallLog(long nativePtr, long callLogPtr); private native int getMissedCallsCount(long nativePtr); private native void resetMissedCallsCount(long nativePtr); + private native boolean isNetworkReachable(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -441,7 +442,7 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } public synchronized boolean isNetworkReachable() { - throw new RuntimeException("Not implemented"); + return isNetworkReachable(nativePtr); } public synchronized void enableKeepAlive(boolean enable) { enableKeepAlive(nativePtr,enable); From 1d59cffb49795a4d588a749efd49ca150a348374 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 2 Aug 2012 10:13:32 +0200 Subject: [PATCH 194/288] Fix settings issues --- LinphoneCoreImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 6f3683745..1f182b47f 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -46,6 +46,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getNumberOfCallLogs(long nativePtr); private native void delete(long nativePtr); private native void setNetworkStateReachable(long nativePtr,boolean isReachable); + private native boolean isNetworkStateReachable(long nativePtr); private native void setPlaybackGain(long nativeptr, float gain); private native float getPlaybackGain(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); @@ -109,7 +110,6 @@ class LinphoneCoreImpl implements LinphoneCore { private native void removeCallLog(long nativePtr, long callLogPtr); private native int getMissedCallsCount(long nativePtr); private native void resetMissedCallsCount(long nativePtr); - private native boolean isNetworkReachable(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -442,8 +442,9 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } public synchronized boolean isNetworkReachable() { - return isNetworkReachable(nativePtr); + return isNetworkStateReachable(nativePtr); } + public synchronized void enableKeepAlive(boolean enable) { enableKeepAlive(nativePtr,enable); From e1e58fbe4c4ec1bae178920261da939470915782 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 2 Aug 2012 12:30:27 +0200 Subject: [PATCH 195/288] Using real useragent when creating an account --- LinphoneCoreImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 1f182b47f..e4f8dd062 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -110,6 +110,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void removeCallLog(long nativePtr, long callLogPtr); private native int getMissedCallsCount(long nativePtr); private native void resetMissedCallsCount(long nativePtr); + private native String getVersion(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -731,4 +732,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void refreshRegisters() { refreshRegisters(nativePtr); } + + @Override + public String getVersion() { + return getVersion(nativePtr); + } } From e7317543b33334d1b15b86c9c9cc61ed3dff313e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 8 Aug 2012 09:48:53 +0200 Subject: [PATCH 196/288] Updated linphone --- LinphoneCoreImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 4a962e52e..c742ea313 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -729,4 +729,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void refreshRegisters() { refreshRegisters(nativePtr); } + @Override + public String getVersion() { + // TODO Auto-generated method stub + return null; + } } From 4e34218a41abbbf175789a5ac37a75ebaa0307d0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 22 Aug 2012 09:21:58 +0200 Subject: [PATCH 197/288] Fix loading of liblinphone on x86 platform. --- LinphoneCoreFactoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index 7d0be46e3..a99509fa3 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -71,7 +71,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { //Main library if (!hasNeonInCpuFeatures()) { try { - if (!isArmv7()) { + if (!isArmv7() && !Version.isX86()) { System.loadLibrary("linphonearmv5"); } else { System.loadLibrary("linphonenoneon"); From c35f464e91a96a2f6dfcc0f23da44bd645daed07 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 28 Aug 2012 09:53:42 +0200 Subject: [PATCH 198/288] findPayloadType() now needs the number of channels in its parameters. --- LinphoneCoreImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index e4f8dd062..80dcaa48e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -56,7 +56,7 @@ 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 long findPayloadType(long nativePtr, String mime, int clockRate, int channels); private native int enablePayloadType(long nativePtr, long payloadType, boolean enable); private native void enableEchoCancellation(long nativePtr,boolean enable); private native boolean isEchoCancellationEnabled(long nativePtr); @@ -255,9 +255,9 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized boolean isMicMuted() { return isMicMuted(nativePtr); } - public synchronized PayloadType findPayloadType(String mime, int clockRate) { + public synchronized PayloadType findPayloadType(String mime, int clockRate, int channels) { isValid(); - long playLoadType = findPayloadType(nativePtr, mime, clockRate); + long playLoadType = findPayloadType(nativePtr, mime, clockRate, channels); if (playLoadType == 0) { return null; } else { From 3cec3cea4c100222a5e702ff69e9c473e3e09c10 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 5 Sep 2012 11:52:18 +0200 Subject: [PATCH 199/288] update linphone submodule, add new interface for chat. --- LinphoneChatRoomImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LinphoneChatRoomImpl.java b/LinphoneChatRoomImpl.java index 76874675d..3513f3283 100644 --- a/LinphoneChatRoomImpl.java +++ b/LinphoneChatRoomImpl.java @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.core.LinphoneChatMessage.StateListener; + class LinphoneChatRoomImpl implements LinphoneChatRoom { protected final long nativePtr; private native long getPeerAddress(long ptr); @@ -34,4 +36,14 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { public void sendMessage(String message) { sendMessage(nativePtr,message); } + @Override + public void sendMessage(LinphoneChatMessage msg, StateListener listener) { + // TODO To be implemened + + } + @Override + public void sendMessage(Object opaque, String message) { + // ignore, deprecated. + + } } From 4e5a4d36f1601f1383c20fce84bf84e5fa13d2b6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 7 Sep 2012 11:13:49 +0200 Subject: [PATCH 200/288] Sending regId to flexisip using proxyconfig contact params --- LinphoneProxyConfigImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index cf5b3a304..0b7aa7f6e 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -75,7 +75,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native int setRoute(long ptr,String uri); private native void enablePublish(long ptr,boolean enable); private native boolean publishEnabled(long ptr); - + private native void setContactParameters(long ptr, String params); public void enableRegister(boolean value) { enableRegister(nativePtr,value); @@ -143,4 +143,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { public boolean publishEnabled() { return publishEnabled(nativePtr); } + @Override + public void setContactParameters(String params) { + setContactParameters(nativePtr, params); + } } From 8fc61e182ceb71ed50ff9ec327cbf932ee67fd51 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 12 Sep 2012 18:09:11 +0200 Subject: [PATCH 201/288] Display if chat message delivered or not --- LinphoneChatMessageImpl.java | 38 ++++++++++++++++++++++++++++++++++++ LinphoneChatRoomImpl.java | 11 +++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 LinphoneChatMessageImpl.java diff --git a/LinphoneChatMessageImpl.java b/LinphoneChatMessageImpl.java new file mode 100644 index 000000000..a6c54e10d --- /dev/null +++ b/LinphoneChatMessageImpl.java @@ -0,0 +1,38 @@ +package org.linphone.core; + +public class LinphoneChatMessageImpl implements LinphoneChatMessage { + protected final long nativePtr; + private native void setUserData(long ptr); + private native String getMessage(long ptr); + private native LinphoneAddress getPeerAddress(long ptr); + + protected LinphoneChatMessageImpl(long aNativePtr) { + nativePtr = aNativePtr; + setUserData(); + } + + public long getNativePtr() { + return nativePtr; + } + + @Override + public Object getUserData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setUserData() { + setUserData(nativePtr); + } + + @Override + public String getMessage() { + return getMessage(nativePtr); + } + + @Override + public LinphoneAddress getPeerAddress() { + return getPeerAddress(nativePtr); + } +} diff --git a/LinphoneChatRoomImpl.java b/LinphoneChatRoomImpl.java index 3513f3283..806e8b68a 100644 --- a/LinphoneChatRoomImpl.java +++ b/LinphoneChatRoomImpl.java @@ -22,8 +22,10 @@ import org.linphone.core.LinphoneChatMessage.StateListener; class LinphoneChatRoomImpl implements LinphoneChatRoom { protected final long nativePtr; + private native long createLinphoneChatMessage(long ptr, String message); private native long getPeerAddress(long ptr); private native void sendMessage(long ptr, String message); + private native void sendMessage2(long ptr, long message, StateListener listener); protected LinphoneChatRoomImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -36,9 +38,10 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { public void sendMessage(String message) { sendMessage(nativePtr,message); } + @Override - public void sendMessage(LinphoneChatMessage msg, StateListener listener) { - // TODO To be implemened + public void sendMessage(LinphoneChatMessage message, StateListener listener) { + sendMessage2(nativePtr, message.getNativePtr(), listener); } @Override @@ -46,4 +49,8 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { // ignore, deprecated. } + @Override + public LinphoneChatMessage createLinphoneChatMessage(String message) { + return new LinphoneChatMessageImpl(createLinphoneChatMessage(nativePtr, message)); + } } From e6b68c893c172f040826dc0856495cbd52802709 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 12 Sep 2012 22:59:54 +0200 Subject: [PATCH 202/288] deprecate LinphoneCore.adjustSoftareVolume(), because it does the same as setPlaybackGain()o --- LinphoneCoreImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 80dcaa48e..8a870cc0e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -93,7 +93,6 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getSignalingTransportPort(long nativePtr, int code); private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls); private native void enableIpv6(long nativePtr,boolean enable); - private native void adjustSoftwareVolume(long nativePtr,int db); private native int pauseCall(long nativePtr, long callPtr); private native int pauseAllCalls(long nativePtr); private native int resumeCall(long nativePtr, long callPtr); @@ -474,7 +473,7 @@ class LinphoneCoreImpl implements LinphoneCore { enableIpv6(nativePtr,enable); } public synchronized void adjustSoftwareVolume(int i) { - adjustSoftwareVolume(nativePtr, i); + //deprecated, does the same as setPlaybackGain(). } public synchronized boolean pauseCall(LinphoneCall call) { From d0175b57d50cd3da78c1fae783787adffa4192bd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 18 Sep 2012 15:57:21 +0200 Subject: [PATCH 203/288] Linphone updated --- LinphoneChatMessageImpl.java | 10 ++++++++-- LinphoneChatRoomImpl.java | 6 +----- LinphoneCoreImpl.java | 5 +++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/LinphoneChatMessageImpl.java b/LinphoneChatMessageImpl.java index a93aae85f..62fac1dc3 100644 --- a/LinphoneChatMessageImpl.java +++ b/LinphoneChatMessageImpl.java @@ -4,9 +4,10 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage { protected final long nativePtr; private native void setUserData(long ptr); private native String getMessage(long ptr); - private native LinphoneAddress getPeerAddress(long ptr); + private native long getPeerAddress(long ptr); private native String getExternalBodyUrl(long ptr); private native void setExternalBodyUrl(long ptr, String url); + private native long getFrom(long ptr); protected LinphoneChatMessageImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -35,7 +36,7 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage { @Override public LinphoneAddress getPeerAddress() { - return getPeerAddress(nativePtr); + return new LinphoneAddressImpl(getPeerAddress(nativePtr)); } @Override @@ -47,4 +48,9 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage { public void setExternalBodyUrl(String url) { setExternalBodyUrl(nativePtr, url); } + + @Override + public LinphoneAddress getFrom() { + return new LinphoneAddressImpl(getFrom(nativePtr)); + } } diff --git a/LinphoneChatRoomImpl.java b/LinphoneChatRoomImpl.java index 806e8b68a..83141ad1c 100644 --- a/LinphoneChatRoomImpl.java +++ b/LinphoneChatRoomImpl.java @@ -44,11 +44,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { sendMessage2(nativePtr, message.getNativePtr(), listener); } - @Override - public void sendMessage(Object opaque, String message) { - // ignore, deprecated. - - } + @Override public LinphoneChatMessage createLinphoneChatMessage(String message) { return new LinphoneChatMessageImpl(createLinphoneChatMessage(nativePtr, message)); diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 8a870cc0e..8677cb285 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -736,4 +736,9 @@ class LinphoneCoreImpl implements LinphoneCore { public String getVersion() { return getVersion(nativePtr); } + + @Override + public PayloadType findPayloadType(String mime, int clockRate) { + return null; + } } From ade685701ff4c4c20f79b5c5225de48d25ca5f3e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 20 Sep 2012 17:59:02 +0200 Subject: [PATCH 204/288] GetRemoteParams returns null if needed --- LinphoneCallImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index 5d886d43e..e73a8aacf 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -76,7 +76,11 @@ class LinphoneCallImpl implements LinphoneCall { return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); } public LinphoneCallParams getRemoteParams() { - return new LinphoneCallParamsImpl(getRemoteParams(nativePtr)); + long remoteParamsPtr = getRemoteParams(nativePtr); + if (remoteParamsPtr == 0) { + return null; + } + return new LinphoneCallParamsImpl(remoteParamsPtr); } public void enableCamera(boolean enabled) { enableCamera(nativePtr, enabled); From adc966996b57d8c12a6efe583cabff2ce348be00 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 19 Sep 2012 17:24:38 +0200 Subject: [PATCH 205/288] Add JNI to access call statistics. --- LinphoneCallImpl.java | 15 +++++++ LinphoneCallStatsImpl.java | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 LinphoneCallStatsImpl.java diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index e73a8aacf..cf471f52c 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -23,6 +23,9 @@ class LinphoneCallImpl implements LinphoneCall { protected final long nativePtr; boolean ownPtr = false; + private LinphoneCallStats audioStats; + private LinphoneCallStats videoStats; + native private void finalize(long nativePtr); native private long getCallLog(long nativePtr); private native boolean isIncoming(long nativePtr); @@ -58,6 +61,18 @@ class LinphoneCallImpl implements LinphoneCall { return null; } } + public void setAudioStats(LinphoneCallStats stats) { + audioStats = stats; + } + public void setVideoStats(LinphoneCallStats stats) { + videoStats = stats; + } + public LinphoneCallStats getAudioStats() { + return audioStats; + } + public LinphoneCallStats getVideoStats() { + return videoStats; + } public CallDirection getDirection() { return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing; } diff --git a/LinphoneCallStatsImpl.java b/LinphoneCallStatsImpl.java new file mode 100644 index 000000000..ffc19eddc --- /dev/null +++ b/LinphoneCallStatsImpl.java @@ -0,0 +1,83 @@ +/* +LinPhoneCallStatsImpl.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 LinphoneCallStatsImpl implements LinphoneCallStats { + private int mediaType; + private float senderLossRate; + private float receiverLossRate; + private float senderInterarrivalJitter; + private float receiverInterarrivalJitter; + private float roundTripDelay; + private long latePacketsCumulativeNumber; + private float jitterBufferSize; + + private native int getMediaType(long nativeStatsPtr); + private native float getSenderLossRate(long nativeStatsPtr); + private native float getReceiverLossRate(long nativeStatsPtr); + private native float getSenderInterarrivalJitter(long nativeStatsPtr, long nativeCallPtr); + private native float getReceiverInterarrivalJitter(long nativeStatsPtr, long nativeCallPtr); + private native float getRoundTripDelay(long nativeStatsPtr); + private native long getLatePacketsCumulativeNumber(long nativeStatsPtr, long nativeCallPtr); + private native float getJitterBufferSize(long nativeStatsPtr); + + protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) { + mediaType = getMediaType(nativeStatsPtr); + senderLossRate = getSenderLossRate(nativeStatsPtr); + receiverLossRate = getReceiverLossRate(nativeStatsPtr); + senderInterarrivalJitter = getSenderInterarrivalJitter(nativeStatsPtr, nativeCallPtr); + receiverInterarrivalJitter = getReceiverInterarrivalJitter(nativeStatsPtr, nativeCallPtr); + roundTripDelay = getRoundTripDelay(nativeStatsPtr); + latePacketsCumulativeNumber = getLatePacketsCumulativeNumber(nativeStatsPtr, nativeCallPtr); + jitterBufferSize = getJitterBufferSize(nativeStatsPtr); + } + + public MediaType getMediaType() { + return MediaType.fromInt(mediaType); + } + + public float getSenderLossRate() { + return senderLossRate; + } + + public float getReceiverLossRate() { + return receiverLossRate; + } + + public float getSenderInterarrivalJitter() { + return senderInterarrivalJitter; + } + + public float getReceiverInterarrivalJitter() { + return receiverInterarrivalJitter; + } + + public float getRoundTripDelay() { + return roundTripDelay; + } + + public long getLatePacketsCumulativeNumber() { + return latePacketsCumulativeNumber; + } + + public float getJitterBufferSize() { + return jitterBufferSize; + } +} From 1799f1cb7e12b398e85981da900ec1f7d3f484e0 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 25 Sep 2012 10:54:42 +0200 Subject: [PATCH 206/288] Linphone updated --- LinphoneProxyConfigImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index 0b7aa7f6e..2295bce03 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -77,6 +77,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native boolean publishEnabled(long ptr); private native void setContactParameters(long ptr, String params); + private native int lookupCCCFromIso(long nativePtr, String iso); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); } @@ -147,4 +149,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { public void setContactParameters(String params) { setContactParameters(nativePtr, params); } + @Override + public int lookupCCCFromIso(String iso) { + return lookupCCCFromIso(nativePtr, iso); + } } From 767a567bd6b173cd72660c3d39237b52c440892c Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 25 Sep 2012 17:22:59 +0200 Subject: [PATCH 207/288] Extend call statistics JNI. Add interface for download bandwidth, upload bandwidth and ICE state. --- LinphoneCallStatsImpl.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/LinphoneCallStatsImpl.java b/LinphoneCallStatsImpl.java index ffc19eddc..53fcb5ffd 100644 --- a/LinphoneCallStatsImpl.java +++ b/LinphoneCallStatsImpl.java @@ -21,6 +21,9 @@ package org.linphone.core; class LinphoneCallStatsImpl implements LinphoneCallStats { private int mediaType; + private int iceState; + private float downloadBandwidth; + private float uploadBandwidth; private float senderLossRate; private float receiverLossRate; private float senderInterarrivalJitter; @@ -30,6 +33,9 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { private float jitterBufferSize; private native int getMediaType(long nativeStatsPtr); + private native int getIceState(long nativeStatsPtr); + private native float getDownloadBandwidth(long nativeStatsPtr); + private native float getUploadBandwidth(long nativeStatsPtr); private native float getSenderLossRate(long nativeStatsPtr); private native float getReceiverLossRate(long nativeStatsPtr); private native float getSenderInterarrivalJitter(long nativeStatsPtr, long nativeCallPtr); @@ -40,6 +46,9 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) { mediaType = getMediaType(nativeStatsPtr); + iceState = getIceState(nativeStatsPtr); + downloadBandwidth = getDownloadBandwidth(nativeStatsPtr); + uploadBandwidth = getUploadBandwidth(nativeStatsPtr); senderLossRate = getSenderLossRate(nativeStatsPtr); receiverLossRate = getReceiverLossRate(nativeStatsPtr); senderInterarrivalJitter = getSenderInterarrivalJitter(nativeStatsPtr, nativeCallPtr); @@ -53,6 +62,18 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { return MediaType.fromInt(mediaType); } + public IceState getIceState() { + return IceState.fromInt(iceState); + } + + public float getDownloadBandwidth() { + return downloadBandwidth; + } + + public float getUploadBandwidth() { + return uploadBandwidth; + } + public float getSenderLossRate() { return senderLossRate; } From f385c6d2f08c8a00fb96d7f73da5ec16dde3300e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 26 Sep 2012 12:42:54 +0200 Subject: [PATCH 208/288] Add JNI for used codecs. --- LinphoneCallParamsImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/LinphoneCallParamsImpl.java b/LinphoneCallParamsImpl.java index bb7e9b1ab..3c4514017 100644 --- a/LinphoneCallParamsImpl.java +++ b/LinphoneCallParamsImpl.java @@ -32,6 +32,8 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { private native void audioBandwidth(long nativePtr, int bw); private native void setMediaEncryption(long nativePtr, int menc); private native int getMediaEncryption(long nativePtr); + private native long getUsedAudioCodec(long nativePtr); + private native long getUsedVideoCodec(long nativePtr); private native void destroy(long nativePtr); @@ -61,6 +63,18 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { setMediaEncryption(nativePtr, menc.mValue); } + public PayloadType getUsedAudioCodec() { + long ptr = getUsedAudioCodec(nativePtr); + if (ptr == 0) return null; + return new PayloadTypeImpl(ptr); + } + + public PayloadType getUsedVideoCodec() { + long ptr = getUsedVideoCodec(nativePtr); + if (ptr == 0) return null; + return new PayloadTypeImpl(ptr); + } + private native boolean localConferenceMode(long nativePtr); public boolean localConferenceMode() { return localConferenceMode(nativePtr); From edec0b18e7adc3a3718a2b8a84efa006822ec12c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 2 Oct 2012 11:04:32 +0200 Subject: [PATCH 209/288] fix tunnel crash --- coreapi/TunnelManager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 9b5dffd29..71ecc5184 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -59,12 +59,12 @@ int TunnelManager::eXosipRecvfrom(int fd, void *buf, size_t len, int flags, stru int TunnelManager::eXosipSelect(int max_fds, fd_set *s1, fd_set *s2, fd_set *s3, struct timeval *tv,void* userdata){ struct timeval begin,cur; TunnelManager* lTunnelMgr=(TunnelManager*)userdata; - if (tv!=0 && tv->tv_sec){ + if (s1 && tv!=0 && tv->tv_sec){ /*this is the select from udp.c, the one that is interesting to us*/ NativeSocket udp_fd=(NativeSocket)eXosip_get_udp_socket(); NativeSocket controlfd=(NativeSocket)eXosip_get_control_fd(); - FD_ZERO(s1); + FD_ZERO(s1); gettimeofday(&begin,NULL); do{ struct timeval abit; @@ -258,7 +258,7 @@ void TunnelManager::processTunnelEvent(const Event &ev){ lTransport.tls_port=0; lTransport.dtls_port=0; - linphone_core_set_sip_transports(mCore, &lTransport); + linphone_core_set_sip_transports(mCore, &lTransport); //register if (lProxy) { linphone_proxy_config_done(lProxy); From b72f80fdc704f266f8e3950c2f88ab8357707ca7 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 2 Oct 2012 11:05:35 +0200 Subject: [PATCH 210/288] Add parameters check in call statistics JNI. --- coreapi/linphonecore_jni.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index a237b1865..ff654b8c3 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1275,7 +1275,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; const report_block_t *srb = NULL; - if (!stats->sent_rtcp) + if (!stats || !stats->sent_rtcp) return (jfloat)0.0; /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ if (stats->sent_rtcp->b_cont != NULL) @@ -1292,7 +1292,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRa const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; const report_block_t *rrb = NULL; - if (!stats->received_rtcp) + if (!stats || !stats->received_rtcp) return (jfloat)0.0; /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ if (stats->received_rtcp->b_cont != NULL) @@ -1308,11 +1308,14 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRa extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; const LinphoneCall *call = (LinphoneCall *)call_ptr; - const LinphoneCallParams *params = linphone_call_get_current_params(call); + const LinphoneCallParams *params; const PayloadType *pt; const report_block_t *srb = NULL; - if (!stats->sent_rtcp) + if (!stats || !call || !stats->sent_rtcp) + return (jfloat)0.0; + params = linphone_call_get_current_params(call); + if (!params) return (jfloat)0.0; /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ if (stats->sent_rtcp->b_cont != NULL) @@ -1332,11 +1335,14 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarr extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; const LinphoneCall *call = (LinphoneCall *)call_ptr; - const LinphoneCallParams *params = linphone_call_get_current_params(call); + const LinphoneCallParams *params; const PayloadType *pt; const report_block_t *rrb = NULL; - if (!stats->received_rtcp) + if (!stats || !call || !stats->received_rtcp) + return (jfloat)0.0; + params = linphone_call_get_current_params(call); + if (!params) return (jfloat)0.0; /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ if (stats->received_rtcp->b_cont != NULL) @@ -1361,6 +1367,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumu LinphoneCall *call = (LinphoneCall *)call_ptr; rtp_stats_t rtp_stats; + if (!stats || !call) + return (jlong)0; memset(&rtp_stats, 0, sizeof(rtp_stats)); if (stats->type == LINPHONE_CALL_STATS_AUDIO) audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats); From 48512d1e101a95f201722c7a85e3bd28955eba54 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 1 Oct 2012 17:15:43 +0200 Subject: [PATCH 211/288] Delete LinphoneCallUpdated state and add LinphoneCallUpdating state. --- coreapi/callbacks.c | 11 +---------- coreapi/linphonecall.c | 10 ++++++---- coreapi/linphonecore.c | 5 +++-- coreapi/linphonecore.h | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 4e5661b35..7f901195f 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -302,11 +302,7 @@ static void call_accepted(SalOp *op){ linphone_core_update_streams (lc,call,md); linphone_call_set_state(call,LinphoneCallPausedByRemote,"Call paused by remote"); }else{ - if (call->state==LinphoneCallStreamsRunning){ - /*media was running before, the remote as acceted a call modification (that is - a reinvite made by us. We must notify the application this reinvite was accepted*/ - linphone_call_set_state(call, LinphoneCallUpdated, "Call updated"); - }else{ + if (call->state!=LinphoneCallUpdating){ if (call->state==LinphoneCallResuming){ if (lc->vtable.display_status){ lc->vtable.display_status(lc,_("Call resumed.")); @@ -343,11 +339,6 @@ static void call_ack(SalOp *op){ if (call->media_pending){ SalMediaDescription *md=sal_call_get_final_media_description(op); if (md && !sal_media_description_empty(md)){ - if (call->state==LinphoneCallStreamsRunning){ - /*media was running before, the remote as acceted a call modification (that is - a reinvite made by us. We must notify the application this reinvite was accepted*/ - linphone_call_set_state(call, LinphoneCallUpdated, "Call updated"); - } linphone_core_update_streams (lc,call,md); linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)"); }else{ diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index b2f53e5a5..9d82476bc 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -520,8 +520,8 @@ const char *linphone_call_state_to_string(LinphoneCallState cs){ return "LinphoneCallUpdatedByRemote"; case LinphoneCallIncomingEarlyMedia: return "LinphoneCallIncomingEarlyMedia"; - case LinphoneCallUpdated: - return "LinphoneCallUpdated"; + case LinphoneCallUpdating: + return "LinphoneCallUpdating"; case LinphoneCallReleased: return "LinphoneCallReleased"; } @@ -1828,7 +1828,7 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ linphone_call_delete_ice_session(call); } switch (call->state) { - case LinphoneCallStreamsRunning: + case LinphoneCallUpdating: linphone_core_start_update_call(call->core, call); break; case LinphoneCallUpdatedByRemote: @@ -1838,10 +1838,12 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ linphone_call_stop_media_streams_for_ice_gathering(call); linphone_core_proceed_with_invite_if_ready(call->core, call, NULL); break; - default: + case LinphoneCallIdle: linphone_call_stop_media_streams_for_ice_gathering(call); linphone_core_notify_incoming_call(call->core, call); break; + default: + break; } } else if (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) { linphone_core_start_accept_call_update(call->core, call); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 93c1a8cf3..dd0072d0a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2564,6 +2564,7 @@ int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){ int err=0; if (params!=NULL){ + linphone_call_set_state(call,LinphoneCallUpdating,"Updating call"); #ifdef VIDEO_ENABLED bool_t has_video = call->params.has_video; if ((call->ice_session != NULL) && (call->videostream != NULL) && !params->has_video) { @@ -2571,7 +2572,7 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho call->videostream->ice_check_list = NULL; } call->params = *params; - if ((call->ice_session != NULL) && (ice_session_state(call->ice_session) != IS_Completed) && !has_video && params->has_video) { + if ((call->ice_session != NULL) && !has_video && params->has_video) { /* Defer call update until the ICE candidates gathering process has finished. */ ms_message("Defer call update to gather ICE candidates"); update_local_media_description(lc, call); @@ -5030,7 +5031,7 @@ bool_t linphone_core_sound_resources_locked(LinphoneCore *lc){ case LinphoneCallConnected: case LinphoneCallRefered: case LinphoneCallIncomingEarlyMedia: - case LinphoneCallUpdated: + case LinphoneCallUpdating: return TRUE; default: break; diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 179ff0ce9..53ad38e9e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -343,7 +343,7 @@ typedef enum _LinphoneCallState{ LinphoneCallPausedByRemote, /** Date: Tue, 2 Oct 2012 11:41:58 +0200 Subject: [PATCH 212/288] Fix JNI newLinphoneAuthInfo --- coreapi/linphonecore_jni.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index ff654b8c3..3cd7b76cc 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1131,11 +1131,17 @@ extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo , jstring jrealm) { const char* username = env->GetStringUTFChars(jusername, NULL); + const char* userid = env->GetStringUTFChars(juserid, NULL); const char* password = env->GetStringUTFChars(jpassword, NULL); - jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL); + const char* ha1 = env->GetStringUTFChars(jha1, NULL); + const char* realm = env->GetStringUTFChars(jrealm, NULL); + jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm); env->ReleaseStringUTFChars(jusername, username); + env->ReleaseStringUTFChars(juserid, userid); env->ReleaseStringUTFChars(jpassword, password); + env->ReleaseStringUTFChars(jha1, ha1); + env->ReleaseStringUTFChars(jrealm, realm); return auth; } From a977e46cbce85aeae1e26824e7e096b377346009 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 2 Oct 2012 15:30:06 +0200 Subject: [PATCH 213/288] add call id to LinphoneCallLogs --- coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 5 +++++ coreapi/linphonecore.h | 3 ++- coreapi/sal.c | 6 +++++- coreapi/sal.h | 2 ++ coreapi/sal_eXosip2.c | 6 +++++- java/common/org/linphone/core/LinphoneCallLog.java | 4 ++++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index b2f53e5a5..1351f0eb9 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -411,6 +411,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro linphone_address_clean(from); linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip); linphone_call_init_common(call, from, to); + call->log->call_id=ms_strdup(sal_op_get_call_id(op)); /*must be known at that time*/ linphone_core_init_default_params(lc, &call->params); call->params.has_video &= !!lc->video_policy.automatically_accept; call->params.has_video &= linphone_core_media_description_contains_video_stream(sal_call_get_remote_media_description(op)); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 93c1a8cf3..66cb26eff 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -139,6 +139,7 @@ void call_logs_write_to_config_file(LinphoneCore *lc){ if (cl->refkey) lp_config_set_string(cfg,logsection,"refkey",cl->refkey); lp_config_set_float(cfg,logsection,"quality",cl->quality); lp_config_set_int(cfg,logsection,"video_enabled", cl->video_enabled); + lp_config_set_string(cfg,logsection,"call_id",cl->call_id); } for(;imax_call_logs;++i){ snprintf(logsection,sizeof(logsection),"call_log_%i",i); @@ -189,6 +190,8 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){ if (tmp) cl->refkey=ms_strdup(tmp); cl->quality=lp_config_get_float(cfg,logsection,"quality",-1); cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0); + cl->call_id=lp_config_get_string(cfg,logsection,"call_id",NULL); + if(cl->call_id) cl->call_id=ms_strdup(cl->call_id); lc->call_logs=ms_list_append(lc->call_logs,cl); }else break; } @@ -296,6 +299,7 @@ void linphone_call_log_destroy(LinphoneCallLog *cl){ if (cl->from!=NULL) linphone_address_destroy(cl->from); if (cl->to!=NULL) linphone_address_destroy(cl->to); if (cl->refkey!=NULL) ms_free(cl->refkey); + if (cl->call_id) ms_free((void*)cl->call_id); ms_free(cl); } @@ -2212,6 +2216,7 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call){ real_url=linphone_address_as_string(call->log->to); from=linphone_address_as_string(call->log->from); err=sal_call(call->op,from,real_url); + call->log->call_id=ms_strdup(sal_op_get_call_id(call->op)); /*must be known at that time*/ if (lc->sip_conf.sdp_200_ack){ call->media_pending=TRUE; diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 179ff0ce9..735f1a048 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -146,7 +146,7 @@ typedef struct _LinphoneCallLog{ LinphoneCallStatus status; /**< The status of the call*/ LinphoneAddress *from; /**origin; } - +const char* sal_op_get_call_id(const SalOp *op) { + return ((SalOpBase*)op)->call_id; +} void __sal_op_init(SalOp *b, Sal *sal){ memset(b,0,sizeof(SalOpBase)); ((SalOpBase*)b)->root=sal; @@ -310,6 +312,8 @@ void __sal_op_free(SalOp *op){ sal_media_description_unref(b->local_media); if (b->remote_media) sal_media_description_unref(b->remote_media); + if (b->call_id) + ms_free((void*)b->call_id); ms_free(op); } diff --git a/coreapi/sal.h b/coreapi/sal.h index 751cc6533..1bce846c6 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -207,6 +207,7 @@ typedef struct SalOpBase{ SalMediaDescription *local_media; SalMediaDescription *remote_media; void *user_pointer; + const char* call_id; } SalOpBase; @@ -373,6 +374,7 @@ const char *sal_op_get_network_origin(const SalOp *op); /*returns far-end "User-Agent" string */ const char *sal_op_get_remote_ua(const SalOp *op); void *sal_op_get_user_pointer(const SalOp *op); +const char* sal_op_get_call_id(const SalOp *op); /*Call API*/ int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index b09cae4ff..4b5c20539 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -603,6 +603,7 @@ int sal_call(SalOp *h, const char *from, const char *to){ int err; const char *route; osip_message_t *invite=NULL; + osip_call_id_t *callid; sal_op_set_from(h,from); sal_op_set_to(h,to); sal_exosip_fix_route(h); @@ -643,6 +644,8 @@ int sal_call(SalOp *h, const char *from, const char *to){ ms_error("Fail to send invite ! Error code %d", err); return -1; }else{ + callid=osip_message_get_call_id(invite); + osip_call_id_to_str(callid,(char **)(&h->base.call_id)); sal_add_call(h->base.root,h); } return 0; @@ -1018,6 +1021,8 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){ osip_call_info_t *call_info; char *tmp; sdp_message_t *sdp=eXosip_get_sdp_info(ev->request); + osip_call_id_t *callid=osip_message_get_call_id(ev->request); + osip_call_id_to_str(callid,(char**)(&op->base.call_id)); set_network_origin(op,ev->request); set_remote_ua(op,ev->request); @@ -1054,7 +1059,6 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){ op->tid=ev->tid; op->cid=ev->cid; op->did=ev->did; - sal_add_call(op->base.root,op); sal->callbacks.call_received(op); } diff --git a/java/common/org/linphone/core/LinphoneCallLog.java b/java/common/org/linphone/core/LinphoneCallLog.java index 40299e6d9..1abdb7bed 100644 --- a/java/common/org/linphone/core/LinphoneCallLog.java +++ b/java/common/org/linphone/core/LinphoneCallLog.java @@ -104,4 +104,8 @@ public interface LinphoneCallLog { * @return the call duration, in seconds */ public int getCallDuration(); + /** + * @return the call id from signaling + */ + public int getCallId(); } From 200a467069a98709ac94505a16f803526aee1732 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 2 Oct 2012 15:30:40 +0200 Subject: [PATCH 214/288] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index c3d6a0953..215e93d08 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit c3d6a095338c7d98647517b949e06e0b85f6443e +Subproject commit 215e93d083e9bc8913803ca836d850d3144f76f6 From 61312092bbda523c8fa98c9804d123a5308d2e57 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 2 Oct 2012 15:51:46 +0200 Subject: [PATCH 215/288] Update ms2 submodule for ICE fix. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 215e93d08..cfe804f4d 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 215e93d083e9bc8913803ca836d850d3144f76f6 +Subproject commit cfe804f4dbae7dc1b8cf6c63018b68b2fb52cd53 From 67ae4525c97cce6a0029d7180a9ff0bb66218ce0 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 2 Oct 2012 16:21:56 +0200 Subject: [PATCH 216/288] Some fixes --- LinphoneAuthInfoImpl.java | 2 +- LinphoneCallLogImpl.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index 7f9e54dd2..7d50a2fa5 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -23,7 +23,7 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo { private native long newLinphoneAuthInfo(String username, String userid, String passwd, String ha1,String realm); private native void delete(long ptr); protected LinphoneAuthInfoImpl(String username,String password, String realm) { - nativePtr = newLinphoneAuthInfo(username,null,password,null,realm); + nativePtr = newLinphoneAuthInfo(username,"",password,"",""); } protected void finalize() throws Throwable { delete(nativePtr); diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index 8972f0a76..ac03d3699 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -29,6 +29,7 @@ class LinphoneCallLogImpl implements LinphoneCallLog { private native int getStatus(long nativePtr); private native String getStartDate(long nativePtr); private native int getCallDuration(long nativePtr); + private native int getCallId(long nativePtr); LinphoneCallLogImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -60,4 +61,8 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public int getCallDuration() { return getCallDuration(nativePtr); } + @Override + public int getCallId() { + return getCallId(nativePtr); + } } From 6a0b67f9b55df4db3b3a7ea70e6eaa560c1fd3da Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 2 Oct 2012 16:51:31 +0200 Subject: [PATCH 217/288] add low bandwidth call param --- coreapi/linphonecall.c | 3 +++ coreapi/linphonecore.h | 9 ++++++++- coreapi/misc.c | 2 +- coreapi/private.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a37096697..95bc62106 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -854,6 +854,9 @@ const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallP return cp->video_codec; } +bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *cp) { + return cp->low_bandwidth; +} /** * Returns whether video is enabled. **/ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 5196d93dc..0209a3774 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -204,7 +204,14 @@ bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp); void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw); void linphone_call_params_destroy(LinphoneCallParams *cp); - +/** + * @ingroup call_control + * Use to know if this call has been configured in low bandwidth mode. + * This mode can be automatically discovered thanks to a stun server when activate_edge_workarounds=1 in section [net] of configuration file + *
When enabled, this param may transform a call request with video in audio only mode. + * @return TRUE if low bandwidth has been configured/detected + */ +bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *cp); /** * Enum describing failure reasons. * @ingroup initializing diff --git a/coreapi/misc.c b/coreapi/misc.c index 6f7aff698..e85005f28 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -586,7 +586,7 @@ void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, Linphone params->up_bw=params->down_bw=edge_bw; params->up_ptime=params->down_ptime=edge_ptime; params->has_video=FALSE; - + params->low_bandwidth=TRUE; }/*else use default settings */ } } diff --git a/coreapi/private.h b/coreapi/private.h index ea21a967a..0cefb1476 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -79,7 +79,7 @@ struct _LinphoneCallParams{ bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t in_conference; /*in conference mode */ bool_t pad; - + bool_t low_bandwidth; }; typedef struct _CallCallbackObj From 8bec813e52a4949f723b94918f4eb37ac5faad86 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 2 Oct 2012 17:06:38 +0200 Subject: [PATCH 218/288] JNI DTMF listener --- coreapi/linphonecore_jni.cc | 17 +++++++++++++++++ .../org/linphone/core/LinphoneCoreListener.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 3cd7b76cc..273d46aa9 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -110,6 +110,7 @@ public: vTable.call_encryption_changed = callEncryptionChange; vTable.text_received = text_received; vTable.message_received = message_received; + vTable.dtmf_received = dtmf_received; vTable.new_subscription_request = new_subscription_request; vTable.notify_presence_recv = notify_presence_recv; vTable.call_stats_updated = callStatsUpdated; @@ -157,6 +158,7 @@ public: /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/ textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V"); messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V"); + dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V"); proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl")); proxyCtrId = env->GetMethodID(proxyClass,"", "(J)V"); @@ -211,6 +213,7 @@ public: jmethodID notifyPresenceReceivedId; jmethodID textReceivedId; jmethodID messageReceivedId; + jmethodID dtmfReceivedId; jmethodID callStatsUpdatedId; jclass globalStateClass; @@ -390,6 +393,20 @@ public: ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend) ,url ? env->NewStringUTF(url) : NULL); } + static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM\n"); + return; + } + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); + env->CallVoidMethod(lcData->listener + ,lcData->dtmfReceivedId + ,lcData->core + ,lcData->getCall(env,call) + ,dtmf); + } static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index c81dafec4..740bdc29c 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -91,6 +91,14 @@ public interface LinphoneCoreListener { */ void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message); + /** + * invoked when a new dtmf is received + * @param lc LinphoneCore + * @param call LinphoneCall involved in the dtmf sending + * @param dtmf value of the dtmf sent + */ + void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf); + /** * Invoked when echo cancalation calibration is completed * @param lc LinphoneCore From 5f348a03c29f71c9d536a7dd3baf257259de8f39 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 2 Oct 2012 17:31:39 +0200 Subject: [PATCH 219/288] dtmf should be notified from main thread --- coreapi/linphonecall.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 95bc62106..cb5397d78 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1078,8 +1078,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){ static int dtmf_tab[16]={'0','1','2','3','4','5','6','7','8','9','*','#','A','B','C','D'}; -static void linphone_core_dtmf_received(RtpSession* s, int dtmf, void* user_data){ - LinphoneCore* lc = (LinphoneCore*)user_data; +static void linphone_core_dtmf_received(LinphoneCore *lc, int dtmf){ if (dtmf<0 || dtmf>15){ ms_warning("Bad dtmf value %i",dtmf); return; @@ -1169,7 +1168,7 @@ static void post_configure_audio_streams(LinphoneCall*call){ if (lc->vtable.dtmf_received!=NULL){ /* replace by our default action*/ audio_stream_play_received_dtmfs(call->audiostream,FALSE); - rtp_session_signal_connect(call->audiostream->session,"telephone-event",(RtpCallback)linphone_core_dtmf_received,(unsigned long)lc); + /*rtp_session_signal_connect(call->audiostream->session,"telephone-event",(RtpCallback)linphone_core_dtmf_received,(unsigned long)lc);*/ } } @@ -1955,6 +1954,8 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED)) { handle_ice_events(call, ev); + } else if (evt==ORTP_EVENT_TELEPHONE_EVENT){ + linphone_core_dtmf_received(lc,evd->info.telephone_event); } ortp_event_destroy(ev); } From e53e2ca9e3e2008222223b98852f756b53bd10d1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 14:10:37 +0200 Subject: [PATCH 220/288] Update ms2 submodule for ICE. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index cfe804f4d..1789adc9a 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit cfe804f4dbae7dc1b8cf6c63018b68b2fb52cd53 +Subproject commit 1789adc9a8f80d71b3178cc2187a1514d542fa8d From 63c5dfed398a9465fdb1942e0364fa1fdfb9e71b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 14:06:16 +0200 Subject: [PATCH 221/288] Unselect previous ICE valid pairs before adding losing pairs. --- coreapi/misc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreapi/misc.c b/coreapi/misc.c index e85005f28..935ec54f3 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -898,6 +898,10 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, int componentID = j + 1; if (candidate->addr[0] == '\0') break; get_default_addr_and_port(componentID, md, stream, &addr, &port); + if (j == 0) { + /* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */ + ice_check_list_unselect_valid_pairs(cl); + } ice_add_losing_pair(cl, j + 1, candidate->addr, candidate->port, addr, port); losing_pairs_added = TRUE; } From 1adb23eb965463e78894d9339300c71e31babbee Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 14:07:26 +0200 Subject: [PATCH 222/288] Add missing updates of ICE state in call statistics. --- coreapi/linphonecall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index cb5397d78..ded521b5f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -277,6 +277,7 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li update_media_description_from_stun(md,&call->ac,&call->vc); if (call->ice_session != NULL) { linphone_core_update_local_media_description_from_ice(md, call->ice_session); + linphone_core_update_ice_state_in_call_stats(call); } linphone_address_destroy(addr); return md; @@ -1850,6 +1851,7 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ } } else if (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) { linphone_core_start_accept_call_update(call->core, call); + linphone_core_update_ice_state_in_call_stats(call); } else if (evt == ORTP_EVENT_ICE_RESTART_NEEDED) { ice_session_restart(call->ice_session); ice_session_set_role(call->ice_session, IR_Controlling); From 65668542fd6bf19ebdc4246ede0a25cd5313ee6e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 14:08:07 +0200 Subject: [PATCH 223/288] Allow logging of large trace messages. --- coreapi/linphonecore_jni.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 273d46aa9..b8d48de53 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -53,6 +53,9 @@ static JavaVM *jvm=0; #ifdef ANDROID static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){ int prio; + char str[4096]; + char *current; + char *next; switch(lev){ case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break; case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break; @@ -61,7 +64,19 @@ static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_l case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break; default: prio = ANDROID_LOG_DEFAULT; break; } - __android_log_vprint(prio, LOG_DOMAIN, fmt, args); + vsnprintf(str, sizeof(str) - 1, fmt, args); + str[sizeof(str) - 1] = '\0'; + if (strlen(str) < 512) { + __android_log_write(prio, LOG_DOMAIN, str); + } else { + current = str; + while ((next = strchr(current, '\n')) != NULL) { + *next = '\0'; + __android_log_write(prio, LOG_DOMAIN, current); + current = next + 1; + } + __android_log_write(prio, LOG_DOMAIN, current); + } } int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() { From 144982b065caab9aaf4b07b773429fe33200b017 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 15:23:52 +0200 Subject: [PATCH 224/288] Update ms2 submodule for ICE. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 1789adc9a..f8d9b2c40 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1789adc9a8f80d71b3178cc2187a1514d542fa8d +Subproject commit f8d9b2c400a7af1ae815725700cdae9a390fa75f From 55f676763afdad5a9c65b8a339652d9661cf71fb Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 15:23:13 +0200 Subject: [PATCH 225/288] If the remote deactivates a media stream, remove the ICE check list for this stream. --- coreapi/misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 935ec54f3..94110fc84 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -871,8 +871,10 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, break; } } - if ((stream->ice_mismatch == TRUE) || (stream->rtp_port == 0)) { + if (stream->ice_mismatch == TRUE) { ice_check_list_set_state(cl, ICL_Failed); + } else if (stream->rtp_port == 0) { + ice_session_remove_check_list(call->ice_session, ice_session_check_list(call->ice_session, i)); } else { if ((stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) ice_check_list_set_remote_credentials(cl, stream->ice_ufrag, stream->ice_pwd); @@ -940,7 +942,9 @@ void linphone_core_deactivate_ice_for_deactivated_media_streams(LinphoneCall *ca for (i = 0; i < md->nstreams; i++) { IceCheckList *cl = ice_session_check_list(call->ice_session, i); if (cl && (md->streams[i].rtp_port == 0)) { - if (ice_check_list_state(cl) != ICL_Completed) ice_check_list_set_state(cl, ICL_Failed); + if (ice_check_list_state(cl) != ICL_Completed) { + ice_session_remove_check_list(call->ice_session, cl); + } } } } From 6b1a4479afcb9ed364374432d4991f56a876dc15 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 3 Oct 2012 16:05:38 +0200 Subject: [PATCH 226/288] Prevent double update of local media description + fix crash when edge detection deactivates video. --- coreapi/linphonecore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b0cc2bb54..4525e2a18 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2537,7 +2537,6 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){ int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){ const char *subject; call->camera_active=call->params.has_video; - update_local_media_description(lc,call); if (call->ice_session != NULL) linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session); @@ -2577,10 +2576,10 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho call->videostream->ice_check_list = NULL; } call->params = *params; + update_local_media_description(lc, call); if ((call->ice_session != NULL) && !has_video && params->has_video) { /* Defer call update until the ICE candidates gathering process has finished. */ ms_message("Defer call update to gather ICE candidates"); - update_local_media_description(lc, call); linphone_call_init_video_stream(call); video_stream_prepare_video(call->videostream); if (linphone_core_gather_ice_candidates(lc,call)<0) { From 789e4ce7cf1795f9e9fe11dc2d293313e97a7eca Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 3 Oct 2012 16:09:09 +0200 Subject: [PATCH 227/288] fix low bw mode --- coreapi/linphonecall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index ded521b5f..a23e39f2f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1374,6 +1374,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna linphone_call_add_to_conf(call, mute); } call->current_params.in_conference=call->params.in_conference; + call->current_params.low_bandwidth=call->params.low_bandwidth; }else ms_warning("No audio stream accepted ?"); } } From 8af1e4767c3629aff8c14773a020dcd84b495bbc Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 3 Oct 2012 16:09:35 +0200 Subject: [PATCH 228/288] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index f8d9b2c40..0e9c3ddc0 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit f8d9b2c400a7af1ae815725700cdae9a390fa75f +Subproject commit 0e9c3ddc0bc78b19a2ba88a1b97b0092a659c835 From 074f1ac939abcde916218cc3e5401fe1f19bc8ad Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 3 Oct 2012 22:03:04 +0200 Subject: [PATCH 229/288] update ms2 and ortp --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 0e9c3ddc0..0850a0add 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 0e9c3ddc0bc78b19a2ba88a1b97b0092a659c835 +Subproject commit 0850a0addc99b3c998f948fc6118d30f77b9570f diff --git a/oRTP b/oRTP index 8a8843b1f..ddc4f7d04 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 8a8843b1f3a56888492b298d5262a61369e15bb7 +Subproject commit ddc4f7d041967305483761fc9c643d3bb290a5f1 From b09cb1daad42c6c3cfc1128bb74e92a5e8076c6e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 4 Oct 2012 15:10:51 +0200 Subject: [PATCH 230/288] update pref order codec list --- coreapi/linphonecore.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 4525e2a18..7c11e83ae 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -704,25 +704,28 @@ static bool_t get_codec(LpConfig *config, const char* type, int index, PayloadTy } #define RANK_END 10000 -static const char *codec_pref_order[]={ - "SILK", - "speex", - "iLBC", - "amr", - "gsm", - "pcmu", - "pcma", - "VP8", - "H264", - "MP4V-ES", - "H263-1998", - NULL, + +typedef struct codec_desc{ + const char *name; + int rate; +}codec_desc_t; + +static codec_desc_t codec_pref_order[]={ + {"SILK", 16000}, + {"speex", 16000}, + {"speex", 8000}, + {"pcmu",8000}, + {"pcma",8000}, + {"VP8",90000}, + {"H264",90000}, + {"MP4V-ES",90000}, + {NULL,0} }; -static int find_codec_rank(const char *mime){ +static int find_codec_rank(const char *mime, int clock_rate){ int i; - for(i=0;codec_pref_order[i]!=NULL;++i){ - if (strcasecmp(codec_pref_order[i],mime)==0) + for(i=0;codec_pref_order[i].name!=NULL;++i){ + if (strcasecmp(codec_pref_order[i].name,mime)==0 && clock_rate==codec_pref_order[i].rate) return i; } return RANK_END; @@ -730,8 +733,8 @@ static int find_codec_rank(const char *mime){ static int codec_compare(const PayloadType *a, const PayloadType *b){ int ra,rb; - ra=find_codec_rank(a->mime_type); - rb=find_codec_rank(b->mime_type); + ra=find_codec_rank(a->mime_type,a->clock_rate); + rb=find_codec_rank(b->mime_type,b->clock_rate); if (ra>rb) return 1; if (ramime_type)){ if (ms_list_find(l,pt)==NULL){ /*unranked codecs are disabled by default*/ - if (find_codec_rank(pt->mime_type)!=RANK_END){ + if (find_codec_rank(pt->mime_type, pt->clock_rate)!=RANK_END){ payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); } ms_message("Adding new codec %s/%i with fmtp %s", From c3894e57f8184d15ad7439f60db9190ea5405550 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 4 Oct 2012 17:03:11 +0200 Subject: [PATCH 231/288] Handle ICE running state in call statistics update. --- coreapi/misc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/coreapi/misc.c b/coreapi/misc.c index 94110fc84..7367fc517 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -689,6 +689,11 @@ void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call) call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed; } } + } else if (session_state == IS_Running) { + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; + if (call->params.has_video && (video_check_list != NULL)) { + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; + } } else { call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed; if (call->params.has_video && (video_check_list != NULL)) { From 591797379a5b544f509a557bae5391e86d46277f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 11:31:25 +0200 Subject: [PATCH 232/288] Update ms2 submodule for ICE. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 0850a0add..2b1016e3e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 0850a0addc99b3c998f948fc6118d30f77b9570f +Subproject commit 2b1016e3e7b6ee5416721d66eba1504fbf260cb6 From d01fa0e643c4c2047daf311bf62b306286ff056c Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 10:24:44 +0200 Subject: [PATCH 233/288] Fix RTP streams route printing. --- coreapi/linphonecall.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a23e39f2f..88e7d01a9 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1575,7 +1575,6 @@ static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){ void linphone_call_stop_audio_stream(LinphoneCall *call) { if (call->audiostream!=NULL) { - call->audiostream->ice_check_list = NULL; rtp_session_unregister_event_queue(call->audiostream->session,call->audiostream_app_evq); ortp_ev_queue_flush(call->audiostream_app_evq); ortp_ev_queue_destroy(call->audiostream_app_evq); @@ -1601,7 +1600,6 @@ void linphone_call_stop_audio_stream(LinphoneCall *call) { void linphone_call_stop_video_stream(LinphoneCall *call) { #ifdef VIDEO_ENABLED if (call->videostream!=NULL){ - call->videostream->ice_check_list = NULL; rtp_session_unregister_event_queue(call->videostream->session,call->videostream_app_evq); ortp_ev_queue_flush(call->videostream_app_evq); ortp_ev_queue_destroy(call->videostream_app_evq); From cb2b97aad073233e309d74bef39da53a9625ed87 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 10:25:18 +0200 Subject: [PATCH 234/288] Clean ICE session deletion on call end. --- coreapi/linphonecall.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 88e7d01a9..fa58bb465 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -582,6 +582,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const static void linphone_call_destroy(LinphoneCall *obj) { + linphone_call_delete_ice_session(obj); if (obj->op!=NULL) { sal_op_release(obj->op); obj->op=NULL; @@ -605,9 +606,6 @@ static void linphone_call_destroy(LinphoneCall *obj) if (obj->auth_token) { ms_free(obj->auth_token); } - if (obj->ice_session) { - ice_session_destroy(obj->ice_session); - } ms_free(obj); } From 8c02cac3909d5c31aa036f377fd645288269b852 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 11:27:48 +0200 Subject: [PATCH 235/288] Fix to prevent crashes. --- coreapi/misc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 7367fc517..ebb19b083 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -787,8 +787,7 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription * if ((ice_check_list_state(cl) == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) { int rtp_port, rtcp_port; memset(stream->ice_remote_candidates, 0, sizeof(stream->ice_remote_candidates)); - ice_check_list_selected_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port); - if ((rtp_addr != NULL) && (rtcp_addr != NULL)) { + if (ice_check_list_selected_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port) == TRUE) { strncpy(stream->ice_remote_candidates[0].addr, rtp_addr, sizeof(stream->ice_remote_candidates[0].addr)); stream->ice_remote_candidates[0].port = rtp_port; strncpy(stream->ice_remote_candidates[1].addr, rtcp_addr, sizeof(stream->ice_remote_candidates[1].addr)); From c7b3b58145d794b3da4b2ae4cd4a4eef8fd269c3 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 11:28:27 +0200 Subject: [PATCH 236/288] Clean ICE remote candidates in the media description when sending re-invite after an ICE restart. --- coreapi/misc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/coreapi/misc.c b/coreapi/misc.c index ebb19b083..035017b51 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -795,6 +795,11 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription * } else { ms_error("ice: Selected valid remote candidates should be present if the check list is in the Completed state"); } + } else { + for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { + stream->ice_remote_candidates[j].addr[0] = '\0'; + stream->ice_remote_candidates[j].port = 0; + } } } } From 1a4712e8cf92a8779214416fa2c40f9f7dc437e0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 5 Oct 2012 15:08:14 +0200 Subject: [PATCH 237/288] Update ms2 submodule for ICE. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 2b1016e3e..c80b4ff9d 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2b1016e3e7b6ee5416721d66eba1504fbf260cb6 +Subproject commit c80b4ff9d80bfd06a7c6fff68cd82580e92c1d49 From 1cc0a418af4718014a614afdbe6f1cd7690a4ccf Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 5 Oct 2012 17:32:38 +0200 Subject: [PATCH 238/288] Few changes in JNI interface for linphone friends + fix issue in linphone_friend_destroy --- coreapi/friend.c | 2 +- coreapi/linphonecore_jni.cc | 15 +++++++++++++++ java/common/org/linphone/core/LinphoneCore.java | 13 ++++++++++--- java/common/org/linphone/core/LinphoneFriend.java | 5 ++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 05a1baeec..c6dee2440 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -396,8 +396,8 @@ void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend* fl){ MSList *el=ms_list_find(lc->friends,(void *)fl); if (el!=NULL){ - lc->friends=ms_list_remove_link(lc->friends,el); linphone_friend_destroy((LinphoneFriend*)el->data); + lc->friends=ms_list_remove_link(lc->friends,el); linphone_core_write_friends_config(lc); } } diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b8d48de53..566269a76 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1592,6 +1592,21 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env ,jlong ptr) { linphone_friend_done((LinphoneFriend*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jlong lf) { + linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf); +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jstring jaddress) { + const char* address = env->GetStringUTFChars(jaddress, NULL); + LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address); + env->ReleaseStringUTFChars(jaddress, address); + return (jlong) lf; +} //LinphoneChatRoom extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env ,jobject thiz diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 6ac821322..732940fdd 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -20,9 +20,6 @@ package org.linphone.core; import java.util.Vector; -import org.linphone.core.LinphoneCallLog; -import org.linphone.core.LinphoneCallParams; - /** * Linphone core main object created by method {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)}. * @@ -802,4 +799,14 @@ public interface LinphoneCore { * return the version code of linphone core */ public String getVersion(); + + /** + * remove a linphone friend from linphone core and linphonerc + */ + void removeFriend(LinphoneFriend lf); + + /** + * return a linphone friend (if exists) that matches the sip address + */ + LinphoneFriend findFriendByAddress(String sipUri); } diff --git a/java/common/org/linphone/core/LinphoneFriend.java b/java/common/org/linphone/core/LinphoneFriend.java index d4f0e7503..e070f6921 100644 --- a/java/common/org/linphone/core/LinphoneFriend.java +++ b/java/common/org/linphone/core/LinphoneFriend.java @@ -123,5 +123,8 @@ public interface LinphoneFriend { */ String toString(); - + /** + * Return the native pointer for this object + */ + long getNativePtr(); } From 34d9c1df71cd92ae2bd9371112bd9d790ddff221 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 5 Oct 2012 17:35:40 +0200 Subject: [PATCH 239/288] Bigger contacts in contacts list + friend presence started --- LinphoneAuthInfoImpl.java | 1 - LinphoneCoreImpl.java | 16 ++++++++++++++++ LinphoneFriendImpl.java | 11 ++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index 7d50a2fa5..45fd8a45e 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -43,7 +43,6 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo { public void setPassword(String password) { // TODO Auto-generated method stub throw new RuntimeException("not implemeneted yet"); - } public void setRealm(String realm) { // TODO Auto-generated method stub diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 8677cb285..7b62ba835 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -741,4 +741,20 @@ class LinphoneCoreImpl implements LinphoneCore { public PayloadType findPayloadType(String mime, int clockRate) { return null; } + + private native void removeFriend(long ptr, long lf); + @Override + public void removeFriend(LinphoneFriend lf) { + removeFriend(nativePtr, lf.getNativePtr()); + } + + private native long getFriendByAddress(long ptr, String sipUri); + @Override + public LinphoneFriend findFriendByAddress(String sipUri) { + long ptr = getFriendByAddress(nativePtr, sipUri); + if (ptr == 0) { + return null; + } + return new LinphoneFriendImpl(ptr); + } } diff --git a/LinphoneFriendImpl.java b/LinphoneFriendImpl.java index bae44679f..6e7aa2db1 100644 --- a/LinphoneFriendImpl.java +++ b/LinphoneFriendImpl.java @@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -class LinphoneFriendImpl implements LinphoneFriend { +import java.io.Serializable; + +class LinphoneFriendImpl implements LinphoneFriend, Serializable { protected final long nativePtr; private native long newLinphoneFriend(String friendUri); private native void setAddress(long nativePtr,long friend); @@ -48,14 +50,12 @@ class LinphoneFriendImpl implements LinphoneFriend { } public void setAddress(LinphoneAddress anAddress) { this.setAddress(nativePtr, ((LinphoneAddressImpl)anAddress).nativePtr); - } public LinphoneAddress getAddress() { return new LinphoneAddressImpl(getAddress(nativePtr)); } public void setIncSubscribePolicy(SubscribePolicy policy) { setIncSubscribePolicy(nativePtr,policy.mValue); - } public SubscribePolicy getIncSubscribePolicy() { return SubscribePolicy.fromInt(getIncSubscribePolicy(nativePtr)) ; @@ -66,7 +66,6 @@ class LinphoneFriendImpl implements LinphoneFriend { public boolean isSubscribesEnabled() { return isSubscribesEnabled(nativePtr); } - public OnlineStatus getStatus() { return OnlineStatus.fromInt(getStatus(nativePtr)); } @@ -76,5 +75,7 @@ class LinphoneFriendImpl implements LinphoneFriend { public void done() { done(nativePtr); } - + public long getNativePtr() { + return nativePtr; + } } From 23b788205b6af8ab4c1e6ca5b285b550364ac18f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 8 Oct 2012 12:36:03 +0200 Subject: [PATCH 240/288] Remove useless code. --- coreapi/callbacks.c | 3 --- coreapi/misc.c | 15 +-------------- coreapi/private.h | 1 - 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7f901195f..52c6d4070 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -46,9 +46,6 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia call->media_pending=TRUE; } call->resultdesc=new_md; - if (call->ice_session != NULL) { - linphone_core_deactivate_ice_for_deactivated_media_streams(call, call->resultdesc); - } if ((call->audiostream && call->audiostream->ticker) || (call->videostream && call->videostream->ticker)){ /* we already started media: check if we really need to restart it*/ if (oldmd){ diff --git a/coreapi/misc.c b/coreapi/misc.c index 035017b51..b9176ebd4 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -883,7 +883,7 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, if (stream->ice_mismatch == TRUE) { ice_check_list_set_state(cl, ICL_Failed); } else if (stream->rtp_port == 0) { - ice_session_remove_check_list(call->ice_session, ice_session_check_list(call->ice_session, i)); + ice_session_remove_check_list(call->ice_session, cl); } else { if ((stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) ice_check_list_set_remote_credentials(cl, stream->ice_ufrag, stream->ice_pwd); @@ -945,19 +945,6 @@ bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescr return FALSE; } -void linphone_core_deactivate_ice_for_deactivated_media_streams(LinphoneCall *call, const SalMediaDescription *md) -{ - int i; - for (i = 0; i < md->nstreams; i++) { - IceCheckList *cl = ice_session_check_list(call->ice_session, i); - if (cl && (md->streams[i].rtp_port == 0)) { - if (ice_check_list_state(cl) != ICL_Completed) { - ice_session_remove_check_list(call->ice_session, cl); - } - } - } -} - LinphoneCall * is_a_linphone_call(void *user_pointer){ LinphoneCall *call=(LinphoneCall*)user_pointer; if (call==NULL) return NULL; diff --git a/coreapi/private.h b/coreapi/private.h index 0cefb1476..82ebf3633 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -252,7 +252,6 @@ void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call); void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session); void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md); bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md); -void linphone_core_deactivate_ice_for_deactivated_media_streams(LinphoneCall *call, const SalMediaDescription *md); void linphone_core_send_initial_subscribes(LinphoneCore *lc); void linphone_core_write_friends_config(LinphoneCore* lc); From eaf16b1784450d7e1c12624ef23348c2bf799c6b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 8 Oct 2012 12:39:15 +0200 Subject: [PATCH 241/288] Deactivate video when the remote accepts the call but without video. --- coreapi/callbacks.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 52c6d4070..7c7d4f003 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -266,6 +266,7 @@ static void call_accepted(SalOp *op){ } md=sal_call_get_final_media_description(op); + call->params.has_video &= linphone_core_media_description_contains_video_stream(md); if (call->state==LinphoneCallOutgoingProgress || call->state==LinphoneCallOutgoingRinging || From bdaa5ae91ac1ba1e3844fceb5f611ba37ddde964 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 8 Oct 2012 18:19:33 +0200 Subject: [PATCH 242/288] save video capture/display while setted --- Makefile.am | 2 -- coreapi/linphonecore.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8756019f4..4aa4332f2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -232,6 +232,4 @@ clean-local: discovery: touch specs.cpp $(CC) --include $(top_builddir)/config.h \ - --include $(top_builddir)/mediastreamer2/mediastreamer-config.h \ - --include $(top_builddir)/oRTP/ortp-config.h \ $(TUNNEL_CFLAGS) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) -E -P -v -dD specs.cpp diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 7c11e83ae..ada16d69b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3840,7 +3840,10 @@ void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t di #endif lc->video_conf.capture=vcap_enabled; lc->video_conf.display=display_enabled; - + if (linphone_core_ready(lc)){ + lp_config_set_int(lc->config,"video","display",lc->video_conf.display); + lp_config_set_int(lc->config,"video","capture",lc->video_conf.capture); + } /* need to re-apply network bandwidth settings*/ linphone_core_set_download_bandwidth(lc, linphone_core_get_download_bandwidth(lc)); From f14bd7a95479355b9030162b18937f27a0145c1c Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 9 Oct 2012 11:30:48 +0200 Subject: [PATCH 243/288] Fix unused warning with LinphoneVideoPolicy --- coreapi/linphonecore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ada16d69b..2e7ff6372 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -830,6 +830,7 @@ static void video_config_read(LinphoneCore *lc){ const char *str; #ifdef VIDEO_ENABLED LinphoneVideoPolicy vpol; + memset(&vpol, 0, sizeof(LinphoneVideoPolicy)); #endif build_video_devices_table(lc); From c9af7c47152e0910765b6ae5447d934f456d22cb Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 9 Oct 2012 12:59:17 +0200 Subject: [PATCH 244/288] Force AC_SUBST INTLLIBS --- configure.ac | 1 + mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4c4bab882..84081f46c 100644 --- a/configure.ac +++ b/configure.ac @@ -107,6 +107,7 @@ if test "$mingw_found" != "yes" ; then dnl AM_GNU_GETTEXT pollutes CPPFLAGS: workaround this. CPPFLAGS_save=$CPPFLAGS AM_GNU_GETTEXT([external]) + AC_SUBST(INTLLIBS) CPPFLAGS=$CPPFLAGS_save LIBS="$LIBS $LIBINTL" else diff --git a/mediastreamer2 b/mediastreamer2 index c80b4ff9d..57229c14d 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit c80b4ff9d80bfd06a7c6fff68cd82580e92c1d49 +Subproject commit 57229c14dedd530bc2775b5a25cad15b62da3ee9 From 3c9b9b7cefd6d17ee746c2fe8f3bdd9bd8699e81 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 9 Oct 2012 16:34:40 +0200 Subject: [PATCH 245/288] Fix function definition. --- LinphoneCallImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LinphoneCallImpl.java b/LinphoneCallImpl.java index cf471f52c..7e39cebc7 100644 --- a/LinphoneCallImpl.java +++ b/LinphoneCallImpl.java @@ -155,7 +155,7 @@ class LinphoneCallImpl implements LinphoneCall { return isAuthenticationTokenVerified(nativePtr); } - private native boolean setAuthenticationTokenVerified(long nativePtr, boolean verified); + private native void setAuthenticationTokenVerified(long nativePtr, boolean verified); public void setAuthenticationTokenVerified(boolean verified){ setAuthenticationTokenVerified(nativePtr, verified); } From d0ccd0894cea7a83495c87b18994b28208ec4f29 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 9 Oct 2012 16:37:09 +0200 Subject: [PATCH 246/288] Fix errors in JNI. --- coreapi/linphonecore_jni.cc | 217 ++++++++++++++++++------------------ 1 file changed, 110 insertions(+), 107 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 566269a76..e8b8a6e2b 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -531,7 +531,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); return nativePtr; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env ,jobject thiz ,jlong lc) { LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc); @@ -539,7 +539,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env delete lcData; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { linphone_core_clear_proxy_config((LinphoneCore*)lc); } @@ -573,7 +573,7 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList return jProxies; } -extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env ,jobject thiz ,jobject jproxyCfg ,jlong lc @@ -581,10 +581,10 @@ extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc; linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg)); - return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); + return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) { +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) { linphone_core_clear_all_auth_info((LinphoneCore*)lc); } @@ -637,13 +637,13 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* e ,jobject thiz ,jlong lc) { - return linphone_core_in_call((LinphoneCore*)lc); + return (jboolean)linphone_core_in_call((LinphoneCore*)lc); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_inc_invite_pending((LinphoneCore*)lc); + return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env ,jobject thiz @@ -685,7 +685,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* en extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env ,jobject thiz ,jlong lc) { - return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); + return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env ,jobject thiz @@ -697,7 +697,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_is_network_reachable((LinphoneCore*)lc); + return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env @@ -707,10 +707,10 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain); } -extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env +extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_get_playback_gain_db((LinphoneCore*)lc); + return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env @@ -748,10 +748,10 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env linphone_core_stop_dtmf((LinphoneCore*)lc); } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env ,jobject thiz ,jlong lc) { - linphone_core_get_missed_calls_count((LinphoneCore*)lc); + return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env @@ -774,7 +774,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* e extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_is_mic_muted((LinphoneCore*)lc); + return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc); } extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env ,jobject thiz @@ -823,12 +823,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTy return jCodecs; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env ,jobject thiz ,jlong lc ,jlong pt ,jboolean enable) { - return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable); + return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env ,jobject thiz @@ -846,14 +846,14 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEn ,jobject thiz ,jlong lc ) { - return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env ,jobject thiz ,jlong lc ) { - return linphone_core_echo_limiter_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env @@ -882,7 +882,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact); } -extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jto) { @@ -890,7 +890,7 @@ extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* const char* to = env->GetStringUTFChars(jto, NULL); LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to); env->ReleaseStringUTFChars(jto, to); - return (long)lResult; + return (jlong)lResult; } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env @@ -904,7 +904,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_video_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env ,jobject thiz @@ -951,67 +951,45 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_keep_alive_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env ,jobject thiz ,jlong lc ,jobject data) { - return linphone_core_start_echo_calibration((LinphoneCore*)lc + return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc , LinphoneCoreData::ecCalibrationStatus , data?env->NewGlobalRef(data):NULL); } -extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env ,jobject thiz ,jlong lc ) { - return (int)linphone_core_get_media_encryption((LinphoneCore*)lc); + return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env ,jobject thiz ,jlong lc - ,int menc) { + ,jint menc) { linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); } -extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) { - return (long)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp); -} - -extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) { - return (long)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp); -} - -extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env - ,jobject thiz - ,jlong cp - ) { - return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp); -} - extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env ,jobject thiz ,jlong lc, jint menc ) { - return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); + return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); } -extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env - ,jobject thiz - ,jlong cp - ,int jmenc) { - linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc); -} - -extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env ,jobject thiz ,jlong lc ) { - return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc); + return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env @@ -1045,9 +1023,9 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JN return NULL; } } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { const char* proxy = env->GetStringUTFChars(jproxy, NULL); - int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); + jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); env->ReleaseStringUTFChars(jproxy, proxy); return err; } @@ -1064,14 +1042,14 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParamet linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params); env->ReleaseStringUTFChars(jparams, params); } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { if (jroute != NULL) { const char* route = env->GetStringUTFChars(jroute, NULL); - int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); + jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); env->ReleaseStringUTFChars(jroute, route); return err; } else { - return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); + return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); } } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -1087,10 +1065,10 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JN linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) { linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg); @@ -1149,7 +1127,7 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNI linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg); } //Auth Info @@ -1213,7 +1191,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNI if (displayName) { return env->NewStringUTF(displayName); } else { - return 0; + return NULL; } } extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env @@ -1223,7 +1201,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv if (userName) { return env->NewStringUTF(userName); } else { - return 0; + return NULL; } } extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env @@ -1233,7 +1211,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* if (domain) { return env->NewStringUTF(domain); } else { - return 0; + return NULL; } } @@ -1269,10 +1247,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env ,jlong ptr) { return (jlong)((LinphoneCallLog*)ptr)->from; } -extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (jlong)((LinphoneCallLog*)ptr)->status; + return (jint)((LinphoneCallLog*)ptr)->status; } extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env ,jobject thiz @@ -1293,15 +1271,15 @@ extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEn extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env ,jobject thiz ,jlong ptr) { - return ((LinphoneCallLog*)ptr)->duration; + return (jint)((LinphoneCallLog*)ptr)->duration; } /* CallStats */ -extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) { - return (int)((LinphoneCallStats *)stats_ptr)->type; +extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jint)((LinphoneCallStats *)stats_ptr)->type; } -extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) { - return (int)((LinphoneCallStats *)stats_ptr)->ice_state; +extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jint)((LinphoneCallStats *)stats_ptr)->ice_state; } extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) { return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth; @@ -1438,7 +1416,7 @@ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,j } extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) { PayloadType* pt = (PayloadType*)ptr; - return payload_type_get_rate(pt); + return (jint)payload_type_get_rate(pt); } //LinphoneCall @@ -1494,7 +1472,7 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr); + return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env @@ -1506,7 +1484,7 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEn extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr); + return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr); } extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env @@ -1530,7 +1508,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNI //LinphoneFriend -extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env ,jobject thiz ,jstring jFriendUri) { LinphoneFriend* lResult; @@ -1542,7 +1520,7 @@ extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIE } else { lResult = linphone_friend_new(); } - return (long)lResult; + return (jlong)lResult; } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env ,jobject thiz @@ -1550,10 +1528,10 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* en ,jlong linphoneAddress) { linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress); } -extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (long)linphone_friend_get_address((LinphoneFriend*)ptr); + return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env ,jobject thiz @@ -1564,7 +1542,7 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy( extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr); + return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env ,jobject thiz @@ -1575,12 +1553,12 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEn extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr); + return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr); } -extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_get_status((LinphoneFriend*)ptr); + return (jint)linphone_friend_get_status((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env ,jobject thiz @@ -1608,10 +1586,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIE return (jlong) lf; } //LinphoneChatRoom -extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr); + return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr); } extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env ,jobject thiz @@ -1736,12 +1714,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){ +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){ linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){ - return linphone_core_get_firewall_policy((LinphoneCore*)lc); + return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){ @@ -1758,6 +1736,30 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv return jvalue; } +//CallParams + +extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) { + return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp); +} + +extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) { + return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp); +} + +extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong cp + ) { + return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp); +} + +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong cp + ,jint jmenc) { + linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc); +} + extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){ linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw); } @@ -1767,11 +1769,11 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv } extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){ - return linphone_call_params_video_enabled((LinphoneCallParams*)lcp); + return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp); } extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){ - return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp); + return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp); } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){ @@ -1792,12 +1794,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JN return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc)); } -extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){ +extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){ linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b); } extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){ - linphone_call_camera_enabled((LinphoneCall *)lc); + return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){ @@ -1845,15 +1847,15 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *e linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime); } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) { - return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr); +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) { + return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) { linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay); } extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) { - linphone_call_get_duration((LinphoneCall *) ptr); + return (jint)linphone_call_get_duration((LinphoneCall *) ptr); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) { @@ -1892,19 +1894,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNI } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { - return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); + return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_pause_all_calls((LinphoneCore *) pCore); + return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { - return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); + return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_is_in_conference((LinphoneCore *) pCore); + return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) { - return 0 == linphone_core_enter_conference((LinphoneCore *) pCore); + return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore)); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) { linphone_core_leave_conference((LinphoneCore *) pCore); @@ -1923,7 +1925,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIE linphone_core_terminate_conference((LinphoneCore *) pCore); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_get_conference_size((LinphoneCore *) pCore); + return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) { linphone_core_terminate_all_calls((LinphoneCore *) pCore); @@ -1934,16 +1936,17 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,j return lcd->getCall(env,lCall); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) { - return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); + return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL); - linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); + jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); env->ReleaseStringUTFChars(jReferTo, cReferTo); + return err; } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { - linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall); +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { + return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) { @@ -1978,7 +1981,7 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *e break; ms_message("Existing device %d : %s\n", i, devices[i]); if (i==id) { - return linphone_core_set_video_device(lc, devices[i]); + return (jint)linphone_core_set_video_device(lc, devices[i]); } } return -1; @@ -2014,7 +2017,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToke } extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) { LinphoneCall *call = (LinphoneCall *) ptr; - return linphone_call_get_authentication_token_verified(call); + return (jboolean)linphone_call_get_authentication_token_verified(call); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) { LinphoneCall *call = (LinphoneCall *) ptr; @@ -2023,11 +2026,11 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVe extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) { LinphoneCall *call = (LinphoneCall *) ptr; - return linphone_call_get_play_volume(call); + return (jfloat)linphone_call_get_play_volume(call); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){ - return linphone_core_sound_resources_locked((LinphoneCore *) ptr); + return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr); } // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working) @@ -2097,7 +2100,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){ - return linphone_core_tunnel_available(); + return (jboolean)linphone_core_tunnel_available(); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){ From eb5ca31cfd8f7dbfde549a81455376b59ba121fe Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 10 Oct 2012 10:28:16 +0200 Subject: [PATCH 247/288] Fix bug 0000201: linphone crashes upon asking for video when low bandwidth detected. --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2e7ff6372..2936ca0ba 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2581,7 +2581,7 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho } call->params = *params; update_local_media_description(lc, call); - if ((call->ice_session != NULL) && !has_video && params->has_video) { + if ((call->ice_session != NULL) && !has_video && call->params.has_video) { /* Defer call update until the ICE candidates gathering process has finished. */ ms_message("Defer call update to gather ICE candidates"); linphone_call_init_video_stream(call); From 39c0aeb136c6da2b118cc85e39a5f91b91a6ccb2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 10 Oct 2012 13:45:05 +0200 Subject: [PATCH 248/288] Updated liblinphone + fix dialer address clear --- LinphoneCallLogImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/LinphoneCallLogImpl.java b/LinphoneCallLogImpl.java index ac03d3699..05468626e 100644 --- a/LinphoneCallLogImpl.java +++ b/LinphoneCallLogImpl.java @@ -61,7 +61,6 @@ class LinphoneCallLogImpl implements LinphoneCallLog { public int getCallDuration() { return getCallDuration(nativePtr); } - @Override public int getCallId() { return getCallId(nativePtr); } From 27d9e15d2b830bf2acd1646b5d965f929b53ba1a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Oct 2012 09:07:39 +0200 Subject: [PATCH 249/288] Update ms2 submodule for ICE. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 57229c14d..dcadb7e8c 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 57229c14dedd530bc2775b5a25cad15b62da3ee9 +Subproject commit dcadb7e8c2f14abfac2dc9d8308ceb20ef4b96ef From 55a3069dff9fac1862f0d57a3dcd19c284e27ebd Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Oct 2012 08:55:46 +0200 Subject: [PATCH 250/288] Use average round trip time for edge detection instead of ICE gathering duration. --- coreapi/linphonecall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index fa58bb465..d0667251d 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1819,9 +1819,8 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ ice_session_compute_candidates_foundations(call->ice_session); ice_session_eliminate_redundant_candidates(call->ice_session); ice_session_choose_default_candidates(call->ice_session); - ping_time = ice_session_gathering_duration(call->ice_session); + ping_time = ice_session_average_gathering_round_trip_time(call->ice_session); if (ping_time >=0) { - ping_time /= ice_session_nb_check_lists(call->ice_session); call->ping_time=ping_time; } } else { From 6f2d48c04e93a2f16497ed8a95ebb3a765663d9b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Oct 2012 14:30:27 +0200 Subject: [PATCH 251/288] Fix tutorials compilation. --- .../java/org/linphone/core/tutorials/TutorialBuddyStatus.java | 1 + .../help/java/org/linphone/core/tutorials/TutorialChatRoom.java | 1 + .../java/org/linphone/core/tutorials/TutorialHelloWorld.java | 1 + .../java/org/linphone/core/tutorials/TutorialRegistration.java | 1 + 4 files changed, 4 insertions(+) diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index bf253b727..dc1341d80 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -102,6 +102,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} + public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {} public static void main(String[] args) { diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java index 7514a1ddc..3e41dba00 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java @@ -80,6 +80,7 @@ public class TutorialChatRoom implements LinphoneCoreListener { public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} + public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {} public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) { write("Message ["+message+"] received from ["+from.asString()+"]"); diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java index 4b63e8813..d6b61cf8b 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java @@ -74,6 +74,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener { public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} + public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {} /* * Call state notification listener */ diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index 86b300143..fa18d51f8 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -85,6 +85,7 @@ public class TutorialRegistration implements LinphoneCoreListener { public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} + public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {} public static void main(String[] args) { // Check tutorial was called with the right number of arguments From d5f8a6f933f00bbdfcfb6a2b86674d87b854a940 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Oct 2012 15:35:08 +0200 Subject: [PATCH 252/288] Add handling of ranges in the config file. --- coreapi/lpconfig.c | 25 +++++++++++++++++++++++++ coreapi/lpconfig.h | 14 ++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 0efdc335e..46d683c59 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -271,6 +271,25 @@ const char *lp_config_get_string(LpConfig *lpconfig, const char *section, const return default_string; } +bool_t lp_config_get_range(LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max) { + const char *str = lp_config_get_string(lpconfig, section, key, NULL); + if (str != NULL) { + char *minusptr = strchr(str, '-'); + if ((minusptr == NULL) || (minusptr == str)) { + *min = default_min; + *max = default_max; + return FALSE; + } + *min = atoi(str); + *max = atoi(minusptr + 1); + return TRUE; + } else { + *min = default_min; + *max = default_max; + return TRUE; + } +} + int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, int default_value){ const char *str=lp_config_get_string(lpconfig,section,key,NULL); if (str!=NULL) { @@ -324,6 +343,12 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke lpconfig->modified++; } +void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value) { + char tmp[30]; + snprintf(tmp, sizeof(tmp), "%i-%i", min_value, max_value); + lp_config_set_string(lpconfig, section, key, tmp); +} + void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value){ char tmp[30]; snprintf(tmp,sizeof(tmp),"%i",value); diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index a27f7e39a..b672e4cbf 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -59,6 +59,14 @@ int lp_config_read_file(LpConfig *lpconfig, const char *filename); **/ const char *lp_config_get_string(LpConfig *lpconfig, const char *section, const char *key, const char *default_string); int lp_config_read_file(LpConfig *lpconfig, const char *filename); +/** + * Retrieves a configuration item as a range, given its section, key, and default min and max values. + * + * @ingroup misc + * @return TRUE if the value is successfully parsed as a range, FALSE otherwise. + * If FALSE is returned, min and max are filled respectively with default_min and default_max values. + */ +bool_t lp_config_get_range(LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max); /** * Retrieves a configuration item as an integer, given its section, key, and default value. * @@ -90,6 +98,12 @@ float lp_config_get_float(LpConfig *lpconfig,const char *section, const char *ke * @ingroup misc **/ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value); +/** + * Sets a range config item + * + * @ingroup misc + */ +void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value); /** * Sets an integer config item * From 3910894b7cf4ae3d8c596fb7106919b5f4886470 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Oct 2012 15:35:52 +0200 Subject: [PATCH 253/288] Allow random selection of media ports without configured ranges. --- coreapi/linphonecall.c | 96 ++++++++++++++++++++++++++++++++++++++---- coreapi/linphonecore.c | 83 ++++++++++++++++++++++++++++++------ coreapi/linphonecore.h | 8 ++++ coreapi/private.h | 6 ++- 4 files changed, 171 insertions(+), 22 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d0667251d..a930b1bed 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -298,17 +298,35 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa return _create_local_media_description(lc,call,id,id); } -static int find_port_offset(LinphoneCore *lc){ +static int find_port_offset(LinphoneCore *lc, SalStreamType type){ int offset; MSList *elem; - int audio_port; + int tried_port; + int existing_port; bool_t already_used=FALSE; for(offset=0;offset<100;offset+=2){ - audio_port=linphone_core_get_audio_port (lc)+offset; + switch (type) { + default: + case SalAudio: + tried_port=linphone_core_get_audio_port (lc)+offset; + break; + case SalVideo: + tried_port=linphone_core_get_video_port (lc)+offset; + break; + } already_used=FALSE; for(elem=lc->calls;elem!=NULL;elem=elem->next){ LinphoneCall *call=(LinphoneCall*)elem->data; - if (call->audio_port==audio_port) { + switch (type) { + default: + case SalAudio: + existing_port = call->audio_port; + break; + case SalVideo: + existing_port = call->video_port; + break; + } + if (existing_port==tried_port) { already_used=TRUE; break; } @@ -322,8 +340,54 @@ static int find_port_offset(LinphoneCore *lc){ return offset; } +static int select_random_port(LinphoneCore *lc, SalStreamType type) { + MSList *elem; + int nb_tries; + int tried_port = 0; + int existing_port = 0; + int min_port = 0, max_port = 0; + bool_t already_used = FALSE; + + switch (type) { + default: + case SalAudio: + linphone_core_get_audio_port_range(lc, &min_port, &max_port); + break; + case SalVideo: + linphone_core_get_video_port_range(lc, &min_port, &max_port); + break; + } + tried_port = (rand() % (max_port - min_port) + min_port) & ~0x1; + if (tried_port < min_port) tried_port = min_port + 2; + for (nb_tries = 0; nb_tries < 100; nb_tries++) { + for (elem = lc->calls; elem != NULL; elem = elem->next) { + LinphoneCall *call = (LinphoneCall *)elem->data; + switch (type) { + default: + case SalAudio: + existing_port = call->audio_port; + break; + case SalVideo: + existing_port = call->video_port; + break; + } + if (existing_port == tried_port) { + already_used = TRUE; + break; + } + } + if (!already_used) break; + } + if (nb_tries == 100) { + ms_error("Could not find any free port!"); + return -1; + } + return tried_port; +} + static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){ int port_offset; + int min_port, max_port; call->magic=linphone_call_magic; call->refcnt=1; call->state=LinphoneCallIdle; @@ -333,10 +397,26 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, call->log=linphone_call_log_new(call, from, to); call->owns_call_log=TRUE; linphone_core_notify_all_friends(call->core,LinphoneStatusOnThePhone); - port_offset=find_port_offset (call->core); - if (port_offset==-1) return; - call->audio_port=linphone_core_get_audio_port(call->core)+port_offset; - call->video_port=linphone_core_get_video_port(call->core)+port_offset; + linphone_core_get_audio_port_range(call->core, &min_port, &max_port); + if (min_port == max_port) { + /* Used fixed RTP audio port. */ + port_offset=find_port_offset (call->core, SalAudio); + if (port_offset==-1) return; + call->audio_port=linphone_core_get_audio_port(call->core)+port_offset; + } else { + /* Select random RTP audio port in the specified range. */ + call->audio_port = select_random_port(call->core, SalAudio); + } + linphone_core_get_video_port_range(call->core, &min_port, &max_port); + if (min_port == max_port) { + /* Used fixed RTP video port. */ + port_offset=find_port_offset (call->core, SalVideo); + if (port_offset==-1) return; + call->video_port=linphone_core_get_video_port(call->core)+port_offset; + } else { + /* Select random RTP video port in the specified range. */ + call->video_port = select_random_port(call->core, SalVideo); + } linphone_call_init_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO], LINPHONE_CALL_STATS_AUDIO); linphone_call_init_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO], LINPHONE_CALL_STATS_VIDEO); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2936ca0ba..db7a8ea7c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -624,18 +624,29 @@ static void sip_config_read(LinphoneCore *lc) static void rtp_config_read(LinphoneCore *lc) { - int port; + int min_port, max_port; int jitt_comp; int nortp_timeout; bool_t rtp_no_xmit_on_audio_mute; bool_t adaptive_jitt_comp_enabled; - port=lp_config_get_int(lc->config,"rtp","audio_rtp_port",7078); - linphone_core_set_audio_port(lc,port); + if (lp_config_get_range(lc->config, "rtp", "audio_rtp_port", &min_port, &max_port, 7078, 7078) == TRUE) { + if (min_port <= 0) min_port = 1; + if (max_port > 65535) max_port = 65535; + linphone_core_set_audio_port_range(lc, min_port, max_port); + } else { + min_port = lp_config_get_int(lc->config, "rtp", "audio_rtp_port", 7078); + linphone_core_set_audio_port(lc, min_port); + } - port=lp_config_get_int(lc->config,"rtp","video_rtp_port",9078); - if (port==0) port=9078; - linphone_core_set_video_port(lc,port); + if (lp_config_get_range(lc->config, "rtp", "video_rtp_port", &min_port, &max_port, 9078, 9078) == TRUE) { + if (min_port <= 0) min_port = 1; + if (max_port > 65535) max_port = 65535; + linphone_core_set_video_port_range(lc, min_port, max_port); + } else { + min_port = lp_config_get_int(lc->config, "rtp", "video_rtp_port", 9078); + linphone_core_set_video_port(lc, min_port); + } jitt_comp=lp_config_get_int(lc->config,"rtp","audio_jitt_comp",60); linphone_core_set_audio_jittcomp(lc,jitt_comp); @@ -1440,7 +1451,18 @@ int linphone_core_get_video_jittcomp(LinphoneCore *lc) **/ int linphone_core_get_audio_port(const LinphoneCore *lc) { - return lc->rtp_conf.audio_rtp_port; + return lc->rtp_conf.audio_rtp_min_port; +} + +/** + * Get the audio port range from which is randomly chosen the UDP port used for audio streaming. + * + * @ingroup network_parameters + */ +void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, int *max_port) +{ + *min_port = lc->rtp_conf.audio_rtp_min_port; + *max_port = lc->rtp_conf.audio_rtp_max_port; } /** @@ -1449,7 +1471,18 @@ int linphone_core_get_audio_port(const LinphoneCore *lc) * @ingroup network_parameters **/ int linphone_core_get_video_port(const LinphoneCore *lc){ - return lc->rtp_conf.video_rtp_port; + return lc->rtp_conf.video_rtp_min_port; +} + +/** + * Get the video port range from which is randomly chosen the UDP port used for video streaming. + * + * @ingroup network_parameters + */ +void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, int *max_port) +{ + *min_port = lc->rtp_conf.video_rtp_min_port; + *max_port = lc->rtp_conf.video_rtp_max_port; } @@ -1501,7 +1534,16 @@ void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc,bool_t rtp_no_ **/ void linphone_core_set_audio_port(LinphoneCore *lc, int port) { - lc->rtp_conf.audio_rtp_port=port; + lc->rtp_conf.audio_rtp_min_port=lc->rtp_conf.audio_rtp_max_port=port; +} + +/** + * Sets the UDP port range from which to randomly select the port used for audio streaming. + */ +void linphone_core_set_audio_port_range(LinphoneCore *lc, int min_port, int max_port) +{ + lc->rtp_conf.audio_rtp_min_port=min_port; + lc->rtp_conf.audio_rtp_max_port=max_port; } /** @@ -1510,7 +1552,16 @@ void linphone_core_set_audio_port(LinphoneCore *lc, int port) * @ingroup network_parameters **/ void linphone_core_set_video_port(LinphoneCore *lc, int port){ - lc->rtp_conf.video_rtp_port=port; + lc->rtp_conf.video_rtp_min_port=lc->rtp_conf.video_rtp_max_port=port; +} + +/** + * Sets the UDP port range from which to randomly select the port used for video streaming. + */ +void linphone_core_set_video_port_range(LinphoneCore *lc, int min_port, int max_port) +{ + lc->rtp_conf.video_rtp_min_port=min_port; + lc->rtp_conf.video_rtp_max_port=max_port; } /** @@ -4556,8 +4607,16 @@ void sip_config_uninit(LinphoneCore *lc) void rtp_config_uninit(LinphoneCore *lc) { rtp_config_t *config=&lc->rtp_conf; - lp_config_set_int(lc->config,"rtp","audio_rtp_port",config->audio_rtp_port); - lp_config_set_int(lc->config,"rtp","video_rtp_port",config->video_rtp_port); + if (config->audio_rtp_min_port == config->audio_rtp_max_port) { + lp_config_set_int(lc->config, "rtp", "audio_rtp_port", config->audio_rtp_min_port); + } else { + lp_config_set_range(lc->config, "rtp", "audio_rtp_port", config->audio_rtp_min_port, config->audio_rtp_max_port); + } + if (config->video_rtp_min_port == config->video_rtp_max_port) { + lp_config_set_int(lc->config, "rtp", "video_rtp_port", config->video_rtp_min_port); + } else { + lp_config_set_range(lc->config, "rtp", "video_rtp_port", config->video_rtp_min_port, config->video_rtp_max_port); + } lp_config_set_int(lc->config,"rtp","audio_jitt_comp",config->audio_jitt_comp); lp_config_set_int(lc->config,"rtp","video_jitt_comp",config->video_jitt_comp); lp_config_set_int(lc->config,"rtp","nortp_timeout",config->nortp_timeout); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 0209a3774..1849c083b 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1115,14 +1115,22 @@ void linphone_core_set_video_jittcomp(LinphoneCore *lc, int value); int linphone_core_get_audio_port(const LinphoneCore *lc); +void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, int *max_port); + int linphone_core_get_video_port(const LinphoneCore *lc); +void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, int *max_port); + int linphone_core_get_nortp_timeout(const LinphoneCore *lc); void linphone_core_set_audio_port(LinphoneCore *lc, int port); +void linphone_core_set_audio_port_range(LinphoneCore *lc, int min_port, int max_port); + void linphone_core_set_video_port(LinphoneCore *lc, int port); +void linphone_core_set_video_port_range(LinphoneCore *lc, int min_port, int max_port); + void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port); void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info); diff --git a/coreapi/private.h b/coreapi/private.h index 82ebf3633..028b408f8 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -398,8 +398,10 @@ typedef struct sip_config typedef struct rtp_config { - int audio_rtp_port; - int video_rtp_port; + int audio_rtp_min_port; + int audio_rtp_max_port; + int video_rtp_min_port; + int video_rtp_max_port; int audio_jitt_comp; /*jitter compensation*/ int video_jitt_comp; /*jitter compensation*/ int nortp_timeout; From b8537ffbd3db0f1eb64b6ab2d83561508fd3f807 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 11 Oct 2012 15:49:45 +0200 Subject: [PATCH 254/288] remove size converter in case of IOS simulator --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index dcadb7e8c..95ef77fe1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit dcadb7e8c2f14abfac2dc9d8308ceb20ef4b96ef +Subproject commit 95ef77fe123c23a71e3fe1cb8932efaf048f399c From 981faabdb46fa8223305eaae11d53acb6c1fcda5 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 11 Oct 2012 01:44:14 +0200 Subject: [PATCH 255/288] improve calibrator. First tone frequency changed because it triggered false detection due to harmonics. --- coreapi/ec-calibrator.c | 42 +++++++++++++++++++++++++---------------- coreapi/private.h | 3 ++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index 5fbf7a1fb..ab3bc80ac 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -36,41 +36,50 @@ static void ecc_init_filters(EcCalibrator *ecc){ ecc->sndread=ms_snd_card_create_reader(ecc->play_card); ms_filter_call_method(ecc->sndread,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); + ms_filter_call_method(ecc->sndread,MS_FILTER_GET_SAMPLE_RATE,&rate); + ecc->read_resampler=ms_filter_new(MS_RESAMPLE_ID); + ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_SAMPLE_RATE,&rate); + ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&ecc->rate); + + ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID); ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); ecc->rec=ms_filter_new(MS_FILE_REC_ID); - ms_filter_link(ecc->sndread,0,ecc->det,0); + ms_filter_link(ecc->sndread,0,ecc->read_resampler,0); + ms_filter_link(ecc->read_resampler,0,ecc->det,0); ms_filter_link(ecc->det,0,ecc->rec,0); ecc->play=ms_filter_new(MS_FILE_PLAYER_ID); ecc->gen=ms_filter_new(MS_DTMF_GEN_ID); ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); - ecc->resampler=ms_filter_new(MS_RESAMPLE_ID); + ecc->write_resampler=ms_filter_new(MS_RESAMPLE_ID); ecc->sndwrite=ms_snd_card_create_writer(ecc->capt_card); - - ms_filter_link(ecc->play,0,ecc->gen,0); - ms_filter_link(ecc->gen,0,ecc->resampler,0); - ms_filter_link(ecc->resampler,0,ecc->sndwrite,0); - + ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate); - ms_filter_call_method(ecc->resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); - ms_filter_call_method(ecc->resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate); + ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate); + ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate); + + ms_filter_link(ecc->play,0,ecc->gen,0); + ms_filter_link(ecc->gen,0,ecc->write_resampler,0); + ms_filter_link(ecc->write_resampler,0,ecc->sndwrite,0); - ms_ticker_attach(ecc->ticker,ecc->play); ms_ticker_attach(ecc->ticker,ecc->sndread); + ms_ticker_attach(ecc->ticker,ecc->play); + } static void ecc_deinit_filters(EcCalibrator *ecc){ - ms_ticker_detach(ecc->ticker,ecc->play); ms_ticker_detach(ecc->ticker,ecc->sndread); + ms_ticker_detach(ecc->ticker,ecc->play); ms_filter_unlink(ecc->play,0,ecc->gen,0); - ms_filter_unlink(ecc->gen,0,ecc->resampler,0); - ms_filter_unlink(ecc->resampler,0,ecc->sndwrite,0); + ms_filter_unlink(ecc->gen,0,ecc->write_resampler,0); + ms_filter_unlink(ecc->write_resampler,0,ecc->sndwrite,0); - ms_filter_unlink(ecc->sndread,0,ecc->det,0); + ms_filter_unlink(ecc->sndread,0,ecc->read_resampler,0); + ms_filter_unlink(ecc->read_resampler,0,ecc->det,0); ms_filter_unlink(ecc->det,0,ecc->rec,0); ms_filter_destroy(ecc->sndread); @@ -78,7 +87,8 @@ static void ecc_deinit_filters(EcCalibrator *ecc){ ms_filter_destroy(ecc->rec); ms_filter_destroy(ecc->play); ms_filter_destroy(ecc->gen); - ms_filter_destroy(ecc->resampler); + ms_filter_destroy(ecc->read_resampler); + ms_filter_destroy(ecc->write_resampler); ms_filter_destroy(ecc->sndwrite); ms_ticker_destroy(ecc->ticker); @@ -113,7 +123,7 @@ static void ecc_play_tones(EcCalibrator *ecc){ ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone); - tone.frequency=1000; + tone.frequency=1300; tone.duration=1000; tone.amplitude=1.0; diff --git a/coreapi/private.h b/coreapi/private.h index 028b408f8..b44fe4a97 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -592,7 +592,8 @@ struct _EcCalibrator{ ms_thread_t thread; MSSndCard *play_card,*capt_card; MSFilter *sndread,*det,*rec; - MSFilter *play, *gen, *sndwrite,*resampler; + MSFilter *play, *gen, *sndwrite; + MSFilter *read_resampler,*write_resampler; MSTicker *ticker; LinphoneEcCalibrationCallback cb; void *cb_data; From 2be16cafc6ff49de073d3d12886fcae03c9a3b5d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 15 Oct 2012 09:56:16 +0200 Subject: [PATCH 256/288] Move linphone core java implementation files --- .../impl/org/linphone/core/LinphoneAddressImpl.java | 0 .../impl/org/linphone/core/LinphoneAuthInfoImpl.java | 0 .../impl/org/linphone/core/LinphoneCallImpl.java | 0 .../impl/org/linphone/core/LinphoneCallLogImpl.java | 0 .../impl/org/linphone/core/LinphoneCallParamsImpl.java | 0 .../impl/org/linphone/core/LinphoneCallStatsImpl.java | 0 .../impl/org/linphone/core/LinphoneChatMessageImpl.java | 0 .../impl/org/linphone/core/LinphoneChatRoomImpl.java | 0 .../impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 0 .../impl/org/linphone/core/LinphoneCoreImpl.java | 0 .../impl/org/linphone/core/LinphoneFriendImpl.java | 0 .../impl/org/linphone/core/LinphoneProxyConfigImpl.java | 0 Log.java => java/impl/org/linphone/core/Log.java | 0 .../impl/org/linphone/core/PayloadTypeImpl.java | 0 {video => java/impl/org/linphone/core/video}/VideoUtil.java | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename LinphoneAddressImpl.java => java/impl/org/linphone/core/LinphoneAddressImpl.java (100%) rename LinphoneAuthInfoImpl.java => java/impl/org/linphone/core/LinphoneAuthInfoImpl.java (100%) rename LinphoneCallImpl.java => java/impl/org/linphone/core/LinphoneCallImpl.java (100%) rename LinphoneCallLogImpl.java => java/impl/org/linphone/core/LinphoneCallLogImpl.java (100%) rename LinphoneCallParamsImpl.java => java/impl/org/linphone/core/LinphoneCallParamsImpl.java (100%) rename LinphoneCallStatsImpl.java => java/impl/org/linphone/core/LinphoneCallStatsImpl.java (100%) rename LinphoneChatMessageImpl.java => java/impl/org/linphone/core/LinphoneChatMessageImpl.java (100%) rename LinphoneChatRoomImpl.java => java/impl/org/linphone/core/LinphoneChatRoomImpl.java (100%) rename LinphoneCoreFactoryImpl.java => java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java (100%) rename LinphoneCoreImpl.java => java/impl/org/linphone/core/LinphoneCoreImpl.java (100%) rename LinphoneFriendImpl.java => java/impl/org/linphone/core/LinphoneFriendImpl.java (100%) rename LinphoneProxyConfigImpl.java => java/impl/org/linphone/core/LinphoneProxyConfigImpl.java (100%) rename Log.java => java/impl/org/linphone/core/Log.java (100%) rename PayloadTypeImpl.java => java/impl/org/linphone/core/PayloadTypeImpl.java (100%) rename {video => java/impl/org/linphone/core/video}/VideoUtil.java (100%) diff --git a/LinphoneAddressImpl.java b/java/impl/org/linphone/core/LinphoneAddressImpl.java similarity index 100% rename from LinphoneAddressImpl.java rename to java/impl/org/linphone/core/LinphoneAddressImpl.java diff --git a/LinphoneAuthInfoImpl.java b/java/impl/org/linphone/core/LinphoneAuthInfoImpl.java similarity index 100% rename from LinphoneAuthInfoImpl.java rename to java/impl/org/linphone/core/LinphoneAuthInfoImpl.java diff --git a/LinphoneCallImpl.java b/java/impl/org/linphone/core/LinphoneCallImpl.java similarity index 100% rename from LinphoneCallImpl.java rename to java/impl/org/linphone/core/LinphoneCallImpl.java diff --git a/LinphoneCallLogImpl.java b/java/impl/org/linphone/core/LinphoneCallLogImpl.java similarity index 100% rename from LinphoneCallLogImpl.java rename to java/impl/org/linphone/core/LinphoneCallLogImpl.java diff --git a/LinphoneCallParamsImpl.java b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java similarity index 100% rename from LinphoneCallParamsImpl.java rename to java/impl/org/linphone/core/LinphoneCallParamsImpl.java diff --git a/LinphoneCallStatsImpl.java b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java similarity index 100% rename from LinphoneCallStatsImpl.java rename to java/impl/org/linphone/core/LinphoneCallStatsImpl.java diff --git a/LinphoneChatMessageImpl.java b/java/impl/org/linphone/core/LinphoneChatMessageImpl.java similarity index 100% rename from LinphoneChatMessageImpl.java rename to java/impl/org/linphone/core/LinphoneChatMessageImpl.java diff --git a/LinphoneChatRoomImpl.java b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java similarity index 100% rename from LinphoneChatRoomImpl.java rename to java/impl/org/linphone/core/LinphoneChatRoomImpl.java diff --git a/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java similarity index 100% rename from LinphoneCoreFactoryImpl.java rename to java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java diff --git a/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java similarity index 100% rename from LinphoneCoreImpl.java rename to java/impl/org/linphone/core/LinphoneCoreImpl.java diff --git a/LinphoneFriendImpl.java b/java/impl/org/linphone/core/LinphoneFriendImpl.java similarity index 100% rename from LinphoneFriendImpl.java rename to java/impl/org/linphone/core/LinphoneFriendImpl.java diff --git a/LinphoneProxyConfigImpl.java b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java similarity index 100% rename from LinphoneProxyConfigImpl.java rename to java/impl/org/linphone/core/LinphoneProxyConfigImpl.java diff --git a/Log.java b/java/impl/org/linphone/core/Log.java similarity index 100% rename from Log.java rename to java/impl/org/linphone/core/Log.java diff --git a/PayloadTypeImpl.java b/java/impl/org/linphone/core/PayloadTypeImpl.java similarity index 100% rename from PayloadTypeImpl.java rename to java/impl/org/linphone/core/PayloadTypeImpl.java diff --git a/video/VideoUtil.java b/java/impl/org/linphone/core/video/VideoUtil.java similarity index 100% rename from video/VideoUtil.java rename to java/impl/org/linphone/core/video/VideoUtil.java From 78a66ffc91e960f4cd3379495f02a00898235f3e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 15 Oct 2012 11:39:55 +0200 Subject: [PATCH 257/288] Added audio and video port API to JNI --- coreapi/linphonecore_jni.cc | 16 +++++++++++++++ .../org/linphone/core/LinphoneCore.java | 20 +++++++++++++++++++ .../org/linphone/core/LinphoneCoreImpl.java | 20 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index e8b8a6e2b..f84ca3bb0 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2114,6 +2114,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv ms_set_cpu_count(count); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) { + linphone_core_set_audio_port((LinphoneCore *)lc, port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) { + linphone_core_set_video_port((LinphoneCore *)lc, port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) { + linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) { + linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port); +} + extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) { jstring jvalue =env->NewStringUTF(linphone_core_get_version()); return jvalue; diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 732940fdd..50b8609f0 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -809,4 +809,24 @@ public interface LinphoneCore { * return a linphone friend (if exists) that matches the sip address */ LinphoneFriend findFriendByAddress(String sipUri); + + /** + * Sets the UDP port used for audio streaming. + **/ + void setAudioPort(int port); + + /** + * Sets the UDP port range from which to randomly select the port used for audio streaming. + */ + void setAudioPortRange(int minPort, int maxPort); + + /** + * Sets the UDP port used for video streaming. + **/ + void setVideoPort(int port); + + /** + * Sets the UDP port range from which to randomly select the port used for video streaming. + */ + void setVideoPortRange(int minPort, int maxPort); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 7b62ba835..91e6e18cd 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -110,6 +110,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native int getMissedCallsCount(long nativePtr); private native void resetMissedCallsCount(long nativePtr); private native String getVersion(long nativePtr); + private native void setAudioPort(long nativePtr, int port); + private native void setVideoPort(long nativePtr, int port); + private native void setAudioPortRange(long nativePtr, int minPort, int maxPort); + private native void setVideoPortRange(long nativePtr, int minPort, int maxPort); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -757,4 +761,20 @@ class LinphoneCoreImpl implements LinphoneCore { } return new LinphoneFriendImpl(ptr); } + + public void setAudioPort(int port) { + setAudioPort(nativePtr, port); + } + + public void setVideoPort(int port) { + setVideoPort(nativePtr, port); + } + + public void setAudioPortRange(int minPort, int maxPort) { + setAudioPortRange(nativePtr, minPort, maxPort); + } + + public void setVideoPortRange(int minPort, int maxPort) { + setVideoPortRange(nativePtr, minPort, maxPort); + } } From 30032453d692bf5440a9b90f830c19f559a72005 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 15 Oct 2012 15:39:00 +0200 Subject: [PATCH 258/288] Added setIncomingTimeout to JNI --- coreapi/linphonecore_jni.cc | 4 ++++ java/common/org/linphone/core/LinphoneCore.java | 7 +++++++ java/impl/org/linphone/core/LinphoneCoreImpl.java | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index f84ca3bb0..080c8b009 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2130,6 +2130,10 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) { + linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout); +} + extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) { jstring jvalue =env->NewStringUTF(linphone_core_get_version()); return jvalue; diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 50b8609f0..f2ad09b90 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -829,4 +829,11 @@ public interface LinphoneCore { * Sets the UDP port range from which to randomly select the port used for video streaming. */ void setVideoPortRange(int minPort, int maxPort); + + /** + * Set the incoming call timeout in seconds. + * If an incoming call isn't answered for this timeout period, it is + * automatically declined. + **/ + void setIncomingTimeout(int timeout); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 91e6e18cd..6059915ea 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -114,6 +114,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setVideoPort(long nativePtr, int port); private native void setAudioPortRange(long nativePtr, int minPort, int maxPort); private native void setVideoPortRange(long nativePtr, int minPort, int maxPort); + private native void setIncomingTimeout(long nativePtr, int timeout); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -777,4 +778,8 @@ class LinphoneCoreImpl implements LinphoneCore { public void setVideoPortRange(int minPort, int maxPort) { setVideoPortRange(nativePtr, minPort, maxPort); } + + public void setIncomingTimeout(int timeout) { + setIncomingTimeout(nativePtr, timeout); + } } From cd9c2c4e09c4c385e6495af9393c87aaab370cc9 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 15 Oct 2012 15:34:25 +0200 Subject: [PATCH 259/288] fix bug in file config parser preventing to reset values. --- coreapi/lpconfig.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 46d683c59..bd2adfbb4 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -184,10 +184,10 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){ if (pos2==NULL) pos2=pos1+strlen(pos1); else { *pos2='\0'; /*replace the '\n' */ - pos2--; } /* remove ending white spaces */ - for (; pos2>pos1 && *pos2==' ';pos2--) *pos2='\0'; + for (; pos2>pos1 && pos2[-1]==' ';pos2--) pos2[-1]='\0'; + if (pos2-pos1>=0){ /* found a pair key,value */ if (cur!=NULL){ @@ -198,7 +198,7 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){ ms_free(item->value); item->value=strdup(pos1); } - /*printf("Found %s %s=%s\n",cur->name,key,pos1);*/ + /*printf("Found %s %s={%s}\n",cur->name,key,pos1);*/ }else{ ms_warning("found key,item but no sections"); } From 187aedb4056785ed99a86a089f302bb92e0b3e28 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Mon, 15 Oct 2012 17:10:54 +0200 Subject: [PATCH 260/288] Fix readline dependency --- console/linphonec.h | 4 ++-- m4/readline.m4 | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/console/linphonec.h b/console/linphonec.h index ba7d346f8..3265d42ac 100644 --- a/console/linphonec.h +++ b/console/linphonec.h @@ -29,13 +29,12 @@ #include "config.h" #endif +#ifdef HAVE_READLINE #ifdef HAVE_READLINE_H #include -#define HAVE_READLINE #else #ifdef HAVE_READLINE_READLINE_H #include -#define HAVE_READLINE #endif #endif #ifdef HAVE_HISTORY_H @@ -45,6 +44,7 @@ #include #endif #endif +#endif #undef PARAMS /************************************************************************** diff --git a/m4/readline.m4 b/m4/readline.m4 index 13a217fda..ebb7656cd 100644 --- a/m4/readline.m4 +++ b/m4/readline.m4 @@ -22,15 +22,22 @@ if test "$readline_prefix" != "none"; then AC_CHECK_HEADERS(readline.h readline/readline.h, readline_h_found=yes) AC_CHECK_HEADERS(history.h readline/history.h) - AC_CHECK_LIB(readline, readline, [readline_libs_found=yes],[],[]) - + for termcap_lib in "" -ltermcap -lcurses -lncurses; do + unset ac_cv_lib_readline_readline + AC_CHECK_LIB(readline, readline, [readline_libs_found=yes],[],[$termcap_lib]) + if test "x$readline_libs_found" = "xyes" ; then + READLINE_LIBS="$READLINE_LIBS -lreadline $termcap_lib" + break + fi + done + LIBS=$LIBS_save CPPFLAGS=$CPPFLAGS_save if test "$readline_libs_found$readline_h_found" != "yesyes" ; then AC_MSG_WARN([Could not find libreadline headers or library, linphonec will have limited prompt features]) else - READLINE_LIBS="$READLINE_LIBS -lreadline " + AC_DEFINE([HAVE_READLINE],1,[defined when compiling with readline support]) fi From ca80f9d9140d950891c8fb0e7ac31981186617f5 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Mon, 15 Oct 2012 17:13:11 +0200 Subject: [PATCH 261/288] Add pbuf nullity checks --- gtk/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gtk/main.c b/gtk/main.c index 193803256..b773a5b7f 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -279,8 +279,10 @@ static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name) linphone_gtk_visibility_set(shown,window_name,w,TRUE); if (icon_path) { GdkPixbuf *pbuf=create_pixbuf(icon_path); - gtk_window_set_icon(GTK_WINDOW(w),pbuf); - g_object_unref(G_OBJECT(pbuf)); + if(pbuf != NULL) { + gtk_window_set_icon(GTK_WINDOW(w),pbuf); + g_object_unref(G_OBJECT(pbuf)); + } } } @@ -1526,8 +1528,10 @@ static void linphone_gtk_configure_main_window(){ } if (search_icon){ GdkPixbuf *pbuf=create_pixbuf(search_icon); - gtk_image_set_from_pixbuf(GTK_IMAGE(linphone_gtk_get_widget(w,"directory_search_button_icon")),pbuf); - g_object_unref(G_OBJECT(pbuf)); + if(pbuf != NULL) { + gtk_image_set_from_pixbuf(GTK_IMAGE(linphone_gtk_get_widget(w,"directory_search_button_icon")),pbuf); + g_object_unref(G_OBJECT(pbuf)); + } } if (home){ gchar *tmp; From 2448f16d92d0cb768eda7d0da98cd249ef411009 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 15 Oct 2012 23:40:51 +0200 Subject: [PATCH 262/288] add linphonerc option to put dates in REGISTER messages --- coreapi/linphonecore.c | 1 + coreapi/sal.h | 1 + coreapi/sal_eXosip2.c | 28 +++++++++++++++++++++++++++- coreapi/sal_eXosip2.h | 1 + 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index db7a8ea7c..6ae5563ae 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -620,6 +620,7 @@ static void sip_config_read(LinphoneCore *lc) sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0)); sal_use_double_registrations(lc->sal,lp_config_get_int(lc->config,"sip","use_double_registrations",1)); sal_set_dscp(lc->sal,linphone_core_get_sip_dscp(lc)); + sal_use_dates(lc->sal,lp_config_get_int(lc->config,"sip","put_date",0)); } static void rtp_config_read(LinphoneCore *lc) diff --git a/coreapi/sal.h b/coreapi/sal.h index 1bce846c6..2913096ca 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -340,6 +340,7 @@ unsigned int sal_get_keepalive_period(Sal *ctx); void sal_use_session_timers(Sal *ctx, int expires); void sal_use_double_registrations(Sal *ctx, bool_t enabled); void sal_expire_old_registration_contacts(Sal *ctx, bool_t enabled); +void sal_use_dates(Sal *ctx, bool_t enabled); void sal_reuse_authorization(Sal *ctx, bool_t enabled); void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec); void sal_use_rport(Sal *ctx, bool_t use_rports); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 4b5c20539..1b5f5a2b7 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -283,6 +283,7 @@ Sal * sal_init(){ sal->rootCa = 0; sal->verify_server_certs=TRUE; sal->expire_old_contact=FALSE; + sal->add_dates=FALSE; sal->dscp=-1; return sal; } @@ -460,6 +461,10 @@ void sal_expire_old_registration_contacts(Sal *ctx, bool_t enabled){ ctx->expire_old_contact=enabled; } +void sal_use_dates(Sal *ctx, bool_t enabled){ + ctx->add_dates=enabled; +} + void sal_use_rport(Sal *ctx, bool_t use_rports){ ctx->use_rports=use_rports; } @@ -2215,6 +2220,25 @@ static void sal_register_add_route(osip_message_t *msg, const char *proxy){ osip_message_set_route(msg,tmp); } +static const char *days[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; +static const char *months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; + +static void sal_register_set_date(osip_message_t *msg){ + char tmp[256]={0}; + time_t curtime=time(NULL); + struct tm *ret; +#ifndef WIN32 + struct tm gmt; + ret=gmtime_r(&curtime,&gmt); +#else + ret=gmtime(&curtime); +#endif + /*cannot use strftime because it is locale dependant*/ + snprintf(tmp,sizeof(tmp)-1,"%s, %i %s %i %02i:%02i:%02i GMT", + days[ret->tm_wday],ret->tm_mday,months[ret->tm_mon],1900+ret->tm_year,ret->tm_hour,ret->tm_min,ret->tm_sec); + osip_message_replace_header(msg,"Date",tmp); +} + int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ osip_message_t *msg; const char *contact=sal_op_get_contact(h); @@ -2255,8 +2279,10 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ eXosip_register_build_register(h->rid,expires,&msg); sal_register_add_route(msg,proxy); } - if (msg) + if (msg){ + if (h->base.root->add_dates) sal_register_set_date(msg); eXosip_register_send_register(h->rid,msg); + } eXosip_unlock(); h->expires=expires; return (msg != NULL) ? 0 : -1; diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 71463854c..29eee78ae 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -49,6 +49,7 @@ struct Sal{ bool_t reuse_authorization; bool_t verify_server_certs; bool_t expire_old_contact; + bool_t add_dates; }; struct SalOp{ From 36be073987bf502cdd867e7fc8f798e180acb6e0 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 15 Oct 2012 23:46:42 +0200 Subject: [PATCH 263/288] add linphonerc setting to disable sending of text chats through existing call dialogs if any. --- coreapi/chat.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index 941cce423..31f360135 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -22,8 +22,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "linphonecore.h" - #include "private.h" +#include "linphonecore.h" +#include "private.h" +#include "lpconfig.h" LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to){ LinphoneAddress *parsed_url=NULL; @@ -56,15 +57,18 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM SalOp *op=NULL; LinphoneCall *call; char* content_type; - if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL){ - if (call->state==LinphoneCallConnected || - call->state==LinphoneCallStreamsRunning || - call->state==LinphoneCallPaused || - call->state==LinphoneCallPausing || - call->state==LinphoneCallPausedByRemote){ - ms_message("send SIP message through the existing call."); - op = call->op; - call->pending_message=msg; + + if (lp_config_get_int(cr->lc->config,"sip","chat_use_call_dialogs",1)){ + if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL){ + if (call->state==LinphoneCallConnected || + call->state==LinphoneCallStreamsRunning || + call->state==LinphoneCallPaused || + call->state==LinphoneCallPausing || + call->state==LinphoneCallPausedByRemote){ + ms_message("send SIP message through the existing call."); + op = call->op; + call->pending_message=msg; + } } } if (op==NULL){ From 85535d345646cf60f75549bf4d5fcd0490504393 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 16 Oct 2012 14:22:40 +0200 Subject: [PATCH 264/288] move dates header addon to exosip --- coreapi/sal_eXosip2.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 1b5f5a2b7..b5f6cc10f 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -463,6 +463,14 @@ void sal_expire_old_registration_contacts(Sal *ctx, bool_t enabled){ void sal_use_dates(Sal *ctx, bool_t enabled){ ctx->add_dates=enabled; +#ifdef EXOSIP_OPT_REGISTER_WITH_DATE + { + int tmp=enabled; + eXosip_set_option(EXOSIP_OPT_REGISTER_WITH_DATE,&tmp); + } +#else + if (enabled) ms_warning("Exosip does not support EXOSIP_OPT_REGISTER_WITH_DATE option."); +#endif } void sal_use_rport(Sal *ctx, bool_t use_rports){ @@ -2220,24 +2228,6 @@ static void sal_register_add_route(osip_message_t *msg, const char *proxy){ osip_message_set_route(msg,tmp); } -static const char *days[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; -static const char *months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; - -static void sal_register_set_date(osip_message_t *msg){ - char tmp[256]={0}; - time_t curtime=time(NULL); - struct tm *ret; -#ifndef WIN32 - struct tm gmt; - ret=gmtime_r(&curtime,&gmt); -#else - ret=gmtime(&curtime); -#endif - /*cannot use strftime because it is locale dependant*/ - snprintf(tmp,sizeof(tmp)-1,"%s, %i %s %i %02i:%02i:%02i GMT", - days[ret->tm_wday],ret->tm_mday,months[ret->tm_mon],1900+ret->tm_year,ret->tm_hour,ret->tm_min,ret->tm_sec); - osip_message_replace_header(msg,"Date",tmp); -} int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ osip_message_t *msg; @@ -2280,7 +2270,6 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ sal_register_add_route(msg,proxy); } if (msg){ - if (h->base.root->add_dates) sal_register_set_date(msg); eXosip_register_send_register(h->rid,msg); } eXosip_unlock(); From 1442b46eeaa2e9b1029c937e71f5ae3970bdfe34 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 12 Oct 2012 12:12:56 +0200 Subject: [PATCH 265/288] Add done no echo state for the echo canceller. --- coreapi/ec-calibrator.c | 30 ++++++++++++------- coreapi/linphonecore_utils.h | 7 +++-- .../org/linphone/core/LinphoneCore.java | 13 +++++--- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index ab3bc80ac..7fb001d3d 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -114,7 +114,6 @@ static void ecc_play_tones(EcCalibrator *ecc){ MSDtmfGenCustomTone tone; MSToneDetectorDef expected_tone; - ms_filter_set_notify_callback(ecc->det,on_tone_received,ecc); expected_tone.frequency=2000; @@ -142,20 +141,29 @@ static void ecc_play_tones(EcCalibrator *ecc){ ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone); ms_sleep(1); - if (ecc->sent_count==3 && ecc->recv_count==3){ - int delay=ecc->acc/3; - if (delay<0){ - ms_error("Quite surprising calibration result, delay=%i",delay); - ecc->status=LinphoneEcCalibratorFailed; - }else{ms_message("Echo calibration estimated delay to be %i ms",delay); - ecc->delay=delay; - ecc->status=LinphoneEcCalibratorDone; + if (ecc->sent_count==3) { + if (ecc->recv_count==3){ + int delay=ecc->acc/3; + if (delay<0){ + ms_error("Quite surprising calibration result, delay=%i",delay); + ecc->status=LinphoneEcCalibratorFailed; + }else{ + ms_message("Echo calibration estimated delay to be %i ms",delay); + ecc->delay=delay; + ecc->status=LinphoneEcCalibratorDone; + } + } else if (ecc->recv_count == 0) { + ms_message("Echo calibration succeeded, no echo has been detected"); + ecc->status = LinphoneEcCalibratorDoneNoEcho; + } else { + ecc->status = LinphoneEcCalibratorFailed; } }else{ - ms_error("Echo calibration failed, tones received = %i",ecc->recv_count); ecc->status=LinphoneEcCalibratorFailed; } - + if (ecc->status == LinphoneEcCalibratorFailed) { + ms_error("Echo calibration failed, tones received = %i",ecc->recv_count); + } } static void * ecc_thread(void *p){ diff --git a/coreapi/linphonecore_utils.h b/coreapi/linphonecore_utils.h index 964385683..fadfc1a36 100644 --- a/coreapi/linphonecore_utils.h +++ b/coreapi/linphonecore_utils.h @@ -56,9 +56,10 @@ void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj); * Enum describing the result of the echo canceller calibration process. **/ typedef enum { - LinphoneEcCalibratorInProgress, - LinphoneEcCalibratorDone, - LinphoneEcCalibratorFailed + LinphoneEcCalibratorInProgress, /**< The echo canceller calibration process is on going. */ + LinphoneEcCalibratorDone, /**< The echo canceller calibration has been performed and produced an echo delay measure. */ + LinphoneEcCalibratorFailed, /**< The echo canceller calibration process has failed. */ + LinphoneEcCalibratorDoneNoEcho /**< The echo canceller calibration has been performed and no echo has been detected. */ }LinphoneEcCalibratorStatus; diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index f2ad09b90..de1b4743c 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -234,18 +234,23 @@ public interface LinphoneCore { public static final int IN_PROGRESS_STATUS=0; public static final int DONE_STATUS=1; public static final int FAILED_STATUS=2; + public static final int DONE_NO_ECHO_STATUS=3; /** * Calibration in progress */ - static public EcCalibratorStatus InProgress = new EcCalibratorStatus(IN_PROGRESS_STATUS,"InProgress"); + static public EcCalibratorStatus InProgress = new EcCalibratorStatus(IN_PROGRESS_STATUS,"InProgress"); /** - * Calibration done + * Calibration done that produced an echo delay measure */ - static public EcCalibratorStatus Done = new EcCalibratorStatus(DONE_STATUS,"Done"); + static public EcCalibratorStatus Done = new EcCalibratorStatus(DONE_STATUS,"Done"); /** - * Calibration in progress + * Calibration failed */ static public EcCalibratorStatus Failed = new EcCalibratorStatus(FAILED_STATUS,"Failed"); + /** + * Calibration done with no echo detected + */ + static public EcCalibratorStatus DoneNoEcho = new EcCalibratorStatus(DONE_NO_ECHO_STATUS, "DoneNoEcho"); private final int mValue; private final String mStringValue; From 539f3396b2da95db8c5a24a11e6ac4dfc7bc8f90 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 15 Oct 2012 15:59:38 +0200 Subject: [PATCH 266/288] Define common macros to get default configuration values. --- coreapi/lpconfig.h | 14 ++++++++++++++ coreapi/proxy.c | 17 ++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index b672e4cbf..8f3cae0a1 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -49,6 +49,20 @@ typedef struct _LpConfig LpConfig; extern "C" { #endif + +#define LP_CONFIG_DEFAULT_STRING(config, name, default) \ + (config) ? (lp_config_get_string(config, "default_values", name, default)) : (default) + +#define LP_CONFIG_DEFAULT_INT(config, name, default) \ + (config) ? (lp_config_get_int(config, "default_values", name, default)) : (default) + +#define LP_CONFIG_DEFAULT_INT64(config, name, default) \ + (config) ? (lp_config_get_int64(config, "default_values", name, default)) : (default) + +#define LP_CONFIG_DEFAULT_FLOAT(config, name, default) \ + (config) ? (lp_config_get_float(config, "default_values", name, default)) : (default) + + LpConfig * lp_config_new(const char *filename); int lp_config_read_file(LpConfig *lpconfig, const char *filename); /** diff --git a/coreapi/proxy.c b/coreapi/proxy.c index ba9c0d752..718f7b0f5 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -41,17 +41,12 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){ lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL)); } -#define DEFAULT_INT(config,name,default) \ - config?lp_config_get_int(config,"default_values",#name,default):default -#define DEFAULT_STRING(config,name,default) \ - config?lp_config_get_string(config,"default_values",#name,default):default - static void linphone_proxy_config_init(LinphoneCore* lc,LinphoneProxyConfig *obj){ memset(obj,0,sizeof(LinphoneProxyConfig)); obj->magic=linphone_proxy_config_magic; - obj->expires=DEFAULT_INT((lc?lc->config:NULL),reg_expires,3600); - obj->dial_prefix=ms_strdup(DEFAULT_STRING((lc?lc->config:NULL),dial_prefix,'\0')); - obj->dial_escape_plus=DEFAULT_INT((lc?lc->config:NULL),dial_escape_plus,0); + obj->expires=LP_CONFIG_DEFAULT_INT((lc?lc->config:NULL),"reg_expires",3600); + obj->dial_prefix=ms_strdup(LP_CONFIG_DEFAULT_STRING((lc?lc->config:NULL),"dial_prefix",'\0')); + obj->dial_escape_plus=LP_CONFIG_DEFAULT_INT((lc?lc->config:NULL),"dial_escape_plus",0); } /** @@ -779,13 +774,13 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config linphone_proxy_config_set_contact_parameters(cfg,lp_config_get_string(config,key,"contact_parameters",NULL)); - linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",DEFAULT_INT(config,reg_expires,600))); + linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",LP_CONFIG_DEFAULT_INT(config,"reg_expires",600))); linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0)); linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0)); - linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",DEFAULT_INT(config,dial_escape_plus,0))); - linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",DEFAULT_STRING(config,dial_prefix,NULL))); + linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",LP_CONFIG_DEFAULT_INT(config,"dial_escape_plus",0))); + linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",LP_CONFIG_DEFAULT_STRING(config,"dial_prefix",NULL))); tmp=lp_config_get_string(config,key,"type",NULL); if (tmp!=NULL && strlen(tmp)>0) From 40c1c95eeb8fd0f2cf5e80e071043195f3aa4e93 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 15 Oct 2012 16:00:17 +0200 Subject: [PATCH 267/288] Set a default echo canceller delay if echo canceller calibration fails. --- coreapi/linphonecore.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6ae5563ae..7159edd6f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1935,6 +1935,10 @@ void linphone_core_iterate(LinphoneCore *lc){ if (ecs==LinphoneEcCalibratorDone){ int len=lp_config_get_int(lc->config,"sound","ec_tail_len",0); lp_config_set_int(lc->config, "sound", "ec_delay",MAX(lc->ecc->delay-(len/2),0)); + } else if (ecs == LinphoneEcCalibratorFailed) { + lp_config_set_int(lc->config, "sound", "ec_delay", LP_CONFIG_DEFAULT_INT(lc->config, "ec_delay", 250)); + } else if (ecs == LinphoneEcCalibratorDoneNoEcho) { + linphone_core_enable_echo_cancellation(lc, FALSE); } ec_calibrator_destroy(lc->ecc); lc->ecc=NULL; From 8631bb29cb35247f8690caccb6c31445ff6f9df2 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 16 Oct 2012 15:01:48 +0200 Subject: [PATCH 268/288] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 95ef77fe1..f321d7c76 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 95ef77fe123c23a71e3fe1cb8932efaf048f399c +Subproject commit f321d7c760d65048bebb5dae7f997285c257328b From aa49870d7117df201ea56838f34fe651b458d0ee Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 16 Oct 2012 14:59:32 +0200 Subject: [PATCH 269/288] remove op from chatroom --- coreapi/callbacks.c | 10 ++++++++++ coreapi/chat.c | 7 ------- coreapi/private.h | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7c7d4f003..e7f6a7b21 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -804,14 +804,24 @@ static LinphoneChatMessageState chatStatusSal2Linphone(SalTextDeliveryStatus sta return LinphoneChatMessageStateIdle; } +static int op_equals(LinphoneCall *a, SalOp *b) { + return a->op !=b; /*return 0 if equals*/ +} static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){ LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op); + const MSList* calls = linphone_core_get_calls(chat_msg->chat_room->lc); + if (chat_msg && chat_msg->cb) { chat_msg->cb(chat_msg ,chatStatusSal2Linphone(status) ,chat_msg->cb_ud); } linphone_chat_message_destroy(chat_msg); + + if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) { + /*op was only create for messaging purpose, destroying*/ + sal_op_release(op); + } } SalCallbacks linphone_sal_callbacks={ diff --git a/coreapi/chat.c b/coreapi/chat.c index 31f360135..ea87c9740 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -46,8 +46,6 @@ lc->chatrooms=ms_list_remove(lc->chatrooms,(void *) cr); linphone_address_destroy(cr->peer_url); ms_free(cr->peer); - if (cr->op) - sal_op_release(cr->op); } @@ -75,11 +73,6 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM /*sending out of calls*/ op = sal_op_new(cr->lc->sal); sal_op_set_route(op,route); - if (cr->op!=NULL){ - sal_op_release (cr->op); - cr->op=NULL; - } - cr->op=op; sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/ } if (msg->external_body_url) { diff --git a/coreapi/private.h b/coreapi/private.h index b44fe4a97..07fd1c689 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -354,7 +354,6 @@ struct _LinphoneChatRoom{ struct _LinphoneCore *lc; char *peer; LinphoneAddress *peer_url; - SalOp *op; void * user_data; }; From 314a5559581b945d22fda5776669e0038c270f79 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 16 Oct 2012 16:22:16 +0200 Subject: [PATCH 270/288] Update echo canceller part of documentation. --- java/common/org/linphone/core/package.html | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/java/common/org/linphone/core/package.html b/java/common/org/linphone/core/package.html index 8371def49..a3f08b288 100644 --- a/java/common/org/linphone/core/package.html +++ b/java/common/org/linphone/core/package.html @@ -220,25 +220,37 @@ mic_gain=0.1 Echo cancellation
-On Android devices, echo is a problem, especially with low-end devices. The root cause is the unpredictable latency of Android's sound system. The liblinphone software {@link org.linphone.core.LinphoneCore#enableEchoCancellation echo canceller} that is operating well on desktop platforms (Mac, Linux, Windows) is unable to operate under Android platform. The situation is very heterogenous:
+On Android devices, there are two types of devices regarding echo cancellation:
    -
  • On new (after 2011) high end devices, manufacturers often include a hardware echo cancellation. If available, liblinphone will make use of it and no software correction is required. - Source file linphone-android/submodules/linphone/mediastreamer2/java/src/org/linphone/mediastream/video/capture/hwconf/Hacks.java contains a method hasBuiltInEchoCanceller() that returns true if an hardware echo canceller is available, based on device model identifier. The current list is incomplete. -
  • -
  • On former models with decent CPU power (armv7), sound system behaves in a nearly predictive way so that it is possible to use {@link org.linphone.core.LinphoneCore#enableEchoLimiter echo limiter}. Echo limiter is a simple echo attenuation technique which consists in strongly attenuating the microphone input when speaker is playing voice, in order to cut the echo. The main drawback of echo limiter is that the conversation is perceived as half duplex by users, because they won't hear background noise from the remote side while they are speaking. -
  • -
  • On low class android devices or very old models (armv5 processor), no solution works. -
  • +
  • The new (after 2011) high end devices, on which manufacturers often include a hardware echo cancellation. If available, liblinphone will make use of it and no software correction is required. Source file linphone-android/submodules/linphone/mediastreamer2/java/src/org/linphone/mediastream/video/capture/hwconf/Hacks.java contains a method hasBuiltInEchoCanceller() that returns true if an hardware echo canceller is available, based on device model identifier. The current list is incomplete.
  • +
  • The other devices, on which it is recommended to enable the software echo canceller of liblinphone.

In order to benefit from the best echo cancellation solution, we recommend applications to run the following algorithm, when it is run for the first time:
-First of {@link org.linphone.core.LinphoneCore#enableEchoCancellation echo canceller} should not be used, in any case.
    -
  • Use the Hacks.hasBuiltInEchoCanceller() method to first check if the device has hardware echo canceller. If yes, then echo limiter must be turned off.
  • -
  • If no the hasBuiltInEchoCanceller() returned false, then it is possible to use the echo calibration procedure. If the calibration procedure fails, it means that - probably the phone performs hardware echo cancellation, so in this case echo limiter must be turned off.
  • -
  • If the echo calibration succeeded, then echo is present, so it is recommended to enable echo limiter. +
  • Use the Hacks.hasBuiltInEchoCanceller() method to first check if the device has hardware echo cancellation. If yes, then echo canceller must be turned off.
  • +
  • If no the hasBuiltInEchoCanceller() returned false, then it is possible to use the echo calibration procedure. This procedure can produce the following results: +
      +
    • success with no echo detected: it means that the device has an hardware echo canceller but is not (yet) referenced in our list of devices having hardware echo cancellation.
    • +
    • success with an estimated echo delay: the echo canceller should be enabled and configured with the delay found by the calibration.
    • +
    • failure: it means that some echo has been detected but the delay could not be estimated. In this case it is recommended to activate the echo canceller anyway with a default value for the delay of 250 ms.
    • +
    +
  • +
+In any case, the echo limiter should be disabled while using the earpiece, but enabled while using the speaker. It is also recommended to disable echo canceller while using the speaker. Therefore you should have the following situation: +
    +
  • While using the earpiece
  • +
      +
    • Echo canceller enabled (or disabled for devices that have hardware echo cancellation)
    • +
    • Echo limiter disabled
    • +
    +
  • While using the speaker
  • +
      +
    • Echo canceller disabled
    • +
    • Echo limiter enabled
    • +
    +

From aea4b642524ea42306f791c0202bfbbfd5ad5b97 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 16 Oct 2012 17:13:43 +0200 Subject: [PATCH 271/288] update android documentation --- java/common/org/linphone/core/package.html | 58 +++++++++++++--------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/java/common/org/linphone/core/package.html b/java/common/org/linphone/core/package.html index a3f08b288..3cb6670be 100644 --- a/java/common/org/linphone/core/package.html +++ b/java/common/org/linphone/core/package.html @@ -159,12 +159,7 @@ Any subsequente modifications to {@link org.linphone.core.LinphoneFriend} must b my_friend.enableSubscribes(true); /*disable subscription for this friend*/ my_friend.done(); /*commit changes triggering an UNSUBSCRIBE message*/ - Do not display status messages --J Pass directly to the runtime system - -Provided by Standard doclet: --d Destination directory for output files --use + Publishing presence status
Local presence status can be changed using function {@link org.linphone.core.LinphoneCore#setPresenceInfo }.New status is propagated to all friends {@link org.linphone.core.LinphoneCore#addFriend(LinphoneFriend lf) previously added } to LinphoneCore. @@ -220,48 +215,65 @@ mic_gain=0.1 Echo cancellation
-On Android devices, there are two types of devices regarding echo cancellation:
+On Android devices, there are two kind of situations regarding echo cancellation:
  • The new (after 2011) high end devices, on which manufacturers often include a hardware echo cancellation. If available, liblinphone will make use of it and no software correction is required. Source file linphone-android/submodules/linphone/mediastreamer2/java/src/org/linphone/mediastream/video/capture/hwconf/Hacks.java contains a method hasBuiltInEchoCanceller() that returns true if an hardware echo canceller is available, based on device model identifier. The current list is incomplete.
  • -
  • The other devices, on which it is recommended to enable the software echo canceller of liblinphone.
  • +
  • The other devices, for which it is recommended to enable the software echo canceller of liblinphone.

-In order to benefit from the best echo cancellation solution, we recommend applications to run the following algorithm, when it is run for the first time:
+Echo calibration tool +
+The echo calibration procedure is a five second audio test which consists in playing small beeps to the speaker while the microphone input is recorded. +If the device is subject to echo (or doesn't have hardware echo cancellation), then beeps recorded by the microphone will be detected and a measurement of echo delay can be computed. +Echo calibration procedure can be started by calling {@link org.linphone.core.LinphoneCore#startEchoCalibration LinphoneCore.startEchoCalibration}. +The measurement of the echo delay is important to save CPU computations by restricting the temporal area where the software echo canceller has to perform. +
+ +
+Echo limiter +
+The echo limiter is a liblinphone algorithm to clear out echo with a brute force method. It consists in cutting down the microphone signal when active signal is played by the speaker, to prevent voice to feed back into the microphone. This algorithm has disadvantages compared to the hardware or software echo cancellers because the remote user will be not hear any background noise when speaking, which is confusing. As a result the echo limiter method shall be used only under situation where echo canceller can't perform, that is loud signals with heavy saturations, which usually happens when using the device in speaker mode. Echo limiter can be enabled or disabled during a call with {@link org.linphone.core.LinphoneCall#enableEchoLimiter LinphoneCall.enableEchoLimiter()}. +
+ +
+Recommandations to applications for optimal audio performance +
+ +
+In order to benefit from the best echo cancellation solution, we recommend applications to run the following procedure, when they are run for the first time:
  • Use the Hacks.hasBuiltInEchoCanceller() method to first check if the device has hardware echo cancellation. If yes, then echo canceller must be turned off.
  • -
  • If no the hasBuiltInEchoCanceller() returned false, then it is possible to use the echo calibration procedure. This procedure can produce the following results: +
  • If hasBuiltInEchoCanceller() returned false, then it is recommended to run the echo calibration procedure. This procedure can produce the following results:
      -
    • success with no echo detected: it means that the device has an hardware echo canceller but is not (yet) referenced in our list of devices having hardware echo cancellation.
    • -
    • success with an estimated echo delay: the echo canceller should be enabled and configured with the delay found by the calibration.
    • -
    • failure: it means that some echo has been detected but the delay could not be estimated. In this case it is recommended to activate the echo canceller anyway with a default value for the delay of 250 ms.
    • +
    • success with no echo detected: it means that the device has an hardware echo canceller but is not (yet) referenced in our list of devices having hardware echo cancellation. Echo cancellation should be disabled with {@link org.linphone.core.LinphoneCore#enableEchoCancellation LinphoneCore.enableEchoCancellation(false)}
    • +
    • success with an estimated echo delay: the echo canceller should be enabled.
    • +
    • failure: it means that some echo has been detected but the delay could not be estimated. In this case it is recommended to activate the echo canceller. A typical for android minimum delay of 250 ms will be used as default.
-In any case, the echo limiter should be disabled while using the earpiece, but enabled while using the speaker. It is also recommended to disable echo canceller while using the speaker. Therefore you should have the following situation: + +During calls, the echo limiter should be disabled while using the earpiece, but enabled while using the speaker. It is also recommended to disable echo canceller while using the echo limiter, because the first one would be useless. Therefore you should have the following situations:
  • While using the earpiece
    • -
    • Echo canceller enabled (or disabled for devices that have hardware echo cancellation)
    • +
    • Echo canceller enabled, unless the device has hardware echo cancellation
    • Echo limiter disabled
  • While using the speaker
    • Echo canceller disabled
    • -
    • Echo limiter enabled
    • +
    • Echo limiter enabled, unless the device has hardware echo cancellation.
+Controlling echo limiter during a call has to be done with {@link org.linphone.core.LinphoneCall#enableEchoLimiter LinphoneCall.enableEchoLimiter()}. +Controlling echo canceller during a call has to be done with {@link org.linphone.core.LinphoneCall#enableEchoCancellation LinphoneCall.enableEchoCancellation()}. -
-Echo calibration procedure -
-The echo calibration procedure is a five second test which consists in playing small beeps to the speaker while the microphone input is recorded. -If the device is subject to echo (or doesn't have hardware echo cancellation), then beeps recorded by the microphone will be detected and a measurement of echo delay can be computed. -Echo calibration procedure can be started by calling {@link org.linphone.core.LinphoneCore#startEchoCalibration LinphoneCore.startEchoCalibration}.

-Echo limiter settings
+Echo limiter settings +
Echo limiter requires settings to be defined in linphonerc factory config file for correction operation. Typical settings are:

From b0729789bbf71fc82c243dafa8af253b30174af1 Mon Sep 17 00:00:00 2001
From: Simon Morlat 
Date: Tue, 16 Oct 2012 21:50:05 +0200
Subject: [PATCH 272/288] update ms2

---
 mediastreamer2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mediastreamer2 b/mediastreamer2
index f321d7c76..ac76a8396 160000
--- a/mediastreamer2
+++ b/mediastreamer2
@@ -1 +1 @@
-Subproject commit f321d7c760d65048bebb5dae7f997285c257328b
+Subproject commit ac76a839655828a9006777d08538df2e6622ae7e

From c6eaf5a2fe4f643fd416a77c529df8c288d12ff4 Mon Sep 17 00:00:00 2001
From: Ghislain MARY 
Date: Wed, 17 Oct 2012 09:57:32 +0200
Subject: [PATCH 273/288] Update ms2 submodule.

---
 mediastreamer2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mediastreamer2 b/mediastreamer2
index ac76a8396..23c75b195 160000
--- a/mediastreamer2
+++ b/mediastreamer2
@@ -1 +1 @@
-Subproject commit ac76a839655828a9006777d08538df2e6622ae7e
+Subproject commit 23c75b19523c172c97ba89c76cf7672fc804b14a

From e5d63effa20da11bb8c341d92f6446b6756fc1b8 Mon Sep 17 00:00:00 2001
From: Simon Morlat 
Date: Wed, 17 Oct 2012 14:35:34 +0200
Subject: [PATCH 274/288] document linphone_call_zoom_video and put it in the
 right place.

---
 coreapi/linphonecall.c | 35 +++++++++++++++++++++++++++++++++++
 coreapi/linphonecore.c | 23 -----------------------
 coreapi/linphonecore.h |  3 +--
 3 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c
index a930b1bed..32dc9d59c 100644
--- a/coreapi/linphonecall.c
+++ b/coreapi/linphonecall.c
@@ -2092,3 +2092,38 @@ void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState stat
 bool_t linphone_call_is_in_conference(const LinphoneCall *call) {
 	return call->params.in_conference;
 }
+
+
+/**
+ * Perform a zoom of the video displayed during a call.
+ * @param zoom_factor a floating point number describing the zoom factor. A value 1.0 corresponds to no zoom applied.
+ * @param cx a floating point number pointing the horizontal center of the zoom to be applied. This value should be between 0.0 and 1.0.
+ * @param cy a floating point number pointing the vertical center of the zoom to be applied. This value should be between 0.0 and 1.0.
+ * 
+ * cx and cy are updated in return in case their coordinates were to excentrated for the requested zoom factor. The zoom ensures that all the screen is fullfilled with the video.
+**/
+void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy) {
+	VideoStream* vstream = call->videostream;
+	if (vstream) {
+		float zoom[3];
+		
+		if (zoom_factor < 1)
+			zoom_factor = 1;
+		float halfsize = 0.5 * 1.0 / zoom_factor;
+
+		if ((*cx - halfsize) < 0)
+			*cx = 0 + halfsize;
+		if ((*cx + halfsize) > 1)
+			*cx = 1 - halfsize;
+		if ((*cy - halfsize) < 0)
+			*cy = 0 + halfsize;
+		if ((*cy + halfsize) > 1)
+			*cy = 1 - halfsize;
+	
+		zoom[0] = zoom_factor;
+		zoom[1] = *cx;
+		zoom[2] = *cy;
+        	ms_filter_call_method(vstream->output, MS_VIDEO_DISPLAY_ZOOM, &zoom);
+	}else ms_warning("Could not apply zoom: video output wasn't activated.");
+}
+
diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index 7159edd6f..d96a1905b 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -5181,30 +5181,7 @@ void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *para
 	params->in_conference=FALSE;
 }
 
-void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy) {
-	VideoStream* vstream = call->videostream;
-	if (vstream) {
-		float zoom[3];
-		
-		if (zoom_factor < 1)
-			zoom_factor = 1;
-		float halfsize = 0.5 * 1.0 / zoom_factor;
 
-		if ((*cx - halfsize) < 0)
-			*cx = 0 + halfsize;
-		if ((*cx + halfsize) > 1)
-			*cx = 1 - halfsize;
-		if ((*cy - halfsize) < 0)
-			*cy = 0 + halfsize;
-		if ((*cy + halfsize) > 1)
-			*cy = 1 - halfsize;
-	
-		zoom[0] = zoom_factor;
-		zoom[1] = *cx;
-		zoom[2] = *cy;
-        	ms_filter_call_method(vstream->output, MS_VIDEO_DISPLAY_ZOOM, &zoom);
-	}else ms_warning("Could not apply zoom: video output wasn't activated.");
-}
 
 void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) {
 	if (lc->device_id) ms_free(lc->device_id);
diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h
index 1849c083b..ad52c559f 100644
--- a/coreapi/linphonecore.h
+++ b/coreapi/linphonecore.h
@@ -390,6 +390,7 @@ void *linphone_call_get_user_pointer(LinphoneCall *call);
 void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
 void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data);
 LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call);
+void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy);
 /**
  * Return TRUE if this call is currently part of a conference
  *@param call #LinphoneCall
@@ -1428,8 +1429,6 @@ typedef struct LinphoneTunnel LinphoneTunnel;
 */
 LinphoneTunnel *linphone_core_get_tunnel(LinphoneCore *lc);
 
-void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy);
-
 void linphone_core_set_sip_dscp(LinphoneCore *lc, int dscp);
 int linphone_core_get_sip_dscp(const LinphoneCore *lc);
 

From d79f3d3fa9e5da3fe13ae280cabe9f8a28b578fa Mon Sep 17 00:00:00 2001
From: Ghislain MARY 
Date: Wed, 17 Oct 2012 14:58:55 +0200
Subject: [PATCH 275/288] Add comment to warn about change of echo canceller
 calibration statuses.

---
 java/common/org/linphone/core/LinphoneCore.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java
index de1b4743c..562ae86cd 100644
--- a/java/common/org/linphone/core/LinphoneCore.java
+++ b/java/common/org/linphone/core/LinphoneCore.java
@@ -231,6 +231,8 @@ public interface LinphoneCore {
 	static public class EcCalibratorStatus {
 		
 		static private Vector values = new Vector();
+		/* Do not change the values of these constants or the strings associated with them to prevent breaking
+		   the collection of echo canceller calibration results during the wizard! */
 		public static final int IN_PROGRESS_STATUS=0;
 		public static final int DONE_STATUS=1;
 		public static final int FAILED_STATUS=2;

From d6a8aef9944b09b702e3449abf7fef23738529a4 Mon Sep 17 00:00:00 2001
From: Ghislain MARY 
Date: Thu, 18 Oct 2012 11:58:43 +0200
Subject: [PATCH 276/288] Fix terminology about speaker and receiver in the
 documentation.

---
 java/common/org/linphone/core/package.html | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/java/common/org/linphone/core/package.html b/java/common/org/linphone/core/package.html
index 3cb6670be..f4ba3711b 100644
--- a/java/common/org/linphone/core/package.html
+++ b/java/common/org/linphone/core/package.html
@@ -224,7 +224,7 @@ On Android devices, there are two kind of situations regarding echo cancellation
 
Echo calibration tool
-The echo calibration procedure is a five second audio test which consists in playing small beeps to the speaker while the microphone input is recorded. +The echo calibration procedure is a five second audio test which consists in playing small beeps to the receiver while the microphone input is recorded. If the device is subject to echo (or doesn't have hardware echo cancellation), then beeps recorded by the microphone will be detected and a measurement of echo delay can be computed. Echo calibration procedure can be started by calling {@link org.linphone.core.LinphoneCore#startEchoCalibration LinphoneCore.startEchoCalibration}. The measurement of the echo delay is important to save CPU computations by restricting the temporal area where the software echo canceller has to perform. @@ -233,7 +233,7 @@ The measurement of the echo delay is important to save CPU computations by restr
Echo limiter
-The echo limiter is a liblinphone algorithm to clear out echo with a brute force method. It consists in cutting down the microphone signal when active signal is played by the speaker, to prevent voice to feed back into the microphone. This algorithm has disadvantages compared to the hardware or software echo cancellers because the remote user will be not hear any background noise when speaking, which is confusing. As a result the echo limiter method shall be used only under situation where echo canceller can't perform, that is loud signals with heavy saturations, which usually happens when using the device in speaker mode. Echo limiter can be enabled or disabled during a call with {@link org.linphone.core.LinphoneCall#enableEchoLimiter LinphoneCall.enableEchoLimiter()}. +The echo limiter is a liblinphone algorithm to clear out echo with a brute force method. It consists in cutting down the microphone signal when active signal is played by the speaker/receiver, to prevent voice to feed back into the microphone. This algorithm has disadvantages compared to the hardware or software echo cancellers because the remote user will be not hear any background noise when speaking, which is confusing. As a result the echo limiter method shall be used only under situation where echo canceller can't perform, that is loud signals with heavy saturations, which usually happens when using the device in speaker mode. Echo limiter can be enabled or disabled during a call with {@link org.linphone.core.LinphoneCall#enableEchoLimiter LinphoneCall.enableEchoLimiter()}.

@@ -253,14 +253,14 @@ In order to benefit from the best echo cancellation solution, we recommend appli -During calls, the echo limiter should be disabled while using the earpiece, but enabled while using the speaker. It is also recommended to disable echo canceller while using the echo limiter, because the first one would be useless. Therefore you should have the following situations: +During calls, the echo limiter should be disabled while using the receiver, but enabled while using the hands-free speaker. It is also recommended to disable echo canceller while using the echo limiter, because the first one would be useless. Therefore you should have the following situations:
    -
  • While using the earpiece
  • +
  • While using the receiver
    • Echo canceller enabled, unless the device has hardware echo cancellation
    • Echo limiter disabled
    -
  • While using the speaker
  • +
  • While using the hands-free speaker
    • Echo canceller disabled
    • Echo limiter enabled, unless the device has hardware echo cancellation.
    • From 5ab96647bc209832a4e4997c4aa89ca1149516a4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 18 Oct 2012 17:10:03 +0200 Subject: [PATCH 277/288] Allow configuration of port range for media ports. --- gtk/parameters.ui | 256 ++++++++++++++++++++++++++++++++-------------- gtk/propertybox.c | 124 ++++++++++++++++++++-- 2 files changed, 294 insertions(+), 86 deletions(-) diff --git a/gtk/parameters.ui b/gtk/parameters.ui index 7e76c385f..d6d2e4927 100644 --- a/gtk/parameters.ui +++ b/gtk/parameters.ui @@ -48,7 +48,22 @@ 1 9.9999999995529656 - + + 65535 + 2 + 10 + + + 65535 + 2 + 10 + + + 65535 + 2 + 10 + + 65535 2 10 @@ -59,11 +74,6 @@ 1 10 - - 65535 - 2 - 10 - @@ -207,10 +217,10 @@ Set Maximum Transmission Unit: + False True True False - False True @@ -247,10 +257,10 @@ Send DTMFs as SIP info + False True True False - False True @@ -263,11 +273,11 @@ Use IPv6 instead of IPv4 + False True True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False True @@ -384,9 +394,9 @@ gtk-edit + False True True - False True @@ -423,46 +433,6 @@ 2 - - - True - True - - False - False - True - True - adjustment_audio_port - True - - - - 1 - 2 - 1 - 2 - - - - - True - True - - False - False - True - True - adjustment_video_port - True - - - - 1 - 2 - 2 - 3 - - True @@ -477,10 +447,10 @@ gtk-edit + False True True True - False True @@ -491,6 +461,140 @@ 5 + + + True + False + + + True + True + + False + False + True + True + adjustment_min_audio_port + True + + + + True + True + 0 + + + + + True + True + + True + False + False + True + True + adjustment_max_audio_port + True + + + + True + True + 1 + + + + + Fixed + False + True + True + False + True + + + + True + True + 2 + + + + + 1 + 2 + 1 + 2 + + + + + True + False + + + True + True + + False + False + True + True + adjustment_min_video_port + True + + + + True + True + 0 + + + + + True + True + + True + False + False + True + True + adjustment_max_video_port + True + + + + True + True + 1 + + + + + Fixed + False + True + True + False + True + + + + True + True + 2 + + + + + 1 + 2 + 2 + 3 + + @@ -525,10 +629,10 @@ Direct connection to the Internet + False True True False - False True True @@ -546,10 +650,10 @@ Behind NAT / Firewall (specify gateway IP below) + False True True False - False True True no_nat @@ -614,10 +718,10 @@ Behind NAT / Firewall (use STUN to resolve) + False True True False - False True no_nat @@ -631,10 +735,10 @@ Behind NAT / Firewall (use ICE) + False True True False - False True no_nat @@ -772,6 +876,9 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 6 2 + + + True @@ -793,11 +900,11 @@ gtk-media-play + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False True @@ -970,10 +1077,10 @@ Enable echo cancellation + False True True False - False True @@ -984,9 +1091,6 @@ 6 - - - @@ -1322,10 +1426,10 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False True True True - False @@ -1369,11 +1473,11 @@ + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1417,11 +1521,11 @@ + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1465,11 +1569,11 @@ + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1513,9 +1617,9 @@ + False True True - False @@ -1602,11 +1706,11 @@ virtual network ! GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1788,11 +1892,11 @@ virtual network ! gtk-go-up + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False True @@ -1805,11 +1909,11 @@ virtual network ! gtk-go-down + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False True @@ -1821,11 +1925,11 @@ virtual network ! + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1869,11 +1973,11 @@ virtual network ! + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False @@ -1988,7 +2092,7 @@ virtual network ! 1 2 GTK_FILL - + @@ -2036,10 +2140,10 @@ virtual network ! Enable adaptive rate control + False True True False - False 0 True @@ -2050,7 +2154,7 @@ virtual network ! 2 3 GTK_FILL - + @@ -2065,7 +2169,7 @@ virtual network ! 2 3 GTK_FILL - + @@ -2191,10 +2295,10 @@ virtual network ! Show advanced settings + False True True False - False True @@ -2271,11 +2375,11 @@ virtual network ! end + False True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False diff --git a/gtk/propertybox.c b/gtk/propertybox.c index 31c76f93b..03092a0a5 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -146,14 +146,74 @@ void linphone_gtk_ipv6_toggled(GtkWidget *w){ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); } -void linphone_gtk_audio_port_changed(GtkWidget *w){ - linphone_core_set_audio_port(linphone_gtk_get_core(), - (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); +void linphone_gtk_min_audio_port_changed(GtkWidget *w){ + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + GtkSpinButton *min_button = GTK_SPIN_BUTTON(w); + GtkSpinButton *max_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_max_rtp_port")); + gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_audio_port"))); + + if (fixed) { + linphone_core_set_audio_port(linphone_gtk_get_core(), (gint) gtk_spin_button_get_value(min_button)); + gtk_spin_button_set_value(max_button, gtk_spin_button_get_value(min_button)); + } else { + gint min_port = gtk_spin_button_get_value(min_button); + gint max_port = gtk_spin_button_get_value(max_button); + if (min_port > max_port) { + gtk_spin_button_set_value(max_button, min_port); + max_port = min_port; + } + linphone_core_set_audio_port_range(linphone_gtk_get_core(), min_port, max_port); + } } -void linphone_gtk_video_port_changed(GtkWidget *w){ - linphone_core_set_video_port(linphone_gtk_get_core(), - (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); +void linphone_gtk_max_audio_port_changed(GtkWidget *w){ + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + GtkSpinButton *min_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port")); + GtkSpinButton *max_button = GTK_SPIN_BUTTON(w); + gint min_port = gtk_spin_button_get_value(min_button); + gint max_port = gtk_spin_button_get_value(max_button); + if (max_port < min_port) { + gtk_spin_button_set_value(min_button, max_port); + min_port = max_port; + } + linphone_core_set_audio_port_range(linphone_gtk_get_core(), min_port, max_port); +} + +void linphone_gtk_min_video_port_changed(GtkWidget *w){ + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + GtkSpinButton *min_button = GTK_SPIN_BUTTON(w); + GtkSpinButton *max_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_max_rtp_port")); + gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_video_port"))); + + if (fixed) { + linphone_core_set_video_port(linphone_gtk_get_core(), (gint) gtk_spin_button_get_value(min_button)); + gtk_spin_button_set_value(max_button, gtk_spin_button_get_value(min_button)); + } else { + gint min_port = gtk_spin_button_get_value(min_button); + gint max_port = gtk_spin_button_get_value(max_button); + if (min_port > max_port) { + gtk_spin_button_set_value(max_button, min_port); + max_port = min_port; + } + linphone_core_set_video_port_range(linphone_gtk_get_core(), min_port, max_port); + } +} + +void linphone_gtk_max_video_port_changed(GtkWidget *w){ + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + GtkSpinButton *min_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port")); + GtkSpinButton *max_button = GTK_SPIN_BUTTON(w); + gint min_port = gtk_spin_button_get_value(min_button); + gint max_port = gtk_spin_button_get_value(max_button); + if (max_port < min_port) { + gtk_spin_button_set_value(min_button, max_port); + min_port = max_port; + } + linphone_core_set_video_port_range(linphone_gtk_get_core(), min_port, max_port); } void linphone_gtk_no_firewall_toggled(GtkWidget *w){ @@ -877,6 +937,7 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){ void linphone_gtk_parameters_destroyed(GtkWidget *pb){ GtkWidget *mw=linphone_gtk_get_main_window(); + ms_error("linphone_gtk_paramters_destroyed"); g_object_set_data(G_OBJECT(mw),"parameters",NULL); } @@ -908,12 +969,15 @@ void linphone_gtk_show_parameters(void){ int mtu; int ui_advanced; LCSipTransports tr; + int min_port = 0, max_port = 0; if (pb==NULL) { pb=linphone_gtk_create_window("parameters"); g_object_set_data(G_OBJECT(mw),"parameters",pb); + ms_error("linphone_gtk_show_paramters: create"); }else { gtk_widget_show(pb); + ms_error("linphone_gtk_show_parameters: show"); return; } codec_list=linphone_gtk_get_widget(pb,"codec_list"); @@ -939,10 +1003,20 @@ void linphone_gtk_show_parameters(void){ tr.udp_port); } - gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"audio_rtp_port")), - linphone_core_get_audio_port(lc)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"video_rtp_port")), - linphone_core_get_video_port(lc)); + linphone_core_get_audio_port_range(lc, &min_port, &max_port); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port")), min_port); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_max_rtp_port")), max_port); + if (min_port == max_port) { + gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "audio_max_rtp_port")), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_audio_port")), TRUE); + } + linphone_core_get_video_port_range(lc, &min_port, &max_port); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port")), min_port); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_max_rtp_port")), max_port); + if (min_port == max_port) { + gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "video_max_rtp_port")), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_video_port")), TRUE); + } linphone_gtk_show_media_encryption(pb); @@ -1032,6 +1106,36 @@ void linphone_gtk_show_parameters(void){ } +void linphone_gtk_fixed_audio_port_toggle(void) { + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_audio_port"))); + gint min_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port"))); + gint max_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_max_rtp_port"))); + gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "audio_max_rtp_port")), !fixed); + if (fixed) { + linphone_core_set_audio_port(linphone_gtk_get_core(), min_port); + } else { + linphone_core_set_audio_port_range(linphone_gtk_get_core(), min_port, max_port); + } +} + + +void linphone_gtk_fixed_video_port_toggle(void) { + GtkWidget *mw = linphone_gtk_get_main_window(); + GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); + gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_video_port"))); + gint min_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port"))); + gint max_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_max_rtp_port"))); + gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "video_max_rtp_port")), !fixed); + if (fixed) { + linphone_core_set_video_port(linphone_gtk_get_core(), min_port); + } else { + linphone_core_set_video_port_range(linphone_gtk_get_core(), min_port, max_port); + } +} + + void linphone_gtk_edit_tunnel_closed(GtkWidget *button){ GtkWidget *pb=gtk_widget_get_toplevel(button); gtk_widget_destroy(pb); From 353465b2850a7d8fa1be41e4859d22596b653464 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 19 Oct 2012 11:02:28 +0200 Subject: [PATCH 278/288] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 23c75b195..49f616a4b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 23c75b19523c172c97ba89c76cf7672fc804b14a +Subproject commit 49f616a4b8d32b1ab2adeaa68c8f614ef77276da From e829fa6e222f37de9c26e4e82f0227078f4b6629 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 19 Oct 2012 11:41:03 +0200 Subject: [PATCH 279/288] add int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason) --- coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 33 +++++++++++++++++++++++++++++++-- coreapi/linphonecore.h | 5 ++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 32dc9d59c..70395841a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2096,6 +2096,7 @@ bool_t linphone_call_is_in_conference(const LinphoneCall *call) { /** * Perform a zoom of the video displayed during a call. + * @param call the call. * @param zoom_factor a floating point number describing the zoom factor. A value 1.0 corresponds to no zoom applied. * @param cx a floating point number pointing the horizontal center of the zoom to be applied. This value should be between 0.0 and 1.0. * @param cy a floating point number pointing the vertical center of the zoom to be applied. This value should be between 0.0 and 1.0. diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d96a1905b..c07380502 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2917,6 +2917,7 @@ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){ linphone_call_stop_media_streams(call); if (lc->vtable.display_status!=NULL) lc->vtable.display_status(lc,_("Call ended") ); + linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); } int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri){ @@ -2924,7 +2925,6 @@ int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char sal_call_decline(call->op,SalReasonRedirect,redirect_uri); call->reason=LinphoneReasonDeclined; terminate_call(lc,call); - linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); }else{ ms_error("Bad state for call redirection."); return -1; @@ -2958,8 +2958,35 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call) } sal_call_terminate(call->op); terminate_call(lc,call); + return 0; +} - linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); +/** + * Decline a pending incoming call, with a reason. + * @param lc the linphone core + * @param call the LinphoneCall, must be in the IncomingReceived state. + * @param reason the reason for rejecting the call: LinphoneReasonDeclined or LinphoneReasonBusy +**/ +int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason){ + SalReason sal_reason=SalReasonUnknown; + if (call->state!=LinphoneCallIncomingReceived && call->state!=LinphoneCallIncomingEarlyMedia){ + ms_error("linphone_core_decline_call(): Cannot decline a call that is in state %s",linphone_call_state_to_string(call->state)); + return -1; + } + switch(reason){ + case LinphoneReasonDeclined: + sal_reason=SalReasonDeclined; + break; + case LinphoneReasonBusy: + sal_reason=SalReasonBusy; + break; + default: + ms_error("linphone_core_decline_call(): unsupported reason %s",linphone_reason_to_string(reason)); + return -1; + break; + } + sal_call_decline(call->op,sal_reason,NULL); + terminate_call(lc,call); return 0; } @@ -4975,6 +5002,8 @@ const char *linphone_reason_to_string(LinphoneReason err){ return "User not found"; case LinphoneReasonNotAnswered: return "Not answered"; + case LinphoneReasonBusy: + return "Busy"; } return "unknown error"; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index ad52c559f..d0ecc11a3 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -222,7 +222,8 @@ enum _LinphoneReason{ LinphoneReasonBadCredentials, /** Date: Fri, 19 Oct 2012 15:22:44 +0200 Subject: [PATCH 280/288] Added getRate method to PayloadType interface --- java/common/org/linphone/core/PayloadType.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/common/org/linphone/core/PayloadType.java b/java/common/org/linphone/core/PayloadType.java index 952da57d2..648d77465 100644 --- a/java/common/org/linphone/core/PayloadType.java +++ b/java/common/org/linphone/core/PayloadType.java @@ -21,4 +21,6 @@ package org.linphone.core; public interface PayloadType { String getMime(); + + int getRate(); } From d6d01caf33ca4abb406dadb1975b1370f7e0cb63 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 19 Oct 2012 16:54:09 +0200 Subject: [PATCH 281/288] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 49f616a4b..d26d2090b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 49f616a4b8d32b1ab2adeaa68c8f614ef77276da +Subproject commit d26d2090b4b9ba1b9eec4244e2b3012ee0b12cbd From 8cdb6923d5fbaa2eea6fadd7ba9c3b093418a370 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 22 Oct 2012 21:54:58 +0200 Subject: [PATCH 282/288] add HAVE_EXOSIP_TRYLOCK to android makefile --- build/android/common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/android/common.mk b/build/android/common.mk index 4db1f6809..704b06045 100644 --- a/build/android/common.mk +++ b/build/android/common.mk @@ -63,7 +63,8 @@ LOCAL_CFLAGS += \ -DENABLE_TRACE \ -DLINPHONE_VERSION=\"$(LINPHONE_VERSION)\" \ -DLINPHONE_PLUGINS_DIR=\"\\tmp\" \ - -DLOG_DOMAIN=$(MY_LOG_DOMAIN) + -DLOG_DOMAIN=$(MY_LOG_DOMAIN) \ + -DHAVE_EXOSIP_TRYLOCK=1 LOCAL_CFLAGS += -DIN_LINPHONE From dd45665ea0fc35273f1dfff0f571f7955320d94a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 22 Oct 2012 15:44:23 +0200 Subject: [PATCH 283/288] Do not restart the media streams if only network addresses have been changed in re-invite. --- coreapi/callbacks.c | 69 ++++++++++++++++++++++++++++++++++++++++++--- coreapi/sal.c | 52 +++++++++++++++++++--------------- coreapi/sal.h | 7 ++++- 3 files changed, 101 insertions(+), 27 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index e7f6a7b21..a4a4232c4 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -27,9 +27,63 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details); -static bool_t media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd){ - if (call->params.in_conference!=call->current_params.in_conference) return TRUE; - return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core); +static int media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd) { + if (call->params.in_conference != call->current_params.in_conference) return SAL_MEDIA_DESCRIPTION_CHANGED; + if (call->up_bw != linphone_core_get_upload_bandwidth(call->core)) return SAL_MEDIA_DESCRIPTION_CHANGED; + return sal_media_description_equals(oldmd, newmd); +} + +void linphone_core_update_streams_destinations(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md) { + SalStreamDescription *old_audiodesc = NULL; + SalStreamDescription *old_videodesc = NULL; + SalStreamDescription *new_audiodesc = NULL; + SalStreamDescription *new_videodesc = NULL; + char *rtp_addr, *rtcp_addr; + int i; + + for (i = 0; i < old_md->nstreams; i++) { + if (old_md->streams[i].type == SalAudio) { + old_audiodesc = &old_md->streams[i]; + } else if (old_md->streams[i].type == SalVideo) { + old_videodesc = &old_md->streams[i]; + } + } + for (i = 0; i < new_md->nstreams; i++) { + if (new_md->streams[i].type == SalAudio) { + new_audiodesc = &new_md->streams[i]; + } else if (new_md->streams[i].type == SalVideo) { + new_videodesc = &new_md->streams[i]; + } + } + if (call->audiostream && new_audiodesc) { + rtp_addr = (new_audiodesc->rtp_addr[0] != '\0') ? new_audiodesc->rtp_addr : new_md->addr; + rtcp_addr = (new_audiodesc->rtcp_addr[0] != '\0') ? new_audiodesc->rtcp_addr : new_md->addr; + ms_message("Change audio stream destination: RTP=%s:%d RTCP=%s:%d", rtp_addr, new_audiodesc->rtp_port, rtcp_addr, new_audiodesc->rtcp_port); + rtp_session_set_remote_addr_full(call->audiostream->session, rtp_addr, new_audiodesc->rtp_port, rtcp_addr, new_audiodesc->rtcp_port); + } +#ifdef VIDEO_ENABLED + if (call->videostream && new_videodesc) { + rtp_addr = (new_videodesc->rtp_addr[0] != '\0') ? new_videodesc->rtp_addr : new_md->addr; + rtcp_addr = (new_videodesc->rtcp_addr[0] != '\0') ? new_videodesc->rtcp_addr : new_md->addr; + ms_message("Change video stream destination: RTP=%s:%d RTCP=%s:%d", rtp_addr, new_videodesc->rtp_port, rtcp_addr, new_videodesc->rtcp_port); + rtp_session_set_remote_addr_full(call->videostream->session, rtp_addr, new_videodesc->rtp_port, rtcp_addr, new_videodesc->rtcp_port); + } +#endif + + /* Copy address and port values from new_md to old_md since we will keep old_md as resultdesc */ + strcpy(old_md->addr, new_md->addr); + if (old_audiodesc && new_audiodesc) { + strcpy(old_audiodesc->rtp_addr, new_audiodesc->rtp_addr); + strcpy(old_audiodesc->rtcp_addr, new_audiodesc->rtcp_addr); + old_audiodesc->rtp_port = new_audiodesc->rtp_port; + old_audiodesc->rtcp_port = new_audiodesc->rtcp_port; + } + if (old_videodesc && new_videodesc) { + strcpy(old_videodesc->rtp_addr, new_videodesc->rtp_addr); + strcpy(old_videodesc->rtcp_addr, new_videodesc->rtcp_addr); + old_videodesc->rtp_port = new_videodesc->rtp_port; + old_videodesc->rtcp_port = new_videodesc->rtcp_port; + } } void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){ @@ -49,7 +103,8 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia if ((call->audiostream && call->audiostream->ticker) || (call->videostream && call->videostream->ticker)){ /* we already started media: check if we really need to restart it*/ if (oldmd){ - if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){ + int md_changed = media_parameters_changed(call, oldmd, new_md); + if ((md_changed == SAL_MEDIA_DESCRIPTION_UNCHANGED) && !call->playing_ringbacktone) { /*as nothing has changed, keep the oldmd */ call->resultdesc=oldmd; sal_media_description_unref(new_md); @@ -66,6 +121,12 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia } ms_message("No need to restart streams, SDP is unchanged."); return; + } else if ((md_changed == SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED) && !call->playing_ringbacktone) { + call->resultdesc = oldmd; + ms_message("Network parameters have changed, update them."); + linphone_core_update_streams_destinations(lc, call, oldmd, new_md); + sal_media_description_unref(new_md); + return; }else{ ms_message("Media descriptions are different, need to restart the streams."); } diff --git a/coreapi/sal.c b/coreapi/sal.c index b349ad0a4..229ee577f 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -177,32 +177,40 @@ static bool_t payload_list_equals(const MSList *l1, const MSList *l2){ return TRUE; } -bool_t sal_stream_description_equals(const SalStreamDescription *sd1, const SalStreamDescription *sd2){ - if (sd1->proto!=sd2->proto) return FALSE; - if (sd1->type!=sd2->type) return FALSE; - if (strcmp(sd1->rtp_addr,sd2->rtp_addr)!=0) return FALSE; - if (sd1->rtp_port!=sd2->rtp_port) return FALSE; - if (strcmp(sd1->rtcp_addr,sd2->rtcp_addr)!=0) return FALSE; - if (sd1->rtcp_port!=sd2->rtcp_port) return FALSE; - if (!payload_list_equals(sd1->payloads,sd2->payloads)) return FALSE; - if (sd1->bandwidth!=sd2->bandwidth) return FALSE; - if (sd1->ptime!=sd2->ptime) return FALSE; - /* compare candidates: TODO */ - if (sd1->dir!=sd2->dir) return FALSE; - return TRUE; +int sal_stream_description_equals(const SalStreamDescription *sd1, const SalStreamDescription *sd2) { + int result = SAL_MEDIA_DESCRIPTION_UNCHANGED; + + /* A different proto should result in SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED but the encryption change + needs a stream restart for now, so use SAL_MEDIA_DESCRIPTION_CODEC_CHANGED */ + if (sd1->proto != sd2->proto) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + + if (sd1->type != sd2->type) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + if (strcmp(sd1->rtp_addr, sd2->rtp_addr) != 0) result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + if (sd1->rtp_port != sd2->rtp_port) { + if ((sd1->rtp_port == 0) || (sd2->rtp_port == 0)) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + else result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + } + if (strcmp(sd1->rtcp_addr, sd2->rtcp_addr) != 0) result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + if (sd1->rtcp_port != sd2->rtcp_port) result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + if (!payload_list_equals(sd1->payloads, sd2->payloads)) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + if (sd1->bandwidth != sd2->bandwidth) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + if (sd1->ptime != sd2->ptime) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + if (sd1->dir != sd2->dir) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + + return result; } -bool_t sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2){ +int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2) { + int result = SAL_MEDIA_DESCRIPTION_UNCHANGED; int i; - - if (strcmp(md1->addr,md2->addr)!=0) return FALSE; - if (md1->nstreams!=md2->nstreams) return FALSE; - if (md1->bandwidth!=md2->bandwidth) return FALSE; - for(i=0;instreams;++i){ - if (!sal_stream_description_equals(&md1->streams[i],&md2->streams[i])) - return FALSE; + + if (strcmp(md1->addr, md2->addr) != 0) result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + if (md1->nstreams != md2->nstreams) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + if (md1->bandwidth != md2->bandwidth) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + for(i = 0; i < md1->nstreams; ++i){ + result |= sal_stream_description_equals(&md1->streams[i], &md2->streams[i]); } - return TRUE; + return result; } static void assign_string(char **str, const char *arg){ diff --git a/coreapi/sal.h b/coreapi/sal.h index 2913096ca..54a075ed6 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -53,6 +53,11 @@ typedef enum { SalTransportDTLS /*DTLS*/ }SalTransport; +#define SAL_MEDIA_DESCRIPTION_UNCHANGED 0x00 +#define SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED 0x01 +#define SAL_MEDIA_DESCRIPTION_CODEC_CHANGED 0x02 +#define SAL_MEDIA_DESCRIPTION_CHANGED (SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED | SAL_MEDIA_DESCRIPTION_CODEC_CHANGED) + const char* sal_transport_to_string(SalTransport transport); SalTransport sal_transport_parse(const char*); /* Address manipulation API*/ @@ -189,7 +194,7 @@ SalMediaDescription *sal_media_description_new(); void sal_media_description_ref(SalMediaDescription *md); void sal_media_description_unref(SalMediaDescription *md); bool_t sal_media_description_empty(const SalMediaDescription *md); -bool_t sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2); +int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2); bool_t sal_media_description_has_dir(const SalMediaDescription *md, SalStreamDir dir); SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalMediaProto proto, SalStreamType type); From 9d1c032211f27bd7fff5af4fd070666789548316 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 23 Oct 2012 10:47:24 +0200 Subject: [PATCH 284/288] Update ms2 submodule for Android video fix. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index d26d2090b..bc398d798 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit d26d2090b4b9ba1b9eec4244e2b3012ee0b12cbd +Subproject commit bc398d79882c9bf136fbba0f5ceabe43ad9848fb From 6b89311813fd2721c48cd793176e02650eea69fb Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 23 Oct 2012 11:11:24 +0200 Subject: [PATCH 285/288] Include linphonecore_jni.h to check validity of JNI at compilation time. --- build/android/common.mk | 3 ++- coreapi/linphonecore_jni.cc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build/android/common.mk b/build/android/common.mk index 704b06045..8772e9003 100644 --- a/build/android/common.mk +++ b/build/android/common.mk @@ -81,7 +81,8 @@ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../oRTP/include \ $(LOCAL_PATH)/../mediastreamer2/include \ $(LOCAL_PATH)/../../externals/exosip/include \ - $(LOCAL_PATH)/../../externals/osip/include + $(LOCAL_PATH)/../../externals/osip/include \ + $(LOCAL_PATH)/../../../gen LOCAL_LDLIBS += -llog -ldl diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 080c8b009..69f9b3cc4 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include "linphonecore_jni.h" #include "linphonecore_utils.h" #include From a349f7993016cac9a598ac3cb1b76d6590901995 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 23 Oct 2012 13:34:41 +0200 Subject: [PATCH 286/288] Fix date header --- coreapi/sal_eXosip2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index b5f6cc10f..b83cc4f24 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -415,6 +415,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101); sal_set_dscp(ctx,ctx->dscp); + sal_use_dates(ctx,ctx->add_dates); ipv6=strchr(addr,':')!=NULL; eXosip_enable_ipv6(ipv6); From 7a4fe143879e249570ae39552a82c5681f0cdf6c Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 23 Oct 2012 15:29:25 +0200 Subject: [PATCH 287/288] Print version of linphone core on initialization. --- coreapi/linphonecore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c07380502..b5f35d59d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1099,6 +1099,7 @@ static void misc_config_read (LinphoneCore *lc) { static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config_path, void * userdata) { + ms_message("Initializing LinphoneCore %s", linphone_core_get_version()); memset (lc, 0, sizeof (LinphoneCore)); lc->data=userdata; lc->ringstream_autorelease=TRUE; From 2d9549f17d2680e0919a3975c05d10b86794817a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 25 Oct 2012 13:18:05 +0200 Subject: [PATCH 288/288] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index bc398d798..832672303 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit bc398d79882c9bf136fbba0f5ceabe43ad9848fb +Subproject commit 83267230336a64dc4a005b29bf8baccf6a5fd2c2