From 797623a146d405a8dedeb1791020c3cb20a1b215 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 22 Sep 2011 17:11:35 +0200 Subject: [PATCH] fix for unique LinphoneCalls again --- src/org/linphone/core/LinphoneCallImpl.java | 13 +++++------ src/org/linphone/core/LinphoneCoreImpl.java | 25 +++++++++------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/org/linphone/core/LinphoneCallImpl.java b/src/org/linphone/core/LinphoneCallImpl.java index ceb541ed0..70968e79d 100644 --- a/src/org/linphone/core/LinphoneCallImpl.java +++ b/src/org/linphone/core/LinphoneCallImpl.java @@ -35,14 +35,17 @@ class LinphoneCallImpl implements LinphoneCall { private native boolean isEchoCancellationEnabled(long nativePtr) ; private native void enableEchoLimiter(long nativePtr,boolean enable); private native boolean isEchoLimiterEnabled(long nativePtr); - private native long getReplacedCall(long nativePtr); + private native Object getReplacedCall(long nativePtr); private native int getDuration(long nativePtr); private native float getCurrentQuality(long nativePtr); private native float getAverageQuality(long nativePtr); private native String getAuthenticationToken(long nativePtr); private native boolean isAuthenticationTokenVerified(long nativePtr); private native boolean areStreamsEncrypted(long nativePtr); - + + /* + * This method must always be called from JNI, nothing else. + */ protected LinphoneCallImpl(long aNativePtr) { nativePtr = aNativePtr; } @@ -98,11 +101,7 @@ class LinphoneCallImpl implements LinphoneCall { return isEchoLimiterEnabled(nativePtr); } public LinphoneCall getReplacedCall(){ - long callptr=getReplacedCall(nativePtr); - if (callptr!=0){ - return new LinphoneCallImpl(callptr); - } - return null; + return (LinphoneCall)getReplacedCall(nativePtr); } public int getDuration() { diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 52019f96b..a45bad1c7 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -42,7 +42,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void clearProxyConfigs(long nativePtr); private native void addAuthInfo(long nativePtr,long authInfoNativePtr); - private native long invite(long nativePtr,String uri); + private native Object invite(long nativePtr,String uri); private native void terminateCall(long nativePtr, long call); private native long getRemoteAddress(long nativePtr); private native boolean isInCall(long nativePtr); @@ -56,8 +56,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native float getPlaybackGain(long nativeptr); private native void muteMic(long nativePtr,boolean isMuted); private native long interpretUrl(long nativePtr,String destination); - private native long inviteAddress(long nativePtr,long to); - private native long inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); + private native Object inviteAddress(long nativePtr,long to); + private native Object inviteAddressWithParams(long nativePtrLc,long to, long nativePtrParam); private native void sendDtmf(long nativePtr,char dtmf); private native void clearCallLogs(long nativePtr); private native boolean isMicMuted(long nativePtr); @@ -140,12 +140,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized LinphoneCall invite(String uri) { isValid(); - long lNativePtr = invite(nativePtr,uri); - if (lNativePtr!=0) { - return new LinphoneCallImpl(lNativePtr); - } else { - return null; - } + return (LinphoneCall)invite(nativePtr,uri); } public synchronized void iterate() { @@ -239,9 +234,9 @@ class LinphoneCoreImpl implements LinphoneCore { } } public synchronized LinphoneCall invite(LinphoneAddress to) throws LinphoneCoreException { - long lNativePtr = inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); - if (lNativePtr!=0) { - return new LinphoneCallImpl(lNativePtr); + LinphoneCall call = (LinphoneCall)inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr); + if (call!=null) { + return call; } else { throw new LinphoneCoreException("Unable to invite address " + to.asString()); } @@ -361,9 +356,9 @@ class LinphoneCoreImpl implements LinphoneCore { long ptrDestination = ((LinphoneAddressImpl)to).nativePtr; long ptrParams =((LinphoneCallParamsImpl)params).nativePtr; - long lcNativePtr = inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); - if (lcNativePtr!=0) { - return new LinphoneCallImpl(lcNativePtr); + LinphoneCall call = (LinphoneCall)inviteAddressWithParams(nativePtr, ptrDestination, ptrParams); + if (call!=null) { + return call; } else { throw new LinphoneCoreException("Unable to invite with params " + to.asString()); }