| //#include "mbtk_audio2.h" |
| //#include "mbtk_audio_ubus.h" |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include "telutl.h" |
| #include "mbtk_at.h" |
| |
| #define AUD_DEMO_WAV "/user_data/demo.wav" |
| |
| typedef enum { |
| MBTK_AUDIO_SAMPLE_RATE_8000 = 0, |
| MBTK_AUDIO_SAMPLE_RATE_16000 |
| } mbtk_audio_sample_rate_enum; |
| |
| |
| int mbtk_at_loopback(int type) |
| { |
| LOG("mbtk_at_loopback() : type - %d", type); |
| if(0 == type) // Stop |
| { |
| if(MBTK_FUNC(mbtk_audio_loopback_stop)()) { |
| return -1; |
| } |
| |
| MBTK_FUNC(mbtk_audio_ubus_deinit)(); |
| } |
| else // Start |
| { |
| MBTK_FUNC(mbtk_audio_ubus_init)(); |
| |
| MBTK_FUNC(mbtk_audio_mode_set)(0); |
| MBTK_FUNC(mbtk_audio_loopback_start)(2); |
| } |
| |
| return 0; |
| } |
| |
| int mbtk_at_play(const char *args) |
| { |
| int ret = 0; |
| if(MBTK_FUNC(mbtk_audio_wav_init)()) { |
| LOG("mbtk_audio_wav_init() fail."); |
| return -1; |
| } |
| |
| if(MBTK_FUNC(mbtk_audio_wav_play_start)(AUD_DEMO_WAV)) { |
| LOG("mbtk_audio_wav_play_start() fail."); |
| ret = -1; |
| goto exit; |
| } |
| |
| sleep(5); |
| |
| exit: |
| if(MBTK_FUNC(mbtk_audio_wav_deinit)()) { |
| LOG("mbtk_audio_wav_deinit() fail."); |
| return -1; |
| } |
| |
| return ret; |
| } |
| |
| int mbtk_at_rec(const char *args) |
| { |
| int ret = 0; |
| if(MBTK_FUNC(mbtk_audio_wav_init)()) { |
| LOG("mbtk_audio_wav_init() fail."); |
| return -1; |
| } |
| |
| if(MBTK_FUNC(mbtk_audio_wav_recorder_start)(AUD_DEMO_WAV, MBTK_AUDIO_SAMPLE_RATE_8000)) { |
| LOG("mbtk_audio_wav_recorder_start() fail."); |
| ret = -1; |
| goto exit; |
| } |
| |
| sleep(5); |
| |
| exit: |
| if(MBTK_FUNC(mbtk_audio_wav_deinit)()) { |
| LOG("mbtk_audio_wav_deinit() fail."); |
| return -1; |
| } |
| |
| return 0; |
| } |