]> sjero.net Git - linphone/blob - LinphoneCallImpl.java
replace vectores by arrays in linphone core api
[linphone] / 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         native private void finalize(long nativePtr);
27         native private long  getCallLog(long nativePtr);
28         private native boolean isIncoming(long nativePtr);
29         native private long getRemoteAddress(long nativePtr);
30         native private int getState(long nativePtr);
31         private native long getCurrentParamsCopy(long nativePtr);
32         private native long getRemoteParams(long nativePtr);
33         private native void enableCamera(long nativePtr, boolean enabled);
34         private native boolean cameraEnabled(long nativePtr);
35         private native void enableEchoCancellation(long nativePtr,boolean enable);
36         private native boolean isEchoCancellationEnabled(long nativePtr) ;
37         private native void enableEchoLimiter(long nativePtr,boolean enable);
38         private native boolean isEchoLimiterEnabled(long nativePtr);
39         private native Object getReplacedCall(long nativePtr);
40         private native int getDuration(long nativePtr);
41         private native float getCurrentQuality(long nativePtr);
42         private native float getAverageQuality(long nativePtr);
43         
44         /*
45          * This method must always be called from JNI, nothing else.
46          */
47         private LinphoneCallImpl(long aNativePtr)  {
48                 nativePtr = aNativePtr;
49         }
50         protected void finalize() throws Throwable {
51                 finalize(nativePtr);
52         }
53         public LinphoneCallLog getCallLog() {
54                 long lNativePtr = getCallLog(nativePtr);
55                 if (lNativePtr!=0) {
56                         return new LinphoneCallLogImpl(lNativePtr); 
57                 } else {
58                         return null;
59                 }
60         }
61         public CallDirection getDirection() {
62                 return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing;
63         }
64         public LinphoneAddress getRemoteAddress() {
65                 long lNativePtr = getRemoteAddress(nativePtr);
66                 if (lNativePtr!=0) {
67                         return new LinphoneAddressImpl(lNativePtr); 
68                 } else {
69                         return null;
70                 }
71         }
72         public State getState() {
73                 return LinphoneCall.State.fromInt(getState(nativePtr));
74         }
75         public LinphoneCallParams getCurrentParamsCopy() {
76                 return new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
77         }
78         public LinphoneCallParams getRemoteParams() {
79                 return new LinphoneCallParamsImpl(getRemoteParams(nativePtr));
80         }
81         public void enableCamera(boolean enabled) {
82                 enableCamera(nativePtr, enabled);
83         }
84         public boolean cameraEnabled() {
85                 return cameraEnabled(nativePtr);
86         }
87
88         @Override
89         public boolean equals(Object call) {
90                 if (this == call) return true;
91                 if (call == null) return false;
92                 if (!(call instanceof LinphoneCallImpl)) return false;
93                 return nativePtr == ((LinphoneCallImpl)call).nativePtr;
94         }
95
96         @Override
97         public int hashCode() {
98                 int result = 17;
99                 result = 31 * result + (int) (nativePtr ^ (nativePtr >>> 32));
100                 return result;
101         }
102         public void enableEchoCancellation(boolean enable) {
103                 enableEchoCancellation(nativePtr,enable);
104                 
105         }
106         public boolean isEchoCancellationEnabled() {
107                 return isEchoCancellationEnabled(nativePtr);
108         }
109         public void enableEchoLimiter(boolean enable) {
110                 enableEchoLimiter(nativePtr,enable);
111         }
112         public boolean isEchoLimiterEnabled() {
113                 return isEchoLimiterEnabled(nativePtr);
114         }
115         public LinphoneCall getReplacedCall(){
116                 return (LinphoneCall)getReplacedCall(nativePtr);
117         }
118
119         public int getDuration() {
120                 return getDuration(nativePtr);
121         }
122         public float getAverageQuality() {
123                 return getAverageQuality(nativePtr);
124         }
125         public float getCurrentQuality() {
126                 return getCurrentQuality(nativePtr);
127         }
128
129         private native String getAuthenticationToken(long nativePtr);
130         public String getAuthenticationToken(){
131                 return getAuthenticationToken(nativePtr);
132         }
133
134         private native boolean isAuthenticationTokenVerified(long nativePtr);
135         public boolean isAuthenticationTokenVerified(){
136                 return isAuthenticationTokenVerified(nativePtr);
137         }
138
139         private native boolean setAuthenticationTokenVerified(long nativePtr, boolean verified);
140         public void setAuthenticationTokenVerified(boolean verified){
141                 setAuthenticationTokenVerified(nativePtr, verified);
142         }
143
144         public boolean isInConference() {
145                 LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
146                 return params.localConferenceMode();
147         }
148
149         @Override
150         public String toString() {
151                 return "Call " + nativePtr;
152         }
153
154         private native float getPlayVolume(long nativePtr);
155         public float getPlayVolume() {
156                 return getPlayVolume(nativePtr);
157         }
158 }