]> sjero.net Git - linphone/blob - LinphoneCoreFactoryImpl.java
add g729 integration
[linphone] / LinphoneCoreFactoryImpl.java
1 /*
2 LinphoneCoreFactoryImpl.java
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
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.
9
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.
14
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.
18 */
19 package org.linphone.core;
20
21 import java.io.File;
22 import java.io.IOException;
23
24 import org.linphone.mediastream.Version;
25
26 public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
27
28         private static void loadOptionalLibrary(String s) {
29                 try {
30                         System.loadLibrary(s);
31                 } catch (Throwable e) {
32                         Log.w("Unable to load optional library lib", s);
33                 }
34         }
35
36         static {
37                 // FFMPEG (audio/video)
38                 loadOptionalLibrary("avutil");
39                 loadOptionalLibrary("swscale");
40                 loadOptionalLibrary("avcore");
41                 loadOptionalLibrary("avcodec");
42  
43                 // OPENSSL (cryptography)
44                 // lin prefix avoids collision with libs in /system/lib
45                 loadOptionalLibrary("lincrypto");
46                 loadOptionalLibrary("linssl");
47
48                 // Secure RTP and key negotiation
49                 loadOptionalLibrary("srtp");
50                 loadOptionalLibrary("zrtpcpp"); // GPLv3+
51
52                 // Tunnel
53                 loadOptionalLibrary("tunnelclient");
54                 
55                 // g729 A implementation
56                 loadOptionalLibrary("bcg729");
57
58                 //Main library
59                 System.loadLibrary("linphone"); 
60
61                 Version.dumpCapabilities();
62         }
63         @Override
64         public LinphoneAuthInfo createAuthInfo(String username, String password,
65                         String realm) {
66                 return new LinphoneAuthInfoImpl(username,password,realm);
67         }
68
69         @Override
70         public LinphoneAddress createLinphoneAddress(String username,
71                         String domain, String displayName) {
72                 return new LinphoneAddressImpl(username,domain,displayName);
73         }
74
75         @Override
76         public LinphoneAddress createLinphoneAddress(String identity) {
77                 return new LinphoneAddressImpl(identity);
78         }
79
80         @Override
81         public LinphoneCore createLinphoneCore(LinphoneCoreListener listener,
82                         String userConfig, String factoryConfig, Object userdata)
83                         throws LinphoneCoreException {
84                 try {
85                         return new LinphoneCoreImpl(listener,new File(userConfig),new File(factoryConfig),userdata);
86                 } catch (IOException e) {
87                         throw new LinphoneCoreException("Cannot create LinphoneCore",e);
88                 }
89         }
90
91         @Override
92         public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException {
93                 try {
94                         return new LinphoneCoreImpl(listener);
95                 } catch (IOException e) {
96                         throw new LinphoneCoreException("Cannot create LinphoneCore",e);
97                 }
98         }
99
100         @Override
101         public LinphoneProxyConfig createProxyConfig(String identity, String proxy,
102                         String route, boolean enableRegister) throws LinphoneCoreException {
103                 return new LinphoneProxyConfigImpl(identity,proxy,route,enableRegister);
104         }
105
106         @Override
107         public native void setDebugMode(boolean enable);
108
109         @Override
110         public void setLogHandler(LinphoneLogHandler handler) {
111                 //not implemented on Android
112                 
113         }
114
115         @Override
116         public LinphoneFriend createLinphoneFriend(String friendUri) {
117                 return new LinphoneFriendImpl(friendUri);
118         }
119
120         @Override
121         public LinphoneFriend createLinphoneFriend() {
122                 return createLinphoneFriend(null);
123         }
124 }