]> sjero.net Git - linphone/blob - java/common/org/linphone/core/LinphoneCall.java
API and makefiles for ZRTP support.
[linphone] / java / common / org / linphone / core / LinphoneCall.java
1 /*
2 LinphoneCall.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 import java.util.Vector;
22
23 /**
24  * Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
25  * 
26  */
27
28 public interface LinphoneCall {
29         /**
30          * Linphone call states
31          *
32          */
33         static class State {
34                 @SuppressWarnings("unchecked")
35                 static private Vector values = new Vector();
36                 private final int mValue;
37                 private final String mStringValue;
38                 /**
39                  * Idle
40                  */
41                 public final static State Idle = new State(0,"Idle");
42                 /**
43                  * Incoming call received.
44                  */
45                 public final static State IncomingReceived = new State(1,"IncomingReceived");
46                 /**
47                  * Outgoing call initialiazed.
48                  */
49                 public final static State OutgoingInit = new State(2,"OutgoingInit");
50                 /**
51                  * Outgoing call in progress. 
52                  */
53                 public final static State OutgoingProgress = new State(3,"OutgoingProgress");
54                 /**
55                  * Outgoing call ringing.
56                  */
57                 public final static State OutgoingRinging = new State(4,"OutgoingRinging");
58                 /**
59                  * Outgoing call early media
60                  */
61                 public final static State OutgoingEarlyMedia = new State(5,"OutgoingEarlyMedia");
62                 /**
63                  * Connected
64                  */
65                 public final static State Connected = new State(6,"Connected");
66                 /**
67                  * Streams running
68                  */
69                 public final static State StreamsRunning = new State(7,"StreamsRunning");
70                 /**
71                  * Paussing
72                  */
73                 public final static State Pausing = new State(8,"Pausing");
74                 /**
75                  * Paused
76                  */
77                 public final static State Paused = new State(9,"Paused");
78                 /**
79                  * Resuming
80                  */
81                 public final static State Resuming = new State(10,"Resuming");
82                 /**
83                  * Refered
84                  */
85                 public final static State Refered = new State(11,"Refered");
86                 /**
87                  * Error
88                  */
89                 public final static State Error = new State(12,"Error");
90                 /**
91                  * Call end
92                  */
93                 public final static State CallEnd = new State(13,"CallEnd");
94                 
95                 /**
96                  * Paused by remote
97                  */
98                 public final static State PausedByRemote = new State(14,"PausedByRemote");
99                 
100                 /**
101                  * The call's parameters are updated, used for example when video is asked by remote
102                  */
103                 public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote");
104
105                 /**
106                  * We are proposing early media to an incoming call
107                  */
108                 public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia");
109
110                 /**
111                  * The remote accepted the call update initiated by us
112                  */
113                 public static final State CallUpdated = new State(17, "CallUpdated");
114                 
115                 /**
116                  * The call object is now released.
117                  */
118                 public static final State CallReleased = new State(18,"CallReleased");
119
120                 @SuppressWarnings("unchecked")
121                 private State(int value,String stringValue) {
122                         mValue = value;
123                         values.addElement(this);
124                         mStringValue=stringValue;
125                 }
126                 public static State fromInt(int value) {
127
128                         for (int i=0; i<values.size();i++) {
129                                 State state = (State) values.elementAt(i);
130                                 if (state.mValue == value) return state;
131                         }
132                         throw new RuntimeException("state not found ["+value+"]");
133                 }
134                 public String toString() {
135                         return mStringValue;
136                 }
137         }
138         
139         /**
140          * Retrieves the call's current state.
141         **/
142         State getState();
143         
144         /**
145          * Returns the remote address associated to this call
146          *
147         **/
148         LinphoneAddress  getRemoteAddress();
149         /**
150          * get direction of the call (incoming or outgoing).
151          * @return CallDirection 
152          */
153         CallDirection getDirection();
154         /**
155          * get the call log associated to this call.
156          * @Return LinphoneCallLog
157         **/
158         LinphoneCallLog getCallLog();
159
160         LinphoneCallParams getCurrentParamsCopy();
161         
162         void enableCamera(boolean enabled);
163         /**
164          * Enables or disable echo cancellation.
165          * @param enable
166          */
167         void enableEchoCancellation(boolean enable);
168         /**
169          * get EC status 
170          * @return true if echo cancellation is enabled.
171          */
172         boolean isEchoCancellationEnabled();
173         /**
174          * Enables or disable echo limiter cancellation.
175          * @param enable
176          */
177         void enableEchoLimiter(boolean enable);
178         /**
179          * get EL status 
180          * @return true if echo limiter is enabled.
181          */
182         boolean isEchoLimiterEnabled();
183         /**
184          * Returns the object associated to a call this one is replacing.
185          * Call replacement can occur during transfer scenarios.
186          */
187         LinphoneCall getReplacedCall();
188
189         /**
190          * @return call duration computed from media start
191          */
192         int getDuration();
193         /**
194          * Obtain real-time quality rating of the call
195          *
196          * Based on local RTP statistics and RTCP feedback, a quality rating is computed and updated
197          * during all the duration of the call. This function returns its value at the time of the function call.
198          * It is expected that the rating is updated at least every 5 seconds or so.
199          * The rating is a floating point number comprised between 0 and 5.
200          *
201          * 4-5 = good quality <br>
202          * 3-4 = average quality <br>
203          * 2-3 = poor quality <br>
204          * 1-2 = very poor quality <br>
205          * 0-1 = can't be worse, mostly unusable <br>
206          *
207          * @returns The function returns -1 if no quality measurement is available, for example if no 
208          * active audio stream exist. Otherwise it returns the quality rating.
209          */
210         float getCurrentQuality();
211         /**
212          * Returns call quality averaged over all the duration of the call.
213          *
214          * See getCurrentQuality() for more details about quality measurement.
215          */
216         float getAverageQuality();
217         
218         
219         String getAuthenticationToken();
220         boolean isAuthenticationTokenVerified();
221         boolean areStreamsEncrypted();
222 }