]> sjero.net Git - linphone/blob - java/impl/org/linphone/tools/Lpc2Xml.java
Use static lib for xml2lpc and lpc2xml
[linphone] / java / impl / org / linphone / tools / Lpc2Xml.java
1 package org.linphone.tools;
2
3 import org.linphone.core.LpConfig;
4 import org.linphone.mediastream.Log;
5
6 public class Lpc2Xml {
7         
8     private enum LogLevel {
9         DEBUG,
10         MESSAGE,
11         WARNING,
12         ERROR,
13     }
14     
15     private static boolean mAvailable;
16     
17         private long internalPtr = 0;
18         
19         private native void init();
20         private native void destroy();
21         
22         public Lpc2Xml() {
23                 init();
24         }
25         
26         public void finalize() {
27                 destroy();
28         }
29         
30         public native int setLpc(LpConfig lpc);
31
32         public native int convertFile(String file);
33         public native int convertString(StringBuffer content);
34         
35         public void printLog(int level, String message) {
36                 if(level > 0 && level < LogLevel.values().length) {
37                         switch(LogLevel.values()[level]) {
38                                 case DEBUG:
39                                         Log.d(message);
40                                 break;
41                                 case MESSAGE:
42                                         Log.i(message);
43                                 break;
44                                 case WARNING:
45                                         Log.w(message);
46                                 break;
47                                 case ERROR:
48                                         Log.e(message);
49                                 break;
50                         }
51                 }
52         }
53         
54         static boolean isAvailable() {
55                 return mAvailable;
56         }
57         
58         // Load library
59         static {
60                 try {
61                         System.loadLibrary("xml2");
62                         //System.loadLibrary("lpc2xml");
63                         mAvailable = true;
64                 } catch (Throwable e) {
65                         mAvailable = false;
66                 }
67         }
68 }