1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#include "../libtimer/timer.h"
#include "../libosmocc/endpoint.h"
#include "../libosmocc/helper.h"
#include "../libsample/sample.h"
#include "../libjitter/jitter.h"
#include "../libwave/wave.h"
#include "../libdtmf/dtmf_decode.h"
enum call_state {
CALL_STATE_IDLE = 0,
CALL_STATE_SETUP,
CALL_STATE_OVERLAP,
CALL_STATE_PROCEEDING,
CALL_STATE_ALERTING,
CALL_STATE_CONNECT,
CALL_STATE_DISC_FROM_ORIG,
CALL_STATE_DISC_FROM_TERM,
};
#include "routing.h"
#define MAX_CODECS 8
/* relation to upper layer */
typedef struct call_relation {
struct call_relation *next;
int num; /* number counter for debugging */
struct call *call; /* points to the call */
uint32_t cc_callref; /* callref for each relation */
const char *sdp; /* received SDP? */
int tones_recv; /* are inband tones available? */
jitter_t orig_dejitter; /* jitter buffer for call recording (originating source) */
jitter_t term_dejitter; /* jitter buffer for call recording (terminating source) */
char interface[256]; /* interface */
char id[256]; /* caller ID / dialing*/
enum call_state state; /* state for status display */
int rtp_proxy;
osmo_cc_session_t *cc_session;
int codec_negotiated;
struct osmo_cc_helper_audio_codecs orig_codecs[MAX_CODECS + 1]; /* codecs for originator */
struct osmo_cc_helper_audio_codecs term_codecs[MAX_CODECS + 1]; /* codecs for terminator, stored at relation of originator */
osmo_cc_session_codec_t *codec;
wave_play_t play; /* play a wave file */
int play_loop; /* set to play loop */
char play_filename[256];/* stored for reopen on loop */
double play_deviation; /* stored for reopen on loop */
wave_rec_t rec; /* record a wave file */
dtmf_dec_t dtmf_dec; /* dtmf decoder */
int dtmf_dec_enable;/* feed decoder with data */
int te_started; /* we got a digit via telephone-event */
} call_relation_t;
/* call instance */
typedef struct call {
struct call *next;
int num; /* number counter for debugging */
/* call */
enum call_state state; /* current state of call */
osmo_cc_msg_t *setup_msg; /* stored setup message for later IE forwarding */
char dialing_number[256]; /* accumulated dial string (setup + info) */
char dialing_keypad[256]; /* accumulated keypad string (setup + info) */
int forking; /* set, if call is forked (started with 2 or more calls) */
uint8_t collect_cause; /* cause from forking calls */
call_relation_t *relation_list; /* list of all upper layer relations */
/* NOTE: the first relation is always the originator */
int tones_sent; /* did we announce inband tones? */
int sdp_forwarded; /* if set, we cannot do RTP-Proxy anymore */
/* routing */
routing_t routing;
/* audio */
double tx_gain; /* gain of what is received from originator */
double rx_gain; /* gain of what is transmitted to the originator */
} call_t;
extern call_t *call_list;
struct telephone_event {
uint8_t event;
uint8_t e, r;
uint8_t volume;
uint16_t duration;
};
int call_init(osmo_cc_endpoint_t *ep, const char *_routing_script, const char *_routing_shell);
void call_exit(void);
int call_handle(void);
void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
void telephone_event(call_relation_t *relation, struct telephone_event *te);
|