~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to coreapi/linphonecore.h

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-06-30 13:58:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040630135816-wwx75gdlodkqbabb
Tags: upstream-0.12.2
ImportĀ upstreamĀ versionĀ 0.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
linphone
 
3
Copyright (C) 2000  Simon MORLAT (simon.morlat@free.fr)
 
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
#ifndef LINPHONECORE_H
 
20
#define LINPHONECORE_H
 
21
 
 
22
#include <sndcard.h>
 
23
#undef PACKAGE
 
24
#undef VERSION
 
25
#include <osipua.h>
 
26
#undef PACKAGE
 
27
#undef VERSION
 
28
 
 
29
#include <config.h>
 
30
 
 
31
#include <libintl.h>
 
32
#ifndef _
 
33
#define _(String) gettext(String)
 
34
#endif
 
35
 
 
36
#ifdef HAVE_GLIB
 
37
#include <glib.h>
 
38
#else
 
39
#include <uglib.h>
 
40
#endif
 
41
 
 
42
 
 
43
 
 
44
 
 
45
#ifdef __cplusplus
 
46
extern "C" {
 
47
#endif
 
48
 
 
49
#ifndef PayloadType_defined
 
50
#define PayloadType_defined
 
51
typedef struct _PayloadType PayloadType;
 
52
#endif
 
53
 
 
54
gboolean payload_type_enabled(struct _PayloadType *pt);
 
55
gboolean payload_type_usable(struct _PayloadType *pt);
 
56
void payload_type_set_enable(struct _PayloadType *pt,gint value);
 
57
void payload_type_set_usable(struct _PayloadType *pt,gint value);
 
58
gchar *payload_type_get_description(struct _PayloadType *pt);
 
59
gint payload_type_get_bitrate(PayloadType *pt);
 
60
const gchar *payload_type_get_mime(PayloadType *pt);
 
61
gint payload_type_get_rate(PayloadType *pt);
 
62
 
 
63
 
 
64
 
 
65
#define CONNECTION_TYPE_28KMODEM 0
 
66
#define CONNECTION_TYPE_56KMODEM 1
 
67
#define CONNECTION_TYPE_NUMERIS 2
 
68
#define CONNECTION_TYPE_ADSL 3
 
69
#define CONNECTION_TYPE_ETHERNET 4
 
70
 
 
71
extern const double bandwidths[5];
 
72
 
 
73
typedef struct registrar_config
 
74
{
 
75
        char *registrar;        /*or proxy */
 
76
        char *passwd;
 
77
        char *addr_of_rec;
 
78
        guint expires;
 
79
        GTimer *timer;
 
80
        guint32 use_registrar:1;                /* general flag */
 
81
        guint32 as_proxy:1;                     /* is the registrar also an outbound proxy */
 
82
        guint32 padding:30;
 
83
} registrar_config_t;
 
84
 
 
85
typedef struct sip_config
 
86
{
 
87
        char *contact;
 
88
        char *username;
 
89
        char *hostname;
 
90
        registrar_config_t reg_conf;
 
91
        gint sip_port;
 
92
} sip_config_t;
 
93
 
 
94
typedef struct rtp_config
 
95
{
 
96
        guint16 audio_rtp_port;
 
97
        guint16 video_rtp_port;
 
98
        gint audio_jitt_comp;  /*jitter compensation*/
 
99
        gint video_jitt_comp;  /*jitter compensation*/
 
100
}rtp_config_t;
 
101
 
 
102
typedef struct _interface_t
 
103
{
 
104
        char name[20];
 
105
#ifdef INET6
 
106
        int  family;
 
107
        char ipaddr[40];
 
108
#else
 
109
        char ip4addr[20];
 
110
#endif
 
111
        int index;
 
112
} interface_t;
 
113
 
 
114
typedef struct net_config
 
115
{
 
116
        GList *interfaces;      /* list of interface_t */
 
117
        interface_t *sel_if;
 
118
        double bandwidth;               /* the bandwidth in bit/s of the selected interface*/ /*unused*/
 
119
        gchar *nat_address;
 
120
        gboolean use_nat;
 
121
        gint con_type;                  /* type of connection 28k 56k 128k adsl ...*/
 
122
}net_config_t;
 
123
 
 
124
 
 
125
typedef struct sound_config
 
126
{
 
127
        SndCard *sndcard;       /* the sndcard currently used */
 
128
        gint dev_id;            /* sound device id */
 
129
        gint latency;   /* latency in samples of the current used sound device */
 
130
        char rec_lev;
 
131
        char play_lev;
 
132
        char source;
 
133
        char pad;
 
134
        char *local_ring;
 
135
        char *remote_ring;
 
136
        int autokill:1;  /* 1= automatically free access to sound device by killing artsd and esd*/
 
137
} sound_config_t;
 
138
 
 
139
typedef struct codecs_config
 
140
{
 
141
        GList *audio_codecs;  /* list of audio codecs in order of preference*/
 
142
        GList *video_codecs;    /* for later use*/
 
143
}codecs_config_t;
 
144
 
 
145
typedef struct video_config{
 
146
        int enabled:1;
 
147
        int show_local:1;
 
148
        int pad:30;
 
149
}video_config_t;
 
150
 
 
151
typedef struct ui_config
 
152
{
 
153
        GList *address_list;
 
154
        int is_daemon;
 
155
        int is_applet;
 
156
        guint timer_id;  /* the timer id for registration */
 
157
}ui_config_t;
 
158
 
 
159
 
 
160
 
 
161
typedef struct autoreplier_config
 
162
{
 
163
        gint enabled;
 
164
        gint after_seconds;             /* accept the call after x seconds*/
 
165
        gint max_users;                 /* maximum number of user that can call simultaneously */
 
166
        gint max_rec_time;      /* the max time of incoming voice recorded */
 
167
        gint max_rec_msg;               /* maximum number of recorded messages */
 
168
        gchar *message;         /* the path of the file to be played */
 
169
}autoreplier_config_t;
 
170
 
 
171
typedef struct _StreamParams
 
172
{
 
173
        int initialized;
 
174
        int line;
 
175
        int localport;
 
176
        int remoteport;
 
177
        char *remoteaddr;
 
178
        int pt;
 
179
} StreamParams;
 
180
 
 
181
typedef struct _LinphoneDialogParams
 
182
{
 
183
        StreamParams audio_params;
 
184
        StreamParams video_params;
 
185
        struct _RtpProfile *profile;    /*points to the local_profile or to the remote "guessed" profile*/
 
186
} LinphoneDialogParams;
 
187
 
 
188
LinphoneDialogParams * linphone_dialog_params_new();
 
189
void linphone_dialog_params_destroy(LinphoneDialogParams *obj);
 
190
struct _LinphoneCore;
 
191
 
 
192
typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
 
193
typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, char *from);
 
