|
@@ -4,6 +4,10 @@
|
|
|
#include "manager/ConfigManager.h"
|
|
|
#include "core/utilities.h"
|
|
|
#include "service/BusinessConfig.h"
|
|
|
+
|
|
|
+#include "core/wavfile.h"
|
|
|
+#include "voip/audio_player.h"
|
|
|
+#include "zkaudio.h"
|
|
|
/*
|
|
|
*此文件由GUI工具生成
|
|
|
*文件功能:用于处理用户的逻辑相应代码
|
|
@@ -37,6 +41,123 @@
|
|
|
|
|
|
static base::MediaPlayer media_player;
|
|
|
|
|
|
+namespace {
|
|
|
+FILE* file = NULL;
|
|
|
+
|
|
|
+class RecordTest : public Thread {
|
|
|
+ public:
|
|
|
+ void recordAudio() {
|
|
|
+ file = wavfile_write_open("/mnt/usb1/record.wav");
|
|
|
+
|
|
|
+ //设置录音(输入)音量
|
|
|
+ zk_audio_input_set_volume_native(0, 0);
|
|
|
+ zk_audio_input_set_volume_native(1, zk_audio_input_volume_native_max());
|
|
|
+
|
|
|
+ if (0 != zk_audio_input_init(2, 8000)) {
|
|
|
+ LOGD("audio input init failed");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// //aec apc 初始化
|
|
|
+// init();
|
|
|
+
|
|
|
+ const int buf_len = zk_audio_input_get_channel_buffer_size();
|
|
|
+ uint8_t* buf[2];
|
|
|
+ buf[0] = (uint8_t*)malloc(buf_len);
|
|
|
+ buf[1] = (uint8_t*)malloc(buf_len);
|
|
|
+
|
|
|
+ time_t deadline = time(NULL) + 10;
|
|
|
+ while (time(NULL) < deadline) {
|
|
|
+ zk_audio_input_get_frame((uint8_t**)buf);
|
|
|
+
|
|
|
+ wavfile_write(file, ( short*) buf[1],
|
|
|
+ ZK_AUDIO_NUMBER_OF_SAMPLES_PER_FRAME);
|
|
|
+ }
|
|
|
+
|
|
|
+ free(buf[0]);
|
|
|
+ free(buf[1]);
|
|
|
+ zk_audio_input_deinit();
|
|
|
+ wavfile_write_close(file);
|
|
|
+
|
|
|
+ mRecordTestTextViewPtr->setText(LANGUAGEMANAGER->getValue("RecordPlay"));
|
|
|
+ playAudio();
|
|
|
+ }
|
|
|
+ void playAudio() {
|
|
|
+ zk_audio_output_set_volume_native(zk_audio_output_volume_native_max());
|
|
|
+
|
|
|
+ std::ifstream ifs("/mnt/usb1/record.wav",
|
|
|
+ std::ios::binary | std::ios::in);
|
|
|
+ if (!ifs.is_open()) {
|
|
|
+ LOGD("file not found");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ base::AudioParameter in;
|
|
|
+ in.number_of_channels = 1;
|
|
|
+ in.sample_rate = 8000;
|
|
|
+ in.sample_format = base::SAMPLE_FMT_S16;
|
|
|
+
|
|
|
+ base::AudioPlayer player(in);
|
|
|
+ uint8_t buffer[256];
|
|
|
+
|
|
|
+ player.Play();
|
|
|
+ while (!ifs.eof()) {
|
|
|
+ ifs.read((char*)buffer, int(sizeof(buffer)));
|
|
|
+ int n = ifs.gcount();
|
|
|
+ player.PutSamples(buffer, n);
|
|
|
+ }
|
|
|
+ ifs.close();
|
|
|
+ player.Stop();
|
|
|
+
|
|
|
+ mRecordTestTextViewPtr->setText(LANGUAGEMANAGER->getValue("RecordStop"));
|
|
|
+ mRecordTestButtonPtr->setSelected(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ void Record() {
|
|
|
+ if(!isRunning()) {
|
|
|
+ mRecordTestTextViewPtr->setText(LANGUAGEMANAGER->getValue("RecordStart"));
|
|
|
+ play_ = true;
|
|
|
+ this->run("recordTest");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void Play() {
|
|
|
+ if(!isRunning()) {
|
|
|
+ play_ = false;
|
|
|
+ this->run("recordTest");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual bool threadLoop() {
|
|
|
+ if(play_) {
|
|
|
+ recordAudio();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ playAudio ();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ private:
|
|
|
+ bool play_ = true;
|
|
|
+};
|
|
|
+static RecordTest recordTest;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+static bool panelCallKeysCheckbox = false;
|
|
|
+
|
|
|
+void setCheckbox(std::string check) {
|
|
|
+ if (check == "KEY<") {
|
|
|
+ if (panelCallKeysCheckbox) {
|
|
|
+ panelCallKeysCheckbox = false;
|
|
|
+ mPanelCallKeysCheckboxPtr->setChecked(false);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ panelCallKeysCheckbox = true;
|
|
|
+ mPanelCallKeysCheckboxPtr->setChecked(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 注册定时器
|
|
|
* 填充数组用于注册定时器
|
|
@@ -135,28 +256,48 @@ static bool onsipTestActivityTouchEvent(const MotionEvent &ev) {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-static bool onButtonClick_Button1(ZKButton *pButton) {
|
|
|
+static void onEditTextChanged_EditTextDestURI(const std::string &text) {
|
|
|
+ //LOGD(" onEditTextChanged_ EditTextDestURI %s !!!\n", text.c_str());
|
|
|
+ StoragePreferences::putString(SIP_REG_DOOR_ACCOUNT, text);
|
|
|
+}
|
|
|
+
|
|
|
+static bool onButtonClick_CallButton(ZKButton *pButton) {
|
|
|
+ LOGD(" ButtonClick CallButton !!!\n");
|
|
|
int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
|
|
|
std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
|
|
|
std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
|
|
|
std::string od_number_uri = URI(od_number, domain, port);
|
|
|
LOGD("od_number_uri: %s", od_number_uri.c_str());
|
|
|
GetTelephone()->MakeCall(od_number_uri);
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-static void onEditTextChanged_EditText1(const std::string &text) {
|
|
|
- //LOGD(" onEditTextChanged_ EditText1 %s !!!\n", text.c_str());
|
|
|
+static bool onButtonClick_sys_back(ZKButton *pButton) {
|
|
|
+ LOGD(" ButtonClick sys_back !!!\n");
|
|
|
+ // 切换回TCP模式
|
|
|
+ StoragePreferences::putString(STORE_SIGNAL_TYPE, "TCP");
|
|
|
+ return false;
|
|
|
}
|
|
|
-static void onEditTextChanged_EditTextDestURI(const std::string &text) {
|
|
|
- //LOGD(" onEditTextChanged_ EditTextDestURI %s !!!\n", text.c_str());
|
|
|
- StoragePreferences::putString(SIP_REG_DOOR_ACCOUNT, text);
|
|
|
+static void onCheckedChanged_Checkbox1(ZKCheckBox* pCheckBox, bool isChecked) {
|
|
|
+ LOGD(" Checkbox Checkbox1 checked %d", isChecked);
|
|
|
+}
|
|
|
+static void onCheckedChanged_HandleKeysCheckbox(ZKCheckBox* pCheckBox, bool isChecked) {
|
|
|
+ LOGD(" Checkbox HandleKeysCheckbox checked %d", isChecked);
|
|
|
}
|
|
|
|
|
|
-static bool onButtonClick_back(ZKButton *pButton) {
|
|
|
- LOGD(" ButtonClick back !!!\n");
|
|
|
- StoragePreferences::putString(STORE_SIGNAL_TYPE, "TCP");
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
+static bool onButtonClick_RecordTestButton(ZKButton *pButton) {
|
|
|
+ LOGD(" ButtonClick RecordTestButton !!!\n");
|
|
|
+
|
|
|
+ // 如果线程在运行,则不能重复运行
|
|
|
+ if(recordTest.isRunning()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(!pButton->isSelected()) {
|
|
|
+ pButton->setSelected(true);
|
|
|
+ }
|
|
|
+ recordTest.Record();
|
|
|
return false;
|
|
|
}
|
|
|
+static void onCheckedChanged_PanelCallKeysCheckbox(ZKCheckBox* pCheckBox, bool isChecked) {
|
|
|
+ LOGD(" Checkbox PanelCallKeysCheckbox checked %d", isChecked);
|
|
|
+}
|