Debian Codegraph @

3rdparty/iaxclient/lib/audio_file.c

raw symbols SCIP
1 /*
2 * iaxclient_lib: An Inter-Asterisk eXchange communication library
3 *
4 * Module: audio_file
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
9 *
10 * This program is free software, distributed under the terms of
11 * the GNU Lesser (Library) General Public License
12 *
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
16 *
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
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 /* 80 frames == 10ms */
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 /* not used
50 static void file_shutdown_audio() {
51 return;
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 /* TODO: something should happen here */
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 /* initialize audio driver */
109 int file_initialize (struct iaxc_audio_driver *d , int sample_rate) {
110
111 if(sample_rate != 8000 ) return -1;
112
113 /* setup methods */
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 }