194
typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, char *from);
 
195
typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, char *message);
 
196
typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, char *message);
 
197
typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, char *message,char *url);
 
198
typedef void (*DisplayQuestionCb)(struct _LinphoneCore *lc, char *message);
 
199
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,gpointer user_data);
 
200
typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, const char *url, const char *status);
 
201
 
 
202
typedef struct _LinphoneVTable
 
203
{
 
204
        ShowInterfaceCb show;
 
205
        InviteReceivedCb inv_recv;
 
206
        ByeReceivedCb bye_recv;
 
207
        NotifyReceivedCb notify_recv;
 
208
        DisplayStatusCb display_status;
 
209
        DisplayMessageCb display_message;
 
210
        DisplayMessageCb display_warning;
 
211
        DisplayUrlCb display_url;
 
212
        DisplayQuestionCb display_question;
 
213
} LinphoneCoreVTable;
 
214
 
 
215
typedef struct _LCCallbackObj
 
216
{
 
217
  LinphoneCoreCbFunc _func;
 
218
  gpointer _user_data;
 
219
}LCCallbackObj;
 
220
 
 
221
 
 
222
typedef struct _LinphoneCore
 
223
{
 
224
        LinphoneCoreVTable vtable;
 
225
        net_config_t net_conf;
 
226
        sip_config_t sip_conf;
 
227
        rtp_config_t rtp_conf;
 
228
        sound_config_t sound_conf;
 
229
        video_config_t video_conf;
 
230
        codecs_config_t codecs_conf;
 
231
        ui_config_t ui_conf;
 
232
        autoreplier_config_t autoreplier_conf;
 
233
        struct _RingStream *ringstream;
 
234
        LCCallbackObj preview_finished_cb;
 
235
        gboolean preview_finished;
 
236
        OsipUA *ua;                     /* the osip user agent*/
 
237
        OsipDialog *call;   /* the current dialog, in the future it will be a list of dialog (conferencing)*/
 
238
        GList *queued_calls;    /* used by the autoreplier */
 
239
        BodyHandler *sdph;      /* the sdp handler */
 
240
        struct _AudioStream *audiostream;  /**/
 
241
        transaction_t *current_trn;     /* REVISIT LATER */
 
242
        struct _RtpProfile *local_profile;
 
243
        int in_main_thread;
 
244
        void *data;
 
245
        GMutex *lock;
 
246
} LinphoneCore;
 
