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 import java.util.Vector;
25 * Linphone core main object created by method {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)}.
28 @SuppressWarnings("unchecked")
29 public interface LinphoneCore {
31 * linphone core states
33 static public class GlobalState {
34 static private Vector values = new Vector();
38 static public GlobalState GlobalOff = new GlobalState(0,"GlobalOff");
42 static public GlobalState GlobalStartup = new GlobalState(1,"GlobalStartup");
46 static public GlobalState GlobalOn = new GlobalState(2,"GlobalOn");
50 static public GlobalState GlobalShutdown = new GlobalState(3,"GlobalShutdown");
52 private final int mValue;
53 private final String mStringValue;
55 private GlobalState(int value,String stringValue) {
57 values.addElement(this);
58 mStringValue=stringValue;
60 public static GlobalState fromInt(int value) {
62 for (int i=0; i<values.size();i++) {
63 GlobalState state = (GlobalState) values.elementAt(i);
64 if (state.mValue == value) return state;
66 throw new RuntimeException("state not found ["+value+"]");
68 public String toString() {
73 * Describes proxy registration states.
76 static public class RegistrationState {
77 private static Vector values = new Vector();
81 public static RegistrationState RegistrationNone = new RegistrationState(0,"RegistrationNone");
85 public static RegistrationState RegistrationProgress = new RegistrationState(1,"RegistrationProgress");
89 public static RegistrationState RegistrationOk = new RegistrationState(2,"RegistrationOk");
93 public static RegistrationState RegistrationCleared = new RegistrationState(3,"RegistrationCleared");
97 public static RegistrationState RegistrationFailed = new RegistrationState(4,"RegistrationFailed");
98 private final int mValue;
99 private final String mStringValue;
101 private RegistrationState(int value,String stringValue) {
103 values.addElement(this);
104 mStringValue=stringValue;
106 public static RegistrationState fromInt(int value) {
108 for (int i=0; i<values.size();i++) {
109 RegistrationState state = (RegistrationState) values.elementAt(i);
110 if (state.mValue == value) return state;
112 throw new RuntimeException("state not found ["+value+"]");
114 public String toString() {
119 * Describes firewall policy.
122 static public class FirewallPolicy {
123 static private Vector values = new Vector();
125 * No firewall is assumed.
127 static public FirewallPolicy NoFirewall = new FirewallPolicy(0,"NoFirewall");
129 * Use NAT address (discouraged)
131 static public FirewallPolicy UseNatAddress = new FirewallPolicy(1,"UseNatAddress");
133 * Use stun server to discover RTP addresses and ports.
135 static public FirewallPolicy UseStun = new FirewallPolicy(2,"UseStun");
137 private final int mValue;
138 private final String mStringValue;
140 private FirewallPolicy(int value,String stringValue) {
142 values.addElement(this);
143 mStringValue=stringValue;
145 public static FirewallPolicy fromInt(int value) {
147 for (int i=0; i<values.size();i++) {
148 FirewallPolicy state = (FirewallPolicy) values.elementAt(i);
149 if (state.mValue == value) return state;
151 throw new RuntimeException("state not found ["+value+"]");
153 public String toString() {
161 * Signaling transports
164 static public class Transport {
168 public final static Transport udp =new Transport("udp");
172 public final static Transport tcp =new Transport("tcp");
173 private final String mStringValue;
175 private Transport(String stringValue) {
176 mStringValue=stringValue;
178 public String toString() {
183 * clear all added proxy configs
185 public void clearProxyConfigs();
187 * Add a proxy configuration. This will start registration on the proxy, if registration is enabled.
189 * @throws LinphoneCoreException
191 public void addProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException;
193 * Sets the default proxy.
195 * This default proxy must be part of the list of already entered {@link LinphoneProxyConfig}.
196 * Toggling it as default will make LinphoneCore use the identity associated with the proxy configuration in all incoming and outgoing calls.
199 public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg);
202 * get he default proxy configuration, that is the one used to determine the current identity.
203 * @return null if no default proxy config
205 public LinphoneProxyConfig getDefaultProxyConfig() ;
208 * clear all the added auth info
210 void clearAuthInfos();
212 * Adds authentication information to the LinphoneCore.
213 * <br>This information will be used during all SIP transacations that require authentication.
216 void addAuthInfo(LinphoneAuthInfo info);
219 * Build an address according to the current proxy config. In case destination is not a sip address, the default proxy domain is automatically appended
222 * @throws If no LinphoneAddress can be built from destination
224 public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException;
227 * Starts a call given a destination. Internally calls {@link #interpretUrl(String)} then {@link #invite(LinphoneAddress)}.
230 public LinphoneCall invite(String destination)throws LinphoneCoreException;
232 * Initiates an outgoing call given a destination LinphoneAddress
233 *<br>The LinphoneAddress can be constructed directly using linphone_address_new(), or created by linphone_core_interpret_url(). The application doesn't own a reference to the returned LinphoneCall object. Use linphone_call_ref() to safely keep the LinphoneCall pointer valid within your application.
234 * @param to the destination of the call (sip address).
235 * @return LinphoneCall
236 * @throws LinphoneCoreException
238 public LinphoneCall invite(LinphoneAddress to)throws LinphoneCoreException;
241 * @param aCall to be terminated
243 public void terminateCall(LinphoneCall aCall);
245 * Returns The LinphoneCall the current call if one is in call
248 public LinphoneCall getCurrentCall();
251 * get current call remote address in case of in/out call
252 * @return null if no call engaged yet
254 public LinphoneAddress getRemoteAddress();
257 * @return TRUE if there is a call running or pending.
259 public boolean isIncall();
262 * @return Returns true if in incoming call is pending, ie waiting for being answered or declined.
264 public boolean isInComingInvitePending();
266 * Main loop function. It is crucial that your application call it periodically.
268 * #iterate() performs various backgrounds tasks:
269 * <li>receiving of SIP messages
270 * <li> handles timers and timeout
271 * <li> performs registration to proxies
272 * <li> authentication retries The application MUST call this function from periodically, in its main loop.
273 * <br> Be careful that this function must be call from the same thread as other liblinphone methods. In not the case make sure all liblinphone calls are serialized with a mutex.
276 public void iterate();
278 * Accept an incoming call.
280 * Basically the application is notified of incoming calls within the
281 * {@link LinphoneCoreListener#inviteReceived(LinphoneCore, String)} listener.
282 * The application can later respond positively to the call using
284 * @throws LinphoneCoreException
286 public void acceptCall(LinphoneCall aCall) throws LinphoneCoreException;
290 * @return a list of LinphoneCallLog
292 public Vector getCallLogs();
295 * This method is called by the application to notify the Linphone core library when network is reachable.
296 * Calling this method with true trigger Linphone to initiate a registration process for all proxy
297 * configuration with parameter register set to enable.
298 * This method disable the automatic registration mode. It means you must call this method after each network state changes
299 * @param network state
302 public void setNetworkReachable(boolean isReachable);
305 * @return if false, there is no network connection.
307 public boolean isNetworkReachable();
309 * destroy linphone core and free all underlying resources
311 public void destroy();
313 * Allow to control play level before entering sound card:
316 public void setPlaybackGain(float gain);
318 * get play level before entering sound card:
319 * @return level in db
321 public float getPlaybackGain();
324 * @param level [0..100]
326 public void setPlayLevel(int level);
328 * get playback level [0..100];
329 * -1 if not cannot be determined
332 public int getPlayLevel();
334 * Mutes or unmutes the local microphone.
337 public void muteMic(boolean isMuted);
340 * @return true is mic is muted
342 public boolean isMicMuted();
345 * Initiate a dtmf signal if in call
348 public void sendDtmf(char number);
350 * Initiate a dtmf signal to the speqker if not in call
352 * @param duration in ms , -1 for unlimited
354 public void playDtmf(char number,int duration);
358 public void stopDtmf();
361 * remove all call logs
363 public void clearCallLogs();
365 * get payload type from mime type an clock rate
367 * return null if not found
369 public PayloadType findPayloadType(String mime,int clockRate);
371 * not implemented yet
374 * @throws LinphoneCoreException
376 public void enablePayloadType(PayloadType pt, boolean enable) throws LinphoneCoreException;
378 * Enables or disable echo cancellation.
381 public void enableEchoCancellation(boolean enable);
384 * @return true if echo cancellation is enabled.
386 public boolean isEchoCancellationEnabled();
388 * not implemented yet
391 public void setSignalingTransport(Transport aTransport);
396 public void enableSpeaker(boolean value);
401 public boolean isSpeakerEnabled();
403 * add a friend to the current buddy list, if subscription attribute is set, a SIP SUBSCRIBE message is sent.
404 * @param lf LinphoenFriend to add
405 * @throws LinphoneCoreException
407 void addFriend(LinphoneFriend lf) throws LinphoneCoreException;
410 * Set my presence status
411 * @param minute_away how long in away
412 * @param status sip uri used to redirect call in state LinphoneStatusMoved
414 void setPresenceInfo(int minute_away,String alternative_contact, OnlineStatus status);
416 * Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org
417 * @param to destination address for messages
419 * @return {@link LinphoneChatRoom} where messaging can take place.
421 LinphoneChatRoom createChatRoom(String to);
423 public void setVideoWindow(Object w);
424 public void setPreviewWindow(Object w);
426 * Enables video globally.
429 * This function does not have any effect during calls. It just indicates #LinphoneCore to
430 * initiate future calls with video or not. The two boolean parameters indicate in which
431 * direction video is enabled. Setting both to false disables video entirely.
433 * @param vcap_enabled indicates whether video capture is enabled
434 * @param display_enabled indicates whether video display should be shown
437 void enableVideo(boolean vcap_enabled, boolean display_enabled);
439 * Returns TRUE if video is enabled, FALSE otherwise.
442 boolean isVideoEnabled();
445 * Specify a STUN server to help firewall traversal.
446 * @param stun_server Stun server address and port, such as stun.linphone.org or stun.linphone.org:3478
448 public void setStunServer(String stun_server);
450 * @return stun server address if previously set.
452 public String getStunServer();
455 * Sets policy regarding workarounding NATs
456 * @param pol one of the FirewallPolicy members.
458 public void setFirewallPolicy(FirewallPolicy pol);
460 * @return previously set firewall policy.
462 public FirewallPolicy getFirewallPolicy();
464 public LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException ;
466 public int updateCall(LinphoneCall call, LinphoneCallParams params);
468 public LinphoneCallParams createDefaultCallParameters();
471 * Sets the path to a wav file used for ringing.
473 * @param path The file must be a wav 16bit linear. Local ring is disabled if null
475 public void setRing(String path);
477 * gets the path to a wav file used for ringing.
479 * @param null if not set
481 public String getRing();
482 public void setUploadBandwidth(int bw);
484 public void setDownloadBandwidth(int bw);
486 public void setPreferredVideoSize(VideoSize vSize);
488 public VideoSize getPreferredVideoSize();
490 public PayloadType[] listVideoCodecs();
492 * enable signaling keep alive. small udp packet sent periodically to keep udp NAT association
494 void enableKeepAlive(boolean enable);
496 * get keep elive mode
497 * @return true if enable
499 boolean isKeepAliveEnabled();