This source file includes following definitions.
- main
1
2 #include "libteletone_detect.h"
3
4 int main(int argc, char *argv[])
5 {
6 int fd, b;
7 short sln[512] = {0};
8 teletone_dtmf_detect_state_t dtmf_detect = {0};
9 char digit_str[128] = "";
10
11 if (argc < 2) {
12 fprintf(stderr, "Arg Error!\n");
13 exit(-1);
14 }
15
16 teletone_dtmf_detect_init (&dtmf_detect, 8000);
17
18 if ((fd = open(argv[1], O_RDONLY)) < 0) {
19 fprintf(stderr, "File Error! [%s]\n", strerror(errno));
20 exit(-1);
21 }
22
23 while((b = read(fd, sln, 320)) > 0) {
24 teletone_dtmf_detect(&dtmf_detect, sln, b / 2);
25 teletone_dtmf_get(&dtmf_detect, digit_str, sizeof(digit_str));
26 if (*digit_str) {
27 printf("digit: %s\n", digit_str);
28 }
29 }
30 close(fd);
31 return 0;
32 }
33