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() {
71 if (audioStats!=null) ((LinphoneCallStatsImpl)audioStats).updateRealTimeStats(this);
74 public LinphoneCallStats getVideoStats() {
75 if (videoStats!=null) ((LinphoneCallStatsImpl)videoStats).updateRealTimeStats(this);
78 public CallDirection getDirection() {
79 return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing;
81 public LinphoneAddress getRemoteAddress() {
82 long lNativePtr = getRemoteAddress(nativePtr);
84 return new LinphoneAddressImpl(lNativePtr);
89 public State getState() {
90 return LinphoneCall.State.fromInt(getState(nativePtr));
92 public LinphoneCallParams getCurrentParamsCopy() {
93 return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
95 public LinphoneCallParams getRemoteParams() {
96 long remoteParamsPtr = getRemoteParams(nativePtr);
97 if (remoteParamsPtr == 0) {
100 return new LinphoneCallParamsImpl(remoteParamsPtr);
102 public void enableCamera(boolean enabled) {
103 enableCamera(nativePtr, enabled);
105 public boolean cameraEnabled() {
106 return cameraEnabled(nativePtr);
110 public boolean equals(Object call) {
111 if (this == call) return true;
112 if (call == null) return false;
113 if (!(call instanceof LinphoneCallImpl)) return false;
114 return nativePtr == ((LinphoneCallImpl)call).nativePtr;
118 public int hashCode() {
120 result = 31 * result + (int) (nativePtr ^ (nativePtr >>> 32));
123 public void enableEchoCancellation(boolean enable) {
124 enableEchoCancellation(nativePtr,enable);
127 public boolean isEchoCancellationEnabled() {
128 return isEchoCancellationEnabled(nativePtr);
130 public void enableEchoLimiter(boolean enable) {
131 enableEchoLimiter(nativePtr,enable);
133 public boolean isEchoLimiterEnabled() {
134 return isEchoLimiterEnabled(nativePtr);
136 public LinphoneCall getReplacedCall(){
137 return (LinphoneCall)getReplacedCall(nativePtr);
140 public int getDuration() {
141 return getDuration(nativePtr);
143 public float getAverageQuality() {
144 return getAverageQuality(nativePtr);
146 public float getCurrentQuality() {
147 return getCurrentQuality(nativePtr);
150 private native String getAuthenticationToken(long nativePtr);
151 public String getAuthenticationToken(){
152 return getAuthenticationToken(nativePtr);
155 private native boolean isAuthenticationTokenVerified(long nativePtr);
156 public boolean isAuthenticationTokenVerified(){
157 return isAuthenticationTokenVerified(nativePtr);
160 private native void setAuthenticationTokenVerified(long nativePtr, boolean verified);
161 public void setAuthenticationTokenVerified(boolean verified){
162 setAuthenticationTokenVerified(nativePtr, verified);
165 public boolean isInConference() {
166 LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
167 return params.localConferenceMode();
171 public String toString() {
172 return "Call " + nativePtr;
175 private native float getPlayVolume(long nativePtr);
176 public float getPlayVolume() {
177 return getPlayVolume(nativePtr);
180 private native String getRemoteUserAgent(long nativePtr);
181 public String getRemoteUserAgent() {
182 return getRemoteUserAgent(nativePtr);
185 private native String getRemoteContact(long nativePtr);
186 public String getRemoteContact() {
187 return getRemoteContact(nativePtr);
190 private native void takeSnapshot(long nativePtr, String path);
191 public void takeSnapshot(String path) {
192 takeSnapshot(nativePtr, path);
195 private native void zoomVideo(long nativePtr, float factor, float cx, float cy);
196 public void zoomVideo(float factor, float cx, float cy) {
197 zoomVideo(nativePtr, factor, cx, cy);
200 private native void startRecording(long nativePtr);
202 public void startRecording() {
203 startRecording(nativePtr);
205 private native void stopRecording(long nativePtr);
207 public void stopRecording() {
208 stopRecording(nativePtr);