#include <stdlib.h> |
#include <openr2/r2chan.h> |
|
//auxiliary function |
void* |
mf_read_init(void* p1, int p2){ |
return malloc(256); |
} |
|
//auxiliary function |
int |
mf_detect_tone(void* p1, int16_t const* p2, int p3){ |
return 1; |
} |
|
//auxiliary function |
int |
mf_generate_tone(void* p1, int16_t* p2, int p3){ |
return 2; |
} |
|
//auxiliary function |
int |
mf_select_tone(void* p1, char p2){ |
return 3; |
} |
|
//auxiliary function |
int |
mf_want_generate(void* p1, int p2){ |
return 4; |
} |
|
//auxiliary function |
void |
mf_read_dispose(void* p1){} |
|
//auxiliary function |
void |
on_call_offered( |
openr2_chan_t* p1, |
char const* p2, |
char const* p3, |
openr2_calling_party_category_t p4){} |
|
//auxiliary function |
void |
on_call_accepted(openr2_chan_t* p1, openr2_call_mode_t p2){} |
|
//auxiliary function |
void |
on_call_disconnect(openr2_chan_t* p1, openr2_call_disconnect_cause_t p2){} |
|
//auxiliary function |
void |
on_call_read(openr2_chan_t* p1, unsigned char const* p2, int p3){} |
|
//auxiliary function |
void |
on_hardware_alarm(openr2_chan_t* p1, int p2){} |
|
//auxiliary function |
void |
on_protocol_error(openr2_chan_t* p1, openr2_protocol_error_t p2){} |
|
//auxiliary function |
void |
on_context_log( |
openr2_context_t* p1, |
openr2_log_level_t p2, |
char const* p3, |
va_list p4){} |
|
//auxiliary function |
int |
on_dnis_digit_received(openr2_chan_t* p1, char p2){ |
return 5; |
} |
|
//auxiliary function |
void |
on_ani_digit_received(openr2_chan_t* p1, char p2){} |
|
//auxiliary function |
int16_t |
alaw_to_linear(uint8_t p1){ |
return 6; |
} |
|
//auxiliary function |
uint8_t |
linear_to_alaw(int p1){ |
return 'A'; |
} |
|
int main(int argc, char *argv[]) |
{ |
openr2_mflib_interface_t mflib = { |
.mf_read_init = &mf_read_init, |
.mf_write_init = &mf_read_init, |
.mf_detect_tone = &mf_detect_tone, |
.mf_generate_tone = &mf_generate_tone, |
.mf_select_tone = &mf_select_tone, |
.mf_want_generate = &mf_want_generate, |
.mf_read_dispose = &mf_read_dispose, |
.mf_write_dispose = &mf_read_dispose}; |
openr2_event_interface_t callmgmt = { |
.on_call_init = &openr2_chan_enable_call_files, |
.on_call_offered = &on_call_offered, |
.on_call_accepted = &on_call_accepted, |
.on_call_answered = &openr2_chan_enable_call_files, |
.on_call_disconnect = &on_call_disconnect, |
.on_call_end = &openr2_chan_enable_call_files, |
.on_call_read = &on_call_read, |
.on_hardware_alarm = &on_hardware_alarm, |
.on_os_error = &on_hardware_alarm, |
.on_protocol_error = &on_protocol_error, |
.on_line_blocked = &openr2_chan_delete, |
.on_line_idle = &openr2_chan_delete, |
.on_context_log = &on_context_log, |
.on_dnis_digit_received = &on_dnis_digit_received, |
.on_ani_digit_received = &on_ani_digit_received, |
.on_billing_pulse_received = &openr2_chan_delete}; |
openr2_transcoder_interface_t transcoder = { |
.alaw_to_linear = &alaw_to_linear, |
.linear_to_alaw = &linear_to_alaw}; |
openr2_context_t* r2context = openr2_context_new( |
&mflib, |
&callmgmt, |
&transcoder, |
OR2_VAR_ARGENTINA, |
4, |
4); |
void* mf_write_handle = malloc(256); |
void* mf_read_handle = malloc(256); |
openr2_chan_t* r2chan = openr2_chan_new_from_fd( |
r2context, |
7, |
mf_write_handle, |
mf_read_handle); |
openr2_context_t* r2context_1 = openr2_chan_get_context(r2chan); |
void* mf_write_handle_1 = malloc(256); |
void* mf_read_handle_1 = malloc(256); |
openr2_chan_t* r2chan_1 = openr2_chan_new( |
r2context_1, |
8, |
mf_write_handle_1, |
mf_read_handle_1); |
void* dtmf_read_handle = malloc(256); |
void* dtmf_write_handle = malloc(256); |
openr2_chan_set_dtmf_handles(r2chan_1, dtmf_read_handle, dtmf_write_handle); //target call |
return 0; |
} |