2
* iaxclient_lib: An Inter-Asterisk eXchange communication library
5
* Purpose: Audio code to read/write to files
6
* based on audio_portaudio, originally Developed by: Shawn Lawrence, Terrace Communications Inc.
7
* Developed by: Steve Kann
8
* Creation Date: October 30, 2003
10
* This program is free software, distributed under the terms of
11
* the GNU Lesser (Library) General Public License
13
* IAX library Copyright (c) 2001 Linux Support Services
14
* IAXlib is free software, distributed under the terms of
15
* the GNU Lesser (Library) General Public License
17
* This library uses the PortAudio Portable Audio Library
18
* For more information see: http://www.portaudio.com
19
* PortAudio Copyright (c) 1999-2000 Ross Bencina and Phil Burk
23
#include "iaxclient_lib.h"
27
static FILE *inFile=NULL, *outFile=NULL;
29
#define FRAMES_PER_BUFFER 80 /* 80 frames == 10ms */
32
static int file_play_sound(struct iaxc_sound *inSound, int ring) {
36
static int file_stop_sound(int soundID) {
41
static int file_start (struct iaxc_audio_driver *d ) {
45
static int file_stop (struct iaxc_audio_driver *d ) {
50
static void file_shutdown_audio() {
55
static int file_input(struct iaxc_audio_driver *d, void *samples, int *nSamples) {
60
static int file_output(struct iaxc_audio_driver *d, void *samples, int nSamples) {
63
fwrite(samples, sizeof(SAMPLE), nSamples, outFile);
68
static int file_select_devices (struct iaxc_audio_driver *d, int input, int output, int ring) {
72
static int file_selected_devices (struct iaxc_audio_driver *d, int *input, int *output, int *ring) {
79
static int file_destroy (struct iaxc_audio_driver *d )
81
/* TODO: something should happen here */
85
static float file_input_level_get(struct iaxc_audio_driver *d){
89
static float file_output_level_get(struct iaxc_audio_driver *d){
93
static int file_input_level_set(struct iaxc_audio_driver *d, float level){
97
static int file_output_level_set(struct iaxc_audio_driver *d, float level){
101
EXPORT int iaxc_set_files(FILE *input, FILE *output) {
108
/* initialize audio driver */
109
int file_initialize (struct iaxc_audio_driver *d , int sample_rate) {
111
if(sample_rate != 8000 ) return -1;
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;
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;