247
 
 
248
 
 
249
LinphoneCore *linphone_core_new(LinphoneCoreVTable *vtable,
 
250
                                                gchar *config_path, gpointer userdata);
 
251
 
 
252
void linphone_core_init(LinphoneCore *lc,LinphoneCoreVTable *vtable,
 
253
                                                gchar *config_path, gpointer userdata);
 
254
 
 
255
int linphone_core_set_primary_contact(LinphoneCore *lc, gchar *contact);
 
256
 
 
257
gchar *linphone_core_get_primary_contact(LinphoneCore *lc);
 
258
 
 
259
from_t *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
 
260
 
 
261
 
 
262
#ifdef LINPHONE_DEPRECATED
 
263
GList * linphone_core_get_net_interfaces(LinphoneCore *lc);
 
264
 
 
265
interface_t * linphone_core_get_selected_interface(LinphoneCore *lc);
 
266
 
 
267
#ifdef INET6
 
268
void linphone_core_select_net_interface(LinphoneCore *lc, gint index);
 
269
#else
 
270
void linphone_core_select_net_interface(LinphoneCore *lc, gchar *ifname);
 
271
#endif
 
272
 
 
273
#endif
 
274
 
 
275
void linphone_core_set_connection_type(LinphoneCore *lc, int type);
 
276
 
 
277
int linphone_core_get_connection_type(LinphoneCore *lc);
 
278
 
 
279
int linphone_core_invite(LinphoneCore *lc, char *url);
 
280
 
 
281
gboolean linphone_core_inc_invite_pending(LinphoneCore*lc);
 
282
 
 
283
int linphone_core_accept_dialog(LinphoneCore *lc, const char *url);
 
284
 
 
285
int linphone_core_terminate_dialog(LinphoneCore *lc, const char *url);
 
286
 
 
287
void linphone_core_send_dtmf(LinphoneCore *lc,gchar dtmf);
 
288
 
 
289
/* returns a GList of MSCodecInfo */
 
290
GList *linphone_core_get_audio_codecs(LinphoneCore *lc);
 
291
 
 
292
int linphone_core_set_audio_codecs(LinphoneCore *lc, GList *codecs);
 
293
 
 
294
/* returns a GList of MSCodecInfo */
 
295
GList *linphone_core_get_video_codecs(LinphoneCore *lc);
 
296
 
 
297
int linphone_core_set_video_codecs(LinphoneCore *lc, GList *codecs);
 
298
 
 
299
GList * linphone_core_get_address_list(LinphoneCore *lc);
 
300
 
 
301
int linphone_core_set_address_list(LinphoneCore *lc, GList *addresses);
 
302
 
 
303
char *linphone_core_get_registrar_addr(LinphoneCore *lc);
 
304
 
 
305
char *linphone_core_get_registrar_passwd(LinphoneCore *lc);
 
306
 
 
307
void linphone_core_set_registrar_passwd(LinphoneCore *lc, gchar *passwd);
 
