summaryrefslogtreecommitdiff
path: root/pjsip/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-27 00:00:30 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-27 00:00:30 +0000
commit887750106a0999aca4638c31d01ffa89eb3d4a74 (patch)
treef32476008af99f7a6be473ecc86166d76a0a1e20 /pjsip/src
parente74059628256afdb725c367d23b9503f011b0d0c (diff)
Moved pjsua framework to pjsua-lib
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@238 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r--pjsip/src/pjsua-lib/getopt.c (renamed from pjsip/src/pjsua/getopt.c)2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c (renamed from pjsip/src/pjsua/pjsua_call.c)2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c (renamed from pjsip/src/pjsua/pjsua_core.c)2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_opt.c (renamed from pjsip/src/pjsua/pjsua_opt.c)15
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c (renamed from pjsip/src/pjsua/pjsua_pres.c)2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_reg.c (renamed from pjsip/src/pjsua/pjsua_reg.c)2
-rw-r--r--pjsip/src/pjsua/getopt.h136
-rw-r--r--pjsip/src/pjsua/main.c2
-rw-r--r--pjsip/src/pjsua/pjsua.h468
9 files changed, 16 insertions, 615 deletions
diff --git a/pjsip/src/pjsua/getopt.c b/pjsip/src/pjsua-lib/getopt.c
index 30f45381..5f39edda 100644
--- a/pjsip/src/pjsua/getopt.c
+++ b/pjsip/src/pjsua-lib/getopt.c
@@ -25,7 +25,7 @@
* $Id$
*/
-#include "getopt.h"
+#include <pjsua-lib/getopt.h>
#include <pj/string.h>
/* Internal only. Users should not call this directly. */
diff --git a/pjsip/src/pjsua/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index e0a9a0af..157b2bb1 100644
--- a/pjsip/src/pjsua/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
+#include <pjsua-lib/pjsua.h>
#include <pj/log.h>
diff --git a/pjsip/src/pjsua/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 974c6d53..b09a7c59 100644
--- a/pjsip/src/pjsua/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
+#include <pjsua-lib/pjsua.h>
/*
* pjsua_core.c
diff --git a/pjsip/src/pjsua/pjsua_opt.c b/pjsip/src/pjsua-lib/pjsua_opt.c
index 5ec37980..bdd1a421 100644
--- a/pjsip/src/pjsua/pjsua_opt.c
+++ b/pjsip/src/pjsua-lib/pjsua_opt.c
@@ -16,9 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
-#include "getopt.h"
-#include <stdlib.h>
+#include <pjsua-lib/pjsua.h>
+#include <pjsua-lib/getopt.h>
#define THIS_FILE "pjsua_opt.c"
@@ -191,6 +190,12 @@ static int read_config_file(pj_pool_t *pool, const char *filename,
}
+static int my_atoi(const char *cs)
+{
+ pj_str_t s;
+ return pj_strtoul(pj_cstr(&s, cs));
+}
+
/* Parse arguments. */
pj_status_t pjsua_parse_args(int argc, char *argv[])
@@ -458,7 +463,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
break;
case OPT_AUTO_ANSWER:
- pjsua.auto_answer = atoi(optarg);
+ pjsua.auto_answer = my_atoi(optarg);
if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) {
puts("Error: invalid code in --auto-answer (expecting 100-699");
return -1;
@@ -466,7 +471,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
break;
case OPT_MAX_CALLS:
- pjsua.max_calls = atoi(optarg);
+ pjsua.max_calls = my_atoi(optarg);
if (pjsua.max_calls < 1 || pjsua.max_calls > 255) {
puts("Too many calls for max-calls (1-255)");
return -1;
diff --git a/pjsip/src/pjsua/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index b203a2ca..9f307c6c 100644
--- a/pjsip/src/pjsua/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
+#include <pjsua-lib/pjsua.h>
/*
* pjsua_pres.c
diff --git a/pjsip/src/pjsua/pjsua_reg.c b/pjsip/src/pjsua-lib/pjsua_reg.c
index 006bc732..e18f7cc8 100644
--- a/pjsip/src/pjsua/pjsua_reg.c
+++ b/pjsip/src/pjsua-lib/pjsua_reg.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
+#include <pjsua-lib/pjsua.h>
/*
diff --git a/pjsip/src/pjsua/getopt.h b/pjsip/src/pjsua/getopt.h
deleted file mode 100644
index ea19c718..00000000
--- a/pjsip/src/pjsua/getopt.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* $Id$ */
-/* This file has now become GPL. */
-/* Declarations for getopt.
- Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
- const char *name;
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-# define no_argument 0
-# define required_argument 1
-# define optional_argument 2
-
-
-/* Get definitions and prototypes for functions to process the
- arguments in ARGV (ARGC of them, minus the program name) for
- options given in OPTS.
-
- Return the option character from OPTS just read. Return -1 when
- there are no more options. For unrecognized options, or options
- missing arguments, `optopt' is set to the option letter, and '?' is
- returned.
-
- The OPTS string is a list of characters which are recognized option
- letters, optionally followed by colons, specifying that that letter
- takes an argument, to be placed in `optarg'.
-
- If a letter in OPTS is followed by two colons, its argument is
- optional. This behavior is specific to the GNU `getopt'.
-
- The argument `--' causes premature termination of argument
- scanning, explicitly telling `getopt' that there are no more
- options.
-
- If OPTS begins with `--', then non-option arguments are treated as
- arguments to the option '\0'. This behavior is specific to the GNU
- `getopt'. */
-
-int getopt (int argc, char *const *argv, const char *shortopts);
-
-int getopt_long (int argc, char *const *argv, const char *options,
- const struct option *longopts, int *longind);
-int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* getopt.h */
-
diff --git a/pjsip/src/pjsua/main.c b/pjsip/src/pjsua/main.c
index 25ce6dcf..ce317078 100644
--- a/pjsip/src/pjsua/main.c
+++ b/pjsip/src/pjsua/main.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "pjsua.h"
+#include <pjsua-lib/pjsua.h>
#include <stdlib.h>
diff --git a/pjsip/src/pjsua/pjsua.h b/pjsip/src/pjsua/pjsua.h
deleted file mode 100644
index 09874160..00000000
--- a/pjsip/src/pjsua/pjsua.h
+++ /dev/null
@@ -1,468 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#ifndef __PJSUA_H__
-#define __PJSUA_H__
-
-/* Include all PJSIP core headers. */
-#include <pjsip.h>
-
-/* Include all PJMEDIA headers. */
-#include <pjmedia.h>
-
-/* Include all PJMEDIA-CODEC headers. */
-#include <pjmedia-codec.h>
-
-/* Include all PJSIP-UA headers */
-#include <pjsip_ua.h>
-
-/* Include all PJSIP-SIMPLE headers */
-#include <pjsip_simple.h>
-
-/* Include all PJLIB-UTIL headers. */
-#include <pjlib-util.h>
-
-/* Include all PJLIB headers. */
-#include <pjlib.h>
-
-
-PJ_BEGIN_DECL
-
-
-/**
- * Max buddies in buddy list.
- */
-#ifndef PJSUA_MAX_BUDDIES
-# define PJSUA_MAX_BUDDIES 32
-#endif
-
-
-/**
- * Max simultaneous calls.
- */
-#ifndef PJSUA_MAX_CALLS
-# define PJSUA_MAX_CALLS 256
-#endif
-
-
-/**
- * Aditional ports to be allocated in the conference ports for non-call
- * streams.
- */
-#define PJSUA_CONF_MORE_PORTS 2
-
-
-/**
- * Maximum accounts.
- */
-#ifndef PJSUA_MAX_ACC
-# define PJSUA_MAX_ACC 8
-#endif
-
-
-/**
- * Maximum credentials.
- */
-#ifndef PJSUA_MAX_CRED
-# define PJSUA_MAX_CRED PJSUA_MAX_ACC
-#endif
-
-
-/**
- * Structure to be attached to invite dialog.
- * Given a dialog "dlg", application can retrieve this structure
- * by accessing dlg->mod_data[pjsua.mod.id].
- */
-struct pjsua_call
-{
- unsigned index; /**< Index in pjsua array. */
- pjsip_inv_session *inv; /**< The invite session. */
- int acc_index; /**< Account index being used. */
- pjmedia_session *session; /**< The media session. */
- unsigned conf_slot; /**< Slot # in conference bridge. */
- pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this
- call was triggered by xfer. */
- pjmedia_sock_info skinfo; /**< Preallocated media sockets. */
-
- void *app_data; /**< Application data. */
-};
-
-typedef struct pjsua_call pjsua_call;
-
-
-/**
- * Buddy data.
- */
-struct pjsua_buddy
-{
- pj_str_t uri; /**< Buddy URI */
- int acc_index; /**< Which account to use. */
- pj_bool_t monitor; /**< Should we monitor? */
- pjsip_evsub *sub; /**< Buddy presence subscription */
- pjsip_pres_status status; /**< Buddy presence status. */
-};
-
-typedef struct pjsua_buddy pjsua_buddy;
-
-
-/**
- * Server presence subscription list head.
- */
-struct pjsua_srv_pres
-{
- PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres);
- pjsip_evsub *sub;
- char *remote;
-};
-
-typedef struct pjsua_srv_pres pjsua_srv_pres;
-
-
-/**
- * Account
- */
-struct pjsua_acc
-{
- int index; /**< Index in accounts array. */
- pj_str_t local_uri; /**< Uri in From: header. */
- pj_str_t user_part; /**< User part of local URI. */
- pj_str_t host_part; /**< Host part of local URI. */
- pj_str_t contact_uri; /**< Uri in Contact: header. */
-
- pj_str_t reg_uri; /**< Registrar URI. */
- pjsip_regc *regc; /**< Client registration session. */
- pj_int32_t reg_timeout; /**< Default timeout. */
- pj_timer_entry reg_timer; /**< Registration timer. */
- pj_status_t reg_last_err; /**< Last registration error. */
- int reg_last_code; /**< Last status last register. */
-
- pj_str_t proxy; /**< Proxy URL. */
- pjsip_route_hdr route_set; /**< Route set. */
-
- pj_bool_t online_status; /**< Our online status. */
- pjsua_srv_pres pres_srv_list; /**< Server subscription list. */
-
- void *app_data; /**< Application data. */
-};
-
-
-typedef struct pjsua_acc pjsua_acc;
-
-
-/* PJSUA application variables. */
-struct pjsua
-{
- /* Control: */
- pj_caching_pool cp; /**< Global pool factory. */
- pjsip_endpoint *endpt; /**< Global endpoint. */
- pj_pool_t *pool; /**< pjsua's private pool. */
- pjsip_module mod; /**< pjsua's PJSIP module. */
-
-
- /* Media: */
- pjmedia_endpt *med_endpt; /**< Media endpoint. */
- pjmedia_conf *mconf; /**< Media conference. */
- pj_bool_t null_audio; /**< Null audio flag. */
- char *wav_file; /**< WAV file name to play. */
- unsigned wav_slot; /**< WAV player slot in bridge */
- pj_bool_t auto_play; /**< Auto play file for calls? */
- pj_bool_t auto_loop; /**< Auto loop RTP stream? */
- pj_bool_t auto_conf; /**< Auto put to conference? */
-
-
- /* User Agent behaviour: */
- int auto_answer; /**< Automatically answer in calls. */
-
- /* Account: */
- int acc_cnt; /**< Number of client registrations */
- pjsua_acc acc[PJSUA_MAX_ACC]; /** Client regs array. */
-
-
- /* Authentication credentials: */
-
- int cred_count; /**< Number of credentials. */
- pjsip_cred_info cred_info[10]; /**< Array of credentials. */
-
-
- /* Threading (optional): */
- int thread_cnt; /**< Thread count. */
- pj_thread_t *threads[8]; /**< Thread instances. */
- pj_bool_t quit_flag; /**< To signal thread to quit. */
-
- /* Transport (UDP): */
- pj_uint16_t sip_port; /**< SIP signaling port. */
- pj_sock_t sip_sock; /**< SIP UDP socket. */
- pj_sockaddr_in sip_sock_name; /**< Public/STUN UDP socket addr. */
-
- pj_str_t outbound_proxy;/**< Outbound proxy. */
-
-
- /* STUN: */
- pj_str_t stun_srv1;
- int stun_port1;
- pj_str_t stun_srv2;
- int stun_port2;
-
-
- /* Logging: */
- int log_level; /**< Logging verbosity. */
- int app_log_level; /**< stdout log verbosity. */
- unsigned log_decor; /**< Log decoration. */
- char *log_filename; /**< Log filename. */
-
-
- /* PJSUA Calls: */
- int max_calls; /**< Max nb of calls. */
- int call_cnt; /**< Number of calls. */
- pjsua_call calls[PJSUA_MAX_CALLS]; /** Calls array. */
-
-
- /* SIMPLE and buddy status: */
- int buddy_cnt;
- pjsua_buddy buddies[PJSUA_MAX_BUDDIES];
-};
-
-
-/** PJSUA instance. */
-extern struct pjsua pjsua;
-
-
-
-/*****************************************************************************
- * PJSUA API (defined in pjsua_core.c).
- */
-
-/**
- * Initialize pjsua settings with default parameters.
- */
-void pjsua_default(void);
-
-
-/**
- * Display error message for the specified error code.
- */
-void pjsua_perror(const char *sender, const char *title,
- pj_status_t status);
-
-
-/**
- * Initialize pjsua application. Application can call this before parsing
- * application settings.
- *
- * This will initialize all libraries, create endpoint instance, and register
- * pjsip modules. Transport will NOT be created however.
- *
- * Application may register module after calling this function.
- */
-pj_status_t pjsua_init(void);
-
-
-/**
- * Start pjsua stack. Application calls this after pjsua settings has been
- * configured.
- *
- * This will start the transport, worker threads (if any), and registration
- * process, if registration is configured.
- */
-pj_status_t pjsua_start(void);
-
-
-/**
- * Destroy pjsua.
- */
-pj_status_t pjsua_destroy(void);
-
-
-/**
- * Find account for incoming request.
- */
-int pjsua_find_account_for_incoming(pjsip_rx_data *rdata);
-
-
-/**
- * Find account for outgoing request.
- */
-int pjsua_find_account_for_outgoing(const pj_str_t *url);
-
-
-/*****************************************************************************
- * PJSUA Call API (defined in pjsua_call.c).
- */
-
-/**
- * Init pjsua call module.
- */
-pj_status_t pjsua_call_init(void);
-
-/**
- * Make outgoing call.
- */
-pj_status_t pjsua_make_call(int acc_index,
- const char *cstr_dest_uri,
- int *p_call_index);
-
-
-/**
- * Handle incoming invite request.
- */
-pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata);
-
-
-/**
- * Answer call.
- */
-void pjsua_call_answer(int call_index, int code);
-
-/**
- * Hangup call.
- */
-void pjsua_call_hangup(int call_index, int code);
-
-
-/**
- * Put call on-hold.
- */
-void pjsua_call_set_hold(int call_index);
-
-
-/**
- * Send re-INVITE (to release hold).
- */
-void pjsua_call_reinvite(int call_index);
-
-
-/**
- * Transfer call.
- */
-void pjsua_call_xfer(int call_index, const char *dest);
-
-
-/**
- * Terminate all calls.
- */
-void pjsua_inv_shutdown(void);
-
-
-/*****************************************************************************
- * PJSUA Client Registration API (defined in pjsua_reg.c).
- */
-
-/**
- * Initialize client registration session.
- *
- * @param app_callback Optional callback
- */
-pj_status_t pjsua_regc_init(int acc_index);
-
-/**
- * Update registration or perform unregistration. If renew argument is zero,
- * this will start unregistration process.
- */
-void pjsua_regc_update(int acc_index, pj_bool_t renew);
-
-
-
-
-/*****************************************************************************
- * PJSUA Presence (pjsua_pres.c)
- */
-
-/**
- * Init presence.
- */
-pj_status_t pjsua_pres_init();
-
-/**
- * Refresh both presence client and server subscriptions.
- */
-void pjsua_pres_refresh(int acc_index);
-
-/**
- * Terminate all subscriptions
- */
-void pjsua_pres_shutdown(void);
-
-/**
- * Dump presence subscriptions.
- */
-void pjsua_pres_dump(void);
-
-
-/*****************************************************************************
- * User Interface API.
- *
- * The UI API specifies functions that will be called by pjsua upon
- * occurence of various events.
- */
-
-/**
- * Notify UI when invite state has changed.
- */
-void pjsua_ui_inv_on_state_changed(int call_index, pjsip_event *e);
-
-/**
- * Notify UI when registration status has changed.
- */
-void pjsua_ui_regc_on_state_changed(int acc_index);
-
-
-/*****************************************************************************
- * Utilities.
- *
- */
-
-/** String to describe invite session states */
-extern const char *pjsua_inv_state_names[];
-
-/**
- * Parse arguments (pjsua_opt.c).
- */
-pj_status_t pjsua_parse_args(int argc, char *argv[]);
-
-/**
- * Load settings from a file.
- */
-pj_status_t pjsua_load_settings(const char *filename);
-
-/**
- * Dump settings.
- */
-int pjsua_dump_settings(char *buf, pj_size_t max);
-
-/**
- * Save settings to a file.
- */
-pj_status_t pjsua_save_settings(const char *filename);
-
-
-/*
- * Verify that valid SIP url is given.
- * @return PJ_SUCCESS if valid.
- */
-pj_status_t pjsua_verify_sip_url(const char *c_url);
-
-/*
- * Dump application states.
- */
-void pjsua_dump(void);
-
-
-PJ_END_DECL
-
-
-#endif /* __PJSUA_H__ */