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;
22 class LinphoneCallImpl implements LinphoneCall {
24 protected final long nativePtr;
25 boolean ownPtr = false;
26 private LinphoneCallStats audioStats;
27 private LinphoneCallStats videoStats;
29 native private void finalize(long nativePtr);
30 native private long getCallLog(long nativePtr);
31 private native boolean isIncoming(long nativePtr);
32 native private long getRemoteAddress(long nativePtr);
33 native private int getState(long nativePtr);
34 private native long getCurrentParamsCopy(long nativePtr);
35 private native long getRemoteParams(long nativePtr);
36 private native void enableCamera(long nativePtr, boolean enabled);
37 private native boolean cameraEnabled(long nativePtr);
38 private native void enableEchoCancellation(long nativePtr,boolean enable);
39 private native boolean isEchoCancellationEnabled(long nativePtr) ;
40 private native void enableEchoLimiter(long nativePtr,boolean enable);
41 private native boolean isEchoLimiterEnabled(long nativePtr);
42 private native Object getReplacedCall(long nativePtr);
43 private native int getDuration(long nativePtr);
44 private native float getCurrentQuality(long nativePtr);
45 private native float getAverageQuality(long nativePtr);
48 * This method must always be called from JNI, nothing else.
50 private LinphoneCallImpl(long aNativePtr) {
51 nativePtr = aNativePtr;
53 protected void finalize() throws Throwable {
56 public LinphoneCallLog getCallLog() {
57 long lNativePtr = getCallLog(nativePtr);
59 return new LinphoneCallLogImpl(lNativePtr);
64 public void setAudioStats(LinphoneCallStats stats) {
67 public void setVideoStats(LinphoneCallStats stats) {
70 public LinphoneCallStats getAudioStats() {
73 public LinphoneCallStats getVideoStats() {
76 public CallDirection getDirection() {
77 return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing;
79 public LinphoneAddress getRemoteAddress() {
80 long lNativePtr = getRemoteAddress(nativePtr);
82 return new LinphoneAddressImpl(lNativePtr);
87 public State getState() {
88 return LinphoneCall.State.fromInt(getState(nativePtr));
90 public LinphoneCallParams getCurrentParamsCopy() {
91 return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
93 public LinphoneCallParams getRemoteParams() {
94 long remoteParamsPtr = getRemoteParams(nativePtr);
95 if (remoteParamsPtr == 0) {
98 return new LinphoneCallParamsImpl(remoteParamsPtr);
100 public void enableCamera(boolean enabled) {
101 enableCamera(nativePtr, enabled);
103 public boolean cameraEnabled() {
104 return cameraEnabled(nativePtr);
108 public boolean equals(Object call) {
109 if (this == call) return true;
110 if (call == null) return false;
111 if (!(call instanceof LinphoneCallImpl)) return false;
112 return nativePtr == ((LinphoneCallImpl)call).nativePtr;
116 public int hashCode() {
118 result = 31 * result + (int) (nativePtr ^ (nativePtr >>> 32));
121 public void enableEchoCancellation(boolean enable) {
122 enableEchoCancellation(nativePtr,enable);
125 public boolean isEchoCancellationEnabled() {
126 return isEchoCancellationEnabled(nativePtr);
128 public void enableEchoLimiter(boolean enable) {
129 enableEchoLimiter(nativePtr,enable);
131 public boolean isEchoLimiterEnabled() {
132 return isEchoLimiterEnabled(nativePtr);
134 public LinphoneCall getReplacedCall(){
135 return (LinphoneCall)getReplacedCall(nativePtr);
138 public int getDuration() {
139 return getDuration(nativePtr);
141 public float getAverageQuality() {
142 return getAverageQuality(nativePtr);
144 public float getCurrentQuality() {
145 return getCurrentQuality(nativePtr);
148 private native String getAuthenticationToken(long nativePtr);
149 public String getAuthenticationToken(){
150 return getAuthenticationToken(nativePtr);
153 private native boolean isAuthenticationTokenVerified(long nativePtr);
154 public boolean isAuthenticationTokenVerified(){
155 return isAuthenticationTokenVerified(nativePtr);
158 private native void setAuthenticationTokenVerified(long nativePtr, boolean verified);
159 public void setAuthenticationTokenVerified(boolean verified){
160 setAuthenticationTokenVerified(nativePtr, verified);
163 public boolean isInConference() {
164 LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
165 return params.localConferenceMode();
169 public String toString() {
170 return "Call " + nativePtr;
173 private native float getPlayVolume(long nativePtr);
174 public float getPlayVolume() {
175 return getPlayVolume(nativePtr);
178 private native String getRemoteUserAgent(long nativePtr);
179 public String getRemoteUserAgent() {
180 return getRemoteUserAgent(nativePtr);
183 private native String getRemoteContact(long nativePtr);
184 public String getRemoteContact() {
185 return getRemoteContact(nativePtr);
188 private native void takeSnapshot(long nativePtr, String path);
189 public void takeSnapshot(String path) {
190 takeSnapshot(nativePtr, path);
193 private native void zoomVideo(long nativePtr, float factor, float cx, float cy);
194 public void zoomVideo(float factor, float cx, float cy) {
195 zoomVideo(nativePtr, factor, cx, cy);
198 private native void startRecording(long nativePtr);
200 public void startRecording() {
201 startRecording(nativePtr);
203 private native void stopRecording(long nativePtr);
205 public void stopRecording() {
206 stopRecording(nativePtr);