Changed from polling to select API
parent
972c43d74e
commit
887aaddeee
|
@ -44,6 +44,7 @@ src/libosmocc/libosmocc.a
|
|||
src/libsample/libsample.a
|
||||
src/libfilter/libfilter.a
|
||||
src/libtimer/libtimer.a
|
||||
src/libselect/libselect.a
|
||||
src/libph_socket/libph_socket.a
|
||||
src/pstn/osmo-cc-pstn-endpoint
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ AC_OUTPUT(
|
|||
src/libfm/Makefile
|
||||
src/libfilter/Makefile
|
||||
src/libtimer/Makefile
|
||||
src/libselect/Makefile
|
||||
src/libjitter/Makefile
|
||||
src/libosmocc/Makefile
|
||||
src/libg711/Makefile
|
||||
|
|
|
@ -9,6 +9,7 @@ SUBDIRS = \
|
|||
libdtmf \
|
||||
libfsk \
|
||||
libtimer \
|
||||
libselect \
|
||||
libjitter \
|
||||
libosmocc \
|
||||
libph_socket \
|
||||
|
|
|
@ -20,6 +20,7 @@ osmo_cc_pstn_endpoint_LDADD = \
|
|||
../libfm/libfm.a \
|
||||
../libfilter/libfilter.a \
|
||||
../libtimer/libtimer.a \
|
||||
../libselect/libselect.a \
|
||||
../libjitter/libjitter.a \
|
||||
../libosmocc/libosmocc.a \
|
||||
../libg711/libg711.a \
|
||||
|
|
|
@ -386,15 +386,22 @@ int main(int argc, char *argv[])
|
|||
signal(SIGPIPE, sighandler);
|
||||
|
||||
while (!quit) {
|
||||
int w;
|
||||
process_timer();
|
||||
pstn_work(pstn_ep);
|
||||
rtp_work(pstn_ep);
|
||||
int work;
|
||||
double timeout;
|
||||
/* handle all handlers until done */
|
||||
do {
|
||||
w = 0;
|
||||
w |= osmo_cc_handle();
|
||||
} while (w);
|
||||
usleep(1000);
|
||||
work = 0;
|
||||
work |= osmo_cc_handle();
|
||||
} while (work);
|
||||
/* handle all timers
|
||||
* timeout is 0, if there was an event
|
||||
* -> handle FDs without waiting, continue this loop
|
||||
* timeout is not 0, if there was no event
|
||||
* -> wait until FD or timeout
|
||||
*/
|
||||
timeout = process_timer();
|
||||
/* wait for FD event until given timeout */
|
||||
work = osmo_fd_select(timeout);
|
||||
}
|
||||
|
||||
signal(SIGINT, SIG_DFL);
|
||||
|
|
|
@ -301,7 +301,7 @@ void pstn_destroy(pstn_t *pstn)
|
|||
PDEBUG(DTEL, DEBUG_DEBUG, "PSTN instance destroyed\n");
|
||||
}
|
||||
|
||||
static void pstn_timeout(struct timer *timer);
|
||||
static void pstn_timeout(void *data);
|
||||
void recv_dtmf(void *priv, char digit, dtmf_meas_t __attribute__((unused)) *meas);
|
||||
|
||||
static void pstn_new_state(pstn_t *pstn, enum pstn_state state)
|
||||
|
@ -332,11 +332,6 @@ int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char
|
|||
pstn->ringing_type_hold = ringing_type_hold;
|
||||
pstn->tones_type = tones_type;
|
||||
|
||||
/* create ph socket */
|
||||
rc = ph_socket_init(&pstn->ph_socket, ph_socket_rx_msg, pstn, socketname, 0);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
/* init DTMF detector */
|
||||
rc = dtmf_decode_init(&pstn->dtmf_dec, pstn, recv_dtmf, 8000, db2level(6.0), db2level(-30.0));
|
||||
if (rc < 0)
|
||||
|
@ -365,6 +360,11 @@ int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char
|
|||
/* bring into service */
|
||||
pstn_new_state(pstn, PSTN_STATE_BLOCKED);
|
||||
|
||||
/* create ph socket here because we get a reply from the function call */
|
||||
rc = ph_socket_init(&pstn->ph_socket, ph_socket_rx_msg, pstn, socketname, 0);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -385,17 +385,6 @@ void rtp_receive(struct osmo_cc_session_codec *codec, uint8_t __attribute__((unu
|
|||
jitter_save(&pstn->tx_dejitter, data, len, 1, sequence, timestamp, ssrc);
|
||||
}
|
||||
|
||||
|
||||
void rtp_work(pstn_t *pstn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (pstn->call[i]->cc_session)
|
||||
osmo_cc_session_handle(pstn->call[i]->cc_session, pstn->call[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void dtmf_on(pstn_t *pstn)
|
||||
{
|
||||
if (pstn->dtmf_on)
|
||||
|
@ -1722,14 +1711,13 @@ static void v5_disc_req_and_cleanup(pstn_t *pstn)
|
|||
v5_send(pstn, PSTN_EVENT_DISC_REQ, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* timeout
|
||||
*/
|
||||
|
||||
static void pstn_timeout(struct timer *timer)
|
||||
static void pstn_timeout(void *data)
|
||||
{
|
||||
pstn_t *pstn = timer->priv;
|
||||
pstn_t *pstn = data;
|
||||
|
||||
switch (pstn->timer_ident) {
|
||||
case TIMER_IDENT_DIALING:
|
||||
|
@ -1781,12 +1769,3 @@ static void pstn_timeout(struct timer *timer)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* work
|
||||
*/
|
||||
|
||||
void pstn_work(pstn_t *pstn)
|
||||
{
|
||||
ph_socket_work(&pstn->ph_socket);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include "../libtimer/timer.h"
|
||||
#include "../libselect/select.h"
|
||||
#include "../libosmocc/endpoint.h"
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libjitter/jitter.h"
|
||||
|
@ -157,5 +158,4 @@ pstn_t *pstn_create(void);
|
|||
int pstn_init(pstn_t *pstn, const char *name, const char *socketname, const char **subscribers, int subscriber_num, uint8_t serving_location, int tx_delay, enum pstn_cid_method clip, int cid_bell, int cid_dtmf, int clip_date, int enblock, int recall, int *ringing_types_incoming, int ringing_type_hold, enum tones_type tones_type, char law);
|
||||
void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
|
||||
void rtp_work(pstn_t *pstn_ep);
|
||||
void pstn_work(pstn_t *pstn_ep);
|
||||
|
||||
|
|
Loading…
Reference in New Issue