308
 
 
309
char *linphone_core_get_addr_of_rec(LinphoneCore *lc);
 
310
 
 
311
int linphone_core_set_registrar_addr(LinphoneCore *lc, char *url,char*addr_of_rec);
 
312
 
 
313
int linphone_core_register(LinphoneCore *lc, char *url);
 
314
 
 
315
void linphone_core_get_registrar_usage(LinphoneCore *lc, gboolean *enabled, gboolean *as_proxy, gint*expires);
 
316
 
 
317
void linphone_core_set_registrar_usage(LinphoneCore *lc, gboolean enabled, gboolean as_proxy, gint expires);
 
318
 
 
319
int linphone_core_get_audio_jittcomp(LinphoneCore *lc);
 
320
 
 
321
int linphone_core_get_audio_port(LinphoneCore *lc);
 
322
 
 
323
void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);
 
324
 
 
325
void linphone_core_set_audio_port(LinphoneCore *lc, int port);
 
326
 
 
327
int linphone_core_get_sip_port(LinphoneCore *lc);
 
328
 
 
329
void linphone_core_set_sip_port(LinphoneCore *lc,int port);
 
330
 
 
331
void linphone_core_set_nat_address(LinphoneCore *lc, gchar *addr, gboolean use);
 
332
 
 
333
gchar *linphone_core_get_nat_address(LinphoneCore *lc, gboolean *use);
 
334
 
 
335
void linphone_core_force_ip_address(LinphoneCore *lc, gchar *ipaddr);
 
336
 
 
337
/* function to be periodically called in a main loop */
 
338
void linphone_core_iterate(LinphoneCore *lc);
 
339
 
 
340
/* sound functions */
 
341
SndCardManager * linphone_core_get_card_manager(LinphoneCore *lc);
 
342
gint linphone_core_get_play_level(LinphoneCore *lc);
 
343
gint linphone_core_get_rec_level(LinphoneCore *lc);
 
344
void linphone_core_set_play_level(LinphoneCore *lc, gint level);
 
345
void linphone_core_set_rec_level(LinphoneCore *lc, gint level);
 
346
gint linphone_core_get_sound_device(LinphoneCore *lc);
 
347
gint linphone_core_set_sound_device(LinphoneCore *lc, gint devid);
 
348
gint linphone_core_set_sound_device_from_name(LinphoneCore *lc,gchar *name);
 
349
gchar linphone_core_get_sound_source(LinphoneCore *lc);
 
350
void linphone_core_set_sound_source(LinphoneCore *lc, gchar source);
 
351
void linphone_core_set_ring(LinphoneCore *lc,gchar *path);
 
352
gchar *linphone_core_get_ring(LinphoneCore *lc);
 
353
gint linphone_core_preview_ring(LinphoneCore *lc, const gchar *ring,LinphoneCoreCbFunc func,gpointer userdata);
 
354
typedef enum {RINGBACK_TYPE_FR,RINGBACK_TYPE_US} RingBackType;
 
355
void linphone_core_set_ringback(LinphoneCore *lc,RingBackType type);
 
356
RingBackType linphone_core_get_ringback(LinphoneCore *lc);
 
357
 
 
358
void linphone_core_set_presence_info(LinphoneCore *lc,gint minutes_away,
 
359
                                                                                                        gchar *contact,
 
360
                                                                                                        int presence_mode);
 
361
 
 
362
#define linphone_core_is_in_main_thread(lc)     ((lc)->in_main_thread)
 
363
 
 
364
void linphone_core_uninit(LinphoneCore *lc);
 
365
void linphone_core_destroy(LinphoneCore *lc);
 
366
 
 
367
/*internal use only */
 
368
#define linphone_core_thread_enter(lc) (lc)->in_main_thread=0
 
369
#define linphone_core_thread_leave(lc) (lc)->in_main_thread=1
 
370
#define linphone_core_lock(lc)  g_mutex_lock((lc)->lock)
 
371
#define linphone_core_unlock(lc)        g_mutex_unlock((lc)->lock)
 
372
 
 
373
#ifdef __cplusplus
 
374
}
 
375
#endif
 
376
 
 
377
#endif