liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /** |
| 2 | * \file dtmf_test.c |
| 3 | * \brief A Documented file. |
| 4 | * |
| 5 | * Detailed description |
| 6 | * \Author: js.wang <js.wang@mobiletek.cn> |
| 7 | * \Version: 1.0.0 |
| 8 | * \Date: 2022-03-31 |
| 9 | */ |
| 10 | |
| 11 | /******************************************************************************\ |
| 12 | * Include files |
| 13 | \******************************************************************************/ |
| 14 | #include <pthread.h> |
| 15 | #include <time.h> |
| 16 | #include <sys/ioctl.h> |
| 17 | #include <fcntl.h> |
| 18 | #include <unistd.h> |
| 19 | #include <sys/types.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <fcntl.h> |
| 22 | #include <string.h> |
| 23 | #include <stdio.h> |
| 24 | #include <signal.h> |
| 25 | #include <unistd.h> |
| 26 | #include <fcntl.h> |
| 27 | #include <errno.h> |
| 28 | #include <string.h> |
| 29 | #include <stdlib.h> |
| 30 | #include <poll.h> |
| 31 | #include <stdlib.h> |
| 32 | |
| 33 | #include <sys/ioctl.h> |
| 34 | #include <sys/types.h> |
| 35 | #include <sys/stat.h> |
| 36 | #include "mbtk_audio.h" |
| 37 | |
| 38 | void dtmf_cb(char dtmf) |
| 39 | { |
| 40 | printf("%s:%c\n", __FUNCTION__, dtmf); |
| 41 | } |
| 42 | |
| 43 | void audio_volume_cb(int volume) |
| 44 | { |
| 45 | printf("%s:%d\n", __FUNCTION__, volume); |
| 46 | } |
| 47 | |
| 48 | int main(int argc, char *argv[]) |
| 49 | { |
| 50 | char operator[10]; |
| 51 | int opt; |
| 52 | mbtk_audio_client_handle_type dtmf_handle; |
| 53 | |
| 54 | |
| 55 | while(1) |
| 56 | { |
| 57 | printf("=========audio main=========\n" |
| 58 | "\t0 exit\n" |
| 59 | "\t1 audio init\n" |
| 60 | "\t2 audio get volume\n" |
| 61 | "\t3 audio set volume\n" |
| 62 | "\t4 audio deinit\n" |
| 63 | "operator: >> "); |
| 64 | fgets(operator, sizeof(operator), stdin); |
| 65 | fflush(stdin); |
| 66 | opt = atoi(operator); |
| 67 | switch (opt) |
| 68 | { |
| 69 | case 0: |
| 70 | printf("main exit\n"); |
| 71 | return 0; |
| 72 | case 1: |
| 73 | mbtk_audio_ubus_client_init(&dtmf_handle, dtmf_cb); |
| 74 | break; |
| 75 | case 2: |
| 76 | mbtk_audio_ubus_volume_get(audio_volume_cb); |
| 77 | break; |
| 78 | case 3: |
| 79 | printf("please input volume (0~100): \n"); |
| 80 | fgets(operator, sizeof(operator), stdin); |
| 81 | fflush(stdin); |
| 82 | opt = atoi(operator); |
| 83 | mbtk_audio_ubus_volume_set(opt); |
| 84 | break; |
| 85 | case 4: |
| 86 | mbtk_audio_ubus_client_deinit(dtmf_handle); |
| 87 | break; |
| 88 | default: |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return 0; |
| 94 | } |