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;
21 import static android.media.AudioManager.MODE_IN_CALL;
22 import static android.media.AudioManager.MODE_RINGTONE;
23 import android.content.Context;
24 import android.media.AudioManager;
27 import java.io.IOException;
29 import org.linphone.core.LinphoneCall.State;
30 import org.linphone.mediastream.video.capture.hwconf.Hacks;
33 class LinphoneCoreImpl implements LinphoneCore {
35 private final LinphoneCoreListener mListener; //to make sure to keep a reference on this object
36 private long nativePtr = 0;
37 private Context mContext = null;
38 private AudioManager mAudioManager = null;
39 private boolean mSpeakerEnabled = false;
40 private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata);
41 private native void iterate(long nativePtr);
42 private native long getDefaultProxyConfig(long nativePtr);
44 private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
45 private native int addProxyConfig(LinphoneProxyConfig jprtoxyCfg,long nativePtr,long proxyCfgNativePtr);
46 private native void clearAuthInfos(long nativePtr);
48 private native void clearProxyConfigs(long nativePtr);
49 private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
50 private native Object invite(long nativePtr,String uri);
51 private native void terminateCall(long nativePtr, long call);
52 private native long getRemoteAddress(long nativePtr);
53 private native boolean isInCall(long nativePtr);
54 private native boolean isInComingInvitePending(long nativePtr);
55 private native void acceptCall(long nativePtr, long call);
56 private native long getCallLog(long nativePtr,int position);
57 private native int getNumberOfCallLogs(long nativePtr);
58 private native void delete(long nativePtr);
59 private native void setNetworkStateReachable(long nativePtr,boolean isReachable);
60 private native boolean isNetworkStateReachable(long nativePtr);
61 private native void setPlaybackGain(long nativeptr, float gain);
62 private native float getPlaybackGain(long nativeptr);
63 private native void muteMic(long nativePtr,boolean isMuted);
64 private native long interpretUrl(long nativePtr,String destination);
65 private native Object inviteAddress(long nativePtr,long to);
66 private native Object inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam);
67 private native void sendDtmf(long nativePtr,char dtmf);
68 private native void clearCallLogs(long nativePtr);
69 private native boolean isMicMuted(long nativePtr);
70 private native long findPayloadType(long nativePtr, String mime, int clockRate, int channels);
71 private native int enablePayloadType(long nativePtr, long payloadType, boolean enable);
72 private native void enableEchoCancellation(long nativePtr,boolean enable);
73 private native boolean isEchoCancellationEnabled(long nativePtr);
74 private native Object getCurrentCall(long nativePtr) ;
75 private native void playDtmf(long nativePtr,char dtmf,int duration);
76 private native void stopDtmf(long nativePtr);
77 private native void setVideoWindowId(long nativePtr, Object wid);
78 private native void setPreviewWindowId(long nativePtr, Object wid);
79 private native void setDeviceRotation(long nativePtr, int rotation);
80 private native void addFriend(long nativePtr,long friend);
81 private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status);
82 private native long createChatRoom(long nativePtr,String to);
83 private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled);
84 private native boolean isVideoEnabled(long nativePtr);
85 private native void setFirewallPolicy(long nativePtr, int enum_value);
86 private native int getFirewallPolicy(long nativePtr);
87 private native void setStunServer(long nativePtr, String stun_server);
88 private native String getStunServer(long nativePtr);
89 private native long createDefaultCallParams(long nativePtr);
90 private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
91 private native void setUploadBandwidth(long nativePtr, int bw);
92 private native void setDownloadBandwidth(long nativePtr, int bw);
93 private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
94 private native int[] getPreferredVideoSize(long nativePtr);
95 private native void setRing(long nativePtr, String path);
96 private native String getRing(long nativePtr);
97 private native void setRootCA(long nativePtr, String path);
98 private native long[] listVideoPayloadTypes(long nativePtr);
99 private native long[] getProxyConfigList(long nativePtr);
100 private native long[] listAudioPayloadTypes(long nativePtr);
101 private native void enableKeepAlive(long nativePtr,boolean enable);
102 private native boolean isKeepAliveEnabled(long nativePtr);
103 private native int startEchoCalibration(long nativePtr,Object data);
104 private native int getSignalingTransportPort(long nativePtr, int code);
105 private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls);
106 private native void enableIpv6(long nativePtr,boolean enable);
107 private native int pauseCall(long nativePtr, long callPtr);
108 private native int pauseAllCalls(long nativePtr);
109 private native int resumeCall(long nativePtr, long callPtr);
110 private native void setUploadPtime(long nativePtr, int ptime);
111 private native void setDownloadPtime(long nativePtr, int ptime);
112 private native void setZrtpSecretsCache(long nativePtr, String file);
113 private native void enableEchoLimiter(long nativePtr2, boolean val);
114 private native int setVideoDevice(long nativePtr2, int id);
115 private native int getVideoDevice(long nativePtr2);
116 private native int getMediaEncryption(long nativePtr);
117 private native void setMediaEncryption(long nativePtr, int menc);
118 private native boolean isMediaEncryptionMandatory(long nativePtr);
119 private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno);
120 private native void removeCallLog(long nativePtr, long callLogPtr);
121 private native int getMissedCallsCount(long nativePtr);
122 private native void resetMissedCallsCount(long nativePtr);
123 private native String getVersion(long nativePtr);
124 private native void setAudioPort(long nativePtr, int port);
125 private native void setVideoPort(long nativePtr, int port);
126 private native void setAudioPortRange(long nativePtr, int minPort, int maxPort);
127 private native void setVideoPortRange(long nativePtr, int minPort, int maxPort);
128 private native void setIncomingTimeout(long nativePtr, int timeout);
129 private native void setInCallTimeout(long nativePtr, int timeout);
130 private native void setPrimaryContact(long nativePtr, String displayName, String username);
132 LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
134 nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata);
136 LinphoneCoreImpl(LinphoneCoreListener listener) throws IOException {
138 nativePtr = newLinphoneCore(listener,null,null,null);
141 protected void finalize() throws Throwable {
145 private boolean contextInitialized() {
146 if (mContext == null) {
147 Log.e("Context of LinphoneCore has not been initialized, call setContext() after creating LinphoneCore.");
152 public void setContext(Object context) {
153 mContext = (Context)context;
154 mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
157 public synchronized void addAuthInfo(LinphoneAuthInfo info) {
159 addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
162 public synchronized LinphoneProxyConfig getDefaultProxyConfig() {
164 long lNativePtr = getDefaultProxyConfig(nativePtr);
166 return new LinphoneProxyConfigImpl(lNativePtr);
172 public synchronized LinphoneCall invite(String uri) {
174 return (LinphoneCall)invite(nativePtr,uri);
177 public synchronized void iterate() {
182 public synchronized void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) {
184 setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr);
186 public synchronized void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{
188 if (addProxyConfig(proxyCfg,nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) {
189 throw new LinphoneCoreException("bad proxy config");
192 public synchronized void clearAuthInfos() {
194 clearAuthInfos(nativePtr);
197 public synchronized void clearProxyConfigs() {
199 clearProxyConfigs(nativePtr);
201 public synchronized void terminateCall(LinphoneCall aCall) {
203 if (aCall!=null)terminateCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr);
205 public synchronized LinphoneAddress getRemoteAddress() {
207 long ptr = getRemoteAddress(nativePtr);
211 return new LinphoneAddressImpl(ptr);
214 public synchronized boolean isIncall() {
216 return isInCall(nativePtr);
218 public synchronized boolean isInComingInvitePending() {
220 return isInComingInvitePending(nativePtr);
222 public synchronized void acceptCall(LinphoneCall aCall) {
224 acceptCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr);
226 public synchronized LinphoneCallLog[] getCallLogs() {
228 LinphoneCallLog[] logs = new LinphoneCallLog[getNumberOfCallLogs(nativePtr)];
229 for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) {
230 logs[i] = new LinphoneCallLogImpl(getCallLog(nativePtr, i));
234 public synchronized void destroy() {
240 private void isValid() {
241 if (nativePtr == 0) {
242 throw new RuntimeException("object already destroyed");
245 public synchronized void setNetworkReachable(boolean isReachable) {
246 setNetworkStateReachable(nativePtr,isReachable);
248 public synchronized void setPlaybackGain(float gain) {
249 setPlaybackGain(nativePtr,gain);
252 public synchronized float getPlaybackGain() {
253 return getPlaybackGain(nativePtr);
255 public synchronized void muteMic(boolean isMuted) {
256 muteMic(nativePtr,isMuted);
259 public synchronized LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException {
260 long lAddress = interpretUrl(nativePtr,destination);
262 return new LinphoneAddressImpl(lAddress,true);
264 throw new LinphoneCoreException("Cannot interpret ["+destination+"]");
267 public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException {
268 LinphoneCall call = (LinphoneCall)inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr);
272 throw new LinphoneCoreException("Unable to invite address " + to.asString());
276 public synchronized void sendDtmf(char number) {
277 sendDtmf(nativePtr,number);
279 public synchronized void clearCallLogs() {
280 clearCallLogs(nativePtr);
282 public synchronized boolean isMicMuted() {
283 return isMicMuted(nativePtr);
285 public synchronized PayloadType findPayloadType(String mime, int clockRate, int channels) {
287 long playLoadType = findPayloadType(nativePtr, mime, clockRate, channels);
288 if (playLoadType == 0) {
291 return new PayloadTypeImpl(playLoadType);
294 public synchronized void enablePayloadType(PayloadType pt, boolean enable)
295 throws LinphoneCoreException {
297 if (enablePayloadType(nativePtr,((PayloadTypeImpl)pt).nativePtr,enable) != 0) {
298 throw new LinphoneCoreException("cannot enable payload type ["+pt+"]");
302 public synchronized void enableEchoCancellation(boolean enable) {
304 enableEchoCancellation(nativePtr, enable);
306 public synchronized boolean isEchoCancellationEnabled() {
308 return isEchoCancellationEnabled(nativePtr);
312 public synchronized LinphoneCall getCurrentCall() {
314 return (LinphoneCall)getCurrentCall(nativePtr);
317 public int getPlayLevel() {
318 // TODO Auto-generated method stub
321 public void setPlayLevel(int level) {
322 // TODO Auto-generated method stub
326 private void applyAudioHacks() {
327 if (Hacks.needGalaxySAudioHack()) {
328 /* The microphone gain is way too high on the Galaxy S so correct it here. */
329 setMicrophoneGain(-9.0f);
332 private void setAudioModeIncallForGalaxyS() {
333 if (!contextInitialized()) return;
334 mAudioManager.setMode(MODE_IN_CALL);
336 public void routeAudioToSpeakerHelper(boolean speakerOn) {
337 if (!contextInitialized()) return;
338 if (Hacks.needGalaxySAudioHack())
339 setAudioModeIncallForGalaxyS();
340 mAudioManager.setSpeakerphoneOn(speakerOn);
342 private native void forceSpeakerState(long nativePtr, boolean speakerOn);
343 public void enableSpeaker(boolean value) {
344 final LinphoneCall call = getCurrentCall();
345 mSpeakerEnabled = value;
347 if (call != null && call.getState() == State.StreamsRunning && Hacks.needGalaxySAudioHack()) {
348 Log.d("Hack to have speaker=", value, " while on call");
349 forceSpeakerState(nativePtr, value);
351 routeAudioToSpeakerHelper(value);
354 public boolean isSpeakerEnabled() {
355 return mSpeakerEnabled;
357 public synchronized void playDtmf(char number, int duration) {
358 playDtmf(nativePtr,number, duration);
361 public synchronized void stopDtmf() {
365 public synchronized void addFriend(LinphoneFriend lf) throws LinphoneCoreException {
366 addFriend(nativePtr,((LinphoneFriendImpl)lf).nativePtr);
369 public synchronized void setPresenceInfo(int minute_away, String alternative_contact,
370 OnlineStatus status) {
371 setPresenceInfo(nativePtr,minute_away,alternative_contact,status.mValue);
374 public synchronized LinphoneChatRoom createChatRoom(String to) {
375 return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to));
377 public synchronized void setPreviewWindow(Object w) {
378 setPreviewWindowId(nativePtr,w);
380 public synchronized void setVideoWindow(Object w) {
381 setVideoWindowId(nativePtr, w);
383 public synchronized void setDeviceRotation(int rotation) {
384 setDeviceRotation(nativePtr, rotation);
387 public synchronized void enableVideo(boolean vcap_enabled, boolean display_enabled) {
388 enableVideo(nativePtr,vcap_enabled, display_enabled);
390 public synchronized boolean isVideoEnabled() {
391 return isVideoEnabled(nativePtr);
393 public synchronized FirewallPolicy getFirewallPolicy() {
394 return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr));
396 public synchronized String getStunServer() {
397 return getStunServer(nativePtr);
399 public synchronized void setFirewallPolicy(FirewallPolicy pol) {
400 setFirewallPolicy(nativePtr,pol.value());
402 public synchronized void setStunServer(String stunServer) {
403 setStunServer(nativePtr,stunServer);
406 public synchronized LinphoneCallParams createDefaultCallParameters() {
407 return new LinphoneCallParamsImpl(createDefaultCallParams(nativePtr));
410 public synchronized LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException {
411 long ptrDestination = ((LinphoneAddressImpl)to).nativePtr;
412 long ptrParams =((LinphoneCallParamsImpl)params).nativePtr;
414 LinphoneCall call = (LinphoneCall)inviteAddressWithParams(nativePtr, ptrDestination, ptrParams);
418 throw new LinphoneCoreException("Unable to invite with params " + to.asString());
422 public synchronized int updateCall(LinphoneCall call, LinphoneCallParams params) {
423 long ptrCall = ((LinphoneCallImpl) call).nativePtr;
424 long ptrParams = params!=null ? ((LinphoneCallParamsImpl)params).nativePtr : 0;
426 return updateCall(nativePtr, ptrCall, ptrParams);
428 public synchronized void setUploadBandwidth(int bw) {
429 setUploadBandwidth(nativePtr, bw);
432 public synchronized void setDownloadBandwidth(int bw) {
433 setDownloadBandwidth(nativePtr, bw);
436 public synchronized void setPreferredVideoSize(VideoSize vSize) {
437 setPreferredVideoSize(nativePtr, vSize.width, vSize.height);
440 public synchronized VideoSize getPreferredVideoSize() {
441 int[] nativeSize = getPreferredVideoSize(nativePtr);
443 VideoSize vSize = new VideoSize();
444 vSize.width = nativeSize[0];
445 vSize.height = nativeSize[1];
448 public synchronized void setRing(String path) {
449 setRing(nativePtr, path);
451 public synchronized String getRing() {
452 return getRing(nativePtr);
455 public synchronized void setRootCA(String path) {
456 setRootCA(nativePtr, path);
459 public synchronized LinphoneProxyConfig[] getProxyConfigList() {
460 long[] typesPtr = getProxyConfigList(nativePtr);
461 if (typesPtr == null) return null;
463 LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length];
465 for (int i=0; i < proxies.length; i++) {
466 proxies[i] = new LinphoneProxyConfigImpl(typesPtr[i]);
472 public synchronized PayloadType[] getVideoCodecs() {
473 long[] typesPtr = listVideoPayloadTypes(nativePtr);
474 if (typesPtr == null) return null;
476 PayloadType[] codecs = new PayloadType[typesPtr.length];
478 for (int i=0; i < codecs.length; i++) {
479 codecs[i] = new PayloadTypeImpl(typesPtr[i]);
484 public synchronized PayloadType[] getAudioCodecs() {
485 long[] typesPtr = listAudioPayloadTypes(nativePtr);
486 if (typesPtr == null) return null;
488 PayloadType[] codecs = new PayloadType[typesPtr.length];
490 for (int i=0; i < codecs.length; i++) {
491 codecs[i] = new PayloadTypeImpl(typesPtr[i]);
496 public synchronized boolean isNetworkReachable() {
497 return isNetworkStateReachable(nativePtr);
500 public synchronized void enableKeepAlive(boolean enable) {
501 enableKeepAlive(nativePtr,enable);
504 public synchronized boolean isKeepAliveEnabled() {
505 return isKeepAliveEnabled(nativePtr);
507 public synchronized void startEchoCalibration(Object data) throws LinphoneCoreException {
508 startEchoCalibration(nativePtr, data);
511 public synchronized Transports getSignalingTransportPorts() {
512 Transports transports = new Transports();
513 transports.udp = getSignalingTransportPort(nativePtr, 0);
514 transports.tcp = getSignalingTransportPort(nativePtr, 1);
515 transports.tls = getSignalingTransportPort(nativePtr, 3);
516 // See C struct LCSipTransports in linphonecore.h
517 // Code is the index in the structure
520 public synchronized void setSignalingTransportPorts(Transports transports) {
521 setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls);
524 public synchronized void enableIpv6(boolean enable) {
525 enableIpv6(nativePtr,enable);
527 public synchronized void adjustSoftwareVolume(int i) {
528 //deprecated, does the same as setPlaybackGain().
531 public synchronized boolean pauseCall(LinphoneCall call) {
532 return 0 == pauseCall(nativePtr, ((LinphoneCallImpl) call).nativePtr);
534 public synchronized boolean resumeCall(LinphoneCall call) {
535 return 0 == resumeCall(nativePtr, ((LinphoneCallImpl) call).nativePtr);
537 public synchronized boolean pauseAllCalls() {
538 return 0 == pauseAllCalls(nativePtr);
540 public synchronized void setDownloadPtime(int ptime) {
541 setDownloadPtime(nativePtr,ptime);
544 public synchronized void setUploadPtime(int ptime) {
545 setUploadPtime(nativePtr,ptime);
548 public synchronized void setZrtpSecretsCache(String file) {
549 setZrtpSecretsCache(nativePtr,file);
551 public synchronized void enableEchoLimiter(boolean val) {
552 enableEchoLimiter(nativePtr,val);
554 public void setVideoDevice(int id) {
555 Log.i("Setting camera id :", id);
556 if (setVideoDevice(nativePtr, id) != 0) {
557 Log.e("Failed to set video device to id:", id);
560 public int getVideoDevice() {
561 return getVideoDevice(nativePtr);
565 private native void leaveConference(long nativePtr);
566 public synchronized void leaveConference() {
567 leaveConference(nativePtr);
570 private native boolean enterConference(long nativePtr);
571 public synchronized boolean enterConference() {
572 return enterConference(nativePtr);
575 private native boolean isInConference(long nativePtr);
576 public synchronized boolean isInConference() {
577 return isInConference(nativePtr);
580 private native void terminateConference(long nativePtr);
581 public synchronized void terminateConference() {
582 terminateConference(nativePtr);
584 private native int getConferenceSize(long nativePtr);
585 public synchronized int getConferenceSize() {
586 return getConferenceSize(nativePtr);
588 private native int getCallsNb(long nativePtr);
589 public synchronized int getCallsNb() {
590 return getCallsNb(nativePtr);
592 private native void terminateAllCalls(long nativePtr);
593 public synchronized void terminateAllCalls() {
594 terminateAllCalls(nativePtr);
596 private native Object getCall(long nativePtr, int position);
597 public synchronized LinphoneCall[] getCalls() {
598 int size = getCallsNb(nativePtr);
599 LinphoneCall[] calls = new LinphoneCall[size];
600 for (int i=0; i < size; i++) {
601 calls[i]=((LinphoneCall)getCall(nativePtr, i));
605 private native void addAllToConference(long nativePtr);
606 public synchronized void addAllToConference() {
607 addAllToConference(nativePtr);
610 private native void addToConference(long nativePtr, long nativePtrLcall);
611 public synchronized void addToConference(LinphoneCall call) {
612 addToConference(nativePtr, getCallPtr(call));
615 private native void removeFromConference(long nativePtr, long nativeCallPtr);
616 public synchronized void removeFromConference(LinphoneCall call) {
617 removeFromConference(nativePtr,getCallPtr(call));
620 private long getCallPtr(LinphoneCall call) {
621 return ((LinphoneCallImpl)call).nativePtr;
624 private long getCallParamsPtr(LinphoneCallParams callParams) {
625 return ((LinphoneCallParamsImpl)callParams).nativePtr;
628 private native int transferCall(long nativePtr, long callPtr, String referTo);
629 public synchronized void transferCall(LinphoneCall call, String referTo) {
630 transferCall(nativePtr, getCallPtr(call), referTo);
633 private native int transferCallToAnother(long nativePtr, long callPtr, long destPtr);
634 public synchronized void transferCallToAnother(LinphoneCall call, LinphoneCall dest) {
635 transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest));
638 private native Object findCallFromUri(long nativePtr, String uri);
640 public synchronized LinphoneCall findCallFromUri(String uri) {
641 return (LinphoneCall) findCallFromUri(nativePtr, uri);
644 public synchronized MediaEncryption getMediaEncryption() {
645 return MediaEncryption.fromInt(getMediaEncryption(nativePtr));
647 public synchronized boolean isMediaEncryptionMandatory() {
648 return isMediaEncryptionMandatory(nativePtr);
650 public synchronized void setMediaEncryption(MediaEncryption menc) {
651 setMediaEncryption(nativePtr, menc.mValue);
653 public synchronized void setMediaEncryptionMandatory(boolean yesno) {
654 setMediaEncryptionMandatory(nativePtr, yesno);
657 private native int getMaxCalls(long nativePtr);
658 public synchronized int getMaxCalls() {
659 return getMaxCalls(nativePtr);
662 public boolean isMyself(String uri) {
663 LinphoneProxyConfig lpc = getDefaultProxyConfig();
664 if (lpc == null) return false;
665 return uri.equals(lpc.getIdentity());
668 private native boolean soundResourcesLocked(long nativePtr);
669 public synchronized boolean soundResourcesLocked() {
670 return soundResourcesLocked(nativePtr);
673 private native void setMaxCalls(long nativePtr, int max);
675 public synchronized void setMaxCalls(int max) {
676 setMaxCalls(nativePtr, max);
678 private native boolean isEchoLimiterEnabled(long nativePtr);
680 public synchronized boolean isEchoLimiterEnabled() {
681 return isEchoLimiterEnabled(nativePtr);
683 private native boolean mediaEncryptionSupported(long nativePtr, int menc);
685 public synchronized boolean mediaEncryptionSupported(MediaEncryption menc) {
686 return mediaEncryptionSupported(nativePtr,menc.mValue);
689 private native void setPlayFile(long nativePtr, String path);
692 public synchronized void setPlayFile(String path) {
693 setPlayFile(nativePtr, path);
697 private native void tunnelAddServerAndMirror(long nativePtr, String host, int port, int mirror, int ms);
699 public synchronized void tunnelAddServerAndMirror(String host, int port, int mirror, int ms) {
700 tunnelAddServerAndMirror(nativePtr, host, port, mirror, ms);
703 private native void tunnelAutoDetect(long nativePtr);
705 public synchronized void tunnelAutoDetect() {
706 tunnelAutoDetect(nativePtr);
709 private native void tunnelCleanServers(long nativePtr);
711 public synchronized void tunnelCleanServers() {
712 tunnelCleanServers(nativePtr);
715 private native void tunnelEnable(long nativePtr, boolean enable);
717 public synchronized void tunnelEnable(boolean enable) {
718 tunnelEnable(nativePtr, enable);
722 public native boolean isTunnelAvailable();
724 private native void acceptCallWithParams(long nativePtr, long aCall,
727 public synchronized void acceptCallWithParams(LinphoneCall aCall,
728 LinphoneCallParams params) throws LinphoneCoreException {
729 acceptCallWithParams(nativePtr, getCallPtr(aCall), getCallParamsPtr(params));
732 private native void acceptCallUpdate(long nativePtr, long aCall, long params);
734 public synchronized void acceptCallUpdate(LinphoneCall aCall, LinphoneCallParams params)
735 throws LinphoneCoreException {
736 acceptCallUpdate(nativePtr, getCallPtr(aCall), getCallParamsPtr(params));
739 private native void deferCallUpdate(long nativePtr, long aCall);
741 public synchronized void deferCallUpdate(LinphoneCall aCall)
742 throws LinphoneCoreException {
743 deferCallUpdate(nativePtr, getCallPtr(aCall));
746 public synchronized void startRinging() {
747 if (!contextInitialized()) return;
748 if (Hacks.needGalaxySAudioHack()) {
749 mAudioManager.setMode(MODE_RINGTONE);
753 private native void setVideoPolicy(long nativePtr, boolean autoInitiate, boolean autoAccept);
754 public synchronized void setVideoPolicy(boolean autoInitiate, boolean autoAccept) {
755 setVideoPolicy(nativePtr, autoInitiate, autoAccept);
757 private native void setStaticPicture(long nativePtr, String path);
758 public void setStaticPicture(String path) {
759 setStaticPicture(nativePtr, path);
761 private native void setUserAgent(long nativePtr, String name, String version);
763 public void setUserAgent(String name, String version) {
764 setUserAgent(nativePtr,name,version);
767 private native void setCpuCountNative(int count);
768 public void setCpuCount(int count)
770 setCpuCountNative(count);
773 public int getMissedCallsCount() {
774 return getMissedCallsCount(nativePtr);
777 public void removeCallLog(LinphoneCallLog log) {
778 removeCallLog(nativePtr, ((LinphoneCallLogImpl) log).getNativePtr());
781 public void resetMissedCallsCount() {
782 resetMissedCallsCount(nativePtr);
785 private native void tunnelSetHttpProxy(long nativePtr, String proxy_host, int port,
786 String username, String password);
788 public void tunnelSetHttpProxy(String proxy_host, int port,
789 String username, String password) {
790 tunnelSetHttpProxy(nativePtr, proxy_host, port, username, password);
793 private native void refreshRegisters(long nativePtr);
794 public void refreshRegisters() {
795 refreshRegisters(nativePtr);
799 public String getVersion() {
800 return getVersion(nativePtr);
804 public PayloadType findPayloadType(String mime, int clockRate) {
805 return findPayloadType(mime, clockRate, 1);
808 private native void removeFriend(long ptr, long lf);
810 public void removeFriend(LinphoneFriend lf) {
811 removeFriend(nativePtr, lf.getNativePtr());
814 private native long getFriendByAddress(long ptr, String sipUri);
816 public LinphoneFriend findFriendByAddress(String sipUri) {
817 long ptr = getFriendByAddress(nativePtr, sipUri);
821 return new LinphoneFriendImpl(ptr);
824 public void setAudioPort(int port) {
825 setAudioPort(nativePtr, port);
828 public void setVideoPort(int port) {
829 setVideoPort(nativePtr, port);
832 public void setAudioPortRange(int minPort, int maxPort) {
833 setAudioPortRange(nativePtr, minPort, maxPort);
836 public void setVideoPortRange(int minPort, int maxPort) {
837 setVideoPortRange(nativePtr, minPort, maxPort);
840 public void setIncomingTimeout(int timeout) {
841 setIncomingTimeout(nativePtr, timeout);
844 public void setInCallTimeout(int timeout)
846 setInCallTimeout(nativePtr, timeout);
849 private native void setMicrophoneGain(long ptr, float gain);
850 public void setMicrophoneGain(float gain) {
851 setMicrophoneGain(nativePtr, gain);
854 public void setPrimaryContact(String displayName, String username) {
855 setPrimaryContact(nativePtr, displayName, username);
858 private native void setUseSipInfoForDtmfs(long ptr, boolean use);
859 public void setUseSipInfoForDtmfs(boolean use) {
860 setUseSipInfoForDtmfs(nativePtr, use);
863 private native void setUseRfc2833ForDtmfs(long ptr, boolean use);
864 public void setUseRfc2833ForDtmfs(boolean use) {
865 setUseRfc2833ForDtmfs(nativePtr, use);