]> sjero.net Git - linphone/blob - java/impl/org/linphone/core/LinphoneCallImpl.java
30bcd528fce17e94ec46bd94c393513cc7962d50
[linphone] / java / impl / org / linphone / core / LinphoneCallImpl.java
1 /*
2 LinphoneCallImpl.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
22 class LinphoneCallImpl implements LinphoneCall {
23  
24         protected final long nativePtr;
25         boolean ownPtr = false;
26         private LinphoneCallStats audioStats;
27         private LinphoneCallStats videoStats;
28
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);
46         
47         /*
48          * This method must always be called from JNI, nothing else.
49          */
50         private LinphoneCallImpl(long aNativePtr)  {
51                 nativePtr = aNativePtr;
52         }
53         protected void finalize() throws Throwable {
54                 finalize(nativePtr);
55         }
56         public LinphoneCallLog getCallLog() {
57                 long lNativePtr = getCallLog(nativePtr);
58                 if (lNativePtr!=0) {
59                         return new LinphoneCallLogImpl(lNativePtr); 
60                 } else {
61                         return null;
62                 }
63         }
64         public void setAudioStats(LinphoneCallStats stats) {
65                 audioStats = stats;
66         }
67         public void setVideoStats(LinphoneCallStats stats) {
68                 videoStats = stats;
69         }
70         public LinphoneCallStats getAudioStats() {
71                 return audioStats;
72         }
73         public LinphoneCallStats getVideoStats() {
74                 return videoStats;
75         }
76         public CallDirection getDirection() {
77                 return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing;
78         }
79         public LinphoneAddress getRemoteAddress() {
80                 long lNativePtr = getRemoteAddress(nativePtr);
81                 if (lNativePtr!=0) {
82                         return new LinphoneAddressImpl(lNativePtr); 
83                 } else {
84                         return null;
85                 }
86         }
87         public State getState() {
88                 return LinphoneCall.State.fromInt(getState(nativePtr));
89         }
90         public LinphoneCallParams getCurrentParamsCopy() {
91                 return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
92         }
93         public LinphoneCallParams getRemoteParams() {
94                 long remoteParamsPtr = getRemoteParams(nativePtr);
95                 if (remoteParamsPtr == 0) {
96                         return null;
97                 }
98                 return new LinphoneCallParamsImpl(remoteParamsPtr);
99         }
100         public void enableCamera(boolean enabled) {
101                 enableCamera(nativePtr, enabled);
102         }
103         public boolean cameraEnabled() {
104                 return cameraEnabled(nativePtr);
105         }
106
107         @Override
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;
113         }
114
115         @Override
116         public int hashCode() {
117                 int result = 17;
118                 result = 31 * result + (int) (nativePtr ^ (nativePtr >>> 32));
119                 return result;
120         }
121         public void enableEchoCancellation(boolean enable) {
122                 enableEchoCancellation(nativePtr,enable);
123                 
124         }
125         public boolean isEchoCancellationEnabled() {
126                 return isEchoCancellationEnabled(nativePtr);
127         }
128         public void enableEchoLimiter(boolean enable) {
129                 enableEchoLimiter(nativePtr,enable);
130         }
131         public boolean isEchoLimiterEnabled() {
132                 return isEchoLimiterEnabled(nativePtr);
133         }
134         public LinphoneCall getReplacedCall(){
135                 return (LinphoneCall)getReplacedCall(nativePtr);
136         }
137
138         public int getDuration() {
139                 return getDuration(nativePtr);
140         }
141         public float getAverageQuality() {
142                 return getAverageQuality(nativePtr);
143         }
144         public float getCurrentQuality() {
145                 return getCurrentQuality(nativePtr);
146         }
147
148         private native String getAuthenticationToken(long nativePtr);
149         public String getAuthenticationToken(){
150                 return getAuthenticationToken(nativePtr);
151         }
152
153         private native boolean isAuthenticationTokenVerified(long nativePtr);
154         public boolean isAuthenticationTokenVerified(){
155                 return isAuthenticationTokenVerified(nativePtr);
156         }
157
158         private native void setAuthenticationTokenVerified(long nativePtr, boolean verified);
159         public void setAuthenticationTokenVerified(boolean verified){
160                 setAuthenticationTokenVerified(nativePtr, verified);
161         }
162
163         public boolean isInConference() {
164                 LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
165                 return params.localConferenceMode();
166         }
167
168         @Override
169         public String toString() {
170                 return "Call " + nativePtr;
171         }
172
173         private native float getPlayVolume(long nativePtr);
174         public float getPlayVolume() {
175                 return getPlayVolume(nativePtr);
176         }
177
178         private native String getRemoteUserAgent(long nativePtr);
179         public String getRemoteUserAgent() {
180                 return getRemoteUserAgent(nativePtr);
181         }
182
183         private native String getRemoteContact(long nativePtr);
184         public String getRemoteContact() {
185                 return getRemoteContact(nativePtr);
186         }
187         
188         private native void takeSnapshot(long nativePtr, String path);
189         public void takeSnapshot(String path) {
190                 takeSnapshot(nativePtr, path);
191         }
192
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);
196         }
197         
198         private native void startRecording(long nativePtr);
199         @Override
200         public void startRecording() {
201                 startRecording(nativePtr);
202         }
203         private native void stopRecording(long nativePtr);
204         @Override
205         public void stopRecording() {
206                 stopRecording(nativePtr);
207         }
208 }