2 LinphoneCoreFactoryImpl.java
3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package org.linphone.core;
22 import java.io.IOException;
24 import org.linphone.mediastream.CpuUtils;
25 import org.linphone.mediastream.Version;
27 import android.util.Log;
29 public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
31 private static boolean loadOptionalLibrary(String s) {
33 System.loadLibrary(s);
35 } catch (Throwable e) {
36 Log.w("Unable to load optional library lib", s);
42 // FFMPEG (audio/video)
43 loadOptionalLibrary("avutil");
44 loadOptionalLibrary("swscale");
45 loadOptionalLibrary("avcore");
47 System.loadLibrary("neon");
49 if (!hasNeonInCpuFeatures()) {
50 boolean noNeonLibrariesLoaded = loadOptionalLibrary("avcodecnoneon");
51 if (!noNeonLibrariesLoaded) {
52 loadOptionalLibrary("avcodec");
55 loadOptionalLibrary("avcodec");
58 // OPENSSL (cryptography)
59 // lin prefix avoids collision with libs in /system/lib
60 loadOptionalLibrary("lincrypto");
61 loadOptionalLibrary("linssl");
63 // Secure RTP and key negotiation
64 loadOptionalLibrary("srtp");
65 loadOptionalLibrary("zrtpcpp"); // GPLv3+
68 loadOptionalLibrary("tunnelclient");
70 // g729 A implementation
71 loadOptionalLibrary("bcg729");
74 if (!hasNeonInCpuFeatures()) {
76 if (!isArmv7() && !Version.isX86()) {
77 System.loadLibrary("linphonearmv5");
79 System.loadLibrary("linphonenoneon");
81 Log.w("linphone", "No-neon liblinphone loaded");
82 } catch (UnsatisfiedLinkError ule) {
83 Log.w("linphone", "Failed to load no-neon liblinphone, loading neon liblinphone");
84 System.loadLibrary("linphone");
87 System.loadLibrary("linphone");
90 Version.dumpCapabilities();
93 public LinphoneAuthInfo createAuthInfo(String username, String password,
95 return new LinphoneAuthInfoImpl(username,password,realm);
99 public LinphoneAddress createLinphoneAddress(String username,
100 String domain, String displayName) {
101 return new LinphoneAddressImpl(username,domain,displayName);
105 public LinphoneAddress createLinphoneAddress(String identity) {
106 return new LinphoneAddressImpl(identity);
110 public LpConfig createLpConfig(String file) {
111 return new LpConfigImpl(file);
115 public LinphoneCore createLinphoneCore(LinphoneCoreListener listener,
116 String userConfig, String factoryConfig, Object userdata)
117 throws LinphoneCoreException {
119 return new LinphoneCoreImpl(listener,new File(userConfig),new File(factoryConfig),userdata);
120 } catch (IOException e) {
121 throw new LinphoneCoreException("Cannot create LinphoneCore",e);
126 public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException {
128 return new LinphoneCoreImpl(listener);
129 } catch (IOException e) {
130 throw new LinphoneCoreException("Cannot create LinphoneCore",e);
135 public LinphoneProxyConfig createProxyConfig(String identity, String proxy,
136 String route, boolean enableRegister) throws LinphoneCoreException {
137 return new LinphoneProxyConfigImpl(identity,proxy,route,enableRegister);
141 public native void setDebugMode(boolean enable, String tag);
144 public void setLogHandler(LinphoneLogHandler handler) {
145 //not implemented on Android
150 public LinphoneFriend createLinphoneFriend(String friendUri) {
151 return new LinphoneFriendImpl(friendUri);
155 public LinphoneFriend createLinphoneFriend() {
156 return createLinphoneFriend(null);
159 public static boolean hasNeonInCpuFeatures()
161 CpuUtils cpu = new CpuUtils();
162 return cpu.isCpuNeon();
165 public static boolean isArmv7()
167 return System.getProperty("os.arch").contains("armv7");
171 public LinphoneAuthInfo createAuthInfo(String username, String userid,
172 String passwd, String ha1, String realm) {
173 return new LinphoneAuthInfoImpl(username,userid,passwd,ha1,realm);