| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "iaxclient_lib.h" |
| 24 |
|
| 25 |
typedef short SAMPLE; |
| 26 |
|
| 27 |
static FILE *inFile=NULL, *outFile=NULL; |
| 28 |
|
| 29 |
#define FRAMES_PER_BUFFER 80 |
| 30 |
|
| 31 |
|
| 32 |
static int file_play_sound(struct iaxc_sound *inSound, int ring) { |
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
static int file_stop_sound(int soundID) { |
| 37 |
return 0; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
static int file_start (struct iaxc_audio_driver *d ) { |
| 42 |
return 0; |
| 43 |
} |
| 44 |
|
| 45 |
static int file_stop (struct iaxc_audio_driver *d ) { |
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
static int file_input(struct iaxc_audio_driver *d, void *samples, int *nSamples) { |
| 56 |
*nSamples = 0; |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
static int file_output(struct iaxc_audio_driver *d, void *samples, int nSamples) { |
| 61 |
|
| 62 |
if(outFile) { |
| 63 |
fwrite(samples, sizeof(SAMPLE), nSamples, outFile); |
| 64 |
} |
| 65 |
return 0; |
| 66 |
} |
| 67 |
|
| 68 |
static int file_select_devices (struct iaxc_audio_driver *d, int input, int output, int ring) { |
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
static int file_selected_devices (struct iaxc_audio_driver *d, int *input, int *output, int *ring) { |
| 73 |
*input = 0; |
| 74 |
*output = 0; |
| 75 |
*ring = 0; |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
static int file_destroy (struct iaxc_audio_driver *d ) |
| 80 |
{ |
| 81 |
|
| 82 |
return 0; |
| 83 |
} |
| 84 |
|
| 85 |
static float file_input_level_get(struct iaxc_audio_driver *d){ |
| 86 |
return -1; |
| 87 |
} |
| 88 |
|
| 89 |
static float file_output_level_get(struct iaxc_audio_driver *d){ |
| 90 |
return -1; |
| 91 |
} |
| 92 |
|
| 93 |
static int file_input_level_set(struct iaxc_audio_driver *d, float level){ |
| 94 |
return -1; |
| 95 |
} |
| 96 |
|
| 97 |
static int file_output_level_set(struct iaxc_audio_driver *d, float level){ |
| 98 |
return -1; |
| 99 |
} |
| 100 |
|
| 101 |
EXPORT int iaxc_set_files(FILE *input, FILE *output) { |
| 102 |
inFile = input; |
| 103 |
outFile = output; |
| 104 |
return 0; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
int file_initialize (struct iaxc_audio_driver *d , int sample_rate) { |
| 110 |
|
| 111 |
if(sample_rate != 8000 ) return -1; |
| 112 |
|
| 113 |
|
| 114 |
d->initialize = file_initialize; |
| 115 |
d->destroy = file_destroy; |
| 116 |
d->select_devices = file_select_devices; |
| 117 |
d->selected_devices = file_selected_devices; |
| 118 |
d->start = file_start; |
| 119 |
d->stop = file_stop; |
| 120 |
d->output = file_output; |
| 121 |
d->input = file_input; |
| 122 |
d->input_level_get = file_input_level_get; |
| 123 |
d->input_level_set = file_input_level_set; |
| 124 |
d->output_level_get = file_output_level_get; |
| 125 |
d->output_level_set = file_output_level_set; |
| 126 |
d->play_sound = file_play_sound; |
| 127 |
d->stop_sound = file_stop_sound; |
| 128 |
|
| 129 |
return 0; |
| 130 |
} |