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