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;
23 import java.io.InputStream;
25 import org.linphone.mediastream.Version;
27 import android.util.Log;
29 public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
31 private static void loadOptionalLibrary(String s) {
33 System.loadLibrary(s);
34 } catch (Throwable e) {
35 Log.w("Unable to load optional library lib", s);
40 // FFMPEG (audio/video)
41 if (!hasNeonInCpuFeatures()) {
42 loadOptionalLibrary("avutilnoneon");
43 loadOptionalLibrary("swscalenoneon");
44 loadOptionalLibrary("avcorenoneon");
45 loadOptionalLibrary("avcodecnoneon");
47 loadOptionalLibrary("avutil");
48 loadOptionalLibrary("swscale");
49 loadOptionalLibrary("avcore");
50 loadOptionalLibrary("avcodec");
53 // OPENSSL (cryptography)
54 // lin prefix avoids collision with libs in /system/lib
55 loadOptionalLibrary("lincrypto");
56 loadOptionalLibrary("linssl");
58 // Secure RTP and key negotiation
59 loadOptionalLibrary("srtp");
60 loadOptionalLibrary("zrtpcpp"); // GPLv3+
63 loadOptionalLibrary("tunnelclient");
65 // g729 A implementation
66 loadOptionalLibrary("bcg729");
69 if (!hasNeonInCpuFeatures()) {
70 System.loadLibrary("linphonenoneon");
71 Log.w("linphone", "No-neon liblinphone loaded");
73 System.loadLibrary("linphone");
76 Version.dumpCapabilities();
79 public LinphoneAuthInfo createAuthInfo(String username, String password,
81 return new LinphoneAuthInfoImpl(username,password,realm);
85 public LinphoneAddress createLinphoneAddress(String username,
86 String domain, String displayName) {
87 return new LinphoneAddressImpl(username,domain,displayName);
91 public LinphoneAddress createLinphoneAddress(String identity) {
92 return new LinphoneAddressImpl(identity);
96 public LinphoneCore createLinphoneCore(LinphoneCoreListener listener,
97 String userConfig, String factoryConfig, Object userdata)
98 throws LinphoneCoreException {
100 return new LinphoneCoreImpl(listener,new File(userConfig),new File(factoryConfig),userdata);
101 } catch (IOException e) {
102 throw new LinphoneCoreException("Cannot create LinphoneCore",e);
107 public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException {
109 return new LinphoneCoreImpl(listener);
110 } catch (IOException e) {
111 throw new LinphoneCoreException("Cannot create LinphoneCore",e);
116 public LinphoneProxyConfig createProxyConfig(String identity, String proxy,
117 String route, boolean enableRegister) throws LinphoneCoreException {
118 return new LinphoneProxyConfigImpl(identity,proxy,route,enableRegister);
122 public native void setDebugMode(boolean enable);
125 public void setLogHandler(LinphoneLogHandler handler) {
126 //not implemented on Android
131 public LinphoneFriend createLinphoneFriend(String friendUri) {
132 return new LinphoneFriendImpl(friendUri);
136 public LinphoneFriend createLinphoneFriend() {
137 return createLinphoneFriend(null);
140 public static boolean hasNeonInCpuFeatures()
143 boolean result = false;
146 String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
147 cmd = new ProcessBuilder(args);
149 Process process = cmd.start();
150 InputStream in = process.getInputStream();
151 byte[] re = new byte[1024];
152 while(in.read(re) != -1){
153 String line = new String(re);
154 if (line.contains("Features")) {
155 result = line.contains("neon");
160 } catch(IOException ex){
161 ex.printStackTrace();