From 2383e865ea7867fb24855ac2b2b66b98ae78b62b Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 29 Mar 2023 11:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0IXWEBSOCKET=E5=BA=93=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E6=9B=B4=E6=96=B0aiui=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E5=BA=93=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/c_cpp_properties.json | 2 +- .vscode/settings.json | 8 +++++++- CMakeLists.txt | 2 +- CMakeListsAARCH64.cmake | 5 +++-- dep/iflytopcpp | 2 +- dep/websocketpp | 2 +- dep/zlinuxcomponents | 2 +- project.config | 0 sh/envsetup.sh | 11 ++++++++++ sh/envsetuppc.sh | 15 ++++++++++++++ src/service/main_control_service.cpp | 28 ++++++++++++++++++++------ src/test/test_H8922S_gps_info_reader.cpp | 2 -- src/test/test_iflytop_voice.cpp | 1 - src/test/test_soundbox4mic_voice_processer.cpp | 1 - 14 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 project.config diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b690ade..ba6be6c 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -11,7 +11,7 @@ "cStandard": "gnu11", "cppStandard": "gnu++14", "intelliSenseMode": "linux-gcc-x64", - "compileCommands": "${workspaceFolder}/build/compile_commands.json" + "compileCommands": "${workspaceFolder}/buildpc/compile_commands.json" } ], "version": 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index d23fa4b..be27491 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -97,6 +97,12 @@ "scoped_allocator": "cpp", "netdb.h": "c", "aiui_cjson.h": "c", - "string.h": "c" + "string.h": "c", + "aiui_base64.h": "c", + "aiui_wsclient.h": "c", + "aiui_sha256.h": "c", + "socket.h": "c", + "unistd.h": "c", + "err.h": "c" } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 82eefd6..66b79af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,9 @@ set(CMAKE_BUILD_TYPE Debug) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/) include(zcmake/zcmake.cmake) project(app) +set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/) # 设置ccache加速C++编译速度 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) diff --git a/CMakeListsAARCH64.cmake b/CMakeListsAARCH64.cmake index e9636ea..8faed25 100644 --- a/CMakeListsAARCH64.cmake +++ b/CMakeListsAARCH64.cmake @@ -23,8 +23,9 @@ zadd_executable_simple(TARGET alsaplayer_main.out SRC dep/zlinuxcomponents/alsaplayer/test_alsaplayer_main.cpp) zadd_executable_simple(TARGET audio_recorder_main.out SRC dep/zlinuxcomponents/audio/audio_recorder_main.cpp) -zadd_executable_simple(TARGET test_asr_main.out SRC - dep/zlinuxcomponents/aiui_ws/aiui_main.c) +zadd_executable_simple(TARGET test_aiui_service.out SRC + dep/zlinuxcomponents/aiui_ws/test_aiui_service.cpp) + # 播放器单元测试 zadd_executable_simple( TARGET test_smart_soundbox_player.out SRC diff --git a/dep/iflytopcpp b/dep/iflytopcpp index dda7872..e416bea 160000 --- a/dep/iflytopcpp +++ b/dep/iflytopcpp @@ -1 +1 @@ -Subproject commit dda7872ae77dbead40a13c3b39497c021562ff1b +Subproject commit e416beae5d0b2bb83e6ea4850f927cd840be66ce diff --git a/dep/websocketpp b/dep/websocketpp index a61fab2..8005a5e 160000 --- a/dep/websocketpp +++ b/dep/websocketpp @@ -1 +1 @@ -Subproject commit a61fab296db75a7a78d48347355c48182ab15929 +Subproject commit 8005a5e9a785128ae984c8a12d201a1bbc557b22 diff --git a/dep/zlinuxcomponents b/dep/zlinuxcomponents index a7eed06..8085579 160000 --- a/dep/zlinuxcomponents +++ b/dep/zlinuxcomponents @@ -1 +1 @@ -Subproject commit a7eed06478b662b8c685aa290cdbd6617dc067ac +Subproject commit 8085579161497e78502e7b50ffe5639ea0bb9183 diff --git a/project.config b/project.config new file mode 100644 index 0000000..e69de29 diff --git a/sh/envsetup.sh b/sh/envsetup.sh index 4a3da39..24ed9ff 100755 --- a/sh/envsetup.sh +++ b/sh/envsetup.sh @@ -5,6 +5,7 @@ CONFIG_SUPPORT_ALSA=true CONFIG_SUPPORT_FFMPEG=true CONFIG_SUPPORT_IFLYTOP_VOICE_PROCESS=true +CONFIG_SUPPORT_IXWEBSOCKET=true # Code Begin mkdir -p ${LIBSDIR} @@ -61,5 +62,15 @@ if [ "$CONFIG_SUPPORT_IFLYTOP_VOICE_PROCESS" = true ]; then PUBLIC_LINK_LIBS="${PUBLIC_LINK_LIBS};iflytopvoice;NE10_static" fi +if [ "$CONFIG_SUPPORT_IXWEBSOCKET" = true ]; then + wget -c "http://iflytop.local:8021/zlibrelease/libixwebsocket/libixwebsocket_v11.4.3_aarch64_static_ubuntu18.04_0.tar.gz" + tar -xvf libixwebsocket_v11.4.3_aarch64_static_ubuntu18.04_0.tar.gz >/dev/null + rm -rf ${LIBSDIR}/libixwebsocket + mv libixwebsocket_v11.4.3_aarch64_static_ubuntu18.04_0 ${LIBSDIR}/libixwebsocket + PUBLIC_LINK_DIRECTORIES="${PUBLIC_LINK_DIRECTORIES};${LIBSDIR}/libixwebsocket/lib" + PUBLIC_INCLUDE_DIRECTORIES="${PUBLIC_INCLUDE_DIRECTORIES};${LIBSDIR}/libixwebsocket/include" + PUBLIC_LINK_LIBS="${PUBLIC_LINK_LIBS};ixwebsocket" +fi + CROSS_TOOLCHAIN_C_COMPILER=aarch64-linux-gnu-gcc CROSS_TOOLCHAIN_CXX_COMPILER=aarch64-linux-gnu-g++ diff --git a/sh/envsetuppc.sh b/sh/envsetuppc.sh index 2d350e2..dd09990 100755 --- a/sh/envsetuppc.sh +++ b/sh/envsetuppc.sh @@ -1,2 +1,17 @@ +CONFIG_SUPPORT_IXWEBSOCKET=true + +mkdir -p ${LIBSDIR} +cd ${LIBSDIR} + PUBLIC_LINK_LIBS="${PUBLIC_LINK_LIBS};asound" PUBLIC_LINK_LIBS="${PUBLIC_LINK_LIBS};avcodec;avdevice;avfilter;avformat;avutil;swresample;swscale" + +if [ "$CONFIG_SUPPORT_IXWEBSOCKET" = true ]; then + wget -c "http://iflytop.local:8021/zlibrelease/libixwebsocket/libixwebsocket_v11.4.3_amd64_static_ubuntu18.04_0.tar.gz" + tar -xvf libixwebsocket_v11.4.3_amd64_static_ubuntu18.04_0.tar.gz >/dev/null + rm -rf ${LIBSDIR}/libixwebsocket + mv libixwebsocket_v11.4.3_amd64_static_ubuntu18.04_0 ${LIBSDIR}/libixwebsocket + PUBLIC_LINK_DIRECTORIES="${PUBLIC_LINK_DIRECTORIES};${LIBSDIR}/libixwebsocket/lib" + PUBLIC_INCLUDE_DIRECTORIES="${PUBLIC_INCLUDE_DIRECTORIES};${LIBSDIR}/libixwebsocket/include" + PUBLIC_LINK_LIBS="${PUBLIC_LINK_LIBS};ixwebsocket" +fi diff --git a/src/service/main_control_service.cpp b/src/service/main_control_service.cpp index b13f01d..76a2be3 100644 --- a/src/service/main_control_service.cpp +++ b/src/service/main_control_service.cpp @@ -6,6 +6,15 @@ using namespace iflytop; using namespace core; using namespace std; +class Trace { + logger_t m_logger; + string m_name; + + public: + Trace(logger_t log, const string& name) : m_logger(log), m_name(name) { m_logger->info("TRACE::ENTER {}", m_name); } + ~Trace() { m_logger->info("TRACE::EXIT {}", m_name); } +}; + /*********************************************************************************************************************** * ======================================================宏定义======================================================= * ***********************************************************************************************************************/ @@ -78,10 +87,10 @@ void MainControlService::initializeVoiceProcess() { } }); - m_aiuiService->onMessage.connect([&](json& rxjson) { + m_aiuiService->onMessage.connect([&](const json& rxjson) { lock_guard lock(m_voiceprocessmutex); - - json msg = rxjson; + Trace trace(logger, "m_aiuiService->onMessage"); + json msg = rxjson; m_workQueue->enQueue([this, msg]() { try { processasrResult(msg); @@ -126,6 +135,7 @@ void MainControlService::processasrResult_tts(json& rxjson) { } void MainControlService::processasrResult(json rxjson) { + Trace trace(logger, "processasrResult"); lock_guard lock(m_voiceprocessmutex); string action = rxjson["action"]; @@ -168,8 +178,8 @@ void MainControlService::constructSession() { * 4. 构建新的session * 5. 启动定时器,如果10s内无人应答,则结束session */ - lock_guard lock(m_voiceprocessmutex); + Trace trace(logger, "constructSession"); /** * @brief * TODO: @@ -203,13 +213,19 @@ void MainControlService::constructSession() { void MainControlService::endSession() { lock_guard lock(m_voiceprocessmutex); - + Trace trace(logger, "endSession"); + logger->info("{}", __LINE__); if (m_conversationSession) { m_conversationSession = nullptr; - m_aiuiService->aiuiFinished(); + logger->info("{}", __LINE__); + int ret = m_aiuiService->aiuiFinished(); + logger->info("{} {}", __LINE__, ret); m_aiuiService->aiuiDestroy(); + logger->info("{}", __LINE__); } + logger->info("{}", __LINE__); m_audioLoggingService->endwakeup(); + logger->info("{}", __LINE__); } void MainControlService::initialize() { diff --git a/src/test/test_H8922S_gps_info_reader.cpp b/src/test/test_H8922S_gps_info_reader.cpp index c02997b..50dbe33 100644 --- a/src/test/test_H8922S_gps_info_reader.cpp +++ b/src/test/test_H8922S_gps_info_reader.cpp @@ -12,7 +12,6 @@ #include "service/device_io_service_mock.hpp" #include "service/light_control_service.hpp" #include "service/report_service.hpp" -#include "zlinuxcomponents/aiui_ws/aiui_service.hpp" // #include @@ -21,7 +20,6 @@ #include #include "service/H8922S_gps_Info_reader.hpp" -#include "zlinuxcomponents/aiui_ws/aiui.h" // using namespace iflytop; diff --git a/src/test/test_iflytop_voice.cpp b/src/test/test_iflytop_voice.cpp index cdffd2d..c505e22 100644 --- a/src/test/test_iflytop_voice.cpp +++ b/src/test/test_iflytop_voice.cpp @@ -19,7 +19,6 @@ // -#include "zlinuxcomponents/aiui_ws/aiui.h" // #include "audio_process_api.h" ZMAIN(); diff --git a/src/test/test_soundbox4mic_voice_processer.cpp b/src/test/test_soundbox4mic_voice_processer.cpp index dec8d08..28123a1 100644 --- a/src/test/test_soundbox4mic_voice_processer.cpp +++ b/src/test/test_soundbox4mic_voice_processer.cpp @@ -22,7 +22,6 @@ #include "iflytopvoicecpp/soundbox4mic_voice_pre_process.hpp" #include "service/H8922S_gps_Info_reader.hpp" -#include "zlinuxcomponents/aiui_ws/aiui.h" #include "zlinuxcomponents/audio/audio_recoder.hpp" //