diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eed8a53..ea63c55d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,140 +1,146 @@ -# Changelog +### Changelog -All notable changes to this project will be documented in this file. +All notable changes to this project will be documented in this file. Dates are displayed in UTC. -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. + -* In the future, generate this file by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.6](https://github.com/rdkcentral/control/compare/1.1.5...1.1.6) -## [1.1.4] - 2025-09-17 +> 19 November 2025 -### Changed -- move certselector logic into ctrlm-main repo (#102) -- use version/branch from recipe (#109) +- RDKEMW-9124 : remove xr-voice-sdk build flags - XRAUDIO_CURTAIL XLOG_CURTAIL [`#132`](https://github.com/rdkcentral/control/pull/132) +- RDKEMW-8676 : remove ctrlm build flags - MIC_TAP, LOCAL_MIC, LOCAL_MIC_DISABLE_VIA_PRIVACY [`#120`](https://github.com/rdkcentral/control/pull/120) +- RDKEMW-8664 : remove ctrlm build flags - MEM_DEBUG, ASSERT_ON_WRONG_THREAD [`#118`](https://github.com/rdkcentral/control/pull/118) +- RDKEMW-8297 : remove ctrlm build flags - A5000_ENABLE [`#117`](https://github.com/rdkcentral/control/pull/117) +- RDKEMW-8668 : modify ctrlm build flag - BREAKPAD [`#119`](https://github.com/rdkcentral/control/pull/119) +- RDKEMW-8296 : remove ctrlm build flags - DEEPSLEEP_CLOSE_DB [`#112`](https://github.com/rdkcentral/control/pull/112) +- RDKEMW-8295 : remove ctrlm build flags - MEMORY_LOCK [`#111`](https://github.com/rdkcentral/control/pull/111) +- RDKEMW-7905 : remove ctrlm build flags - ANSI_CODES_DISABLED [`#110`](https://github.com/rdkcentral/control/pull/110) +- Revert "RDKEMW-8929 (#129)" [`#145`](https://github.com/rdkcentral/control/pull/145) +- RDKEMW-10311 : RF4CE update key mapping [`#140`](https://github.com/rdkcentral/control/pull/140) +- RDKEMW-10164: update CHANGELOG for release v1.1.5 [`#139`](https://github.com/rdkcentral/control/pull/139) -### Added -- update AMC APP key mapping (#98) +#### [1.1.5](https://github.com/rdkcentral/control/compare/1.1.4...1.1.5) -### Fixed -- getNetStatus call time out due to SAT download retries (#97) -- remove device from bluez during factory reset (#100) -- Missing Thunder cflags in ctrlm implemenation (#103) +> 5 November 2025 -### Removed -- remove ctrlm compile flags (#104) -- remove ctrlm build flags - CPC, DUNFELL (#105) -- remove ctrlm build flags - RF4CE_PACKET_ANALYSIS (#107) -- remove ctrlm build flags - DISABLE_BLE_VOICE (#106) +- RDKEMW-9924 : ctrlm RF4CE upgrade skipped when BLE enabled [`#137`](https://github.com/rdkcentral/control/pull/137) +- RDKEMW-7225: BLE pairing retries [`#126`](https://github.com/rdkcentral/control/pull/126) +- RDKEMW-8929: Refactor ctrlm_voice_ipc_t to inherit ctrlm_ipc_iarm_t [`#129`](https://github.com/rdkcentral/control/pull/129) +- Update CODEOWNERS [`#130`](https://github.com/rdkcentral/control/pull/130) +- RDKEMW-8815: only return SUCCESS for autolookup if it found at least 1 code. [`#125`](https://github.com/rdkcentral/control/pull/125) +- Deploy fossid_integration_stateless_diffscan_target_repo action [`#121`](https://github.com/rdkcentral/control/pull/121) +- Deploy cla action [`#74`](https://github.com/rdkcentral/control/pull/74) +- RDKEMW-8354: ctrlm-main crash while holding standby during OTA [`#115`](https://github.com/rdkcentral/control/pull/115) +- RDKEMW-8133: Optional param name for voiceSessionRequest [`#108`](https://github.com/rdkcentral/control/pull/108) -## [1.1.3] - 2025-08-19 +#### [1.1.4](https://github.com/rdkcentral/control/compare/1.1.3...1.1.4) -### Changed -- Modify Remote Control plugin for RF4CE support (#80) -- Mac address fetch (#92) +> 18 September 2025 -### Added -- Runtime detection of ASB (#96) +- RDKEMW-8349 : ctrlm release v1.1.4 [`#113`](https://github.com/rdkcentral/control/pull/113) +- RDKEMW-7979 : use version/branch from recipe [`#109`](https://github.com/rdkcentral/control/pull/109) +- RDKEMW-7122 : Missing Thunder cflags in ctrlm implementation [`#103`](https://github.com/rdkcentral/control/pull/103) +- RDKEMW-7772 : remove ctrlm build flags - DISABLE_BLE_VOICE [`#106`](https://github.com/rdkcentral/control/pull/106) +- RDKEMW-7834 : remove ctrlm build flags - RF4CE_PACKET_ANALYSIS [`#107`](https://github.com/rdkcentral/control/pull/107) +- RDKEMW-7694 : remove ctrlm build flags - CPC, DUNFELL [`#105`](https://github.com/rdkcentral/control/pull/105) +- RDKEMW-7573 : remove ctrlm compile flags [`#104`](https://github.com/rdkcentral/control/pull/104) +- RDKEMW-7333: remove device from bluez during factory reset [`#100`](https://github.com/rdkcentral/control/pull/100) +- RDKEMW-6767: getNetStatus call time out due to SAT download retries [`#97`](https://github.com/rdkcentral/control/pull/97) +- RDKEMW-3409 : move certselector logic into ctrlm-main repo [`#102`](https://github.com/rdkcentral/control/pull/102) +- RDKEMW-7174 : update AMC APP key mapping [`#98`](https://github.com/rdkcentral/control/pull/98) -## [1.1.2] - 2025-08-04 +#### [1.1.3](https://github.com/rdkcentral/control/compare/1.1.2...1.1.3) -### Changed -- use HdmiCecSource instead of deprecated HdmiCec (#93) -- update key code mapping (#91) -- stop BLE audio stream on the RCU when server ends session early (#76) +> 19 August 2025 -### Added -- BLE network discovery (#94) -- try to load VL provided IRDB, upon failure fallback to existing IRDB in MW (#79) -- print raw EDID data at debug log level +- RDKEMW-7232: update CHANGELOG for controlMgr release v1.1.3 [`#99`](https://github.com/rdkcentral/control/pull/99) +- RDKEMW-5576: ctrlm mac address fetch [`#92`](https://github.com/rdkcentral/control/pull/92) +- RDKEMW-4309 : Modify Remote Control plugin for RF4CE support [`#80`](https://github.com/rdkcentral/control/pull/80) +- RDKEMW-5604 : runtime detection of ASB [`#96`](https://github.com/rdkcentral/control/pull/96) -### Fixed -- Voice not initiated due to voice key not initialized to default value - -### Removed -- remove receiver ID, its no longer used (#85) -- Remove RF4CE HAL from the middleware layer (#75) +#### [1.1.2](https://github.com/rdkcentral/control/compare/1.1.1...1.1.2) - +> 18 August 2025 -## [1.1.1] - 2025-06-25 +- RDKEMW-6034: update CHANGELOG for controlMgr release v1.1.2 [`#95`](https://github.com/rdkcentral/control/pull/95) +- RDKEMW-6538: use HdmiCecSource instead of deprecated HdmiCec [`#93`](https://github.com/rdkcentral/control/pull/93) +- RDKEMW-6383 : update key code mapping [`#91`](https://github.com/rdkcentral/control/pull/91) +- RDKEMW-3797 : BLE network discovery [`#94`](https://github.com/rdkcentral/control/pull/94) +- RDKEMW-6195: try to load VL provided IRDB, upon failure fallback to existing IRDB in MW [`#79`](https://github.com/rdkcentral/control/pull/79) +- RDKEMW-5714: Voice not initiated in ctrlm-main [`#81`](https://github.com/rdkcentral/control/pull/81) +- RDKEMW-6884: Logs indicate missing receiver ID [`#85`](https://github.com/rdkcentral/control/pull/85) +- RDKEMW-5413 : Remove RF4CE HAL from the middleware layer [`#75`](https://github.com/rdkcentral/control/pull/75) +- RDKEMW-5506 : stop BLE audio stream on the RCU when server ends session early [`#76`](https://github.com/rdkcentral/control/pull/76) +- RDKEMW-3965: print raw EDID data at debug log level [`447ae08`](https://github.com/rdkcentral/control/commit/447ae0826d15351fa97ccb12b3b18f435ff40089) -### Changed -- Use the deprecated HDMI Input plugin instead of the new AV Input plugin if compile flag is set +#### [1.1.1](https://github.com/rdkcentral/control/compare/1.1.0...1.1.1) -### Fixed -- BLE audio pipe size too small, set minimum size -- enable RF4CE Advanced Secure Binding (ASB) +> 30 June 2025 -### Added -- receive RF4CE IR binding key codes over IR input device -- use new Power Manager Thunder Plugin for power state events, switch to deprecated IARM interface with compile flag - +- RDKEMW-4913: ctrlm release v1.1.1 [`#77`](https://github.com/rdkcentral/control/pull/77) +- RDKEMW-4788: use HDMI Input plugin RDKV and AVInput RDKE [`#67`](https://github.com/rdkcentral/control/pull/67) +- RDKEMW-5247 : BLE audio pipe size too small [`#68`](https://github.com/rdkcentral/control/pull/68) +- RDKEMW-3411 : receive RF4CE IR binding key codes over IR input device [`#69`](https://github.com/rdkcentral/control/pull/69) +- RDKEMW-3563: Enable ASB [`#63`](https://github.com/rdkcentral/control/pull/63) +- RDKEMW-3119: Control Manager to use Power Manager Thunder Plugin [`07c1d22`](https://github.com/rdkcentral/control/commit/07c1d222b5d99849713a4db8dcef3bd847380f4b) -## [1.1.0] - 2025-05-30 +#### [1.1.0](https://github.com/rdkcentral/control/compare/1.0.10...1.1.0) -### Changed -- move thunder and IARM dependencies from irdb to ctrlm -- load irdb library as a plugin with dlopen -- use AVInput instead of HDMI Input thunder plugin for HDMI Infoframes +> 30 June 2025 -### Added -- new interface to ctrlm IRDB -- Default BLE controller type list -- RF4CE network discovery at runtime instead of compile time +- RDKEMW-4793: ctrlm release v1.1.0 [`#61`](https://github.com/rdkcentral/control/pull/61) +- RDKEMW-3408: [ctrlm] refactor interface to ctrlm IR Database for Vendor layer integration [`#18`](https://github.com/rdkcentral/control/pull/18) +- RDKEMW-3798 : RF4CE network discovery [`#53`](https://github.com/rdkcentral/control/pull/53) +- RDKEMW-3410 : Default BLE controller type list [`#29`](https://github.com/rdkcentral/control/pull/29) +- RDKEMW-4381: ctrlm crash during OTA interrupted by unpair or reset [`#54`](https://github.com/rdkcentral/control/pull/54) -### Fixed -- crash during OTA interrupted by unpair or reset +#### [1.0.10](https://github.com/rdkcentral/control/compare/1.0.9...1.0.10) +> 4 June 2025 -## [1.0.10] - 2025-05-16 +- RDKEMW-4424: update CHANGELOG for release 1.0.10 [`#55`](https://github.com/rdkcentral/control/pull/55) +- RDKEMW-3916: ctrlm crash from main queue msgs getting to networks prior to initialization [`#38`](https://github.com/rdkcentral/control/pull/38) +- RDKEMW-4146: ctrlm support both old and new deviceType [`#48`](https://github.com/rdkcentral/control/pull/48) +- RDKEMW-3918 : Control manager crashes on rapid MIC button presses [`#42`](https://github.com/rdkcentral/control/pull/42) +- RDK-56578 : Changed deviceType from tv to IpTv. [`#34`](https://github.com/rdkcentral/control/pull/34) +- RDKEMW-3609 : extend adpcm frame info [`#28`](https://github.com/rdkcentral/control/pull/28) +- RDKEMW-3916: IARM calls registered too early [`ae82b1e`](https://github.com/rdkcentral/control/commit/ae82b1e66f70d6f621eb3c680b7bf870379bd84c) +- RDKEMW-3835 - [Logging] Add Invalid firmware version OTA error code (0x8) mapping in ctrlmgr logs [`80e4d59`](https://github.com/rdkcentral/control/commit/80e4d59e841f3e9744fc6d3dd92b8bccec26c3ea) -### Changed -- ctrlm crash from main queue msgs getting to networks prior to initialization -- ctrlm support both old and new deviceType -- Control manager crashes on rapid MIC button presses -- [Logging] Add Invalid firmware version OTA error code (0x8) mapping in ctrlmgr logs -- Changed deviceType from tv to IpTv. -- Extend adpcm frame info. +#### [1.0.9](https://github.com/rdkcentral/control/compare/1.0.8...1.0.9) +> 7 May 2025 -## [1.0.9] - 2025-04-28 +- update CHANGELOG for controlMgr release 1.0.9 [`#35`](https://github.com/rdkcentral/control/pull/35) +- RDKEMW-3737:Upgrading the halif-headers as iarmmgr [`#30`](https://github.com/rdkcentral/control/pull/30) +- RDKEMW-3564 : Audio samples is always reported as 0 for FFV sessions [`2920c1a`](https://github.com/rdkcentral/control/commit/2920c1a455d1e1afe1d095c0b09fd841a305974d) +- RDKEMW-3605: Remove 'volatile' type qualifier of "binding_in_progress" [`a7d2310`](https://github.com/rdkcentral/control/commit/a7d23104a3b961a26621a1c688ba775c3fe2ad3f) -### Changed -- Audio samples is always reported as 0 for FFV sessions -- Remove 'volatile' type qualifier of "binding_in_progress" -- Upgrading the halif-headers as iarmmgr +#### [1.0.8](https://github.com/rdkcentral/control/compare/1.0.7...1.0.8) +> 28 April 2025 -## [1.0.8] - 2025-04-15 +- update CHANGELOG for controlMgr release 1.0.8 [`#25`](https://github.com/rdkcentral/control/pull/25) +- RDKEMW-3276: common udev node and provide list of possible names for IR input device discovery [`#20`](https://github.com/rdkcentral/control/pull/20) -### Changed -- use list of all possible names for IR input device discovery instead of product specific config +#### [1.0.7](https://github.com/rdkcentral/control/compare/1.0.6...1.0.7) +> 10 April 2025 -## [1.0.7] - 2025-03-31 - -### Changed +- XCTRL-400: add irdb stub implementation if ctrlm-hal-irdb lib does not exist [`#17`](https://github.com/rdkcentral/control/pull/17) +- Merge pull request #14 from rdkcentral/feature/XCTRL-400_rdkv_code_sy… [`#16`](https://github.com/rdkcentral/control/pull/16) +- XCTRL-400: RDKE Release 2025-03-31 (ctrlm v1.0.7) [`#14`](https://github.com/rdkcentral/control/pull/14) - Rationalize Voice Logging - move auth from ctrlm-cpc to ctrlm-main - Add ctrlm HAL certificate interace - Remove irMgr dependencies in controlMgr - create HAL interface for platform specific IRDBs - -### Added - BLE audio stream end time telemetry - voice stream telemetry in single line/event - -### Fixed - Type-Z OTA bug - Remote type changed to type-Z early - controlMgr maintenance time crash at onInitializedTimer @@ -145,28 +151,35 @@ All notable changes to this project will be documented in this file. - Logline error event rcu firmware status -## [1.0.6] - 2025-03-18 +#### [1.0.6](https://github.com/rdkcentral/control/compare/1.0.5...1.0.6) + +> 18 March 2025 -### Added +- RDKEMW-1397: IR input device name move to config file [`#1`](https://github.com/rdkcentral/control/pull/1) +- RDKEMW-1783: controlMgr crash at onInitializedTimer when going to dee… [`#11`](https://github.com/rdkcentral/control/pull/11) - custom target to build ctrlm config file only - additional config override file that can be provided by vendor layer +#### [1.0.5](https://github.com/rdkcentral/control/compare/1.0.4...1.0.5) -## [1.0.5] - 2025-02-24 +> 25 February 2025 -### Changed -- crash at onInitializedTimer when going to deepsleep +- RDKEMW-1783: controlMgr crash at onInitializedTimer when going to deepsleep [`#10`](https://github.com/rdkcentral/control/pull/10) +#### [1.0.4](https://github.com/rdkcentral/control/compare/1.0.3...1.0.4) -## [1.0.4] - 2025-02-20 +> 25 February 2025 -### Changed -- removed references to deprecated irMgr component +- RDKEMW-1890: Remove irMgr dependencies in controlMgr [`#6`](https://github.com/rdkcentral/control/pull/6) -## [1.0.3] - 2025-02-07 +#### 1.0.3 -### Changed +> 13 February 2025 + +- XCTRL-379: CTRLM RDKE Release 2025-02-07 [`#4`](https://github.com/rdkcentral/control/pull/4) +- XCTRL-379: CTRLM RDKE Release 2025-02-07 [`#3`](https://github.com/rdkcentral/control/pull/3) +- Import of source (develop) [`83e2f7b`](https://github.com/rdkcentral/control/commit/83e2f7bd1f5a179b47e0278f49e17466f4b1c457) - check that a file descriptor is valid before FD_SET() - standardize use of singleton pattern ctrlm - speed up BLE auto pairing and surface failures immediately @@ -176,16 +189,13 @@ All notable changes to this project will be documented in this file. - remove legacy url_vrex config field - Add ctrlm Support for XRA BLE key - QAM - ControlMgr crash pairWithMacHash when going to deepsleep - -### Added - RemoteControl plugin methods to pair and unpair targetted RCU devices based on MAC - RemoteControl plugin methods to trigger RCU firmware upgrade and report status of upgrade - ctrlm-factory added to this repo, its no longer a separate repo +#### 1.0.2 -## [1.0.2] - 2024-12-06 - -### Changed +> 6 December 2024 - ctrlm IR uinput device match exact name, simplify IR-initiated BLE pairing event handling - Check for Invalid avDevType - move stop audio stream to separate non iarm related function @@ -194,7 +204,5 @@ All notable changes to this project will be documented in this file. - Detect the platform type (TV vs STB) using DeviceInfo plugin - IR keypresses use same PII mask variable as Voice - fix "last wakeup key code" not received, along with defering gdbus proxy calls for characteristics until they are needed. - -### Added - unit test function to set IR protocol support characteristic on RCU - Added Alexa voice service support in SDT endpoint, along with async voice message support diff --git a/CMakeLists.txt b/CMakeLists.txt index 61dbb8e0..655f17d2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,32 +34,21 @@ set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) project(ctrlm-main VERSION ${CMAKE_PROJECT_VERSION}) # OPTIONS -option(A5000_ENABLE "ES1 A5000 use libse051" OFF) -option(ANSI_CODES_DISABLED "Disable ANSI code logging" OFF) -option(ASSERT_ON_WRONG_THREAD "Assert on wrong thread" OFF) option(AUTH_ENABLED "Enable AUTH" OFF) option(BLE_ENABLED "Enable BLE" ON) option(BLE_SERVICES "Enable BLE Services" OFF) option(BREAKPAD "Enable BREAKPAD" OFF) option(BUILD_CTRLM_FACTORY "Build Control Factory Test" OFF) -option(DEEPSLEEP_CLOSE_DB "Deep Sleep Close DB" OFF) -option(ENABLE_NETWORKED_STANDBY_MODE "Enable Networked Standby Mode)" OFF) option(FACTORY_AUDIO_PLAYBACK "Factory test audio playback" OFF) option(FACTORY_CUSTOM_AUDIO_ANALYSIS "Factory custom audio analysis" OFF) option(FDC_ENABLED "Enable FDC" OFF) option(IP_ENABLED "Enable IP" OFF) -option(LOCAL_MIC "Local Microphone" OFF) -option(LOCAL_MIC_DISABLE_VIA_PRIVACY "Use Privacy to disable microphone" OFF) -option(MEM_DEBUG "Enable memory debugging" OFF) -option(MEMORY_LOCK "Memory Lock" OFF) -option(MIC_TAP "Enable MIC_TAP" OFF) option(RF4CE_ENABLED "Enable RF4CE" ON) option(TELEMETRY_SUPPORT "Enable TELEMETRY_SUPPORT" OFF) option(THUNDER "Enable THUNDER" ON) option(THUNDER_SECURITY "Enable THUNDER_SECURITY" OFF) option(USE_SAFEC "Use safec" OFF) option(USE_IARM_POWER_MANAGER "Use IARM Power Manager" OFF) -option(VOICE_KEYWORD_BEEP "Enable VOICE_KEYWORD_BEEP" OFF) option(XRSR_HTTP "Enable XRSR_HTTP" OFF) option(XRSR_SDT "Enable XRSR_SDT" OFF) option(ENABLE_ASYNC_SRVR_MSG "Enable Asynchronous Server Messaging Feature" OFF) @@ -181,19 +170,10 @@ install(TARGETS controlMgr RUNTIME DESTINATION bin) install(FILES ${CMAKE_BINARY_DIR}/ctrlm_config.json.template DESTINATION ${CMAKE_INSTALL_SYSCONFDIR} COMPONENT config ) # DEFINES FROM OPTIONS -if(A5000_ENABLE) - find_library( SE_HAL_PATH SE_HAL ${CMAKE_SYSROOT}/usr/lib/se051) - target_link_libraries(controlMgr ${SE_HAL_PATH}) -endif() - if(ANSI_CODES_DISABLED) add_compile_definitions(ANSI_CODES_DISABLED) endif() -if(ASSERT_ON_WRONG_THREAD) - add_compile_definitions(ASSERT_ON_WRONG_THREAD) -endif() - if(BLE_ENABLED) target_link_libraries(controlMgr BTMgr) if(BLE_SERVICES) @@ -207,10 +187,6 @@ if(BREAKPAD) add_compile_definitions(BREAKPAD_SUPPORT) endif() -if(DEEPSLEEP_CLOSE_DB) - add_compile_definitions(DEEPSLEEP_CLOSE_DB) -endif() - if(ENABLE_ASYNC_SRVR_MSG) add_compile_definitions(SUPPORT_ASYNC_SRVR_MSG) endif() @@ -219,10 +195,6 @@ if(ENABLE_AVS_WITH_SDT) add_compile_definitions(SUPPORT_VOICE_DEST_ALSA SUPPORT_ASYNC_SRVR_MSG) endif() -if(ENABLE_NETWORKED_STANDBY_MODE) - add_compile_definitions(NETWORKED_STANDBY_MODE_ENABLED) -endif() - if(FDC_ENABLED) add_compile_definitions(FDC_ENABLED) endif() @@ -231,25 +203,6 @@ if(IP_ENABLED) add_compile_definitions(CTRLM_NETWORK_IP CTRLM_IP_HAL_LOG_ENABLED) endif() -if(LOCAL_MIC) - add_compile_definitions(CTRLM_LOCAL_MIC) - if(MIC_TAP) - add_compile_definitions(CTRLM_LOCAL_MIC_TAP) - endif() - if(LOCAL_MIC_DISABLE_VIA_PRIVACY) - add_compile_definitions(CTRLM_LOCAL_MIC_DISABLE_VIA_PRIVACY) - endif() -endif() - -if(MEM_DEBUG) - add_compile_definitions(MEM_DEBUG) -endif() - -if(MEMORY_LOCK) - add_compile_definitions(MEMORY_LOCK) - target_link_libraries(controLMgr clnl) -endif() - # RF4CE options if(RF4CE_ENABLED) # All RF4CE platforms have HAL NVM @@ -303,12 +256,6 @@ else() add_compile_definitions(SAFEC_DUMMY_API) endif() -if(VOICE_KEYWORD_BEEP) - add_compile_definitions(BEEP_ON_KWD_ENABLED) - add_definitions(-DBEEP_ON_KWD_FILE=\"${CMAKE_DATADIR}/${BEEP_ON_KWD_FILE}\") - install(FILES ${CMAKE_SOURCE_DIR}/../${BEEP_ON_KWD_FILE} DESTINATION share ) -endif() - if(USE_DEPRECATED_HDMI_INPUT_PLUGIN) add_compile_definitions(USE_DEPRECATED_HDMI_INPUT_PLUGIN) endif() diff --git a/src/auth/ctrlm_auth_certificate.cpp b/src/auth/ctrlm_auth_certificate.cpp index 63ff900c..63ae514e 100644 --- a/src/auth/ctrlm_auth_certificate.cpp +++ b/src/auth/ctrlm_auth_certificate.cpp @@ -42,7 +42,7 @@ ctrlm_auth_certificate_t::ctrlm_auth_certificate_t() { char *cert_path = NULL; char *cert_password = NULL; - rdkcertselector_h cert_selector = rdkcertselector_new( NULL, NULL, "MTLS" ); + rdkcertselector_h cert_selector = rdkcertselector_new( NULL, NULL, "FBK_MTLS" ); if(cert_selector == NULL){ XLOGD_TELEMETRY("cert selector init failed"); diff --git a/src/ble/ctrlm_ble_network.cpp b/src/ble/ctrlm_ble_network.cpp index dca4c78f..1e141823 100644 --- a/src/ble/ctrlm_ble_network.cpp +++ b/src/ble/ctrlm_ble_network.cpp @@ -525,7 +525,6 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si // only support ADPCM from ble-rcu component ctrlm_hal_ble_VoiceEncoding_t encoding = CTRLM_HAL_BLE_ENCODING_ADPCM; - ctrlm_hal_ble_VoiceStreamEnd_t streamEnd = CTRLM_HAL_BLE_VOICE_STREAM_END_ON_KEY_UP; ctrlm_voice_format_t voice_format = { .type = CTRLM_VOICE_FORMAT_INVALID }; @@ -543,18 +542,21 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si audio_format.getHeaderInfoAdpcm(adpcm_frame->offset_step_size_index, adpcm_frame->offset_predicted_sample_lsb, adpcm_frame->offset_predicted_sample_msb, adpcm_frame->offset_sequence_value, adpcm_frame->shift_sequence_value, adpcm_frame->sequence_value_min, adpcm_frame->sequence_value_max); pressAndHoldSupport = audio_format.getPressAndHoldSupport(); - if(!pressAndHoldSupport) { - streamEnd = CTRLM_HAL_BLE_VOICE_STREAM_END_ON_AUDIO_DURATION; - } controllers_[controller_id]->setPressAndHoldSupport(pressAndHoldSupport); } } + ctrlm_voice_start_audio_params_t audio_start_params; + audio_start_params.m_controller_id = controller_id; + audio_start_params.m_fd = -1; + audio_start_params.m_started = false; + auto audio_start_cb = std::bind(&ctrlm_obj_network_ble_t::start_controller_audio_streaming, this, std::placeholders::_1); + voice_status = ctrlm_get_voice_obj()->voice_session_req(network_id_get(), controller_id, device, voice_format, NULL, controllers_[controller_id]->get_model().c_str(), controllers_[controller_id]->get_sw_revision().to_string().c_str(), controllers_[controller_id]->get_hw_revision().to_string().c_str(), 0.0, - false, NULL, NULL, NULL, true, pressAndHoldSupport); + false, NULL, NULL, NULL, true, pressAndHoldSupport, audio_start_cb, &audio_start_params); if (!controllers_[controller_id]->get_capabilities().has_capability(ctrlm_controller_capabilities_t::capability::PAR) && (VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE == voice_status)) { XLOGD_WARN("PAR voice is enabled but not supported by BLE controller treating as normal voice session"); voice_status = VOICE_SESSION_RESPONSE_AVAILABLE; @@ -562,24 +564,21 @@ void ctrlm_obj_network_ble_t::req_process_voice_session_begin(void *data, int si if (VOICE_SESSION_RESPONSE_AVAILABLE != voice_status) { XLOGD_TELEMETRY("Failed opening voice session in ctrlm_voice_t, error = <%d>", voice_status); } else { + int fd = -1; bool success = false; - if (ble_rcu_interface_) { - int fd = -1; - - if (!ble_rcu_interface_->startAudioStreaming(ieee_address, encoding, streamEnd, fd)) { - XLOGD_ERROR("failed to start audio streaming on remote"); - } else { + if (!audio_start_params.m_started) { // voice session req did not need to start audio + start_controller_audio_streaming(&audio_start_params); + } + fd = audio_start_params.m_fd; - if (fd < 0) { - XLOGD_ERROR("Voice streaming pipe invalid (fd = <%d>), aborting voice session", fd); - success = false; - } else { - XLOGD_INFO("Acquired voice streaming pipe fd = <%d>, sending to voice engine", fd); - //Send the fd acquired from bluez to the voice engine - success = ctrlm_get_voice_obj()->voice_session_data(network_id_get(), controller_id, fd); - } - } + if (fd < 0) { + XLOGD_ERROR("Voice streaming pipe invalid (fd = <%d>), aborting voice session", fd); + success = false; + } else { + XLOGD_INFO("Acquired voice streaming pipe fd = <%d>, sending to voice engine", fd); + //Send the fd acquired from bluez to the voice engine + success = ctrlm_get_voice_obj()->voice_session_data(network_id_get(), controller_id, fd); } if (false == success) { @@ -2616,3 +2615,43 @@ ctrlm_controller_id_t ctrlm_obj_network_ble_t::find_controller_from_upgrade_sess } return id; } + +void ctrlm_obj_network_ble_t::start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params) { + THREAD_ID_VALIDATE(); + int fd = -1; + ctrlm_controller_id_t id = params->m_controller_id; + params->m_fd = fd; + params->m_started = false; + + if (!ready_) { + XLOGD_FATAL("Network is not ready!"); + return; + } + + if(!controller_exists(id)) { + XLOGD_WARN("Controller %u doesn't exist.", id); + return; + } + + if (!ble_rcu_interface_) { + XLOGD_WARN("ble rcu interface not ready"); + return; + } + + ctrlm_hal_ble_VoiceEncoding_t encoding = CTRLM_HAL_BLE_ENCODING_ADPCM; + ctrlm_hal_ble_VoiceStreamEnd_t streamEnd = CTRLM_HAL_BLE_VOICE_STREAM_END_ON_KEY_UP; + auto rcu = controllers_.at(id); + + if (rcu->getPressAndHoldSupport()) { + streamEnd = CTRLM_HAL_BLE_VOICE_STREAM_END_ON_AUDIO_DURATION; + } + + uint64_t ieee_address = rcu->ieee_address_get().get_value(); + if (!ble_rcu_interface_->startAudioStreaming(ieee_address, encoding, streamEnd, fd)) { + XLOGD_ERROR("failed to start audio streaming on remote"); + return; + } + + params->m_fd = fd; + params->m_started = true; +} diff --git a/src/ble/ctrlm_ble_network.h b/src/ble/ctrlm_ble_network.h index 92868ca1..787bb8b8 100644 --- a/src/ble/ctrlm_ble_network.h +++ b/src/ble/ctrlm_ble_network.h @@ -192,6 +192,8 @@ class ctrlm_obj_network_ble_t : public ctrlm_obj_network_t { std::shared_ptr getConfigSettings(); + virtual void start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params); + private: ctrlm_obj_network_ble_t(); diff --git a/src/ctrlm.h b/src/ctrlm.h index 68fa1818..905803d1 100644 --- a/src/ctrlm.h +++ b/src/ctrlm.h @@ -453,6 +453,7 @@ gboolean ctrlm_is_one_touch_autobind_active(void); gboolean ctrlm_is_binding_table_empty(void); gboolean ctrlm_is_binding_table_full(void); bool ctrlm_is_pii_mask_enabled(void); +bool ctrlm_is_networked_standby_supported(void); gboolean ctrlm_main_has_device_id_get(void); gboolean ctrlm_main_has_device_type_get(void); gboolean ctrlm_main_has_service_account_id_get(void); diff --git a/src/ctrlm_log.h b/src/ctrlm_log.h index d804cd84..5bf0eb60 100644 --- a/src/ctrlm_log.h +++ b/src/ctrlm_log.h @@ -22,11 +22,7 @@ #include -#ifdef ANSI_CODES_DISABLED -#define XLOG_OPTS_DEFAULT (XLOG_OPTS_DATE | XLOG_OPTS_TIME | XLOG_OPTS_LF | XLOG_OPTS_MOD_NAME | XLOG_OPTS_LEVEL) -#else #define XLOG_OPTS_DEFAULT (XLOG_OPTS_DATE | XLOG_OPTS_TIME | XLOG_OPTS_LF | XLOG_OPTS_MOD_NAME | XLOG_OPTS_LEVEL | XLOG_OPTS_COLOR) -#endif #ifndef XLOG_MODULE_ID #define XLOG_MODULE_ID XLOG_MODULE_ID_CTRLM diff --git a/src/ctrlm_main.cpp b/src/ctrlm_main.cpp index e12749c5..272d254e 100644 --- a/src/ctrlm_main.cpp +++ b/src/ctrlm_main.cpp @@ -86,9 +86,6 @@ #include "xr_fdc.h" #endif #include -#ifdef MEMORY_LOCK -#include "clnl.h" -#endif using namespace std; @@ -288,9 +285,8 @@ typedef struct { gboolean local_conf; guint telemetry_report_interval; ctrlm_ir_controller_t *ir_controller; -#ifdef NETWORKED_STANDBY_MODE_ENABLED + bool networked_standby_supported; gboolean wake_with_voice_allowed; -#endif } ctrlm_global_t; static ctrlm_global_t g_ctrlm; @@ -402,17 +398,6 @@ static void control_service_values_read_from_db(); #ifdef USE_DEPRECATED_IRMGR static void ctrlm_check_for_key_tag(int key_tag) __attribute__((unused)); //USE_DEPRECATED_IRMGR #endif -#ifdef MEMORY_LOCK -const char *memory_lock_progs[] = { -"/usr/bin/controlMgr", -"/usr/lib/libctrlm_hal_rf4ce.so.0.0.0", -"/usr/lib/libxraudio.so.0.0.0", -"/usr/lib/libxraudio-hal.so.0.0.0", -"/usr/lib/libxr_mq.so.0.0.0", -"/usr/lib/libxr-timer.so.0.0.0", -"/usr/lib/libxr-timestamp.so.0.0.0" -}; -#endif #if CTRLM_HAL_RF4CE_API_VERSION >= 9 static void ctrlm_crash_recovery_check(); @@ -423,13 +408,6 @@ static void ctrlm_ir_controller_thread_poll(void *data); static void ctrlm_vsdk_thread_poll(void *data); static void ctrlm_vsdk_thread_response(void *data); -#ifdef MEM_DEBUG -static gboolean ctrlm_memory_profile(gpointer user_data) { - g_mem_profile(); - return(TRUE); -} -#endif - #ifdef BREAKPAD_SUPPORT static bool ctrlm_minidump_callback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) { XLOGD_FATAL("Minidump location: %s Status: %s", descriptor.path(), succeeded ? "SUCCEEDED" : "FAILED"); @@ -448,24 +426,10 @@ int main(int argc, char *argv[]) { XLOGD_INFO("name <%-24s> version <%-9s> branch <%-20s> commit <%s>", "ctrlm-main", CTRLM_MAIN_VERSION, CTRLM_MAIN_BRANCH, CTRLM_MAIN_COMMIT_ID); -#ifdef MEMORY_LOCK - clnl_init(); - for(unsigned int i = 0; i < (sizeof(memory_lock_progs) / sizeof(memory_lock_progs[0])); i++) { - if(ctrlm_file_exists(memory_lock_progs[i])) { - if(clnl_lock(memory_lock_progs[i], SECTION_TEXT)) { - XLOGD_ERROR("failed to lock instructions to memory <%s>", memory_lock_progs[i]); - } else { - XLOGD_INFO("successfully locked to memory <%s>", memory_lock_progs[i]); - } - } else { - XLOGD_DEBUG("file doesn't exist, cannot lock to memory <%s>", memory_lock_progs[i]); - } - } -#endif - ctrlm_signals_register(); #ifdef BREAKPAD_SUPPORT + XLOGD_INFO("breakpad enabled"); std::string minidump_path = "/opt/minidumps"; #ifdef BREAKPAD_MINIDUMP_PATH_OVERRIDE minidump_path = BREAKPAD_MINIDUMP_PATH_OVERRIDE; @@ -481,6 +445,8 @@ int main(int argc, char *argv[]) { google_breakpad::ExceptionHandler eh(descriptor, NULL, ctrlm_minidump_callback, NULL, true, -1); //ctrlm_crash(); +#else + XLOGD_INFO("breakpad disabled"); #endif XLOGD_INFO("glib run-time version... %d.%d.%d", glib_major_version, glib_minor_version, glib_micro_version); @@ -494,11 +460,6 @@ int main(int argc, char *argv[]) { XLOGD_INFO("Glib run-time library is compatible"); } -#ifdef MEM_DEBUG - XLOGD_WARN("Memory debug is ENABLED."); - g_mem_set_vtable(glib_mem_profiler_table); -#endif - sem_init(&g_ctrlm.ctrlm_utils_sem, 0, 1); if(!ctrlm_iarm_init()) { @@ -518,7 +479,10 @@ int main(int argc, char *argv[]) { XLOGD_INFO("name <%-24s> version <%-9s> branch <%-20s> commit <%s>", entry->name ? entry->name : "NULL", entry->version ? entry->version : "NULL", entry->branch ? entry->branch : "NULL", entry->commit_id ? entry->commit_id : "NULL"); } } - vsdk_init(); + + const char *filename = NULL; + uint32_t file_size_max = 0; + vsdk_init(true, filename, file_size_max); //struct sched_param param; //param.sched_priority = 10; @@ -604,19 +568,21 @@ int main(int argc, char *argv[]) { g_ctrlm.last_key_info.last_ir_remote_type = CTRLM_IR_REMOTE_TYPE_UNKNOWN; g_ctrlm.last_key_info.is_screen_bind_mode = false; g_ctrlm.last_key_info.remote_keypad_config = CTRLM_REMOTE_KEYPAD_CONFIG_INVALID; - #ifdef NETWORKED_STANDBY_MODE_ENABLED + + xrsr_config_t xrsr_config; + if(xrsr_config_get(&xrsr_config)) { + g_ctrlm.networked_standby_supported = xrsr_config.networked_standby; + } else { + g_ctrlm.networked_standby_supported = false; + } + XLOGD_INFO("networked standby supported <%s>", g_ctrlm.networked_standby_supported ? "YES" : "NO"); + g_ctrlm.wake_with_voice_allowed = false; - #endif errno_t safec_rc = strcpy_s(g_ctrlm.last_key_info.source_name, sizeof(g_ctrlm.last_key_info.source_name), ctrlm_rcu_ir_remote_types_str(g_ctrlm.last_key_info.last_ir_remote_type)); ERR_CHK(safec_rc); g_ctrlm.discovery_remote_type[0] = '\0'; -#ifdef MEM_DEBUG - g_mem_profile(); - g_timeout_add_seconds(10, ctrlm_memory_profile, NULL); -#endif - XLOGD_INFO("load version"); if(!ctrlm_load_version()) { XLOGD_FATAL("failed to load version"); @@ -875,15 +841,6 @@ int main(int argc, char *argv[]) { sem_destroy(&g_ctrlm.ctrlm_utils_sem); -#ifdef MEMORY_LOCK - for(unsigned int i = 0; i < (sizeof(memory_lock_progs) / sizeof(memory_lock_progs[0])); i++) { - if(ctrlm_file_exists(memory_lock_progs[i])) { - clnl_unlock(memory_lock_progs[i], SECTION_TEXT); - } - } - clnl_destroy(); -#endif - ctrlm_config_t::destroy_instance(); ctrlm_rfc_t::destroy_instance(); #ifdef TELEMETRY_SUPPORT @@ -2684,9 +2641,9 @@ gpointer ctrlm_main_thread(gpointer param) { if( (old_state == CTRLM_POWER_STATE_DEEP_SLEEP) && (dqm->new_state != CTRLM_POWER_STATE_DEEP_SLEEP) ) { XLOGD_INFO("power_state_change: wake DB and networks"); - #ifdef NETWORKED_STANDBY_MODE_ENABLED - g_ctrlm.wake_with_voice_allowed = true; - #endif + if(g_ctrlm.networked_standby_supported) { + g_ctrlm.wake_with_voice_allowed = true; + } ctrlm_db_power_state_change(true); for(auto const &itr : g_ctrlm.networks) { itr.second->power_state_change(true); @@ -2699,9 +2656,8 @@ gpointer ctrlm_main_thread(gpointer param) { } } - #ifdef NETWORKED_STANDBY_MODE_ENABLED //Wake with voice? Handle NSM voice, do not change power state - if(dqm->new_state == CTRLM_POWER_STATE_ON) { + if(g_ctrlm.networked_standby_supported && dqm->new_state == CTRLM_POWER_STATE_ON) { bool wake_with_voice_allowed = g_ctrlm.wake_with_voice_allowed; g_ctrlm.wake_with_voice_allowed = false; @@ -2715,17 +2671,14 @@ gpointer ctrlm_main_thread(gpointer param) { break; } } - #endif //If execution reaches here, then change power state and inform VSDK of on or deep sleep states g_ctrlm.power_state = dqm->new_state; XLOGD_INFO("Enter power state <%s>", ctrlm_power_state_str(g_ctrlm.power_state)); - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(g_ctrlm.power_state == CTRLM_POWER_STATE_DEEP_SLEEP) { + if(g_ctrlm.networked_standby_supported && (g_ctrlm.power_state == CTRLM_POWER_STATE_DEEP_SLEEP)) { XLOGD_INFO("NSM is <%s>", (ctrlm_main_get_networked_standby_mode())?"ENABLED":"DISABLED"); } - #endif if(dqm->new_state != CTRLM_POWER_STATE_STANDBY) { // Set VSDK power state @@ -3181,6 +3134,10 @@ bool ctrlm_is_pii_mask_enabled(void) { return(g_ctrlm.mask_pii); } +bool ctrlm_is_networked_standby_supported(void) { + return(g_ctrlm.networked_standby_supported); +} + gboolean ctrlm_timeout_recently_booted(gpointer user_data) { XLOGD_INFO("Timeout - Recently booted."); g_ctrlm.recently_booted = FALSE; @@ -5859,11 +5816,9 @@ ctrlm_power_state_t ctrlm_main_get_system_power_state(void) { gboolean ctrlm_main_get_networked_standby_mode(void) { bool networked_standby_mode = false; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(g_ctrlm.power_state == CTRLM_POWER_STATE_DEEP_SLEEP) { + if(g_ctrlm.networked_standby_supported && (g_ctrlm.power_state == CTRLM_POWER_STATE_DEEP_SLEEP)) { networked_standby_mode = g_ctrlm.power_manager->get_networked_standby_mode(); } - #endif return networked_standby_mode ? true : false; } diff --git a/src/ctrlm_main_iarm.cpp b/src/ctrlm_main_iarm.cpp index 92ceb987..8012b334 100644 --- a/src/ctrlm_main_iarm.cpp +++ b/src/ctrlm_main_iarm.cpp @@ -26,9 +26,6 @@ #include "irMgr.h" #endif #include "sysMgr.h" -#ifdef NETWORKED_STANDBY_MODE_ENABLED -#include "deepSleepMgr.h" -#endif #include "comcastIrKeyCodes.h" #include "ctrlm.h" #include "ctrlm_log.h" @@ -62,11 +59,9 @@ static IARM_Result_t ctrlm_main_iarm_call_start_pair_with_code(void *arg); static IARM_Result_t ctrlm_main_iarm_call_chip_status_get(void *arg); static IARM_Result_t ctrlm_main_iarm_call_audio_capture_start(void *arg); static IARM_Result_t ctrlm_main_iarm_call_audio_capture_stop(void *arg); -#ifdef NETWORKED_STANDBY_MODE_ENABLED #if CTRLM_HAL_RF4CE_API_VERSION >= 10 && !defined(CTRLM_DPI_CONTROL_NOT_SUPPORTED) extern IARM_Result_t ctrlm_iarm_powermanager_event_handler_power_pre_change(void* pArgs); #endif -#endif typedef struct { const char * name; diff --git a/src/ctrlm_network.cpp b/src/ctrlm_network.cpp index 74ff4129..69fa462b 100644 --- a/src/ctrlm_network.cpp +++ b/src/ctrlm_network.cpp @@ -1074,3 +1074,8 @@ void ctrlm_obj_network_t::iarm_event_rcu_firmware_status(const ctrlm_obj_control } #endif } + +void ctrlm_obj_network_t::start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params) { + XLOGD_WARN("not implemented for %s network", name_get()); + return; +} diff --git a/src/ctrlm_network.h b/src/ctrlm_network.h index ab22b51b..c39f3285 100644 --- a/src/ctrlm_network.h +++ b/src/ctrlm_network.h @@ -289,6 +289,8 @@ class ctrlm_obj_network_t virtual void iarm_event_rcu_validation_status(void); virtual void iarm_event_rcu_firmware_status(const ctrlm_obj_controller_t &rcu); + virtual void start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params); + // Internal methods std::string version_; diff --git a/src/ctrlm_powermanager.h b/src/ctrlm_powermanager.h index 89705b32..c55223ce 100755 --- a/src/ctrlm_powermanager.h +++ b/src/ctrlm_powermanager.h @@ -28,10 +28,8 @@ class ctrlm_powermanager_t { static ctrlm_powermanager_t *get_instance(); static void destroy_instance(); virtual ctrlm_power_state_t get_power_state() = 0; - #ifdef NETWORKED_STANDBY_MODE_ENABLED virtual bool get_networked_standby_mode() = 0; virtual bool get_wakeup_reason_voice() = 0; - #endif }; #endif diff --git a/src/ctrlm_powermanager_factory.cpp b/src/ctrlm_powermanager_factory.cpp index 93d9dcea..7048c028 100755 --- a/src/ctrlm_powermanager_factory.cpp +++ b/src/ctrlm_powermanager_factory.cpp @@ -16,10 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "ctrlm_powermanager.h" +#ifdef USE_IARM_POWER_MANAGER #include "ctrlm_ipc_iarm_powermanager.h" +#else #include "ctrlm_thunder_powermanager.h" - +#endif static ctrlm_powermanager_t *instance = NULL; diff --git a/src/ctrlm_utils.cpp b/src/ctrlm_utils.cpp index 7166aba5..b77595ac 100644 --- a/src/ctrlm_utils.cpp +++ b/src/ctrlm_utils.cpp @@ -1373,7 +1373,7 @@ const char *ctrlm_linux_key_code_str(uint16_t code, bool mask) { } } -#ifdef NETWORKED_STANDBY_MODE_ENABLED +#ifdef USE_IARM_POWER_MANAGER const char *ctrlm_wakeup_reason_str(DeepSleep_WakeupReason_t wakeup_reason) { switch(wakeup_reason) { case DEEPSLEEP_WAKEUPREASON_IR: return("IR"); @@ -1400,7 +1400,6 @@ const char *ctrlm_wakeup_reason_str(DeepSleep_WakeupReason_t wakeup_reason) { } #endif - bool ctrlm_file_copy(const char* src, const char* dst, bool overwrite, bool follow_dst_symbolic_link) { bool ret = FALSE; GFile *g_src = g_file_new_for_path(src); diff --git a/src/ctrlm_utils.h b/src/ctrlm_utils.h index 5e984a1e..baed40e7 100644 --- a/src/ctrlm_utils.h +++ b/src/ctrlm_utils.h @@ -36,7 +36,7 @@ #include "libIBus.h" #include "libIBusDaemon.h" #include -#ifdef NETWORKED_STANDBY_MODE_ENABLED +#ifdef USE_IARM_POWER_MANAGER #include "deepSleepMgr.h" #endif #ifdef TELEMETRY_SUPPORT @@ -205,7 +205,7 @@ const char *ctrlm_ir_state_str(ctrlm_ir_state_t state); const char *ctrlm_power_state_str(ctrlm_power_state_t state); const char *ctrlm_device_type_str(ctrlm_device_type_t device_type); -#ifdef NETWORKED_STANDBY_MODE_ENABLED +#ifdef USE_IARM_POWER_MANAGER const char *ctrlm_wakeup_reason_str(DeepSleep_WakeupReason_t wakeup_reason); #endif const char *ctrlm_rcu_wakeup_config_str(ctrlm_rcu_wakeup_config_t config); diff --git a/src/database/ctrlm_database.cpp b/src/database/ctrlm_database.cpp index c334cc7a..dfe2bb21 100644 --- a/src/database/ctrlm_database.cpp +++ b/src/database/ctrlm_database.cpp @@ -91,9 +91,7 @@ typedef enum { CTRLM_DB_QUEUE_MSG_TYPE_CONTROLLER_DESTROY = 5, CTRLM_DB_QUEUE_MSG_TYPE_CONTROLLER_CREATE = 6, CTRLM_DB_QUEUE_MSG_TYPE_BACKUP = 7, -#ifdef DEEPSLEEP_CLOSE_DB CTRLM_DB_QUEUE_MSG_TYPE_POWER_STATE_CHANGE = 8, -#endif CTRLM_DB_QUEUE_MSG_TYPE_WRITE_ATTR = 9, CTRLM_DB_QUEUE_MSG_TYPE_TICKLE = CTRLM_MAIN_QUEUE_MSG_TYPE_TICKLE } ctrlm_db_queue_msg_type_t; @@ -147,12 +145,10 @@ typedef struct { bool * ret; } ctrlm_db_queue_msg_backup_t; -#ifdef DEEPSLEEP_CLOSE_DB typedef struct { ctrlm_db_queue_msg_header_t header; gboolean waking_up; } ctrlm_db_queue_msg_power_state_change_t; -#endif typedef struct { sqlite3 * handle; @@ -162,10 +158,9 @@ typedef struct { GAsyncQueue * queue; sem_t semaphore; -#ifdef DEEPSLEEP_CLOSE_DB + bool deepsleep_close_db; char path[PATH_MAX]; sem_t ds_signal; -#endif vector rf4ce_network_list; vector ip_network_list; @@ -216,9 +211,7 @@ static void ctrlm_db_write_blob (const char *table, const char *key, const gucha static void ctrlm_db_write_blob_(const char *table, const char *key, const guchar *value, guint32 length); static void ctrlm_db_write_file_(const char *path, const guchar *data, guint32 length); -#ifdef DEEPSLEEP_CLOSE_DB static void ctrlm_db_power_state_change_(gboolean waking_up); -#endif static int ctrlm_db_insert_or_update(const char *table, const char *key, const int *value_int, const sqlite3_int64 *value_int64, const guchar *value_str, guint32 blob_length); #if 0 static int ctrlm_db_insert(const char *table, const char *key, const int *value_int, const char *value_str, guint32 blob_length); @@ -284,11 +277,13 @@ void ctrlm_db_close() { gboolean ctrlm_db_init(const char *db_path) { g_ctrlm_db.created_default_db = false; -#ifdef DEEPSLEEP_CLOSE_DB - errno_t safec_rc = strcpy_s(g_ctrlm_db.path, sizeof(g_ctrlm_db.path), db_path); - ERR_CHK(safec_rc); - sem_init(&g_ctrlm_db.ds_signal, 0, 0); -#endif + g_ctrlm_db.deepsleep_close_db = true; // Default to true. This can be overridden by vendor layer config as required in the future. + + if(g_ctrlm_db.deepsleep_close_db) { + errno_t safec_rc = strcpy_s(g_ctrlm_db.path, sizeof(g_ctrlm_db.path), db_path); + ERR_CHK(safec_rc); + sem_init(&g_ctrlm_db.ds_signal, 0, 0); + } // check for presence of database file and if not present, create it if(false == ctrlm_db_open(db_path)) { @@ -360,9 +355,9 @@ void ctrlm_db_terminate(void) { } } } -#ifdef DEEPSLEEP_CLOSE_DB - sem_destroy(&g_ctrlm_db.ds_signal); -#endif + if(g_ctrlm_db.deepsleep_close_db) { + sem_destroy(&g_ctrlm_db.ds_signal); + } sem_destroy(&g_ctrlm_db.semaphore); ctrlm_db_close(); @@ -399,29 +394,28 @@ bool ctrlm_db_backup() { } void ctrlm_db_power_state_change(gboolean waking_up) { -#ifdef DEEPSLEEP_CLOSE_DB - ctrlm_db_queue_msg_power_state_change_t *msg = (ctrlm_db_queue_msg_power_state_change_t *)g_malloc(sizeof(ctrlm_db_queue_msg_power_state_change_t)); - if(NULL == msg) { - XLOGD_ERROR("Failed to allocate memory"); - g_assert(0); - return; - } + if(g_ctrlm_db.deepsleep_close_db) { + ctrlm_db_queue_msg_power_state_change_t *msg = (ctrlm_db_queue_msg_power_state_change_t *)g_malloc(sizeof(ctrlm_db_queue_msg_power_state_change_t)); + if(NULL == msg) { + XLOGD_ERROR("Failed to allocate memory"); + g_assert(0); + return; + } - msg->header.type = CTRLM_DB_QUEUE_MSG_TYPE_POWER_STATE_CHANGE; - msg->waking_up = waking_up; + msg->header.type = CTRLM_DB_QUEUE_MSG_TYPE_POWER_STATE_CHANGE; + msg->waking_up = waking_up; - if(waking_up) { - ctrlm_db_queue_msg_push_front(msg); - sem_post(&g_ctrlm_db.ds_signal); + if(waking_up) { + ctrlm_db_queue_msg_push_front(msg); + sem_post(&g_ctrlm_db.ds_signal); + } else { + ctrlm_db_queue_msg_push(msg); + } } else { - ctrlm_db_queue_msg_push(msg); + XLOGD_INFO("No action for DB"); } -#else - XLOGD_INFO("No action for DB"); -#endif } -#ifdef DEEPSLEEP_CLOSE_DB void ctrlm_db_power_state_change_(gboolean waking_up) { if(waking_up == true ) { @@ -432,13 +426,10 @@ void ctrlm_db_power_state_change_(gboolean waking_up) { ctrlm_db_close(); } } -#endif gpointer ctrlm_db_thread(gpointer param) { bool running = true; -#ifdef DEEPSLEEP_CLOSE_DB bool ds_sem_wait = false; -#endif XLOGD_INFO("Started"); // Unblock the caller that launched this thread @@ -531,26 +522,24 @@ gpointer ctrlm_db_thread(gpointer param) { sem_post(&g_ctrlm_db.semaphore); break; } -#ifdef DEEPSLEEP_CLOSE_DB case CTRLM_DB_QUEUE_MSG_TYPE_POWER_STATE_CHANGE: { - XLOGD_DEBUG("POWER STATE CHANGE"); - ctrlm_db_queue_msg_power_state_change_t *power_state_change = (ctrlm_db_queue_msg_power_state_change_t *)msg; - ds_sem_wait = power_state_change->waking_up ? false : true; - ctrlm_db_power_state_change_(power_state_change->waking_up); + if(g_ctrlm_db.deepsleep_close_db) { + XLOGD_DEBUG("POWER STATE CHANGE"); + ctrlm_db_queue_msg_power_state_change_t *power_state_change = (ctrlm_db_queue_msg_power_state_change_t *)msg; + ds_sem_wait = power_state_change->waking_up ? false : true; + ctrlm_db_power_state_change_(power_state_change->waking_up); + } break; } -#endif default: { break; } } ctrlm_db_queue_msg_destroy(msg); -#ifdef DEEPSLEEP_CLOSE_DB if(ds_sem_wait == true) { sem_wait(&g_ctrlm_db.ds_signal); } -#endif } while(running); return(NULL); } diff --git a/src/factory/ctrlmf_version.c b/src/factory/ctrlmf_version.c index 9fd9b69a..459f0fd7 100644 --- a/src/factory/ctrlmf_version.c +++ b/src/factory/ctrlmf_version.c @@ -36,7 +36,7 @@ bool ctrlmf_init(xlog_level_t level, bool requires_audio_playback) { rdk_version_object_free(&info); - int rc = xlog_init(XLOG_MODULE_ID, NULL, 0); + int rc = xlog_init(XLOG_MODULE_ID, NULL, 0, true, false); xlog_level_set_all(level); if(rc != 0) { diff --git a/src/input_event/ctrlm_input_event_writer.h b/src/input_event/ctrlm_input_event_writer.h index 54d7c51d..c05876e0 100644 --- a/src/input_event/ctrlm_input_event_writer.h +++ b/src/input_event/ctrlm_input_event_writer.h @@ -66,7 +66,7 @@ const std::map ctrlm_key_to_linux_map {CTRLM_KEY_CODE_CH_DOWN, linux_ui_code_values_t(KEY_PAGEDOWN, 0x59, KEY_LEFTCTRL)}, {CTRLM_KEY_CODE_LAST, linux_ui_code_values_t(KEY_ESC, 0x0, KEY_LEFTCTRL)}, {CTRLM_KEY_CODE_INPUT_SELECT, linux_ui_code_values_t(KEY_F15, 0x0, KEY_RESERVED)}, - {CTRLM_KEY_CODE_INFO, linux_ui_code_values_t(KEY_F9, 0xcb, KEY_LEFTCTRL)}, + {CTRLM_KEY_CODE_INFO, linux_ui_code_values_t(KEY_F20, 0x0, KEY_RESERVED)}, {CTRLM_KEY_CODE_VOL_UP, linux_ui_code_values_t(KEY_KPPLUS, 0x0, KEY_RESERVED)}, {CTRLM_KEY_CODE_VOL_DOWN, linux_ui_code_values_t(KEY_KPMINUS, 0x0, KEY_RESERVED)}, {CTRLM_KEY_CODE_MUTE, linux_ui_code_values_t(KEY_KPASTERISK, 0x0, KEY_RESERVED)}, @@ -86,6 +86,7 @@ const std::map ctrlm_key_to_linux_map {CTRLM_KEY_CODE_OCAP_C, linux_ui_code_values_t(KEY_RESERVED, 0x0, KEY_RESERVED)}, {CTRLM_KEY_CODE_OCAP_D, linux_ui_code_values_t(KEY_RESERVED, 0x0, KEY_RESERVED)}, {CTRLM_KEY_CODE_ASTERISK, linux_ui_code_values_t(KEY_F14, 0x0, KEY_RESERVED)}, + {CTRLM_KEY_CODE_PUSH_TO_TALK, linux_ui_code_values_t(KEY_F8, 0x0, KEY_RESERVED)} }; enum class key_stroke { diff --git a/src/ipc/ctrlm_ipc_iarm_powermanager.cpp b/src/ipc/ctrlm_ipc_iarm_powermanager.cpp index 0fb5cd5e..0bef46ce 100755 --- a/src/ipc/ctrlm_ipc_iarm_powermanager.cpp +++ b/src/ipc/ctrlm_ipc_iarm_powermanager.cpp @@ -41,19 +41,16 @@ ctrlm_power_state_t ctrlm_ipc_iarm_powermanager_t::get_power_state() { XLOGD_WARN("IARM bus failed to read power state, defaulting to <%s>", ctrlm_power_state_str(power_state)); } else { power_state = ctrlm_iarm_power_state_map(param.curState); - #ifdef NETWORKED_STANDBY_MODE_ENABLED //If ctrlm restarts with system STANDBY state, set to ON, will receive a DEEP_SLEEP or ON message shortly - if(power_state == CTRLM_POWER_STATE_STANDBY) { + if(ctrlm_is_networked_standby_supported() && (power_state == CTRLM_POWER_STATE_STANDBY)) { power_state = CTRLM_POWER_STATE_ON; } - #endif XLOGD_DEBUG("power state <%s>", ctrlm_power_state_str(power_state)); } return power_state; } -#ifdef NETWORKED_STANDBY_MODE_ENABLED bool ctrlm_ipc_iarm_powermanager_t::get_networked_standby_mode() { IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t param = {0}; IARM_Result_t res = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_GetNetworkStandbyMode, (void *)¶m, sizeof(param)); @@ -89,7 +86,6 @@ bool ctrlm_ipc_iarm_powermanager_t::get_wakeup_reason_voice() { return wakeup_reason_voice; } -#endif #if CTRLM_HAL_RF4CE_API_VERSION >= 10 && !defined(CTRLM_DPI_CONTROL_NOT_SUPPORTED) IARM_Result_t ctrlm_iarm_powermanager_event_handler_power_pre_change(void* pArgs) diff --git a/src/ipc/ctrlm_ipc_iarm_powermanager.h b/src/ipc/ctrlm_ipc_iarm_powermanager.h index 20613c20..4944340a 100755 --- a/src/ipc/ctrlm_ipc_iarm_powermanager.h +++ b/src/ipc/ctrlm_ipc_iarm_powermanager.h @@ -26,10 +26,8 @@ class ctrlm_ipc_iarm_powermanager_t : public ctrlm_powermanager_t { ~ctrlm_ipc_iarm_powermanager_t(); ctrlm_power_state_t get_power_state(); - #ifdef NETWORKED_STANDBY_MODE_ENABLED bool get_networked_standby_mode(); bool get_wakeup_reason_voice(); - #endif private: diff --git a/src/rf4ce/ctrlm_rf4ce_network.cpp b/src/rf4ce/ctrlm_rf4ce_network.cpp index f01c52d5..5fea2cd3 100644 --- a/src/rf4ce/ctrlm_rf4ce_network.cpp +++ b/src/rf4ce/ctrlm_rf4ce_network.cpp @@ -3660,6 +3660,11 @@ void ctrlm_obj_network_rf4ce_t::ind_process_voice_session_request(void *data, in device_type = CTRLM_VOICE_DEVICE_FF; } + if(device_type == CTRLM_VOICE_DEVICE_PTT) { + // Send voice key down event since the session was requested + process_event_key(dqm->controller_id, CTRLM_KEY_STATUS_DOWN, CTRLM_KEY_CODE_PUSH_TO_TALK); + } + bool command_status = (controller_type == RF4CE_CONTROLLER_TYPE_XR11 || controller_type == RF4CE_CONTROLLER_TYPE_XR19) ? true : false; @@ -3746,94 +3751,35 @@ void ctrlm_obj_network_rf4ce_t::ind_process_voice_session_request(void *data, in XLOGD_INFO("processing session request - type <%s> voice format <%s>", ctrlm_voice_device_str(device_type), ctrlm_voice_format_str(voice_format)); } - std::string controller_name = controllers_[dqm->controller_id]->product_name_get(); - ctrlm_hal_rf4ce_cfm_data_t cb_confirm_rf4ce = NULL; - void * cb_confirm_param = NULL; + std::string controller_name = controllers_[dqm->controller_id]->product_name_get(); + void * cb_confirm_param = NULL; ctrlm_voice_session_rsp_confirm_t cb_confirm_voice_obj = NULL; + ctrlm_voice_start_audio_params_t start_audio_params; + start_audio_params.m_controller_id = dqm->controller_id; + start_audio_params.m_use_stream_params = use_stream_params; + start_audio_params.m_offset = offset; + start_audio_params.m_started = false; + start_audio_params.m_timestamp = dqm->timestamp; + start_audio_params.m_device_type = device_type; + auto audio_start_cb = std::bind(&ctrlm_obj_network_rf4ce_t::start_controller_audio_streaming, this, std::placeholders::_1); + session = ctrlm_get_voice_obj()->voice_session_req(network_id_get(), dqm->controller_id, device_type, voice_format, use_stream_params ? &stream_params : NULL, controller_name.c_str(), sw_version.to_string().c_str(), hw_version.to_string().c_str(), (((double)battery_status.get_voltage_loaded()) * 4.0 / 255), command_status, - &dqm->timestamp, &cb_confirm_voice_obj, &cb_confirm_param); - if(session == VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { - if(controllers_[dqm->controller_id]->get_capabilities().has_capability(ctrlm_controller_capabilities_t::capability::PAR)) { - session = VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE; - } else { - session = VOICE_SESSION_RESPONSE_AVAILABLE; - } - } - if(session == VOICE_SESSION_RESPONSE_AVAILABLE) { - session = VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK; - } + &dqm->timestamp, &cb_confirm_voice_obj, &cb_confirm_param, + false, false, audio_start_cb, &start_audio_params); - XLOGD_INFO("Voice Session Response Status <%#x>", session); - - // Send the response back to the HAL device - guchar response[5]; - guchar response_len = 2; - - response[0] = MSO_VOICE_CMD_ID_VOICE_SESSION_RESPONSE; - response[1] = session; - if(use_stream_params && session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK) { // Add stream params in the response - response[1] |= 0x80; - response[2] = (guchar) stream_begin_; - response[3] = (offset & 0xFF); - response[4] = (offset >> 8); - response_len = 5; - } - - if(session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE) { - voice_params_par_t params; - ctrlm_get_voice_obj()->voice_params_par_get(¶ms); - - XLOGD_INFO("PAR Voice EOS data bytes timeout <%d> method <%d>", params.par_voice_eos_timeout, params.par_voice_eos_method); - response[2] = params.par_voice_eos_method; - response[3] = (params.par_voice_eos_timeout & 0xFF); - response[4] = (params.par_voice_eos_timeout >> 8); - response_len = 5; + if(!start_audio_params.m_started) { + start_audio_params.m_cb_confirm_voice_obj = cb_confirm_voice_obj; + start_audio_params.m_cb_confirm_param = cb_confirm_param; + start_audio_params.m_status = session; + start_controller_audio_streaming(&start_audio_params); } - ctrlm_timestamp_t hal_timestamp = dqm->timestamp; - - // Determine when to send the response (50 ms after receipt) - if(controller_type_get(dqm->controller_id) == RF4CE_CONTROLLER_TYPE_XR19) { - ctrlm_timestamp_add_ms(&dqm->timestamp, response_idle_time_ff_); - } else { - ctrlm_timestamp_add_ms(&dqm->timestamp, CTRLM_RF4CE_CONST_RESPONSE_IDLE_TIME); - } - - - if(cb_confirm_voice_obj != NULL && (session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK || - session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE)) { // Only confirm response for accepted session so there is only ever one response stored - voice_session_rsp_confirm_ = cb_confirm_voice_obj; - voice_session_rsp_confirm_param_ = cb_confirm_param; - - timestamp_voice_session_request_ = hal_timestamp; - timestamp_voice_first_packet_ = hal_timestamp; - - cb_confirm_rf4ce = ctrlm_network_rf4ce_cfm_voice_session_rsp; - cb_confirm_param = voice_session_rsp_params_.network_id; - - // Store controller id, packet and timestamp for retransmission in case of send error - voice_session_rsp_params_.controller_id = dqm->controller_id; - voice_session_rsp_params_.response_len = response_len; - voice_session_rsp_params_.timestamp_hal = hal_timestamp; - voice_session_rsp_params_.timestamp_begin = dqm->timestamp; - voice_session_rsp_params_.timestamp_end = dqm->timestamp; - voice_session_rsp_params_.retries = 0; - ctrlm_timestamp_add_ms(&voice_session_rsp_params_.timestamp_end, CTRLM_RF4CE_CONST_RESPONSE_WAIT_TIME); - errno_t safec_rc = memcpy_s(&voice_session_rsp_params_.response, sizeof(voice_session_rsp_params_.response),response, response_len); - ERR_CHK(safec_rc); - ctrlm_timestamp_get(&voice_session_rsp_params_.timestamp_rsp_req); - } - - req_data(CTRLM_RF4CE_PROFILE_ID_VOICE, dqm->controller_id, dqm->timestamp, response_len, response, NULL, NULL, false, single_channel_rsp_, cb_confirm_rf4ce, cb_confirm_param); - - XLOGD_INFO("session response delivered"); - if(session != VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK && session != VOICE_SESSION_RESPONSE_AVAILABLE && session != VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE && session != VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { voice_session_active_count_--; @@ -3846,17 +3792,6 @@ void ctrlm_obj_network_rf4ce_t::ind_process_voice_session_request(void *data, in if(dqm->status != VOICE_SESSION_RESPONSE_AVAILABLE && dqm->status != VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK) { // Session was aborted XLOGD_INFO("voice session abort"); - - // // Broadcast the event over the iarm bus - // ctrlm_voice_iarm_event_session_abort_t event; - // event.api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - // event.network_id = dqm->header.network_id; - // event.network_type = ctrlm_network_type_get(dqm->header.network_id); - // event.controller_id = dqm->controller_id; - // event.session_id = ctrlm_voice_session_id_get_next(); - // event.reason = dqm->reason; - - // ctrlm_voice_iarm_event_session_abort(&event); } } @@ -3891,7 +3826,6 @@ void ctrlm_obj_network_rf4ce_t::cfm_voice_session_rsp(void *data, int size) { } ctrlm_timestamp_t now; ctrlm_timestamp_get(&now); - double loadavg[3] = { -1, -1, -1 }; getloadavg(loadavg, 3); struct sysinfo s_info; @@ -3937,6 +3871,17 @@ void ctrlm_obj_network_rf4ce_t::ind_process_voice_session_stop(void *data, int s g_assert(dqm); g_assert(size == sizeof(ctrlm_main_queue_msg_voice_session_stop_t)); + if(!controller_exists(dqm->controller_id)) { + XLOGD_INFO("invalid controller id (%u)", dqm->controller_id); + return; + } + + ctrlm_rf4ce_controller_type_t controller_type = controllers_[dqm->controller_id]->controller_type_get(); + if(!ctrlm_is_voice_assistant((ctrlm_rcu_controller_type_t) controller_type)) { + // Send voice key up event since the session stop was received + process_event_key(dqm->controller_id, CTRLM_KEY_STATUS_UP, CTRLM_KEY_CODE_PUSH_TO_TALK); + } + // Check adjacent key press if(CTRLM_VOICE_SESSION_END_REASON_OTHER_KEY_PRESSED == dqm->session_end_reason && true == is_key_adjacent(dqm->controller_id, dqm->key_code)) { dqm->session_end_reason = CTRLM_VOICE_SESSION_END_REASON_ADJACENT_KEY_PRESSED; @@ -5072,3 +5017,117 @@ void ctrlm_obj_network_rf4ce_t::controller_init_uinput(ctrlm_controller_id_t con return; } } + +void ctrlm_obj_network_rf4ce_t::start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params) { + THREAD_ID_VALIDATE(); + params->m_started = false; + ctrlm_controller_id_t controller_id = params->m_controller_id; + ctrlm_voice_device_t device_type = params->m_device_type; + + if(!ready_) { + XLOGD_FATAL("Network is not ready!"); + return; + } + + if(!controller_exists(controller_id)) { + XLOGD_WARN("Controller %u doesn't exist.", controller_id); + return; + } + + ctrlm_voice_session_response_status_t session = params->m_status; + + if(session == VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { + if(controllers_[controller_id]->get_capabilities().has_capability(ctrlm_controller_capabilities_t::capability::PAR)) { + session = VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE; + } else { + session = VOICE_SESSION_RESPONSE_AVAILABLE; + } + } + if(session == VOICE_SESSION_RESPONSE_AVAILABLE) { + session = VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK; + } + + XLOGD_INFO("Voice Session Response Status <%#x>", session); + + // Send the response back to the HAL device + guchar response[5]; + guchar response_len = 2; + gint16 offset = params->m_offset; + + response[0] = MSO_VOICE_CMD_ID_VOICE_SESSION_RESPONSE; + response[1] = session; + if(params->m_use_stream_params && session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK) { // Add stream params in the response + response[1] |= 0x80; + response[2] = (guchar) stream_begin_; + response[3] = (offset & 0xFF); + response[4] = (offset >> 8); + response_len = 5; + } + + if(session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE) { + voice_params_par_t voice_params; + ctrlm_get_voice_obj()->voice_params_par_get(&voice_params); + + XLOGD_INFO("PAR Voice EOS data bytes timeout <%d> method <%d>", voice_params.par_voice_eos_timeout, voice_params.par_voice_eos_method); + response[2] = voice_params.par_voice_eos_method; + response[3] = (voice_params.par_voice_eos_timeout & 0xFF); + response[4] = (voice_params.par_voice_eos_timeout >> 8); + response_len = 5; + } + + ctrlm_timestamp_t hal_timestamp = params->m_timestamp; + + // Determine when to send the response (50 ms after receipt) + if(controller_type_get(controller_id) == RF4CE_CONTROLLER_TYPE_XR19) { + ctrlm_timestamp_add_ms(¶ms->m_timestamp, response_idle_time_ff_); + } else { + ctrlm_timestamp_add_ms(¶ms->m_timestamp, CTRLM_RF4CE_CONST_RESPONSE_IDLE_TIME); + } + + ctrlm_hal_rf4ce_cfm_data_t cb_confirm_rf4ce = NULL; + + if(params->m_cb_confirm_voice_obj != NULL && (session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK || + session == VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE)) { // Only confirm response for accepted session so there is only ever one response stored + voice_session_rsp_confirm_ = params->m_cb_confirm_voice_obj; + voice_session_rsp_confirm_param_ = params->m_cb_confirm_param; + + timestamp_voice_session_request_ = hal_timestamp; + timestamp_voice_first_packet_ = hal_timestamp; + + cb_confirm_rf4ce = ctrlm_network_rf4ce_cfm_voice_session_rsp; + params->m_cb_confirm_param = voice_session_rsp_params_.network_id; + + // Store controller id, packet and timestamp for retransmission in case of send error + voice_session_rsp_params_.controller_id = controller_id; + voice_session_rsp_params_.response_len = response_len; + voice_session_rsp_params_.timestamp_hal = hal_timestamp; + voice_session_rsp_params_.timestamp_begin = params->m_timestamp; + voice_session_rsp_params_.timestamp_end = params->m_timestamp; + voice_session_rsp_params_.retries = 0; + ctrlm_timestamp_add_ms(&voice_session_rsp_params_.timestamp_end, CTRLM_RF4CE_CONST_RESPONSE_WAIT_TIME); + errno_t safec_rc = memcpy_s(&voice_session_rsp_params_.response, sizeof(voice_session_rsp_params_.response),response, response_len); + ERR_CHK(safec_rc); + ctrlm_timestamp_get(&voice_session_rsp_params_.timestamp_rsp_req); + } + + req_data(CTRLM_RF4CE_PROFILE_ID_VOICE, controller_id, params->m_timestamp, response_len, response, NULL, NULL, false, single_channel_rsp_, cb_confirm_rf4ce, params->m_cb_confirm_param); + + XLOGD_INFO("session response delivered"); + + if(session != VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK && session != VOICE_SESSION_RESPONSE_AVAILABLE && + session != VOICE_SESSION_RESPONSE_AVAILABLE_SKIP_CHAN_CHECK_PAR_VOICE && session != VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { + voice_session_active_count_--; + if(voice_session_active_count_ == 0) { // Re-enable frequency agility if the no other active RF4CE voice sessions + ctrlm_hal_network_property_frequency_agility_t property; + property.state = CTRLM_HAL_FREQUENCY_AGILITY_ENABLE; + ctrlm_network_property_set(network_id_get(), CTRLM_HAL_NETWORK_PROPERTY_FREQUENCY_AGILITY, (void *)&property, sizeof(property)); + } + + if(device_type == CTRLM_VOICE_DEVICE_PTT) { + // Send voice key up event since the session was not accepted + process_event_key(controller_id, CTRLM_KEY_STATUS_UP, CTRLM_KEY_CODE_PUSH_TO_TALK); + } + } + + params->m_started = true; +} diff --git a/src/rf4ce/ctrlm_rf4ce_network.h b/src/rf4ce/ctrlm_rf4ce_network.h index 1e4ce251..07298971 100644 --- a/src/rf4ce/ctrlm_rf4ce_network.h +++ b/src/rf4ce/ctrlm_rf4ce_network.h @@ -462,6 +462,8 @@ class ctrlm_obj_network_rf4ce_t : public ctrlm_obj_network_t virtual std::vector get_controller_obj_list() const; void rcu_timeout_key_release(void *data, int data_size); + virtual void start_controller_audio_streaming(ctrlm_voice_start_audio_params_t *params); + protected: virtual gboolean key_event_hook(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_key_status_t key_status, ctrlm_key_code_t key_code); diff --git a/src/shared_memory/ctrlm_shared_memory.cpp b/src/shared_memory/ctrlm_shared_memory.cpp index 03249419..b53b6db0 100644 --- a/src/shared_memory/ctrlm_shared_memory.cpp +++ b/src/shared_memory/ctrlm_shared_memory.cpp @@ -54,10 +54,8 @@ typedef struct { char url_ptt[CTRLM_VOICE_SERVER_URL_MAX_LENGTH]; bool url_ff_valid; char url_ff[CTRLM_VOICE_SERVER_URL_MAX_LENGTH]; - #ifdef CTRLM_LOCAL_MIC_TAP bool url_mic_tap_valid; char url_mic_tap[CTRLM_VOICE_SERVER_URL_MAX_LENGTH]; - #endif uint32_t query_string_ptt_count; query_string_pair_t query_string_ptt_pairs[CTRLM_VOICE_QUERY_STRING_MAX_PAIRS]; @@ -313,7 +311,6 @@ void ctrlm_sm_voice_url_ff_write(std::string url) { g_ctrlm_sm.mmap->url_ff_valid = true; } -#ifdef CTRLM_LOCAL_MIC_TAP void ctrlm_sm_voice_url_mic_tap_read(std::string &url) { if(g_ctrlm_sm.mmap == NULL) { XLOGD_ERROR("mmap is invalid"); @@ -334,7 +331,6 @@ void ctrlm_sm_voice_url_mic_tap_write(std::string url) { g_ctrlm_sm.mmap->url_mic_tap[sizeof(g_ctrlm_sm.mmap->url_mic_tap) - 1] = '\0'; g_ctrlm_sm.mmap->url_mic_tap_valid = true; } -#endif void ctrlm_sm_voice_query_string_ptt_count_read(uint8_t &count) { if(g_ctrlm_sm.mmap == NULL) { diff --git a/src/shared_memory/ctrlm_shared_memory.h b/src/shared_memory/ctrlm_shared_memory.h index 9c4e05e9..25479c66 100644 --- a/src/shared_memory/ctrlm_shared_memory.h +++ b/src/shared_memory/ctrlm_shared_memory.h @@ -53,10 +53,8 @@ void ctrlm_sm_voice_url_ptt_write(std::string url); void ctrlm_sm_voice_url_ff_read(std::string &url); void ctrlm_sm_voice_url_ff_write(std::string url); -#ifdef CTRLM_LOCAL_MIC_TAP void ctrlm_sm_voice_url_mic_tap_read(std::string &url); void ctrlm_sm_voice_url_mic_tap_write(std::string url); -#endif void ctrlm_sm_voice_query_string_ptt_count_read(uint8_t &count); void ctrlm_sm_voice_query_string_ptt_count_write(uint8_t count); diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index 70c9c1d5..6e0c83b0 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -86,7 +86,6 @@ ctrlm_power_state_t ctrlm_thunder_plugin_powermanager_t::get_power_state() { } -#ifdef NETWORKED_STANDBY_MODE_ENABLED /* root@pioneer-uhd:~# curl --request POST --url http://127.0.0.1:9998/jsonrpc --header 'Content-Type: application/json' --data '{ "jsonrpc": "2.0", "id": 1234567890, "method": "org.rdk.PowerManager.1.getNetworkStandbyMode", "params": {} }' {"jsonrpc":"2.0","id":1234567890,"result":true} */ bool ctrlm_thunder_plugin_powermanager_t::get_networked_standby_mode() { @@ -124,7 +123,6 @@ bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() { return wakeup_reason_voice; } -#endif void ctrlm_thunder_plugin_powermanager_t::on_power_state_changed(const ctrlm_power_state_t ¤t_state, const ctrlm_power_state_t &new_state) { ctrlm_main_queue_power_state_change_t *msg = (ctrlm_main_queue_power_state_change_t *)g_malloc(sizeof(ctrlm_main_queue_power_state_change_t)); diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.h b/src/thunder/ctrlm_thunder_plugin_powermanager.h index ab6ae554..9d2c51a2 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.h +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.h @@ -54,7 +54,6 @@ class ctrlm_thunder_plugin_powermanager_t : public Thunder::Plugin::ctrlm_thunde */ ctrlm_power_state_t get_power_state(); - #ifdef NETWORKED_STANDBY_MODE_ENABLED /** * This function is used to get the networked standby mode from PowerManager plugin. * @@ -67,7 +66,6 @@ class ctrlm_thunder_plugin_powermanager_t : public Thunder::Plugin::ctrlm_thunde * */ bool get_wakeup_reason_voice(); - #endif void on_power_state_changed(const ctrlm_power_state_t ¤t_state, const ctrlm_power_state_t &new_state); diff --git a/src/thunder/ctrlm_thunder_powermanager.cpp b/src/thunder/ctrlm_thunder_powermanager.cpp index ddc95499..8b80a4aa 100755 --- a/src/thunder/ctrlm_thunder_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_powermanager.cpp @@ -36,14 +36,13 @@ ctrlm_power_state_t ctrlm_thunder_powermanager_t::get_power_state() { } } -#ifdef NETWORKED_STANDBY_MODE_ENABLED bool ctrlm_thunder_powermanager_t::get_networked_standby_mode() { if(this->plugin == NULL) { XLOGD_ERROR("plugin not yet available"); return false; } else { - return this->plugin->get_networked_standby_mode(networked_standby_mode); + return this->plugin->get_networked_standby_mode(); } } @@ -53,7 +52,6 @@ bool ctrlm_thunder_powermanager_t::get_wakeup_reason_voice() { XLOGD_WARN("plugin not yet available"); return false; } else { - return this->plugin->get_wakeup_reason_voice(wakeup_reason_voice); + return this->plugin->get_wakeup_reason_voice(); } } -#endif diff --git a/src/thunder/ctrlm_thunder_powermanager.h b/src/thunder/ctrlm_thunder_powermanager.h index 25dc45e9..b87ef19e 100755 --- a/src/thunder/ctrlm_thunder_powermanager.h +++ b/src/thunder/ctrlm_thunder_powermanager.h @@ -11,10 +11,8 @@ class ctrlm_thunder_powermanager_t : public ctrlm_powermanager_t { bool is_ready(); ctrlm_power_state_t get_power_state(); - #ifdef NETWORKED_STANDBY_MODE bool get_networked_standby_mode(); bool get_wakeup_reason_voice(); - #endif private: Thunder::PowerManager::ctrlm_thunder_plugin_powermanager_t *plugin; diff --git a/src/voice/ctrlm_voice_obj.cpp b/src/voice/ctrlm_voice_obj.cpp index 2491ae9a..4a26f316 100644 --- a/src/voice/ctrlm_voice_obj.cpp +++ b/src/voice/ctrlm_voice_obj.cpp @@ -56,14 +56,18 @@ #define ADPCM_COMMAND_ID_MIN (0x20) ///< Minimum bound of command id as defined by XVP Spec. #define ADPCM_COMMAND_ID_MAX (0x3F) ///< Maximum bound of command id as defined by XVP Spec. +#define BEEP_ON_KWD_FILE_VD "/vendor/usr/share/keyword_beep.wav" +#define BEEP_ON_KWD_FILE_MW "/usr/share/keyword_beep.wav" + +#define BEEP_ON_KWD_SAP_VD "file://" BEEP_ON_KWD_FILE_VD +#define BEEP_ON_KWD_SAP_MW "file://" BEEP_ON_KWD_FILE_MW + static void ctrlm_voice_session_response_confirm(bool result, signed long long rsp_time, unsigned int rsp_window, const std::string &err_str, ctrlm_timestamp_t *timestamp, void *user_data); static void ctrlm_voice_data_post_processing_cb(int bytes_sent, void *user_data); static ctrlm_voice_session_group_t voice_device_to_session_group(ctrlm_voice_device_t device_type); -#ifdef BEEP_ON_KWD_ENABLED static void ctrlm_voice_system_audio_player_event_handler(system_audio_player_event_t event, void *user_data); -#endif static xrsr_power_mode_t voice_xrsr_power_map(ctrlm_power_state_t ctrlm_power_state); @@ -138,15 +142,38 @@ ctrlm_voice_t::ctrlm_voice_t() { this->session_id = 0; this->software_version = "N/A"; this->mask_pii = ctrlm_is_production_build() ? JSON_ARRAY_VAL_BOOL_CTRLM_GLOBAL_MASK_PII_0 : JSON_ARRAY_VAL_BOOL_CTRLM_GLOBAL_MASK_PII_1; + + xrsr_config_t xrsr_config; + if(xrsr_config_get(&xrsr_config)) { + this->local_mic = xrsr_config.local_mic; + this->local_mic_tap = xrsr_config.local_mic_tap; + this->local_mic_disable_via_privacy = this->local_mic; // set if local mic is present for now + } else { + XLOGD_ERROR("xrsr_config_get failed"); + this->local_mic = false; + this->local_mic_tap = false; + this->local_mic_disable_via_privacy = false; + + } + + if(ctrlm_file_exists(BEEP_ON_KWD_FILE_VD)) { + this->beep_on_kwd_file = BEEP_ON_KWD_SAP_VD; + this->beep_on_kwd_supported = true; + } else if(ctrlm_file_exists(BEEP_ON_KWD_FILE_MW)) { + this->beep_on_kwd_file = BEEP_ON_KWD_SAP_MW; + this->beep_on_kwd_supported = true; + } else { + this->beep_on_kwd_file = NULL; + this->beep_on_kwd_supported = false; + } + this->ocsp_verify_stapling = false; this->ocsp_verify_ca = false; this->capture_active = false; this->device_cert.type = CTRLM_VOICE_CERT_TYPE_NONE; this->prefs.server_url_src_ptt = JSON_STR_VALUE_VOICE_URL_SRC_PTT; this->prefs.server_url_src_ff = JSON_STR_VALUE_VOICE_URL_SRC_FF; - #ifdef CTRLM_LOCAL_MIC_TAP this->prefs.server_url_src_mic_tap = JSON_STR_VALUE_VOICE_URL_SRC_MIC_TAP; - #endif #ifdef JSON_ARRAY_VAL_STR_VOICE_SERVER_HOSTS_0 this->url_hostname_pattern_add(JSON_ARRAY_VAL_STR_VOICE_SERVER_HOSTS_0); #endif @@ -203,14 +230,12 @@ ctrlm_voice_t::ctrlm_voice_t() { } #endif - #ifdef NETWORKED_STANDBY_MODE_ENABLED this->prefs.dst_params_standby.connect_check_interval = JSON_INT_VALUE_VOICE_DST_PARAMS_STANDBY_CONNECT_CHECK_INTERVAL; this->prefs.dst_params_standby.timeout_connect = JSON_INT_VALUE_VOICE_DST_PARAMS_STANDBY_TIMEOUT_CONNECT; this->prefs.dst_params_standby.timeout_inactivity = JSON_INT_VALUE_VOICE_DST_PARAMS_STANDBY_TIMEOUT_INACTIVITY; this->prefs.dst_params_standby.timeout_session = JSON_INT_VALUE_VOICE_DST_PARAMS_STANDBY_TIMEOUT_SESSION; this->prefs.dst_params_standby.ipv4_fallback = JSON_BOOL_VALUE_VOICE_DST_PARAMS_STANDBY_IPV4_FALLBACK; this->prefs.dst_params_standby.backoff_delay = JSON_INT_VALUE_VOICE_DST_PARAMS_STANDBY_BACKOFF_DELAY; - #endif this->prefs.dst_params_low_latency.connect_check_interval = JSON_INT_VALUE_VOICE_DST_PARAMS_LOW_LATENCY_CONNECT_CHECK_INTERVAL; this->prefs.dst_params_low_latency.timeout_connect = JSON_INT_VALUE_VOICE_DST_PARAMS_LOW_LATENCY_TIMEOUT_CONNECT; @@ -225,14 +250,10 @@ ctrlm_voice_t::ctrlm_voice_t() { this->device_requires_stb_data[CTRLM_VOICE_DEVICE_PTT] = true; this->device_status[CTRLM_VOICE_DEVICE_FF] = CTRLM_VOICE_DEVICE_STATUS_NONE; this->device_requires_stb_data[CTRLM_VOICE_DEVICE_FF] = true; -#ifdef CTRLM_LOCAL_MIC this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] = CTRLM_VOICE_DEVICE_STATUS_NONE; this->device_requires_stb_data[CTRLM_VOICE_DEVICE_MICROPHONE] = true; -#endif -#ifdef CTRLM_LOCAL_MIC_TAP this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE_TAP] = CTRLM_VOICE_DEVICE_STATUS_NONE; this->device_requires_stb_data[CTRLM_VOICE_DEVICE_MICROPHONE_TAP] = true; -#endif this->device_status[CTRLM_VOICE_DEVICE_INVALID] = CTRLM_VOICE_DEVICE_STATUS_NOT_SUPPORTED; this->device_requires_stb_data[CTRLM_VOICE_DEVICE_INVALID] = true; @@ -247,14 +268,14 @@ ctrlm_voice_t::ctrlm_voice_t() { // These semaphores are used to make sure we have all the data before calling the session begin callback sem_init(&this->vsr_semaphore, 0, 0); - #ifdef BEEP_ON_KWD_ENABLED - this->obj_sap = Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t::getInstance(); - this->obj_sap->add_event_handler(ctrlm_voice_system_audio_player_event_handler, this); - this->sap_opened = this->obj_sap->open(SYSTEM_AUDIO_PLAYER_AUDIO_TYPE_WAV, SYSTEM_AUDIO_PLAYER_SOURCE_TYPE_FILE, SYSTEM_AUDIO_PLAYER_PLAY_MODE_SYSTEM); - if(!this->sap_opened) { - XLOGD_WARN("unable to open system audio player"); + if(this->beep_on_kwd_supported) { + this->obj_sap = Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t::getInstance(); + this->obj_sap->add_event_handler(ctrlm_voice_system_audio_player_event_handler, this); + this->sap_opened = this->obj_sap->open(SYSTEM_AUDIO_PLAYER_AUDIO_TYPE_WAV, SYSTEM_AUDIO_PLAYER_SOURCE_TYPE_FILE, SYSTEM_AUDIO_PLAYER_PLAY_MODE_SYSTEM); + if(!this->sap_opened) { + XLOGD_WARN("unable to open system audio player"); + } } - #endif // Set audio mode to default ctrlm_voice_audio_settings_t settings = CTRLM_VOICE_AUDIO_SETTINGS_INITIALIZER; @@ -293,14 +314,12 @@ ctrlm_voice_t::~ctrlm_voice_t() { } } - #ifdef BEEP_ON_KWD_ENABLED - if(this->sap_opened) { + if(this->beep_on_kwd_supported && this->sap_opened) { if(!this->obj_sap->close()) { XLOGD_WARN("unable to close system audio player"); } this->sap_opened = false; } - #endif /* Close Voice SDK */ @@ -422,9 +441,7 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * conf.config_value_get(JSON_BOOL_NAME_VOICE_ENABLE, enabled); conf.config_value_get(JSON_STR_NAME_VOICE_URL_SRC_PTT, this->prefs.server_url_src_ptt); conf.config_value_get(JSON_STR_NAME_VOICE_URL_SRC_FF, this->prefs.server_url_src_ff); - #ifdef CTRLM_LOCAL_MIC_TAP conf.config_value_get(JSON_STR_NAME_VOICE_URL_SRC_MIC_TAP, this->prefs.server_url_src_mic_tap); - #endif conf.config_value_get(JSON_STR_NAME_VOICE_LANGUAGE, this->prefs.guide_language); conf.config_value_get(JSON_INT_NAME_VOICE_MINIMUM_DURATION, this->prefs.utterance_duration_min); if(conf.config_value_get(JSON_BOOL_NAME_VOICE_ENABLE_SAT, this->sat_token_required)) { @@ -483,14 +500,12 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * conf.config_value_get(JSON_FLOAT_NAME_VOICE_AUDIO_DUCKING_LEVEL, audio_settings.ducking_level, 0.0, 1.0); conf.config_value_get(JSON_BOOL_NAME_VOICE_AUDIO_DUCKING_BEEP, audio_settings.ducking_beep); - #ifdef NETWORKED_STANDBY_MODE_ENABLED conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_CONNECT_CHECK_INTERVAL, this->prefs.dst_params_standby.connect_check_interval); conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_CONNECT, this->prefs.dst_params_standby.timeout_connect); conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_INACTIVITY, this->prefs.dst_params_standby.timeout_inactivity); conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_SESSION, this->prefs.dst_params_standby.timeout_session); conf.config_value_get(JSON_BOOL_NAME_VOICE_DST_PARAMS_STANDBY_IPV4_FALLBACK, this->prefs.dst_params_standby.ipv4_fallback); conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_BACKOFF_DELAY, this->prefs.dst_params_standby.backoff_delay); - #endif conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_LOW_LATENCY_CONNECT_CHECK_INTERVAL, this->prefs.dst_params_low_latency.connect_check_interval); conf.config_value_get(JSON_INT_NAME_VOICE_DST_PARAMS_LOW_LATENCY_TIMEOUT_CONNECT, this->prefs.dst_params_low_latency.timeout_connect); @@ -517,11 +532,9 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * for(int i = CTRLM_VOICE_DEVICE_PTT; i < CTRLM_VOICE_DEVICE_INVALID; i++) { uint8_t voice_device_status = CTRLM_VOICE_DEVICE_STATUS_NONE; ctrlm_db_voice_read_device_status(i, (int *)&voice_device_status); - #ifdef CTRLM_LOCAL_MIC if((i == CTRLM_VOICE_DEVICE_MICROPHONE) && (voice_device_status & CTRLM_VOICE_DEVICE_STATUS_PRIVACY)) { this->voice_privacy_enable(false); } - #endif if((voice_device_status & CTRLM_VOICE_DEVICE_STATUS_LEGACY) && (voice_device_status != CTRLM_VOICE_DEVICE_STATUS_DISABLED)) { // Convert from legacy to current (some value other than DISABLED set) XLOGD_INFO("Converting legacy device status value 0x%02X", voice_device_status); voice_device_status = CTRLM_VOICE_DEVICE_STATUS_NONE; @@ -533,9 +546,7 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * } ctrlm_sm_voice_url_ptt_read(this->prefs.server_url_src_ptt); ctrlm_sm_voice_url_ff_read(this->prefs.server_url_src_ff); - #ifdef CTRLM_LOCAL_MIC_TAP ctrlm_sm_voice_url_mic_tap_read(this->prefs.server_url_src_mic_tap); - #endif ctrlm_sm_voice_sat_enable_read(this->sat_token_required); ctrlm_sm_voice_mtls_enable_read(this->mtls_required); ctrlm_sm_voice_secure_url_required_read(this->secure_url_required); @@ -584,28 +595,28 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * // Update routes this->voice_sdk_update_routes(); - #ifdef CTRLM_LOCAL_MIC - // Read privacy mode state from the DB in case power cycle lost HW GPIO state - if(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_DISABLED) { - XLOGD_INFO("voice is disabled, skip privacy"); - } else { - bool privacy_enabled = this->voice_is_privacy_enabled(); - if(privacy_enabled != this->vsdk_is_privacy_enabled()) { - privacy_enabled ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); - } - // Check keyword detector sensitivity value against limits; apply default if out of range. - double sensitivity_set = this->vsdk_keyword_sensitivity_limit_check(this->prefs.keyword_sensitivity); - if(sensitivity_set != this->prefs.keyword_sensitivity) { - xrsr_keyword_config_t kw_config; - kw_config.sensitivity = (float)sensitivity_set; - if(!xrsr_keyword_config_set(&kw_config)) { - XLOGD_ERROR("error updating keyword config"); - } else { - this->prefs.keyword_sensitivity = sensitivity_set; + if(this->local_mic) { + // Read privacy mode state from the DB in case power cycle lost HW GPIO state + if(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_DISABLED) { + XLOGD_INFO("voice is disabled, skip privacy"); + } else { + bool privacy_enabled = this->voice_is_privacy_enabled(); + if(privacy_enabled != this->vsdk_is_privacy_enabled()) { + privacy_enabled ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); + } + // Check keyword detector sensitivity value against limits; apply default if out of range. + double sensitivity_set = this->vsdk_keyword_sensitivity_limit_check(this->prefs.keyword_sensitivity); + if(sensitivity_set != this->prefs.keyword_sensitivity) { + xrsr_keyword_config_t kw_config; + kw_config.sensitivity = (float)sensitivity_set; + if(!xrsr_keyword_config_set(&kw_config)) { + XLOGD_ERROR("error updating keyword config"); + } else { + this->prefs.keyword_sensitivity = sensitivity_set; + } } } } - #endif // Set init message if read from DB if(!init.empty()) { @@ -726,7 +737,6 @@ bool ctrlm_voice_t::voice_configure(ctrlm_voice_iarm_call_settings_t *settings, ctrlm_sm_voice_url_ff_write(this->prefs.server_url_src_ff); } } - #ifdef CTRLM_LOCAL_MIC_TAP if(settings->available & CTRLM_VOICE_SETTINGS_MIC_TAP_SERVER_URL) { settings->server_url_src_mic_tap[CTRLM_VOICE_SERVER_URL_MAX_LENGTH - 1] = '\0'; XLOGD_INFO("Mic tap URL <%s>", this->mask_pii ? "***" : settings->server_url_src_mic_tap); @@ -736,7 +746,6 @@ bool ctrlm_voice_t::voice_configure(ctrlm_voice_iarm_call_settings_t *settings, ctrlm_sm_voice_url_mic_tap_write(this->prefs.server_url_src_mic_tap); } } - #endif if(update_routes && this->xrsr_opened) { this->voice_sdk_update_routes(); @@ -781,9 +790,7 @@ bool ctrlm_voice_t::voice_configure(json_t *settings, bool db_write) { } } if(conf.config_value_get("urlAll", url)) { - #ifdef CTRLM_LOCAL_MIC_TAP this->prefs.server_url_src_mic_tap = url; - #endif this->prefs.server_url_src_ptt = url; this->prefs.server_url_src_ff = std::move(url); update_routes = true; @@ -796,12 +803,10 @@ bool ctrlm_voice_t::voice_configure(json_t *settings, bool db_write) { this->prefs.server_url_src_ff = std::move(url); update_routes = true; } - #ifdef CTRLM_LOCAL_MIC_TAP if(conf.config_value_get("urlMicTap", url)) { this->prefs.server_url_src_mic_tap = std::move(url); update_routes = true; } - #endif if(conf.config_value_get("prv", prv_enabled)) { this->prefs.par_voice_enabled = prv_enabled; XLOGD_INFO("Press and Release Voice is <%s>", this->prefs.par_voice_enabled ? "ENABLED" : "DISABLED"); @@ -829,45 +834,43 @@ bool ctrlm_voice_t::voice_configure(json_t *settings, bool db_write) { } } } - #ifdef CTRLM_LOCAL_MIC - if(conf.config_object_get("mic", device_config)) { - if(device_config.config_value_get("enable", enable)) { - XLOGD_TELEMETRY("Voice Control MIC is <%s>", enable ? "ENABLED" : "DISABLED"); - #ifdef CTRLM_LOCAL_MIC_DISABLE_VIA_PRIVACY - bool privacy_enabled = this->voice_is_privacy_enabled(); - if(enable) { - if(privacy_enabled) { - this->voice_privacy_disable(true); + if(this->local_mic) { + if(conf.config_object_get("mic", device_config)) { + if(device_config.config_value_get("enable", enable)) { + XLOGD_TELEMETRY("Voice Control MIC is <%s>", enable ? "ENABLED" : "DISABLED"); + if(this->local_mic_disable_via_privacy) { + bool privacy_enabled = this->voice_is_privacy_enabled(); + if(enable) { + if(privacy_enabled) { + this->voice_privacy_disable(true); + } + } else if(!privacy_enabled) { + this->voice_privacy_enable(true); + } + } else { + if(enable) { + this->voice_device_enable(CTRLM_VOICE_DEVICE_MICROPHONE, db_write, &update_routes); + } else { + this->voice_device_disable(CTRLM_VOICE_DEVICE_MICROPHONE, db_write, &update_routes); + } } - } else if(!privacy_enabled) { - this->voice_privacy_enable(true); - } - #else - if(enable) { - this->voice_device_enable(CTRLM_VOICE_DEVICE_MICROPHONE, db_write, &update_routes); - } else { - this->voice_device_disable(CTRLM_VOICE_DEVICE_MICROPHONE, db_write, &update_routes); } - #endif } - } - #endif - if(conf.config_value_get("wwFeedback", enable)) { // This option will enable / disable the Wake Word feedback (typically an audible beep). - XLOGD_INFO("Voice Control kwd feedback is <%s>", enable ? "ENABLED" : "DISABLED"); - this->audio_ducking_beep_enabled = enable; + if(conf.config_value_get("wwFeedback", enable)) { // This option will enable / disable the Wake Word feedback (typically an audible beep). + XLOGD_INFO("Voice Control kwd feedback is <%s>", enable ? "ENABLED" : "DISABLED"); + this->audio_ducking_beep_enabled = enable; - if(db_write) { - ctrlm_db_voice_write_audio_ducking_beep_enable(enable); - } + if(db_write) { + ctrlm_db_voice_write_audio_ducking_beep_enable(enable); + } + } } if(update_routes && this->xrsr_opened) { this->voice_sdk_update_routes(); if(db_write) { ctrlm_sm_voice_url_ptt_write(this->prefs.server_url_src_ptt); ctrlm_sm_voice_url_ff_write(this->prefs.server_url_src_ff); - #ifdef CTRLM_LOCAL_MIC_TAP ctrlm_sm_voice_url_mic_tap_write(this->prefs.server_url_src_mic_tap); - #endif } } } @@ -914,11 +917,7 @@ bool ctrlm_voice_t::voice_status(ctrlm_voice_status_t *status) { */ ctrlm_voice_status_capabilities_t capabilities = { .prv = true, - #ifdef BEEP_ON_KWD_ENABLED - .wwFeedback = true, - #else - .wwFeedback = false, - #endif + .wwFeedback = this->beep_on_kwd_supported, }; if(!this->xrsr_opened) { @@ -928,9 +927,7 @@ bool ctrlm_voice_t::voice_status(ctrlm_voice_status_t *status) { } else { status->urlPtt = this->prefs.server_url_src_ptt; status->urlHf = this->prefs.server_url_src_ff; - #ifdef CTRLM_LOCAL_MIC_TAP status->urlMicTap = this->prefs.server_url_src_mic_tap; - #endif sem_wait(&this->device_status_semaphore); for(int i = CTRLM_VOICE_DEVICE_PTT; i < CTRLM_VOICE_DEVICE_INVALID; i++) { status->status[i] = this->device_status[i]; @@ -1347,7 +1344,7 @@ ctrlm_voice_session_response_status_t ctrlm_voice_t::voice_session_req(ctrlm_net ctrlm_voice_device_t device_type, ctrlm_voice_format_t format, voice_session_req_stream_params *stream_params, const char *controller_name, const char *sw_version, const char *hw_version, double voltage, bool command_status, - ctrlm_timestamp_t *timestamp, ctrlm_voice_session_rsp_confirm_t *cb_confirm, void **cb_confirm_param, bool use_external_data_pipe, bool press_and_hold, const char *l_transcription_in, const char *audio_file_in, const uuid_t *uuid, bool low_latency, bool low_cpu_util, int audio_fd) { + ctrlm_timestamp_t *timestamp, ctrlm_voice_session_rsp_confirm_t *cb_confirm, void **cb_confirm_param, bool use_external_data_pipe, bool press_and_hold, std::function cb_start_audio, ctrlm_voice_start_audio_params_t *cb_audio_start_params, const char *l_transcription_in, const char *audio_file_in, const uuid_t *uuid, bool low_latency, bool low_cpu_util, int audio_fd) { ctrlm_voice_session_t *session = &this->voice_session[voice_device_to_session_group(device_type)]; @@ -1379,6 +1376,7 @@ ctrlm_voice_session_response_status_t ctrlm_voice_t::voice_session_req(ctrlm_net // Cancel current speech router session XLOGD_INFO("Waiting on the results from previous session, aborting this and continuing.."); + pre_session_terminate(cb_start_audio, cb_audio_start_params, cb_confirm, cb_confirm_param); xrsr_session_terminate(voice_device_to_xrsr(session->voice_device)); // Synchronous - this will take a bit of time. Might need to revisit this down the road. } bool request_new_session = true; @@ -1390,6 +1388,7 @@ ctrlm_voice_session_response_status_t ctrlm_voice_t::voice_session_req(ctrlm_net request_new_session = false; } else { // Cancel current speech router session XLOGD_WARN("Session in progress with same controller - src <%s> dst <%s>, aborting this and continuing..", ctrlm_voice_state_src_str(session->state_src), ctrlm_voice_state_dst_str(session->state_dst)); + pre_session_terminate(cb_start_audio, cb_audio_start_params, cb_confirm, cb_confirm_param); xrsr_session_terminate(voice_device_to_xrsr(session->voice_device)); // Synchronous - this will take a bit of time. Might need to revisit this down the road. } } else { // session in progress with different controller @@ -2358,6 +2357,14 @@ bool ctrlm_voice_t::voice_stb_data_pii_mask_get() const { return(this->mask_pii); } +bool ctrlm_voice_t::voice_stb_data_local_mic_get() const { + return(this->local_mic); +} + +bool ctrlm_voice_t::voice_stb_data_local_mic_tap_get() const { + return(this->local_mic_tap); +} + bool ctrlm_voice_t::voice_stb_data_device_certificate_set(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca) { this->ocsp_verify_stapling = ocsp_verify_stapling; this->ocsp_verify_ca = ocsp_verify_ca; @@ -2659,29 +2666,20 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses this->voice_status_set(session); break; } - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: { command_status = (session_end->success ? VOICE_COMMAND_STATUS_SUCCESS : VOICE_COMMAND_STATUS_FAILURE); // No need to set, as it's not a controller break; } - #endif default: { break; } } } - #ifdef CTRLM_LOCAL_MIC - #ifdef CTRLM_LOCAL_MIC_TAP if(session->voice_device == CTRLM_VOICE_DEVICE_MICROPHONE || session->voice_device == CTRLM_VOICE_DEVICE_MICROPHONE_TAP) { - #else - if(session->voice_device == CTRLM_VOICE_DEVICE_MICROPHONE) { - #endif XLOGD_INFO("src <%s> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), xrsr_session_end_reason_str(stats->reason), ctrlm_voice_command_status_str(command_status)); - } else - #endif - { + } else { XLOGD_INFO("src <%s> audio sent bytes <%u> samples <%u> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), session->audio_sent_bytes, session->audio_sent_samples, xrsr_session_end_reason_str(stats->reason), ctrlm_voice_command_status_str(command_status)); } @@ -3079,8 +3077,7 @@ void ctrlm_voice_t::voice_action_keyword_verification_callback(const uuid_t uuid } void ctrlm_voice_t::voice_keyword_verified_action(void) { - #ifdef BEEP_ON_KWD_ENABLED - if(this->audio_ducking_beep_enabled) { // play beep audio before ducking audio + if(this->beep_on_kwd_supported && (this->beep_on_kwd_file != NULL) && this->audio_ducking_beep_enabled) { // play beep audio before ducking audio if(this->audio_ducking_beep_in_progress) { XLOGD_WARN("audio ducking beep already in progress!"); this->obj_sap->close(); @@ -3102,8 +3099,8 @@ void ctrlm_voice_t::voice_keyword_verified_action(void) { } } - if(!this->obj_sap->play("file://" BEEP_ON_KWD_FILE)) { - XLOGD_WARN("unable to play beep file <%s>", BEEP_ON_KWD_FILE); + if(!this->obj_sap->play(this->beep_on_kwd_file)) { + XLOGD_WARN("unable to play beep file <%s>", this->beep_on_kwd_file); if(!this->obj_sap->close()) { XLOGD_WARN("unable to close system audio player"); } @@ -3120,11 +3117,9 @@ void ctrlm_voice_t::voice_keyword_verified_action(void) { return; } while(retry >= 0); } - #endif this->audio_state_set(true); } -#ifdef BEEP_ON_KWD_ENABLED void ctrlm_voice_t::voice_keyword_beep_completed_normal(void *data, int size) { this->voice_keyword_beep_completed_callback(false, false); } @@ -3159,7 +3154,6 @@ void ctrlm_voice_t::voice_keyword_beep_completed_callback(bool timeout, bool pla this->audio_state_set(true); } } -#endif void ctrlm_voice_t::voice_session_transcription_callback(const uuid_t uuid, const char *transcription) { // Get session based on uuid @@ -3241,12 +3235,8 @@ const char *ctrlm_voice_device_str(ctrlm_voice_device_t device) { switch(device) { case CTRLM_VOICE_DEVICE_PTT: return("PTT"); case CTRLM_VOICE_DEVICE_FF: return("FF"); - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: return("MICROPHONE"); - #endif - #ifdef CTRLM_LOCAL_MIC_TAP case CTRLM_VOICE_DEVICE_MICROPHONE_TAP: return("MICROPHONE_TAP"); - #endif case CTRLM_VOICE_DEVICE_INVALID: return("INVALID"); } return("UNKNOWN"); @@ -3307,18 +3297,14 @@ ctrlm_voice_device_t xrsr_to_voice_device(xrsr_src_t device) { ret = CTRLM_VOICE_DEVICE_FF; break; } - #ifdef CTRLM_LOCAL_MIC case XRSR_SRC_MICROPHONE: { ret = CTRLM_VOICE_DEVICE_MICROPHONE; break; } - #endif - #ifdef CTRLM_LOCAL_MIC_TAP case XRSR_SRC_MICROPHONE_TAP: { ret = CTRLM_VOICE_DEVICE_MICROPHONE_TAP; break; } - #endif default: { XLOGD_ERROR("unrecognized device type %d", device); break; @@ -3338,18 +3324,14 @@ xrsr_src_t voice_device_to_xrsr(ctrlm_voice_device_t device) { ret = XRSR_SRC_RCU_FF; break; } - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: { ret = XRSR_SRC_MICROPHONE; break; } - #endif - #ifdef CTRLM_LOCAL_MIC_TAP case CTRLM_VOICE_DEVICE_MICROPHONE_TAP: { ret = XRSR_SRC_MICROPHONE_TAP; break; } - #endif default: { XLOGD_ERROR("unrecognized device type %d", device); break; @@ -3359,11 +3341,9 @@ xrsr_src_t voice_device_to_xrsr(ctrlm_voice_device_t device) { } ctrlm_voice_session_group_t voice_device_to_session_group(ctrlm_voice_device_t device_type) { - #ifdef CTRLM_LOCAL_MIC_TAP if(device_type == CTRLM_VOICE_DEVICE_MICROPHONE_TAP) { return(VOICE_SESSION_GROUP_MIC_TAP); } - #endif return(VOICE_SESSION_GROUP_DEFAULT); } @@ -3463,16 +3443,12 @@ ctrlm_voice_format_t xrsr_to_voice_format(xrsr_audio_format_t format) { bool ctrlm_voice_t::is_voice_assistant(ctrlm_voice_device_t device) { bool voice_assistant = false; switch(device) { - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: - #endif case CTRLM_VOICE_DEVICE_FF: { voice_assistant = true; break; } - #ifdef CTRLM_LOCAL_MIC_TAP case CTRLM_VOICE_DEVICE_MICROPHONE_TAP: - #endif case CTRLM_VOICE_DEVICE_PTT: case CTRLM_VOICE_DEVICE_INVALID: default: { @@ -3590,12 +3566,10 @@ int ctrlm_voice_t::ctrlm_voice_controller_command_status_read_timeout(void *data return(false); } -#ifdef BEEP_ON_KWD_ENABLED int ctrlm_voice_t::ctrlm_voice_keyword_beep_end_timeout(void *data) { ctrlm_get_voice_obj()->voice_keyword_beep_completed_callback(true, false); return(false); } -#endif // Timeouts end @@ -3642,9 +3616,7 @@ const char *ctrlm_voice_session_response_status_str(ctrlm_voice_session_response const char *ctrlm_voice_session_group_str(ctrlm_voice_session_group_t group) { switch(group) { case VOICE_SESSION_GROUP_DEFAULT: return("DEFAULT"); - #ifdef CTRLM_LOCAL_MIC_TAP case VOICE_SESSION_GROUP_MIC_TAP: return("MIC_TAP"); - #endif case VOICE_SESSION_GROUP_QTY: break; // fall thru to return an invalid group } return(ctrlm_invalid_return(group)); @@ -3810,14 +3782,14 @@ void ctrlm_voice_t::voice_power_state_change(ctrlm_power_state_t power_state) { xrsr_power_mode_t xrsr_power_mode = voice_xrsr_power_map(power_state); - #ifdef CTRLM_LOCAL_MIC - if(power_state == CTRLM_POWER_STATE_ON) { - bool privacy_enabled = this->vsdk_is_privacy_enabled(); - if(privacy_enabled != this->voice_is_privacy_enabled()) { - privacy_enabled ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); + if(this->local_mic) { + if(power_state == CTRLM_POWER_STATE_ON) { + bool privacy_enabled = this->vsdk_is_privacy_enabled(); + if(privacy_enabled != this->voice_is_privacy_enabled()) { + privacy_enabled ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); + } } } - #endif if(!xrsr_power_mode_set(xrsr_power_mode)) { XLOGD_ERROR("failed to set xrsr to power state %s", ctrlm_power_state_str(power_state)); @@ -3851,57 +3823,56 @@ void ctrlm_voice_t::voice_session_set_inactive(ctrlm_voice_device_t device) { } bool ctrlm_voice_t::voice_is_privacy_enabled(void) { - #ifdef CTRLM_LOCAL_MIC - sem_wait(&this->device_status_semaphore); - bool value = (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY) ? true : false; - sem_post(&this->device_status_semaphore); - return(value); - #else + if(this->local_mic) { + sem_wait(&this->device_status_semaphore); + bool value = (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY) ? true : false; + sem_post(&this->device_status_semaphore); + return(value); + } return(false); - #endif } void ctrlm_voice_t::voice_privacy_enable(bool update_vsdk) { - #ifdef CTRLM_LOCAL_MIC - sem_wait(&this->device_status_semaphore); - if(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY) { - sem_post(&this->device_status_semaphore); - XLOGD_WARN("already enabled"); - return; - } + if(this->local_mic) { + sem_wait(&this->device_status_semaphore); + if(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY) { + sem_post(&this->device_status_semaphore); + XLOGD_WARN("already enabled"); + return; + } - this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] |= CTRLM_VOICE_DEVICE_STATUS_PRIVACY; - ctrlm_db_voice_write_device_status(CTRLM_VOICE_DEVICE_MICROPHONE, (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_MASK_DB)); + this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] |= CTRLM_VOICE_DEVICE_STATUS_PRIVACY; + ctrlm_db_voice_write_device_status(CTRLM_VOICE_DEVICE_MICROPHONE, (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_MASK_DB)); - #ifdef CTRLM_LOCAL_MIC_DISABLE_VIA_PRIVACY - if(update_vsdk && this->xrsr_opened && !xrsr_privacy_mode_set(true)) { - XLOGD_ERROR("xrsr_privacy_mode_set failed"); - } - #endif + if(this->local_mic_disable_via_privacy) { + if(update_vsdk && this->xrsr_opened && !xrsr_privacy_mode_set(true)) { + XLOGD_ERROR("xrsr_privacy_mode_set failed"); + } + } - sem_post(&this->device_status_semaphore); - #endif + sem_post(&this->device_status_semaphore); + } } void ctrlm_voice_t::voice_privacy_disable(bool update_vsdk) { - #ifdef CTRLM_LOCAL_MIC - sem_wait(&this->device_status_semaphore); - if(!(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY)) { - sem_post(&this->device_status_semaphore); - XLOGD_WARN("already disabled"); - return; - } + if(this->local_mic) { + sem_wait(&this->device_status_semaphore); + if(!(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_PRIVACY)) { + sem_post(&this->device_status_semaphore); + XLOGD_WARN("already disabled"); + return; + } - this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] &= ~CTRLM_VOICE_DEVICE_STATUS_PRIVACY; - ctrlm_db_voice_write_device_status(CTRLM_VOICE_DEVICE_MICROPHONE, (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_MASK_DB)); + this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] &= ~CTRLM_VOICE_DEVICE_STATUS_PRIVACY; + ctrlm_db_voice_write_device_status(CTRLM_VOICE_DEVICE_MICROPHONE, (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_MASK_DB)); - #ifdef CTRLM_LOCAL_MIC_DISABLE_VIA_PRIVACY - if(update_vsdk && this->xrsr_opened && !xrsr_privacy_mode_set(false)) { - XLOGD_ERROR("xrsr_privacy_mode_set failed"); - } - #endif - sem_post(&this->device_status_semaphore); - #endif + if(this->local_mic_disable_via_privacy) { + if(update_vsdk && this->xrsr_opened && !xrsr_privacy_mode_set(false)) { + XLOGD_ERROR("xrsr_privacy_mode_set failed"); + } + } + sem_post(&this->device_status_semaphore); + } } void ctrlm_voice_t::voice_device_enable(ctrlm_voice_device_t device, bool db_write, bool *update_routes) { @@ -3940,7 +3911,6 @@ void ctrlm_voice_t::voice_device_disable(ctrlm_voice_device_t device, bool db_wr sem_post(&this->device_status_semaphore); } -#ifdef BEEP_ON_KWD_ENABLED void ctrlm_voice_system_audio_player_event_handler(system_audio_player_event_t event, void *user_data) { if(user_data == NULL) { return; @@ -3980,27 +3950,24 @@ void ctrlm_voice_system_audio_player_event_handler(system_audio_player_event_t e } } } -#endif -#ifdef NETWORKED_STANDBY_MODE_ENABLED void ctrlm_voice_t::voice_nsm_session_request(void) { ctrlm_network_id_t network_id = CTRLM_MAIN_NETWORK_ID_DSP; ctrlm_controller_id_t controller_id = CTRLM_MAIN_CONTROLLER_ID_DSP; ctrlm_voice_device_t device = CTRLM_VOICE_DEVICE_MICROPHONE; ctrlm_voice_format_t format = { .type = CTRLM_VOICE_FORMAT_PCM_32_BIT }; - #ifdef CTRLM_LOCAL_MIC_DISABLE_VIA_PRIVACY - //If the user un-muted the microphones in standby, we must un-mute our components - if(this->voice_is_privacy_enabled()) { - this->voice_privacy_disable(true); + if(this->local_mic_disable_via_privacy) { + //If the user un-muted the microphones in standby, we must un-mute our components + if(this->voice_is_privacy_enabled()) { + this->voice_privacy_disable(true); + } } - #endif this->nsm_voice_session = true; voice_session_req(network_id, controller_id, device, format, NULL, "NSM", "0.0.0.0", "0.0.0.0", 0.0); } -#endif int ctrlm_voice_t::packet_loss_threshold_get() const { return(this->packet_loss_threshold); @@ -4025,11 +3992,11 @@ xrsr_power_mode_t voice_xrsr_power_map(ctrlm_power_state_t ctrlm_power_state) { switch(ctrlm_power_state) { case CTRLM_POWER_STATE_DEEP_SLEEP: - #ifdef NETWORKED_STANDBY_MODE_ENABLED - xrsr_power_mode = ctrlm_main_get_networked_standby_mode() ? XRSR_POWER_MODE_LOW : XRSR_POWER_MODE_SLEEP; - #else - xrsr_power_mode = XRSR_POWER_MODE_SLEEP; - #endif + if(ctrlm_is_networked_standby_supported()) { + xrsr_power_mode = ctrlm_main_get_networked_standby_mode() ? XRSR_POWER_MODE_LOW : XRSR_POWER_MODE_SLEEP; + } else { + xrsr_power_mode = XRSR_POWER_MODE_SLEEP; + } break; case CTRLM_POWER_STATE_ON: case CTRLM_POWER_STATE_STANDBY: @@ -4149,14 +4116,13 @@ void ctrlm_voice_t::voice_rfc_retrieved_handler(const ctrlm_rfc_attr_t& attr) { // All attributes that need a re-route to apply if(attr.get_rfc_value(JSON_INT_NAME_VOICE_MINIMUM_DURATION, this->prefs.utterance_duration_min) | - #ifdef NETWORKED_STANDBY_MODE_ENABLED attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_CONNECT_CHECK_INTERVAL, this->prefs.dst_params_standby.connect_check_interval) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_CONNECT, this->prefs.dst_params_standby.timeout_connect) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_INACTIVITY, this->prefs.dst_params_standby.timeout_inactivity) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_TIMEOUT_SESSION, this->prefs.dst_params_standby.timeout_session) | attr.get_rfc_value(JSON_BOOL_NAME_VOICE_DST_PARAMS_STANDBY_IPV4_FALLBACK, this->prefs.dst_params_standby.ipv4_fallback) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_STANDBY_BACKOFF_DELAY, this->prefs.dst_params_standby.backoff_delay) | - #endif + attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_LOW_LATENCY_CONNECT_CHECK_INTERVAL, this->prefs.dst_params_low_latency.connect_check_interval) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_LOW_LATENCY_TIMEOUT_CONNECT, this->prefs.dst_params_low_latency.timeout_connect) | attr.get_rfc_value(JSON_INT_NAME_VOICE_DST_PARAMS_LOW_LATENCY_TIMEOUT_INACTIVITY, this->prefs.dst_params_low_latency.timeout_inactivity) | @@ -4176,9 +4142,7 @@ void ctrlm_voice_t::voice_rfc_retrieved_handler(const ctrlm_rfc_attr_t& attr) { attr.get_rfc_value(JSON_BOOL_NAME_VOICE_ENABLE, enabled); attr.get_rfc_value(JSON_STR_NAME_VOICE_URL_SRC_PTT, this->prefs.server_url_src_ptt); attr.get_rfc_value(JSON_STR_NAME_VOICE_URL_SRC_FF, this->prefs.server_url_src_ff); - #ifdef CTRLM_LOCAL_MIC_TAP attr.get_rfc_value(JSON_STR_NAME_VOICE_URL_SRC_MIC_TAP, this->prefs.server_url_src_mic_tap); - #endif // Check if enabled if(!enabled) { for(int i = CTRLM_VOICE_DEVICE_PTT; i < CTRLM_VOICE_DEVICE_INVALID; i++) { @@ -4282,3 +4246,14 @@ void ctrlm_voice_t::url_hostname_patterns(const std::vector &obj_se this->url_hostname_pattern_add(itr.c_str()); } } + +void ctrlm_voice_t::pre_session_terminate(std::function cb_start_audio, ctrlm_voice_start_audio_params_t *cb_audio_start_params, ctrlm_voice_session_rsp_confirm_t *cb_confirm, void **cb_confirm_param) { + if (cb_start_audio != nullptr && cb_audio_start_params != nullptr) { + if(cb_confirm != NULL && cb_confirm_param != NULL) { + cb_audio_start_params->m_cb_confirm_voice_obj = ctrlm_voice_session_response_confirm; + cb_audio_start_params->m_cb_confirm_param = NULL; + cb_audio_start_params->m_status = (this->prefs.par_voice_enabled) ? VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE : VOICE_SESSION_RESPONSE_AVAILABLE; + } + cb_start_audio(cb_audio_start_params); + } +} diff --git a/src/voice/ctrlm_voice_obj.h b/src/voice/ctrlm_voice_obj.h index 70ddb4c7..3976a62c 100644 --- a/src/voice/ctrlm_voice_obj.h +++ b/src/voice/ctrlm_voice_obj.h @@ -37,21 +37,14 @@ #include "ctrlm_rfc.h" #include "xrsr.h" #include "ctrlm_voice_telemetry_events.h" - -#ifdef BEEP_ON_KWD_ENABLED #include "ctrlm_thunder_plugin_system_audio_player.h" -#endif #define VOICE_SESSION_REQ_DATA_LEN_MAX (33) typedef enum { VOICE_SESSION_GROUP_DEFAULT = 0, // Session index for regular voice sessions (PTT, FFV) - #ifdef CTRLM_LOCAL_MIC_TAP VOICE_SESSION_GROUP_MIC_TAP = 1, // Session index for microphone tap voice sessions VOICE_SESSION_GROUP_QTY = 2 - #else - VOICE_SESSION_GROUP_QTY = 1 - #endif } ctrlm_voice_session_group_t; #ifdef VOICE_BUFFER_STATS @@ -282,9 +275,7 @@ typedef struct { typedef struct { std::string server_url_src_ptt; std::string server_url_src_ff; - #ifdef CTRLM_LOCAL_MIC_TAP std::string server_url_src_mic_tap; - #endif std::vector server_hosts; std::string aspect_ratio; std::string guide_language; @@ -313,9 +304,7 @@ typedef struct { uint8_t opus_encoder_params[CTRLM_RCU_RIB_ATTR_LEN_OPUS_ENCODING_PARAMS]; bool force_toggle_fallback; bool telemetry_session_stats; - #ifdef NETWORKED_STANDBY_MODE_ENABLED xrsr_dst_params_t dst_params_standby; - #endif xrsr_dst_params_t dst_params_low_latency; bool par_voice_enabled; uint8_t par_voice_eos_method; @@ -391,9 +380,7 @@ typedef struct { typedef struct { std::string urlPtt; std::string urlHf; - #ifdef CTRLM_LOCAL_MIC_TAP std::string urlMicTap; - #endif uint8_t status[CTRLM_VOICE_DEVICE_INVALID]; bool prv_enabled; bool wwFeedback; @@ -402,6 +389,29 @@ typedef struct { typedef void (*ctrlm_voice_session_rsp_confirm_t)(bool result, signed long long rsp_time, unsigned int rsp_window, const std::string &err_str, ctrlm_timestamp_t *timestamp, void *user_data); +class ctrlm_voice_start_audio_params_t +{ +public: + // Generic + ctrlm_voice_start_audio_params_t() = default; + virtual ~ctrlm_voice_start_audio_params_t() = default; + + ctrlm_controller_id_t m_controller_id = -1; + bool m_started = false; + + // BLE + int m_fd = -1; + + // RF4CE + bool m_use_stream_params = false; + int16_t m_offset = 0; + ctrlm_timestamp_t m_timestamp; + ctrlm_voice_session_rsp_confirm_t m_cb_confirm_voice_obj; + void * m_cb_confirm_param; + ctrlm_voice_session_response_status_t m_status; + ctrlm_voice_device_t m_device_type; +}; + typedef struct { ctrlm_network_id_t network_id; ctrlm_network_type_t network_type; @@ -484,7 +494,7 @@ class ctrlm_voice_t { ctrlm_voice_t(); virtual ~ctrlm_voice_t(); - ctrlm_voice_session_response_status_t voice_session_req(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_voice_device_t device_type, ctrlm_voice_format_t format, voice_session_req_stream_params *stream_params, const char *controller_name, const char *sw_version, const char *hw_version, double voltage, bool command_status=false, ctrlm_timestamp_t *timestamp=NULL, ctrlm_voice_session_rsp_confirm_t *cb_confirm=NULL, void **cb_confirm_param=NULL, bool use_external_data_pipe=false, bool press_and_hold=true, const char *transcription_in=NULL, const char *audio_file_in=NULL, const uuid_t *uuid = NULL, bool low_latency=false, bool low_cpu_util=false, int audio_fd = -1); + ctrlm_voice_session_response_status_t voice_session_req(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_voice_device_t device_type, ctrlm_voice_format_t format, voice_session_req_stream_params *stream_params, const char *controller_name, const char *sw_version, const char *hw_version, double voltage, bool command_status=false, ctrlm_timestamp_t *timestamp=NULL, ctrlm_voice_session_rsp_confirm_t *cb_confirm=NULL, void **cb_confirm_param=NULL, bool use_external_data_pipe=false, bool press_and_hold=true, std::function cb_start_audio=NULL, ctrlm_voice_start_audio_params_t *cb_audio_start_params=NULL, const char *transcription_in=NULL, const char *audio_file_in=NULL, const uuid_t *uuid = NULL, bool low_latency=false, bool low_cpu_util=false, int audio_fd = -1); void voice_session_rsp_confirm(bool result, signed long long rsp_time, unsigned int rsp_window, const std::string &err_str, ctrlm_timestamp_t *timestamp); bool voice_session_data(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, const char *buffer, long unsigned int length, ctrlm_timestamp_t *timestamp=NULL, uint8_t *lqi=NULL); bool voice_session_data(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, int fd, const uuid_t *uuid=NULL); @@ -529,6 +539,8 @@ class ctrlm_voice_t { bool voice_stb_data_bypass_wuw_verify_failure_get() const; virtual void voice_stb_data_pii_mask_set(bool mask_pii); bool voice_stb_data_pii_mask_get() const; + bool voice_stb_data_local_mic_get() const; + bool voice_stb_data_local_mic_tap_get() const; virtual bool voice_stb_data_device_certificate_set(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca); virtual bool voice_stb_data_device_certificate_set(const char *p12_cert, const char *p12_pass); virtual bool voice_stb_data_device_certificate_set(const char *pem_cert, const char *pem_pkey, const char *pem_chain, const char *pem_passphrase); @@ -586,9 +598,7 @@ class ctrlm_voice_t { static int ctrlm_voice_packet_timeout(void *data); static int ctrlm_voice_controller_session_stats_rxd_timeout(void *data); static int ctrlm_voice_controller_command_status_read_timeout(void *data); - #ifdef BEEP_ON_KWD_ENABLED static int ctrlm_voice_keyword_beep_end_timeout(void *data); - #endif // End Static Callbacks // Event Interface @@ -609,15 +619,11 @@ class ctrlm_voice_t { virtual void voice_server_return_code_callback(const uuid_t uuid, const char *reason, long ret_code); virtual void voice_session_transcription_callback(const uuid_t uuid, const char *transcription); virtual void voice_power_state_change(ctrlm_power_state_t power_state); - #ifdef NETWORKED_STANDBY_MODE_ENABLED virtual void voice_nsm_session_request(void); - #endif virtual void voice_keyword_verified_action(void); - #ifdef BEEP_ON_KWD_ENABLED virtual void voice_keyword_beep_completed_normal(void *data, int size); virtual void voice_keyword_beep_completed_error(void *data, int size); virtual void voice_keyword_beep_completed_callback(bool timeout, bool playback_error); - #endif // End Event Interface protected: @@ -663,6 +669,11 @@ class ctrlm_voice_t { bool mtls_required; bool secure_url_required; bool mask_pii; + bool local_mic; + bool local_mic_tap; + bool local_mic_disable_via_privacy; + const char * beep_on_kwd_file; + bool beep_on_kwd_supported; bool ocsp_verify_stapling; bool ocsp_verify_ca; bool capture_active; @@ -685,11 +696,9 @@ class ctrlm_voice_t { bool xrsr_opened; ctrlm_voice_ipc_t *voice_ipc; - #ifdef BEEP_ON_KWD_ENABLED Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t *obj_sap; bool sap_opened; ctrlm_timestamp_t sap_play_timestamp; - #endif // Current Session Data unsigned long opus_samples_per_packet; @@ -737,6 +746,10 @@ class ctrlm_voice_t { void audio_state_set(bool session); bool vsdk_is_privacy_enabled(void); double vsdk_keyword_sensitivity_limit_check(double sensitivity); + void pre_session_terminate(std::function cb_start_audio, + ctrlm_voice_start_audio_params_t *cb_audio_start_params, + ctrlm_voice_session_rsp_confirm_t *cb_confirm, + void **cb_confirm_param); }; // Helper Functions @@ -759,27 +772,11 @@ xrsr_src_t voice_device_to_xrsr(ctrlm_voice_device_t device); __inline bool ctrlm_voice_device_is_mic(ctrlm_voice_device_t device) { - #ifdef CTRLM_LOCAL_MIC - #ifdef CTRLM_LOCAL_MIC_TAP return(device == CTRLM_VOICE_DEVICE_MICROPHONE || device == CTRLM_VOICE_DEVICE_MICROPHONE_TAP); - #else - return(device == CTRLM_VOICE_DEVICE_MICROPHONE); - #endif - #else - return(false); - #endif } __inline bool ctrlm_voice_xrsr_src_is_mic(xrsr_src_t src) { - #ifdef CTRLM_LOCAL_MIC - #ifdef CTRLM_LOCAL_MIC_TAP return(src == XRSR_SRC_MICROPHONE || src == XRSR_SRC_MICROPHONE_TAP); - #else - return(src == XRSR_SRC_MICROPHONE); - #endif - #else - return(false); - #endif } #endif diff --git a/src/voice/ctrlm_voice_obj_generic.cpp b/src/voice/ctrlm_voice_obj_generic.cpp index 340b295d..4cb35f99 100644 --- a/src/voice/ctrlm_voice_obj_generic.cpp +++ b/src/voice/ctrlm_voice_obj_generic.cpp @@ -165,6 +165,8 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { errno_t safec_rc = memset_s(&routes, sizeof(routes), 0, sizeof(routes)); ERR_CHK(safec_rc); + bool networked_standby_supported = ctrlm_is_networked_standby_supported(); + // iterate over source to url mapping for(int j = 0; j < XRSR_SRC_INVALID; j++) { xrsr_src_t src = (xrsr_src_t)j; @@ -178,19 +180,15 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { url = &this->prefs.server_url_src_ptt; break; } - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: - #endif case CTRLM_VOICE_DEVICE_FF: { url = &this->prefs.server_url_src_ff; break; } - #ifdef CTRLM_LOCAL_MIC_TAP case CTRLM_VOICE_DEVICE_MICROPHONE_TAP: { url = &this->prefs.server_url_src_mic_tap; break; } - #endif default: { break; } @@ -243,11 +241,9 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { routes[i].dsts[0].stream_from = stream_from; routes[i].dsts[0].stream_offset = stream_offset; routes[i].dsts[0].stream_until = stream_until; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(src == XRSR_SRC_MICROPHONE) { + if(networked_standby_supported && (src == XRSR_SRC_MICROPHONE)) { routes[i].dsts[0].params[XRSR_POWER_MODE_LOW] = &this->prefs.dst_params_standby; } - #endif i++; XLOGD_INFO("url translation from %s to %s", url->c_str(), urls_translated[translated_index].c_str()); } @@ -277,11 +273,9 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { routes[i].dsts[0].stream_from = XRSR_STREAM_FROM_LIVE; routes[i].dsts[0].stream_offset = 0; routes[i].dsts[0].stream_until = XRSR_STREAM_UNTIL_END_OF_STREAM; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(src == XRSR_SRC_MICROPHONE) { + if(networked_standby_supported && (src == XRSR_SRC_MICROPHONE)) { routes[i].dsts[0].params[XRSR_POWER_MODE_LOW] = &this->prefs.dst_params_standby; } - #endif // Set low latency websocket parameters routes[i].dsts[0].params[XRSR_POWER_MODE_FULL] = &this->prefs.dst_params_low_latency; @@ -324,11 +318,9 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { routes[i].dsts[0].stream_from = stream_from; routes[i].dsts[0].stream_offset = stream_offset; routes[i].dsts[0].stream_until = stream_until; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(src == XRSR_SRC_MICROPHONE) { + if(networked_standby_supported && (src == XRSR_SRC_MICROPHONE)) { routes[i].dsts[0].params[XRSR_POWER_MODE_LOW] = &this->prefs.dst_params_standby; } - #endif i++; } } @@ -351,11 +343,9 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { routes[i].dsts[0].stream_from = stream_from; routes[i].dsts[0].stream_offset = stream_offset; routes[i].dsts[0].stream_until = stream_until; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(src == XRSR_SRC_MICROPHONE) { + if(networked_standby_supported && (src == XRSR_SRC_MICROPHONE)) { routes[i].dsts[0].params[XRSR_POWER_MODE_LOW] = &this->prefs.dst_params_standby; } - #endif i++; } } else if(url->rfind("avs", 0) == 0) { @@ -376,11 +366,9 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { routes[i].dsts[0].stream_from = stream_from; routes[i].dsts[0].stream_offset = stream_offset; routes[i].dsts[0].stream_until = stream_until; - #ifdef NETWORKED_STANDBY_MODE_ENABLED - if(src == XRSR_SRC_MICROPHONE) { + if(networked_standby_supported && (src == XRSR_SRC_MICROPHONE)) { routes[i].dsts[0].params[XRSR_POWER_MODE_LOW] = &this->prefs.dst_params_standby; } - #endif i++; } } diff --git a/src/voice/ctrlm_voice_types.h b/src/voice/ctrlm_voice_types.h index e8f86fe6..e65a49ba 100644 --- a/src/voice/ctrlm_voice_types.h +++ b/src/voice/ctrlm_voice_types.h @@ -31,12 +31,8 @@ typedef enum { CTRLM_VOICE_DEVICE_PTT, CTRLM_VOICE_DEVICE_FF, - #ifdef CTRLM_LOCAL_MIC CTRLM_VOICE_DEVICE_MICROPHONE, - #ifdef CTRLM_LOCAL_MIC_TAP CTRLM_VOICE_DEVICE_MICROPHONE_TAP, - #endif - #endif CTRLM_VOICE_DEVICE_INVALID, } ctrlm_voice_device_t; diff --git a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp index 1dfa80b8..f88d6fb9 100644 --- a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp +++ b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp @@ -444,9 +444,7 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::status(void *data) { rc |= json_object_set_new_nocheck(obj, JSON_URL_PTT, json_string(status.urlPtt.c_str())); rc |= json_object_set_new_nocheck(obj, JSON_URL_HF, json_string(status.urlHf.c_str())); - #ifdef CTRLM_LOCAL_MIC_TAP rc |= json_object_set_new_nocheck(obj, JSON_URL_MIC_TAP, json_string(status.urlMicTap.c_str())); - #endif rc |= json_object_set_new_nocheck(obj, JSON_WW_FEEDBACK, status.wwFeedback ? json_true() : json_false()); rc |= json_object_set_new_nocheck(obj, JSON_PRV, status.prv_enabled ? json_true() : json_false()); rc |= json_object_set_new_nocheck(obj, JSON_THUNDER_RESULT, json_true()); @@ -586,14 +584,16 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_types(void *data) { int rc = json_array_append_new(obj_types, json_string("ptt_transcription")); rc |= json_array_append_new(obj_types, json_string("ptt_audio_file")); - #ifdef CTRLM_LOCAL_MIC - rc |= json_array_append_new(obj_types, json_string("mic_audio_file")); - rc |= json_array_append_new(obj_types, json_string("mic_stream_single")); - rc |= json_array_append_new(obj_types, json_string("mic_stream_multi")); - rc |= json_array_append_new(obj_types, json_string("mic_tap_stream_single")); - rc |= json_array_append_new(obj_types, json_string("mic_tap_stream_multi")); - rc |= json_array_append_new(obj_types, json_string("mic_factory_test")); - #endif + if(voice_obj->voice_stb_data_local_mic_get()) { + rc |= json_array_append_new(obj_types, json_string("mic_audio_file")); + rc |= json_array_append_new(obj_types, json_string("mic_stream_single")); + rc |= json_array_append_new(obj_types, json_string("mic_stream_multi")); + if(voice_obj->voice_stb_data_local_mic_tap_get()) { + rc |= json_array_append_new(obj_types, json_string("mic_tap_stream_single")); + rc |= json_array_append_new(obj_types, json_string("mic_tap_stream_multi")); + } + rc |= json_array_append_new(obj_types, json_string("mic_factory_test")); + } rc |= json_object_set_new_nocheck(obj_result, JSON_TYPES, obj_types); rc |= json_object_set_new_nocheck(obj_result, JSON_THUNDER_RESULT, json_true()); @@ -793,7 +793,8 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) ctrlm_voice_session_response_status_t voice_status = voice_obj->voice_session_req( CTRLM_MAIN_NETWORK_ID_INVALID, CTRLM_MAIN_CONTROLLER_ID_INVALID, request_config.device, request_config.format, NULL, str_name_of_source.c_str(), "0.0.0.0", "0.0.0.0", 0.0, - false, NULL, NULL, NULL, (fd >= 0) ? true : false, true, str_transcription.empty() ? NULL : str_transcription.c_str(), str_audio_file.empty() ? NULL : str_audio_file.c_str(), &request_uuid, request_config.low_latency, request_config.low_cpu_util, fd); + false, NULL, NULL, NULL, (fd >= 0) ? true : false, true, NULL, NULL, + str_transcription.empty() ? NULL : str_transcription.c_str(), str_audio_file.empty() ? NULL : str_audio_file.c_str(), &request_uuid, request_config.low_latency, request_config.low_cpu_util, fd); if (voice_status != VOICE_SESSION_RESPONSE_AVAILABLE && voice_status != VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { XLOGD_ERROR("Failed opening voice session <%s>", ctrlm_voice_session_response_status_str(voice_status)); @@ -964,12 +965,8 @@ const char *voice_device_str(ctrlm_voice_device_t device) { switch(device) { case CTRLM_VOICE_DEVICE_PTT: return("ptt"); case CTRLM_VOICE_DEVICE_FF: return("ff"); - #ifdef CTRLM_LOCAL_MIC case CTRLM_VOICE_DEVICE_MICROPHONE: return("mic"); - #ifdef CTRLM_LOCAL_MIC_TAP case CTRLM_VOICE_DEVICE_MICROPHONE_TAP: return("mic_tap"); - #endif - #endif default: break; } return("invalid"); @@ -1051,9 +1048,9 @@ bool ctrlm_voice_ipc_request_supported_mic_transcription(ctrlm_voice_ipc_request } bool ctrlm_voice_ipc_request_supported_mic_audio_file(ctrlm_voice_ipc_request_config_t *config) { - #ifndef CTRLM_LOCAL_MIC - return(false); - #else + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = true; config->supports_named_pipe = false; @@ -1062,7 +1059,6 @@ bool ctrlm_voice_ipc_request_supported_mic_audio_file(ctrlm_voice_ipc_request_co config->low_latency = false; config->low_cpu_util = false; return(true); - #endif } bool ctrlm_voice_ipc_request_supported_mic_stream_default(ctrlm_voice_ipc_request_config_t *config) { @@ -1081,9 +1077,9 @@ bool ctrlm_voice_ipc_request_supported_mic_stream_default(ctrlm_voice_ipc_reques } bool ctrlm_voice_ipc_request_supported_mic_stream_single(ctrlm_voice_ipc_request_config_t *config) { - #ifndef CTRLM_LOCAL_MIC - return(false); - #else + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = false; config->supports_named_pipe = false; @@ -1092,13 +1088,12 @@ bool ctrlm_voice_ipc_request_supported_mic_stream_single(ctrlm_voice_ipc_request config->low_latency = true; config->low_cpu_util = false; return(true); - #endif } bool ctrlm_voice_ipc_request_supported_mic_stream_multi(ctrlm_voice_ipc_request_config_t *config) { - #ifndef CTRLM_LOCAL_MIC - return(false); - #else + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = false; config->supports_named_pipe = false; @@ -1107,13 +1102,12 @@ bool ctrlm_voice_ipc_request_supported_mic_stream_multi(ctrlm_voice_ipc_request_ config->low_latency = true; config->low_cpu_util = false; return(true); - #endif } bool ctrlm_voice_ipc_request_supported_mic_tap_stream_single(ctrlm_voice_ipc_request_config_t *config) { - #ifndef CTRLM_LOCAL_MIC_TAP - return(false); - #else + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_tap_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = false; config->supports_named_pipe = false; @@ -1122,13 +1116,12 @@ bool ctrlm_voice_ipc_request_supported_mic_tap_stream_single(ctrlm_voice_ipc_req config->low_latency = true; config->low_cpu_util = true; return(true); - #endif } bool ctrlm_voice_ipc_request_supported_mic_tap_stream_multi(ctrlm_voice_ipc_request_config_t *config) { - #ifndef CTRLM_LOCAL_MIC_TAP - return(false); - #else + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_tap_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = false; config->supports_named_pipe = false; @@ -1137,20 +1130,22 @@ bool ctrlm_voice_ipc_request_supported_mic_tap_stream_multi(ctrlm_voice_ipc_requ config->low_latency = true; config->low_cpu_util = true; return(true); - #endif } bool ctrlm_voice_ipc_request_supported_mic_factory_test(ctrlm_voice_ipc_request_config_t *config) { - #ifdef CTRLM_LOCAL_MIC_TAP - config->requires_transcription = false; - config->requires_audio_file = false; - config->supports_named_pipe = false; - config->device = CTRLM_VOICE_DEVICE_MICROPHONE_TAP; - config->format = { .type = CTRLM_VOICE_FORMAT_PCM_RAW }; - config->low_latency = true; - config->low_cpu_util = true; - return(true); - #elif defined(CTRLM_LOCAL_MIC) + if(ctrlm_get_voice_obj()->voice_stb_data_local_mic_tap_get()) { + config->requires_transcription = false; + config->requires_audio_file = false; + config->supports_named_pipe = false; + config->device = CTRLM_VOICE_DEVICE_MICROPHONE_TAP; + config->format = { .type = CTRLM_VOICE_FORMAT_PCM_RAW }; + config->low_latency = true; + config->low_cpu_util = true; + return(true); + } + if(!ctrlm_get_voice_obj()->voice_stb_data_local_mic_get()) { + return(false); + } config->requires_transcription = false; config->requires_audio_file = false; config->supports_named_pipe = false; @@ -1159,7 +1154,4 @@ bool ctrlm_voice_ipc_request_supported_mic_factory_test(ctrlm_voice_ipc_request_ config->low_latency = true; config->low_cpu_util = false; return(true); - #else - return(false); - #endif }