]> sjero.net Git - linphone/blob - java/impl/org/linphone/core/LinphoneCoreImpl.java
320939da05fc85ef9d095f95bae1970be1b0a1db
[linphone] / java / impl / org / linphone / core / LinphoneCoreImpl.java
1 /*
2 LinphoneCoreImpl.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
25 class LinphoneCoreImpl implements LinphoneCore {
26
27         private final  LinphoneCoreListener mListener; //to make sure to keep a reference on this object
28         private long nativePtr = 0;
29         private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object  userdata);
30         private native void iterate(long nativePtr);
31         private native long getDefaultProxyConfig(long nativePtr);
32
33         private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
34         private native int addProxyConfig(LinphoneProxyConfig jprtoxyCfg,long nativePtr,long proxyCfgNativePtr);
35         private native void clearAuthInfos(long nativePtr);
36         
37         private native void clearProxyConfigs(long nativePtr);
38         private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
39         private native Object invite(long nativePtr,String uri);
40         private native void terminateCall(long nativePtr, long call);
41         private native long getRemoteAddress(long nativePtr);
42         private native boolean  isInCall(long nativePtr);
43         private native boolean isInComingInvitePending(long nativePtr);
44         private native void acceptCall(long nativePtr, long call);
45         private native long getCallLog(long nativePtr,int position);
46         private native int getNumberOfCallLogs(long nativePtr);
47         private native void delete(long nativePtr);
48         private native void setNetworkStateReachable(long nativePtr,boolean isReachable);
49         private native boolean isNetworkStateReachable(long nativePtr);
50         private native void setPlaybackGain(long nativeptr, float gain);
51         private native float getPlaybackGain(long nativeptr);
52         private native void muteMic(long nativePtr,boolean isMuted);
53         private native long interpretUrl(long nativePtr,String destination);
54         private native Object inviteAddress(long nativePtr,long to);
55         private native Object inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam);
56         private native void sendDtmf(long nativePtr,char dtmf);
57         private native void clearCallLogs(long nativePtr);
58         private native boolean isMicMuted(long nativePtr);
59         private native long findPayloadType(long nativePtr, String mime, int clockRate, int channels);
60         private native int enablePayloadType(long nativePtr, long payloadType,  boolean enable);
61         private native void enableEchoCancellation(long nativePtr,boolean enable);
62         private native boolean isEchoCancellationEnabled(long nativePtr);
63         private native Object getCurrentCall(long nativePtr) ;
64         private native void playDtmf(long nativePtr,char dtmf,int duration);
65         private native void stopDtmf(long nativePtr);
66         private native void setVideoWindowId(long nativePtr, Object wid);
67         private native void setPreviewWindowId(long nativePtr, Object wid);
68         private native void setDeviceRotation(long nativePtr, int rotation);
69         private native void addFriend(long nativePtr,long friend);
70         private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status);
71         private native long createChatRoom(long nativePtr,String to);
72         private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled);
73         private native boolean isVideoEnabled(long nativePtr);
74         private native void setFirewallPolicy(long nativePtr, int enum_value);
75         private native int getFirewallPolicy(long nativePtr);
76         private native void setStunServer(long nativePtr, String stun_server);
77         private native String getStunServer(long nativePtr);
78         private native long createDefaultCallParams(long nativePtr);
79         private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
80         private native void setUploadBandwidth(long nativePtr, int bw);
81         private native void setDownloadBandwidth(long nativePtr, int bw);
82         private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
83         private native int[] getPreferredVideoSize(long nativePtr);
84         private native void setRing(long nativePtr, String path);
85         private native String getRing(long nativePtr);
86         private native void setRootCA(long nativePtr, String path);
87         private native long[] listVideoPayloadTypes(long nativePtr);
88         private native long[] getProxyConfigList(long nativePtr);
89         private native long[] listAudioPayloadTypes(long nativePtr);
90         private native void enableKeepAlive(long nativePtr,boolean enable);
91         private native boolean isKeepAliveEnabled(long nativePtr);
92         private native int startEchoCalibration(long nativePtr,Object data);
93         private native int getSignalingTransportPort(long nativePtr, int code);
94         private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls);
95         private native void enableIpv6(long nativePtr,boolean enable);
96         private native int pauseCall(long nativePtr, long callPtr);
97         private native int pauseAllCalls(long nativePtr);
98         private native int resumeCall(long nativePtr, long callPtr);
99         private native void setUploadPtime(long nativePtr, int ptime);
100         private native void setDownloadPtime(long nativePtr, int ptime);
101         private native void setZrtpSecretsCache(long nativePtr, String file);
102         private native void enableEchoLimiter(long nativePtr2, boolean val);
103         private native int setVideoDevice(long nativePtr2, int id);
104         private native int getVideoDevice(long nativePtr2);
105         private native int getMediaEncryption(long nativePtr);
106         private native void setMediaEncryption(long nativePtr, int menc);
107         private native boolean isMediaEncryptionMandatory(long nativePtr);
108         private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno);
109         private native void removeCallLog(long nativePtr, long callLogPtr);
110         private native int getMissedCallsCount(long nativePtr);
111         private native void resetMissedCallsCount(long nativePtr);
112         private native String getVersion(long nativePtr);
113         private native void setAudioPort(long nativePtr, int port);
114         private native void setVideoPort(long nativePtr, int port);
115         private native void setAudioPortRange(long nativePtr, int minPort, int maxPort);
116         private native void setVideoPortRange(long nativePtr, int minPort, int maxPort);
117         private native void setIncomingTimeout(long nativePtr, int timeout);
118         private native void setInCallTimeout(long nativePtr, int timeout);
119         
120         LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object  userdata) throws IOException {
121                 mListener=listener;
122                 nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata);
123         }
124         LinphoneCoreImpl(LinphoneCoreListener listener) throws IOException {
125                 mListener=listener;
126                 nativePtr = newLinphoneCore(listener,null,null,null);
127         }
128         
129         protected void finalize() throws Throwable {
130                 
131         }
132         
133         public synchronized void addAuthInfo(LinphoneAuthInfo info) {
134                 isValid();
135                 addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
136         }
137
138
139
140         public synchronized LinphoneProxyConfig getDefaultProxyConfig() {
141                 isValid();
142                 long lNativePtr = getDefaultProxyConfig(nativePtr);
143                 if (lNativePtr!=0) {
144                         return new LinphoneProxyConfigImpl(lNativePtr); 
145                 } else {
146                         return null;
147                 }
148         }
149
150         public synchronized LinphoneCall invite(String uri) {
151                 isValid();
152                 return (LinphoneCall)invite(nativePtr,uri);
153         }
154
155         public synchronized void iterate() {
156                 isValid();
157                 iterate(nativePtr);
158         }
159
160         public synchronized void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) {
161                 isValid();
162                 setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr);
163         }
164         public synchronized void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{
165                 isValid();
166                 if (addProxyConfig(proxyCfg,nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) {
167                         throw new LinphoneCoreException("bad proxy config");
168                 }
169         }
170         public synchronized void clearAuthInfos() {
171                 isValid();
172                 clearAuthInfos(nativePtr);
173                 
174         }
175         public synchronized void clearProxyConfigs() {
176                 isValid();
177                 clearProxyConfigs(nativePtr);
178         }
179         public synchronized void terminateCall(LinphoneCall aCall) {
180                 isValid();
181                 if (aCall!=null)terminateCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr);
182         }
183         public synchronized LinphoneAddress getRemoteAddress() {
184                 isValid();
185                 long ptr = getRemoteAddress(nativePtr);
186                 if (ptr==0) {
187                         return null;
188                 } else {
189                         return new LinphoneAddressImpl(ptr);
190                 }
191         }
192         public synchronized  boolean isIncall() {
193                 isValid();
194                 return isInCall(nativePtr);
195         }
196         public synchronized boolean isInComingInvitePending() {
197                 isValid();
198                 return isInComingInvitePending(nativePtr);
199         }
200         public synchronized void acceptCall(LinphoneCall aCall) {
201                 isValid();
202                 acceptCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr);
203                 
204         }
205         public synchronized LinphoneCallLog[] getCallLogs() {
206                 isValid();
207                 LinphoneCallLog[] logs = new LinphoneCallLog[getNumberOfCallLogs(nativePtr)]; 
208                 for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) {
209                         logs[i] = new LinphoneCallLogImpl(getCallLog(nativePtr, i));
210                 }
211                 return logs;
212         }
213         public synchronized void destroy() {
214                 isValid();
215                 delete(nativePtr);
216                 nativePtr = 0;
217         }
218         
219         private void isValid() {
220                 if (nativePtr == 0) {
221                         throw new RuntimeException("object already destroyed");
222                 }
223         }
224         public synchronized void setNetworkReachable(boolean isReachable) {
225                 setNetworkStateReachable(nativePtr,isReachable);
226         }
227         public synchronized void setPlaybackGain(float gain) {
228                 setPlaybackGain(nativePtr,gain);
229                 
230         }
231         public synchronized float getPlaybackGain() {
232                 return getPlaybackGain(nativePtr);
233         }
234         public synchronized void muteMic(boolean isMuted) {
235                 muteMic(nativePtr,isMuted);
236         }
237         public synchronized LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException {
238                 long lAddress = interpretUrl(nativePtr,destination);
239                 if (lAddress != 0) {
240                         return new LinphoneAddressImpl(lAddress,true);
241                 } else {
242                         throw new LinphoneCoreException("Cannot interpret ["+destination+"]");
243                 }
244         }
245         public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { 
246                 LinphoneCall call = (LinphoneCall)inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr);
247                 if (call!=null) {
248                         return call;
249                 } else {
250                         throw new LinphoneCoreException("Unable to invite address " + to.asString());
251                 }
252         }
253
254         public synchronized void sendDtmf(char number) {
255                 sendDtmf(nativePtr,number);
256         }
257         public synchronized void clearCallLogs() {
258                 clearCallLogs(nativePtr);
259         }
260         public synchronized boolean isMicMuted() {
261                 return isMicMuted(nativePtr);
262         }
263         public synchronized PayloadType findPayloadType(String mime, int clockRate, int channels) {
264                 isValid();
265                 long playLoadType = findPayloadType(nativePtr, mime, clockRate, channels);
266                 if (playLoadType == 0) {
267                         return null;
268                 } else {
269                         return new PayloadTypeImpl(playLoadType);
270                 }
271         }
272         public synchronized void enablePayloadType(PayloadType pt, boolean enable)
273                         throws LinphoneCoreException {
274                 isValid();
275                 if (enablePayloadType(nativePtr,((PayloadTypeImpl)pt).nativePtr,enable) != 0) {
276                         throw new LinphoneCoreException("cannot enable payload type ["+pt+"]");
277                 }
278                 
279         }
280         public synchronized void enableEchoCancellation(boolean enable) {
281                 isValid();
282                 enableEchoCancellation(nativePtr, enable);
283         }
284         public synchronized boolean isEchoCancellationEnabled() {
285                 isValid();
286                 return isEchoCancellationEnabled(nativePtr);
287                 
288         }
289
290         public synchronized LinphoneCall getCurrentCall() {
291                 isValid();
292                 return (LinphoneCall)getCurrentCall(nativePtr);
293         }
294         
295         public int getPlayLevel() {
296                 // TODO Auto-generated method stub
297                 return 0;
298         }
299         public void setPlayLevel(int level) {
300                 // TODO Auto-generated method stub
301                 
302         }
303         public void enableSpeaker(boolean value) {
304                 // TODO Auto-generated method stub
305                 
306         }
307         public boolean isSpeakerEnabled() {
308                 // TODO Auto-generated method stub
309                 return false;
310         }
311         public synchronized void playDtmf(char number, int duration) {
312                 playDtmf(nativePtr,number, duration);
313                 
314         }
315         public synchronized void stopDtmf() {
316                 stopDtmf(nativePtr);
317         }
318         
319         public synchronized void addFriend(LinphoneFriend lf) throws LinphoneCoreException {
320                 addFriend(nativePtr,((LinphoneFriendImpl)lf).nativePtr);
321                 
322         }
323         public synchronized void setPresenceInfo(int minute_away, String alternative_contact,
324                         OnlineStatus status) {
325                 setPresenceInfo(nativePtr,minute_away,alternative_contact,status.mValue);
326                 
327         }
328         public synchronized LinphoneChatRoom createChatRoom(String to) {
329                 return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to));
330         }
331         public synchronized void setPreviewWindow(Object w) {
332                 setPreviewWindowId(nativePtr,w);
333         }
334         public synchronized void setVideoWindow(Object w) {
335                 setVideoWindowId(nativePtr, w);
336         }
337         public synchronized void setDeviceRotation(int rotation) {
338                 setDeviceRotation(nativePtr, rotation);
339         }
340         
341         public synchronized void enableVideo(boolean vcap_enabled, boolean display_enabled) {
342                 enableVideo(nativePtr,vcap_enabled, display_enabled);
343         }
344         public synchronized boolean isVideoEnabled() {
345                 return isVideoEnabled(nativePtr);
346         }
347         public synchronized FirewallPolicy getFirewallPolicy() {
348                 return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr));
349         }
350         public synchronized String getStunServer() {
351                 return getStunServer(nativePtr);
352         }
353         public synchronized void setFirewallPolicy(FirewallPolicy pol) {
354                 setFirewallPolicy(nativePtr,pol.value());
355         }
356         public synchronized void setStunServer(String stunServer) {
357                 setStunServer(nativePtr,stunServer);
358         }
359         
360         public synchronized LinphoneCallParams createDefaultCallParameters() {
361                 return new LinphoneCallParamsImpl(createDefaultCallParams(nativePtr));
362         }
363         
364         public synchronized LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException {
365                 long ptrDestination = ((LinphoneAddressImpl)to).nativePtr;
366                 long ptrParams =((LinphoneCallParamsImpl)params).nativePtr;
367                 
368                 LinphoneCall call = (LinphoneCall)inviteAddressWithParams(nativePtr, ptrDestination, ptrParams);
369                 if (call!=null) {
370                         return call;
371                 } else {
372                         throw new LinphoneCoreException("Unable to invite with params " + to.asString());
373                 }
374         }
375
376         public synchronized int updateCall(LinphoneCall call, LinphoneCallParams params) {
377                 long ptrCall = ((LinphoneCallImpl) call).nativePtr;
378                 long ptrParams = params!=null ? ((LinphoneCallParamsImpl)params).nativePtr : 0;
379
380                 return updateCall(nativePtr, ptrCall, ptrParams);
381         }
382         public synchronized void setUploadBandwidth(int bw) {
383                 setUploadBandwidth(nativePtr, bw);
384         }
385
386         public synchronized void setDownloadBandwidth(int bw) {
387                 setDownloadBandwidth(nativePtr, bw);
388         }
389
390         public synchronized void setPreferredVideoSize(VideoSize vSize) {
391                 setPreferredVideoSize(nativePtr, vSize.width, vSize.height);
392         }
393
394         public synchronized VideoSize getPreferredVideoSize() {
395                 int[] nativeSize = getPreferredVideoSize(nativePtr);
396
397                 VideoSize vSize = new VideoSize();
398                 vSize.width = nativeSize[0];
399                 vSize.height = nativeSize[1];
400                 return vSize;
401         }
402         public synchronized void setRing(String path) {
403                 setRing(nativePtr, path);
404         }
405         public synchronized String getRing() {
406                 return getRing(nativePtr);
407         }
408         
409         public synchronized void setRootCA(String path) {
410                 setRootCA(nativePtr, path);
411         }
412         
413         public synchronized LinphoneProxyConfig[] getProxyConfigList() {
414                 long[] typesPtr = getProxyConfigList(nativePtr);
415                 if (typesPtr == null) return null;
416                 
417                 LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length];
418
419                 for (int i=0; i < proxies.length; i++) {
420                         proxies[i] = new LinphoneProxyConfigImpl(typesPtr[i]);
421                 }
422
423                 return proxies;
424         }
425         
426         public synchronized PayloadType[] getVideoCodecs() {
427                 long[] typesPtr = listVideoPayloadTypes(nativePtr);
428                 if (typesPtr == null) return null;
429                 
430                 PayloadType[] codecs = new PayloadType[typesPtr.length];
431
432                 for (int i=0; i < codecs.length; i++) {
433                         codecs[i] = new PayloadTypeImpl(typesPtr[i]);
434                 }
435
436                 return codecs;
437         }
438         public synchronized PayloadType[] getAudioCodecs() {
439                 long[] typesPtr = listAudioPayloadTypes(nativePtr);
440                 if (typesPtr == null) return null;
441                 
442                 PayloadType[] codecs = new PayloadType[typesPtr.length];
443
444                 for (int i=0; i < codecs.length; i++) {
445                         codecs[i] = new PayloadTypeImpl(typesPtr[i]);
446                 }
447
448                 return codecs;
449         }
450         public synchronized boolean isNetworkReachable() {
451                 return isNetworkStateReachable(nativePtr);
452         }
453         
454         public synchronized void enableKeepAlive(boolean enable) {
455                 enableKeepAlive(nativePtr,enable);
456                 
457         }
458         public synchronized boolean isKeepAliveEnabled() {
459                 return isKeepAliveEnabled(nativePtr);
460         }
461         public synchronized void startEchoCalibration(Object data) throws LinphoneCoreException {
462                 startEchoCalibration(nativePtr, data);
463         }
464         
465         public synchronized Transports getSignalingTransportPorts() {
466                 Transports transports = new Transports();
467                 transports.udp = getSignalingTransportPort(nativePtr, 0);
468                 transports.tcp = getSignalingTransportPort(nativePtr, 1);
469                 transports.tls = getSignalingTransportPort(nativePtr, 3);
470                 // See C struct LCSipTransports in linphonecore.h
471                 // Code is the index in the structure
472                 return transports;
473         }
474         public synchronized void setSignalingTransportPorts(Transports transports) {
475                 setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls);
476         }
477
478         public synchronized void enableIpv6(boolean enable) {
479                 enableIpv6(nativePtr,enable);
480         }
481         public synchronized void adjustSoftwareVolume(int i) {
482                 //deprecated, does the same as setPlaybackGain().
483         }
484
485         public synchronized boolean pauseCall(LinphoneCall call) {
486                 return 0 == pauseCall(nativePtr, ((LinphoneCallImpl) call).nativePtr);
487         }
488         public synchronized boolean resumeCall(LinphoneCall call) {
489                 return 0 == resumeCall(nativePtr, ((LinphoneCallImpl) call).nativePtr);
490         }
491         public synchronized boolean pauseAllCalls() {
492                 return 0 == pauseAllCalls(nativePtr);
493         }
494         public synchronized void setDownloadPtime(int ptime) {
495                 setDownloadPtime(nativePtr,ptime);
496                 
497         }
498         public synchronized void setUploadPtime(int ptime) {
499                 setUploadPtime(nativePtr,ptime);
500         }
501
502         public synchronized void setZrtpSecretsCache(String file) {
503                 setZrtpSecretsCache(nativePtr,file);
504         }
505         public synchronized void enableEchoLimiter(boolean val) {
506                 enableEchoLimiter(nativePtr,val);
507         }
508         public void setVideoDevice(int id) {
509                 Log.i("Setting camera id :", id);
510                 if (setVideoDevice(nativePtr, id) != 0) {
511                         Log.e("Failed to set video device to id:", id);
512                 }
513         }
514         public int getVideoDevice() {
515                 return getVideoDevice(nativePtr);
516         }
517
518
519         private native void leaveConference(long nativePtr);    
520         public synchronized void leaveConference() {
521                 leaveConference(nativePtr);
522         }
523
524         private native boolean enterConference(long nativePtr); 
525         public synchronized boolean enterConference() {
526                 return enterConference(nativePtr);
527         }
528
529         private native boolean isInConference(long nativePtr);
530         public synchronized boolean isInConference() {
531                 return isInConference(nativePtr);
532         }
533
534         private native void terminateConference(long nativePtr);
535         public synchronized void terminateConference() {
536                 terminateConference(nativePtr);
537         }
538         private native int getConferenceSize(long nativePtr);
539         public synchronized int getConferenceSize() {
540                 return getConferenceSize(nativePtr);
541         }
542         private native int getCallsNb(long nativePtr);
543         public synchronized int getCallsNb() {
544                 return getCallsNb(nativePtr);
545         }
546         private native void terminateAllCalls(long nativePtr);
547         public synchronized void terminateAllCalls() {
548                 terminateAllCalls(nativePtr);
549         }
550         private native Object getCall(long nativePtr, int position);
551         public synchronized LinphoneCall[] getCalls() {
552                 int size = getCallsNb(nativePtr);
553                 LinphoneCall[] calls = new LinphoneCall[size];
554                 for (int i=0; i < size; i++) {
555                         calls[i]=((LinphoneCall)getCall(nativePtr, i));
556                 }
557                 return calls;
558         }
559         private native void addAllToConference(long nativePtr);
560         public synchronized void addAllToConference() {
561                 addAllToConference(nativePtr);
562                 
563         }
564         private native void addToConference(long nativePtr, long nativePtrLcall);
565         public synchronized void addToConference(LinphoneCall call) {
566                 addToConference(nativePtr, getCallPtr(call));
567                 
568         }
569         private native void removeFromConference(long nativePtr, long nativeCallPtr);
570         public synchronized void removeFromConference(LinphoneCall call) {
571                 removeFromConference(nativePtr,getCallPtr(call));
572         }
573
574         private long getCallPtr(LinphoneCall call) {
575                 return ((LinphoneCallImpl)call).nativePtr;
576         }
577         
578         private long getCallParamsPtr(LinphoneCallParams callParams) {
579                 return ((LinphoneCallParamsImpl)callParams).nativePtr;
580         }
581
582         private native int transferCall(long nativePtr, long callPtr, String referTo);
583         public synchronized void transferCall(LinphoneCall call, String referTo) {
584                 transferCall(nativePtr, getCallPtr(call), referTo);
585         }
586
587         private native int transferCallToAnother(long nativePtr, long callPtr, long destPtr);
588         public synchronized void transferCallToAnother(LinphoneCall call, LinphoneCall dest) {
589                 transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest));
590         }
591
592         private native Object findCallFromUri(long nativePtr, String uri);
593         @Override
594         public synchronized LinphoneCall findCallFromUri(String uri) {
595                 return (LinphoneCall) findCallFromUri(nativePtr, uri);
596         }
597
598         public synchronized MediaEncryption getMediaEncryption() {
599                 return MediaEncryption.fromInt(getMediaEncryption(nativePtr));
600         }
601         public synchronized boolean isMediaEncryptionMandatory() {
602                 return isMediaEncryptionMandatory(nativePtr);
603         }
604         public synchronized void setMediaEncryption(MediaEncryption menc) {
605                 setMediaEncryption(nativePtr, menc.mValue);     
606         }
607         public synchronized void setMediaEncryptionMandatory(boolean yesno) {
608                 setMediaEncryptionMandatory(nativePtr, yesno);
609         }
610
611         private native int getMaxCalls(long nativePtr);
612         public synchronized int getMaxCalls() {
613                 return getMaxCalls(nativePtr);
614         }
615         @Override
616         public boolean isMyself(String uri) {
617                 LinphoneProxyConfig lpc = getDefaultProxyConfig();
618                 if (lpc == null) return false;
619                 return uri.equals(lpc.getIdentity());
620         }
621
622         private native boolean soundResourcesLocked(long nativePtr);
623         public synchronized boolean soundResourcesLocked() {
624                 return soundResourcesLocked(nativePtr);
625         }
626
627         private native void setMaxCalls(long nativePtr, int max);
628         @Override
629         public synchronized void setMaxCalls(int max) {
630                 setMaxCalls(nativePtr, max);
631         }
632         private native boolean isEchoLimiterEnabled(long nativePtr);
633         @Override
634         public synchronized boolean isEchoLimiterEnabled() {
635                 return isEchoLimiterEnabled(nativePtr);
636         }
637         private native boolean mediaEncryptionSupported(long nativePtr, int menc);
638         @Override
639         public synchronized boolean mediaEncryptionSupported(MediaEncryption menc) {
640                 return mediaEncryptionSupported(nativePtr,menc.mValue);
641         }
642
643         private native void setPlayFile(long nativePtr, String path);
644
645         @Override
646         public synchronized void setPlayFile(String path) {
647                 setPlayFile(nativePtr, path);
648         }
649
650
651         private native void tunnelAddServerAndMirror(long nativePtr, String host, int port, int mirror, int ms);
652         @Override
653         public synchronized void tunnelAddServerAndMirror(String host, int port, int mirror, int ms) {
654                 tunnelAddServerAndMirror(nativePtr, host, port, mirror, ms);
655         }
656
657         private native void tunnelAutoDetect(long nativePtr);
658         @Override
659         public synchronized void tunnelAutoDetect() {
660                 tunnelAutoDetect(nativePtr);
661         }
662
663         private native void tunnelCleanServers(long nativePtr);
664         @Override
665         public synchronized void tunnelCleanServers() {
666                 tunnelCleanServers(nativePtr);
667         }
668
669         private native void tunnelEnable(long nativePtr, boolean enable);
670         @Override
671         public synchronized void tunnelEnable(boolean enable) {
672                 tunnelEnable(nativePtr, enable);
673         }
674
675         @Override
676         public native boolean isTunnelAvailable();
677         
678         private native void acceptCallWithParams(long nativePtr, long aCall,
679                         long params);
680         @Override
681         public synchronized void acceptCallWithParams(LinphoneCall aCall,
682                         LinphoneCallParams params) throws LinphoneCoreException {
683                 acceptCallWithParams(nativePtr, getCallPtr(aCall), getCallParamsPtr(params));
684         }
685         
686         private native void acceptCallUpdate(long nativePtr, long aCall, long params);
687         @Override
688         public synchronized void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params)
689                         throws LinphoneCoreException {
690                 acceptCallUpdate(nativePtr, getCallPtr(aCall), getCallParamsPtr(params));               
691         }
692         
693         private native void deferCallUpdate(long nativePtr, long aCall);
694         @Override
695         public synchronized void deferCallUpdate(LinphoneCall aCall)
696                         throws LinphoneCoreException {
697                 deferCallUpdate(nativePtr, getCallPtr(aCall));
698         }
699         
700         private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept);
701         public synchronized void setVideoPolicy(boolean autoInitiate, boolean autoAccept) {
702                 setVideoPolicy(nativePtr, autoInitiate, autoAccept);
703         }
704         private native void setUserAgent(long nativePtr, String name, String version);
705         @Override
706         public void setUserAgent(String name, String version) {
707                 setUserAgent(nativePtr,name,version);
708         }
709
710         private native void setCpuCountNative(int count);
711         public void setCpuCount(int count)
712         {
713                 setCpuCountNative(count);
714         }
715         
716         public int getMissedCallsCount() {
717                 return getMissedCallsCount(nativePtr);
718         }
719         
720         public void removeCallLog(LinphoneCallLog log) {
721                 removeCallLog(nativePtr, ((LinphoneCallLogImpl) log).getNativePtr());
722         }
723
724         public void resetMissedCallsCount() {
725                 resetMissedCallsCount(nativePtr);
726         }
727         
728         private native void tunnelSetHttpProxy(long nativePtr, String proxy_host, int port,
729                         String username, String password);
730         @Override
731         public void tunnelSetHttpProxy(String proxy_host, int port,
732                         String username, String password) {
733                 tunnelSetHttpProxy(nativePtr, proxy_host, port, username, password);
734         }
735         
736         private native void refreshRegisters(long nativePtr);
737         public void refreshRegisters() {
738                 refreshRegisters(nativePtr);
739         }
740         
741         @Override
742         public String getVersion() {
743                 return getVersion(nativePtr);
744         }
745         
746         @Override
747         public PayloadType findPayloadType(String mime, int clockRate) {
748                 return findPayloadType(mime, clockRate, 1);
749         }
750         
751         private native void removeFriend(long ptr, long lf);
752         @Override
753         public void removeFriend(LinphoneFriend lf) {
754                 removeFriend(nativePtr, lf.getNativePtr());
755         }
756         
757         private native long getFriendByAddress(long ptr, String sipUri);
758         @Override
759         public LinphoneFriend findFriendByAddress(String sipUri) {
760                 long ptr = getFriendByAddress(nativePtr, sipUri);
761                 if (ptr == 0) {
762                         return null;
763                 }
764                 return new LinphoneFriendImpl(ptr);
765         }
766         
767         public void setAudioPort(int port) {
768                 setAudioPort(nativePtr, port);
769         }
770         
771         public void setVideoPort(int port) {
772                 setVideoPort(nativePtr, port);
773         }
774         
775         public void setAudioPortRange(int minPort, int maxPort) {
776                 setAudioPortRange(nativePtr, minPort, maxPort);
777         }
778         
779         public void setVideoPortRange(int minPort, int maxPort) {
780                 setVideoPortRange(nativePtr, minPort, maxPort);
781         }
782         
783         public void setIncomingTimeout(int timeout) {
784                 setIncomingTimeout(nativePtr, timeout);
785         }
786         
787         public void setInCallTimeout(int timeout)
788         {
789                 setInCallTimeout(nativePtr, timeout);
790         }
791         
792         private native void setMicrophoneGain(long ptr, float gain);
793         public void setMicrophoneGain(float gain) {
794                 setMicrophoneGain(nativePtr, gain);
795         }
796 }