diff --git a/CMakeLists.txt b/CMakeLists.txt index 61dbb8e0..7169498b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,9 +223,9 @@ if(ENABLE_NETWORKED_STANDBY_MODE) add_compile_definitions(NETWORKED_STANDBY_MODE_ENABLED) endif() -if(FDC_ENABLED) - add_compile_definitions(FDC_ENABLED) -endif() +#if(FDC_ENABLED) +add_compile_definitions(PUBLIC FDC_ENABLED) +#endif() if(IP_ENABLED) add_compile_definitions(CTRLM_NETWORK_IP CTRLM_IP_HAL_LOG_ENABLED) diff --git a/src/auth/ctrlm_hal_certificate.h b/src/auth/ctrlm_hal_certificate.h new file mode 100644 index 00000000..93e6f039 --- /dev/null +++ b/src/auth/ctrlm_hal_certificate.h @@ -0,0 +1,82 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file + * the following copyright and licenses apply: + * + * Copyright 2023 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CTRLM_HAL_CERTIFICATE_H__ +#define __CTRLM_HAL_CERTIFICATE_H__ + +#include +#include +#include +#include + +#define PASSPHRASE_LEN_MAX (32) + +typedef enum { + CTRLM_VOICE_CERT_TYPE_NONE = 0, + CTRLM_VOICE_CERT_TYPE_P12 = 1, + CTRLM_VOICE_CERT_TYPE_PEM = 2, + CTRLM_VOICE_CERT_TYPE_X509 = 3, + CTRLM_VOICE_CERT_TYPE_INVALID = 4 +} ctrlm_voice_cert_type_t; + +typedef struct { + const char *certificate; + const char *passphrase; +} ctrlm_voice_cert_p12_t; + +typedef struct { + const char *filename_cert; + const char *filename_pkey; + const char *filename_chain; + const char *passphrase; +} ctrlm_voice_cert_pem_t; + +typedef struct { + X509 * cert_x509; + EVP_PKEY * cert_pkey; + STACK_OF(X509) *cert_chain; +} ctrlm_voice_cert_x509_t; + +typedef struct { + ctrlm_voice_cert_type_t type; + union { + ctrlm_voice_cert_p12_t p12; + ctrlm_voice_cert_pem_t pem; + ctrlm_voice_cert_x509_t x509; + } cert; +} ctrlm_voice_cert_t; + +class ctrlm_hal_certificate_t { +public: + ctrlm_hal_certificate_t(); + virtual ~ctrlm_hal_certificate_t(); + + virtual bool device_cert_get(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca); + +private: + virtual bool device_cert_p12_set(const char *certificate, const char *passphrase); + + ctrlm_voice_cert_t device_cert; + bool ocsp_verify_stapling; + bool ocsp_verify_ca; +}; + +ctrlm_hal_certificate_t *ctrlm_hal_certificate_get(); + +#endif diff --git a/src/ble/ctrlm_ble_rcu_interface.cpp b/src/ble/ctrlm_ble_rcu_interface.cpp index 6abecad1..993622e1 100644 --- a/src/ble/ctrlm_ble_rcu_interface.cpp +++ b/src/ble/ctrlm_ble_rcu_interface.cpp @@ -21,7 +21,7 @@ #include "ctrlm_ble_rcu_interface.h" #include "ctrlm_ble_utils.h" #include "ctrlm_voice_obj.h" - +#include #define CTRLM_BLE_KEY_MSG_QUEUE_MSG_MAX (10) #define CTRLM_BLE_KEY_MSG_QUEUE_MSG_SIZE_MAX (sizeof(ctrlm_ble_key_queue_device_changed_msg_t)) @@ -1516,6 +1516,7 @@ static int OpenKeyInputDevice(uint64_t ieee_address) return input_fd; } } + XLOGD_INFO("closing fd <%d>", input_fd); close(input_fd); if (NULL != evdev) { libevdev_free(evdev); @@ -1599,6 +1600,7 @@ void *KeyMonitorThread(void *data) sem_post(&metadata->m_keyThreadSem); XLOGD_INFO("Enter main loop for new key monitor thread"); + XLOGD_INFO("TID <%d>", (int)gettid()); do { // Needs to be reinitialized before each call to select() because select() will modify these variables FD_ZERO(&rfds); @@ -1644,6 +1646,7 @@ void *KeyMonitorThread(void *data) if (rcuKeypressFds.end() != rcuKeypressFds.find(device_changed_msg->address)) { if (rcuKeypressFds[device_changed_msg->address] >= 0) { + XLOGD_INFO("closing fd <%d>", rcuKeypressFds[device_changed_msg->address]); close(rcuKeypressFds[device_changed_msg->address]); } rcuKeypressFds.erase(device_changed_msg->address); @@ -1657,6 +1660,7 @@ void *KeyMonitorThread(void *data) if (rcu.second >= 0) { XLOGD_INFO("Closing key input device for RCU <%s> so key monitor thread can reopen...", rcu.first.toString().c_str()); + XLOGD_INFO("closing fd <%d>", rcu.second); close(rcu.second); rcu.second = -1; } @@ -1675,6 +1679,7 @@ void *KeyMonitorThread(void *data) for (auto &rcu : rcuKeypressFds) { if (rcu.second >= 0) { + XLOGD_INFO("closing fd <%d>", rcu.second); close(rcu.second); rcu.second = -1; } diff --git a/src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp b/src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp index 333a76e7..0722cb8d 100644 --- a/src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp +++ b/src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp @@ -138,11 +138,13 @@ GattAudioPipe::~GattAudioPipe() *m_isAlive = false; // close any fds that we may still have open + XLOGD_INFO("closing fd <%d>", m_outputPipeRdFd); if ((m_outputPipeRdFd >= 0) && (::close(m_outputPipeRdFd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close output read pipe fd: error = <%d>, <%s>", errsv, strerror(errsv)); } + XLOGD_INFO("closing fd <%d>", m_outputPipeWrFd); if ((m_outputPipeWrFd >= 0) && (::close(m_outputPipeWrFd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close output write pipe fd: error = <%d>, <%s>", errsv, strerror(errsv)); @@ -294,6 +296,7 @@ int GattAudioPipe::takeOutputReadFd() } // now close our internal copy + XLOGD_INFO("closing fd <%d>", m_outputPipeRdFd); if (::close(m_outputPipeRdFd) != 0) { int errsv = errno; XLOGD_ERROR("failed to close internal copy of read end of output pipe: error = <%d>, <%s>", @@ -435,6 +438,7 @@ void GattAudioPipe::onOutputPipeException(int pipeFd) XLOGD_DEBUG("detected close on the client output pipe"); // close the output pipe + XLOGD_INFO("closing fd <%d>", m_outputPipeWrFd); if ((m_outputPipeWrFd >= 0) && (::close(m_outputPipeWrFd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close output pipe: error = <%d>, <%s>", errsv, strerror(errsv)); diff --git a/src/ble/hal/blercu/bluez/blegattcharacteristic.cpp b/src/ble/hal/blercu/bluez/blegattcharacteristic.cpp index e79849c9..1afeacc1 100644 --- a/src/ble/hal/blercu/bluez/blegattcharacteristic.cpp +++ b/src/ble/hal/blercu/bluez/blegattcharacteristic.cpp @@ -573,6 +573,7 @@ void BleGattCharacteristicBluez::enablePipeNotifications(const Slot", pipeFd); close(pipeFd); XLOGD_ERROR("invalid MTU size on the notify pipe (%hd bytes)", mtu); @@ -589,6 +590,7 @@ void BleGattCharacteristicBluez::enablePipeNotifications(const Slot(pipeFd, mtu, m_uuid); //BleGattNotifyPipe dups the pipe, so close the original here. + XLOGD_INFO("closing fd <%d>", pipeFd); close(pipeFd); if (!m_notifyPipe || !m_notifyPipe->isValid()) { diff --git a/src/ble/hal/blercu/bluez/blegattnotifypipe.cpp b/src/ble/hal/blercu/bluez/blegattnotifypipe.cpp index 6f54af37..292510e9 100644 --- a/src/ble/hal/blercu/bluez/blegattnotifypipe.cpp +++ b/src/ble/hal/blercu/bluez/blegattnotifypipe.cpp @@ -221,12 +221,15 @@ void BleGattNotifyPipe::shutdown() ThreadJoin(&m_notifyThread, 2); } if (FD_SIGNAL(m_exitEventFds) > -1) { + XLOGD_INFO("closing fd <%d>", FD_SIGNAL(m_exitEventFds)); close(FD_SIGNAL(m_exitEventFds)); } if (FD_RECV(m_exitEventFds) > -1) { + XLOGD_INFO("closing fd <%d>", FD_RECV(m_exitEventFds)); close(FD_RECV(m_exitEventFds)); } + XLOGD_INFO("closing fd <%d>", m_pipeFd); if ((m_pipeFd >= 0) && (::close(m_pipeFd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close notification pipe fd: error = <%d>, <%s>", errsv, strerror(errsv)); @@ -276,7 +279,8 @@ bool BleGattNotifyPipe::onActivated() // this will stop the recording, XLOGD_INFO("remote end of notification pipe closed for %s", m_uuid.toString().c_str()); - if (::close(m_pipeFd) != 0) { + XLOGD_INFO("closing fd <%d>", m_pipeFd); + if (::close(m_pipeFd) != 0) { int errsv = errno; XLOGD_ERROR("failed to close pipe fd: error = <%d>, <%s>", errsv, strerror(errsv)); } @@ -310,6 +314,7 @@ void *NotifyThread(void *data) XLOGD_INFO("Enter main loop for bluez notification pipe (%d) for %s", notifyPipe->m_pipeFd, notifyPipe->m_uuid.toString().c_str()); + XLOGD_INFO("TID <%d>", (int)gettid()); do { // Needs to be reinitialized before each call to select() because select() will modify these variables FD_ZERO(&rfds); diff --git a/src/ble/hal/utils/filedescriptor.cpp b/src/ble/hal/utils/filedescriptor.cpp index 0e289d89..19f24a06 100644 --- a/src/ble/hal/utils/filedescriptor.cpp +++ b/src/ble/hal/utils/filedescriptor.cpp @@ -86,6 +86,8 @@ FileDescriptor::FileDescriptor(const FileDescriptor &other) FileDescriptor &FileDescriptor::operator=(FileDescriptor &&other) { + + XLOGD_INFO("closing fd <%d>", m_fd); if ((m_fd >= 0) && (::close(m_fd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv)); @@ -99,6 +101,7 @@ FileDescriptor &FileDescriptor::operator=(FileDescriptor &&other) FileDescriptor &FileDescriptor::operator=(const FileDescriptor &other) { + XLOGD_INFO("closing fd <%d>", m_fd); if ((m_fd >= 0) && (::close(m_fd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv)); @@ -134,6 +137,7 @@ int FileDescriptor::fd() const void FileDescriptor::reset() { + XLOGD_INFO("closing fd <%d>", m_fd); if ((m_fd >= 0) && (::close(m_fd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv)); diff --git a/src/ble/hal/utils/fwimagefile.cpp b/src/ble/hal/utils/fwimagefile.cpp index 8f7454cd..c405fe99 100644 --- a/src/ble/hal/utils/fwimagefile.cpp +++ b/src/ble/hal/utils/fwimagefile.cpp @@ -94,6 +94,7 @@ FwImageFile::FwImageFile(const string &filePath) // check the file header / contents m_valid = checkFile(); if (!m_valid) { + XLOGD_INFO("closing fd <%d>", m_fd); close(m_fd); m_fd = -1; } @@ -101,6 +102,7 @@ FwImageFile::FwImageFile(const string &filePath) FwImageFile::~FwImageFile() { + XLOGD_INFO("closing fd <%d>", m_fd)); if ((m_fd >= 0) && (::close(m_fd) != 0)) { int errsv = errno; XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv)); diff --git a/src/ble/hal/utils/hcisocket.cpp b/src/ble/hal/utils/hcisocket.cpp index 4c96b72f..2dc73c7b 100644 --- a/src/ble/hal/utils/hcisocket.cpp +++ b/src/ble/hal/utils/hcisocket.cpp @@ -31,7 +31,7 @@ // #include "linux/containerhelpers.h" #include "ctrlm_log_ble.h" - +#include using namespace std; @@ -434,6 +434,7 @@ HciSocketImpl::HciSocketImpl(uint hciDeviceId, int netNsFd) // setup the hci socket if (!setSocketFilter(sockFd) || !bindSocket(sockFd, hciDeviceId)) { + XLOGD_INFO("closing <%d>", sockFd); close(sockFd); return; } @@ -462,14 +463,17 @@ HciSocketImpl::~HciSocketImpl() ctrlm_utils_thread_join(&m_socketThread, 2); } if (FD_SIGNAL(m_exitEventFds) > -1) { + XLOGD_INFO("closing <%d>", FD_SIGNAL(m_exitEventFds)); close(FD_SIGNAL(m_exitEventFds)); } if (FD_RECV(m_exitEventFds) > -1) { + XLOGD_INFO("closing <%d>", FD_RECV(m_exitEventFds)); close(FD_RECV(m_exitEventFds)); } *m_isAlive = false; + XLOGD_INFO("closing fd <%d>", m_hciSocket); if ((m_hciSocket >= 0) && (::close(m_hciSocket) != 0)) { int errsv = errno; XLOGD_WARN("failed to close hci socket %d (%s)", errsv, strerror(errsv)); @@ -1058,6 +1062,7 @@ void *SocketThread(void *data) sem_post(&socketImpl->m_socketThreadSem); XLOGD_INFO("Enter main loop for HCI socket thread"); + XLOGD_INFO("TID <%d>", (int)gettid()); do { if (FD_RECV(socketImpl->m_exitEventFds) < 0 || socketImpl->m_hciSocket < 0) { XLOGD_ERROR("one of the fds is invalid, exiting thread"); diff --git a/src/ctrlm_ir_controller.cpp b/src/ctrlm_ir_controller.cpp index db978c7c..65329f73 100644 --- a/src/ctrlm_ir_controller.cpp +++ b/src/ctrlm_ir_controller.cpp @@ -28,6 +28,7 @@ #include "ctrlm_config_types.h" #include "ctrlm_config_default.h" #include "ctrlm_network.h" +#include "unistd.h" #include @@ -348,6 +349,7 @@ static int ctrlm_ir_open_key_input_device(vector names) { } } } + XLOGD_INFO("closing fd <%d>", input_fd); close(input_fd); if (NULL != evdev) { libevdev_free(evdev); @@ -376,6 +378,7 @@ static gboolean ctrlm_ir_retry_input_open(gpointer user_data) { void* ctrlm_ir_key_monitor_thread(void *data) { XLOGD_INFO("Enter..."); + XLOGD_INFO("TID <%d>", (int)gettid()); ctrlm_ir_controller_t *ir_controller = (ctrlm_ir_controller_t *)data; @@ -468,6 +471,7 @@ void* ctrlm_ir_key_monitor_thread(void *data) { XLOGD_ERROR("error = <%d>, <%s>, closing and reopening device...", errsv, strerror(errsv)); input_device_retry_cnt = 0; if (input_device_fd >= 0) { + XLOGD_INFO("closing fd <%d>", input_device_fd); close(input_device_fd); input_device_fd = -1; } @@ -521,6 +525,7 @@ void* ctrlm_ir_key_monitor_thread(void *data) { ctrlm_timeout_destroy(&g_retry_input_open_timer_tag); if (input_device_fd >= 0) { + XLOGD_INFO("closing fd <%d>", input_device_fd); close(input_device_fd); } return NULL; diff --git a/src/ctrlm_voice_packet_analysis.h b/src/ctrlm_voice_packet_analysis.h new file mode 100644 index 00000000..f75b4e95 --- /dev/null +++ b/src/ctrlm_voice_packet_analysis.h @@ -0,0 +1,51 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2014 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ +#ifndef CTRLM_VOICE_PACKET_ANALYSIS_H_ +#define CTRLM_VOICE_PACKET_ANALYSIS_H_ + +#include + +enum ctrlm_voice_packet_analysis_result_t { + CTRLM_VOICE_PACKET_ANALYSIS_GOOD, + CTRLM_VOICE_PACKET_ANALYSIS_DUPLICATE, + CTRLM_VOICE_PACKET_ANALYSIS_DISCONTINUITY, + CTRLM_VOICE_PACKET_ANALYSIS_BAD, + CTRLM_VOICE_PACKET_ANALYSIS_ERROR +}; + +struct ctrlm_voice_packet_analysis_stats_t { + uint32_t total_packets; + uint32_t bad_packets; + uint32_t duplicated_packets; + uint32_t lost_packets; + uint32_t sequence_error_count; +}; + +class ctrlm_voice_packet_analysis { + public: + ctrlm_voice_packet_analysis(){}; + virtual ~ctrlm_voice_packet_analysis(){}; + virtual void reset()=0; + virtual ctrlm_voice_packet_analysis_result_t packet_check(const void* header, unsigned long header_len, const void* data, unsigned long data_len) =0; + virtual void stats_get(ctrlm_voice_packet_analysis_stats_t& stats) const=0; +}; + +ctrlm_voice_packet_analysis* ctrlm_voice_packet_analysis_factory(); + +#endif /* CTRLM_VOICE_PACKET_ANALYSIS_H_ */ diff --git a/src/factory/ctrlmf_ws.c b/src/factory/ctrlmf_ws.c index ea175c06..f3ea51d2 100644 --- a/src/factory/ctrlmf_ws.c +++ b/src/factory/ctrlmf_ws.c @@ -131,6 +131,8 @@ void *ctrlmf_ws_main(void *param) { return(NULL); } ctrlmf_ws_thread_state_t state; + + XLOGD_INFO("TID <%d>", (int)gettid()); state.audio_frames = params.audio_frames; state.audio_frame_qty = params.audio_frame_qty; diff --git a/src/input_event/ctrlm_input_event_writer.cpp b/src/input_event/ctrlm_input_event_writer.cpp index c463a78e..3347ce69 100644 --- a/src/input_event/ctrlm_input_event_writer.cpp +++ b/src/input_event/ctrlm_input_event_writer.cpp @@ -73,6 +73,7 @@ void ctrlm_input_event_writer::shutdown(void) { return; } ioctl(fd_, UI_DEV_DESTROY); + XLOGD_INFO("closing fd <%d>", fd_); close(fd_); fd_ = -1; initialized_ = false; diff --git a/src/irdb/ctrlm_irdb.cpp b/src/irdb/ctrlm_irdb.cpp new file mode 100644 index 00000000..b5392a7e --- /dev/null +++ b/src/irdb/ctrlm_irdb.cpp @@ -0,0 +1,181 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2014 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include "ctrlm_irdb.h" +#include "ctrlm_network.h" +#include "ctrlm_log.h" +#include "ctrlm_utils.h" +#if defined(CTRLM_THUNDER) +#include "ctrlm_thunder_controller.h" +#endif + +#include + + +ctrlm_irdb_ir_code_set_t::ctrlm_irdb_ir_code_set_t(ctrlm_irdb_dev_type_t type, const ctrlm_irdb_ir_entry_id_t &id) { + type_ = type; + id_ = id; +} + +void ctrlm_irdb_ir_code_set_t::add_key(ctrlm_key_code_t key, ctrlm_irdb_ir_code_t ir_code) { + ir_codes_[key] = std::move(ir_code); +} + +std::map *ctrlm_irdb_ir_code_set_t::get_key_map() { + return &ir_codes_; +} + +ctrlm_irdb_dev_type_t ctrlm_irdb_ir_code_set_t::get_type() { + return type_; +} + +ctrlm_irdb_ir_entry_id_t ctrlm_irdb_ir_code_set_t::get_id() { + return id_; +} + +#if defined(CTRLM_THUNDER) +static int _on_thunder_ready_thread(void *data) { + ctrlm_irdb_t *irdb = (ctrlm_irdb_t *)data; + if(irdb) { + irdb->on_thunder_ready(); + } else { + XLOGD_ERROR("irdb is null"); + } + return(0); +} + +static void _on_thunder_ready(void *data) { + g_idle_add(_on_thunder_ready_thread, data); +} +#endif + +ctrlm_irdb_t::ctrlm_irdb_t(ctrlm_irdb_mode_t mode, bool platform_tv) { + this->mode = mode; + this->platform_tv = platform_tv; + this->ipc = NULL; + this->initialized = 0; +#if defined(CTRLM_THUNDER) + Thunder::Controller::ctrlm_thunder_controller_t *controller = Thunder::Controller::ctrlm_thunder_controller_t::getInstance(); + if(controller) { + if(controller->is_ready()) { + this->on_thunder_ready(); + } else { + controller->add_ready_handler(_on_thunder_ready, (void *)this); + } + } else { + XLOGD_ERROR("Thunder controller is NULL"); + } +#endif +} + +ctrlm_irdb_t::~ctrlm_irdb_t() { + if(this->ipc) { + this->ipc->deregister_ipc(); + delete this->ipc; + this->ipc = NULL; + } +} + +bool ctrlm_irdb_t::initialize_irdb() { + return(this->initialized > 0); +} + +bool ctrlm_irdb_t::get_initialized() { + return(this->initialized > 0); +} + + +bool ctrlm_irdb_t::_set_ir_codes(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_irdb_ir_code_set_t &ir_codes, ctrlm_irdb_vendor_t vendor) { + bool ret = false; + + XLOGD_INFO("Setting IR codes for (%u, %u)", network_id, controller_id); + + ctrlm_main_queue_msg_ir_set_code_t msg = {0}; + + msg.network_id = network_id; + msg.controller_id = controller_id; + msg.ir_codes = &ir_codes; + msg.success = &ret; + msg.vendor = vendor; + + ctrlm_main_queue_handler_push(CTRLM_HANDLER_NETWORK, (ctrlm_msg_handler_network_t)&ctrlm_obj_network_t::req_process_ir_set_code, &msg, sizeof(msg), NULL, network_id, true); + + return(ret); +} + +bool ctrlm_irdb_t::_clear_ir_codes(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id) { + bool ret = false; + + XLOGD_INFO("Clearing IR codes for (%u, %u)", network_id, controller_id); + + ctrlm_main_queue_msg_ir_clear_t msg = {0}; + + msg.network_id = network_id; + msg.controller_id = controller_id; + msg.success = &ret; + + ctrlm_main_queue_handler_push(CTRLM_HANDLER_NETWORK, (ctrlm_msg_handler_network_t)&ctrlm_obj_network_t::req_process_ir_clear_codes, &msg, sizeof(msg), NULL, network_id, true); + + return(ret); +} + +void ctrlm_irdb_t::normalize_string(std::string &str) { + std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { + switch (c) { + case u'à': case u'á': case u'ä': case u'â': case u'ã': case u'å': + case u'À': case u'Á': case u'Ä': case u'Â': case u'Ã': case u'Å': { + c = 'a'; + break; + } + case u'é': case u'è': case u'ê': case u'ë': + case u'È': case u'É': case u'Ê': case u'Ë': { + c = 'e'; + break; + } + case u'ì': case u'í': case u'î': case u'ï': + case u'Ì': case u'Í': case u'Î': case u'Ï': { + c = 'i'; + break; + } + case u'ò': case u'ó': case u'ô': case u'õ': case u'ö': case u'ø': + case u'Ò': case u'Ó': case u'Ô': case u'Õ': case u'Ö': case u'Ø': { + c = 'o'; + break; + } + case u'ù': case u'ú': case u'û': case u'ü': + case u'Ù': case u'Ú': case u'Û': case u'Ü': { + c = 'u'; + break; + } + case u'ß': { + c = 'b'; + break; + } + case u'Ñ': case u'ñ': { + c = 'n'; + break; + } + default: { + c = std::tolower(c); + break; + } + } + return(c); + }); +} diff --git a/src/irdb/ctrlm_irdb.h b/src/irdb/ctrlm_irdb.h new file mode 100644 index 00000000..b87fb42c --- /dev/null +++ b/src/irdb/ctrlm_irdb.h @@ -0,0 +1,150 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2014 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __CTRLM_IRDB_H__ +#define __CTRLM_IRDB_H__ + +#include +#include +#include +#include +#include +#include "ctrlm_hal.h" +#include "ctrlm_ipc_key_codes.h" +#include "ctrlm_ipc_iarm.h" + +typedef enum { + CTRLM_IRDB_MODE_OFFLINE, + CTRLM_IRDB_MODE_ONLINE, + CTRLM_IRDB_MODE_HYBRID +} ctrlm_irdb_mode_t; + +typedef enum { + CTRLM_IRDB_DEV_TYPE_TV, + CTRLM_IRDB_DEV_TYPE_AVR, + CTRLM_IRDB_DEV_TYPE_INVALID +} ctrlm_irdb_dev_type_t; + +typedef enum { + CTRLM_IRDB_VENDOR_UEI, + CTRLM_IRDB_VENDOR_RUWIDO, + CTRLM_IRDB_VENDOR_INVALID +} ctrlm_irdb_vendor_t; + +typedef std::vector ctrlm_irdb_ir_code_t; +typedef std::map ctrlm_irdb_ir_codes_t; + +typedef std::string ctrlm_irdb_manufacturer_t; +typedef std::vector ctrlm_irdb_manufacturer_list_t; +typedef std::string ctrlm_irdb_model_t; +typedef std::vector ctrlm_irdb_model_list_t; +typedef std::string ctrlm_irdb_ir_entry_id_t; +typedef std::vector ctrlm_irdb_ir_entry_id_list_t; + +// Autolookup +class ctrlm_irdb_autolookup_entry_ranked_t { +public: + ctrlm_irdb_manufacturer_t man; + ctrlm_irdb_model_t model; + ctrlm_irdb_ir_entry_id_t id; + int rank; + ctrlm_irdb_autolookup_entry_ranked_t() { + this->man = "Unknown"; + this->model = "Unknown"; + this->id = ""; + this->rank = 0; + } +}; +inline bool operator==(const ctrlm_irdb_autolookup_entry_ranked_t& lhs, const ctrlm_irdb_autolookup_entry_ranked_t& rhs) { + return (lhs.id.compare(rhs.id) == 0); +} + +typedef std::vector ctrlm_irdb_autolookup_ranked_list_t; +typedef std::map ctrlm_irdb_autolookup_ranked_list_by_type_t; +// End Autolookup + +class ctrlm_irdb_ir_code_set_t { +public: + ctrlm_irdb_ir_code_set_t(ctrlm_irdb_dev_type_t type = CTRLM_IRDB_DEV_TYPE_INVALID, const ctrlm_irdb_ir_entry_id_t &id = ""); + + void add_key(ctrlm_key_code_t key, ctrlm_irdb_ir_code_t ir_code); + ctrlm_irdb_ir_codes_t *get_key_map(); + ctrlm_irdb_dev_type_t get_type(); + ctrlm_irdb_ir_entry_id_t get_id(); + +private: + ctrlm_irdb_dev_type_t type_; + ctrlm_irdb_ir_entry_id_t id_; + ctrlm_irdb_ir_codes_t ir_codes_; +}; + +typedef struct { + ctrlm_network_id_t network_id; + ctrlm_controller_id_t controller_id; + ctrlm_irdb_ir_code_set_t * ir_codes; + bool * success; + sem_t * semaphore; + ctrlm_irdb_vendor_t vendor; +} ctrlm_main_queue_msg_ir_set_code_t; + +typedef struct { + ctrlm_network_id_t network_id; + ctrlm_controller_id_t controller_id; + bool * success; + sem_t * semaphore; +} ctrlm_main_queue_msg_ir_clear_t; + +class ctrlm_irdb_t { +public: + ctrlm_irdb_t(ctrlm_irdb_mode_t mode, bool platform_tv); + virtual ~ctrlm_irdb_t(); + + bool get_initialized(); + + virtual bool get_manufacturers(ctrlm_irdb_manufacturer_list_t &manufacturers, ctrlm_irdb_dev_type_t type, const std::string &prefix = "") = 0; + virtual bool get_models(ctrlm_irdb_model_list_t &models, ctrlm_irdb_dev_type_t type, ctrlm_irdb_manufacturer_t manufacturer, const std::string &prefix = "") = 0; + virtual bool get_ir_codes_by_names(ctrlm_irdb_ir_entry_id_list_t &codes, ctrlm_irdb_dev_type_t type, ctrlm_irdb_manufacturer_t manufacturer, const ctrlm_irdb_model_t &model = "") = 0; + virtual bool set_ir_codes_by_name(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_irdb_dev_type_t type, const ctrlm_irdb_ir_entry_id_t &name) = 0; + virtual bool clear_ir_codes(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id) = 0; + + virtual bool get_ir_codes_by_autolookup(ctrlm_irdb_autolookup_ranked_list_by_type_t &codes); + virtual bool initialize_irdb(); + virtual void on_thunder_ready(); + +protected: + virtual bool get_ir_codes_by_infoframe(ctrlm_irdb_autolookup_ranked_list_t &codes, ctrlm_irdb_dev_type_t &type, unsigned char *infoframe, size_t infoframe_len); + virtual bool get_ir_codes_by_edid(ctrlm_irdb_autolookup_ranked_list_t &codes, ctrlm_irdb_dev_type_t &type, unsigned char *edid, size_t edid_len); + virtual bool get_ir_codes_by_cec(ctrlm_irdb_autolookup_ranked_list_t &codes, ctrlm_irdb_dev_type_t &type, const std::string &osd, unsigned int vendor_id, unsigned int logical_address); + + virtual ctrlm_irdb_vendor_t get_vendor() = 0; + +protected: + bool _set_ir_codes(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id, ctrlm_irdb_ir_code_set_t &ir_codes, ctrlm_irdb_vendor_t vendor); + bool _clear_ir_codes(ctrlm_network_id_t network_id, ctrlm_controller_id_t controller_id); + void normalize_string(std::string &str); + +protected: + ctrlm_irdb_mode_t mode; + bool platform_tv; + ctrlm_ipc_iarm_t *ipc; + volatile int initialized; + +}; + +#endif diff --git a/src/irdb/ctrlm_irdb_factory.cpp b/src/irdb/ctrlm_irdb_factory.cpp new file mode 100644 index 00000000..20b736f1 --- /dev/null +++ b/src/irdb/ctrlm_irdb_factory.cpp @@ -0,0 +1,25 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2014 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include "ctrlm_irdb_factory.h" +#include "ctrlm_irdb_stub.h" + +ctrlm_irdb_t *ctrlm_irdb_create(bool platform_tv) { + return(new ctrlm_irdb_stub_t(CTRLM_IRDB_MODE_OFFLINE, platform_tv)); +} diff --git a/src/irdb/ctrlm_irdb_factory.h b/src/irdb/ctrlm_irdb_factory.h new file mode 100644 index 00000000..dfb3fbb7 --- /dev/null +++ b/src/irdb/ctrlm_irdb_factory.h @@ -0,0 +1,26 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2014 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __CTRLM_IRDB_FACTORY_H__ +#define __CTRLM_IRDB_FACTORY_H__ +#include "ctrlm_irdb.h" + +ctrlm_irdb_t *ctrlm_irdb_create(bool platform_tv); + +#endif diff --git a/src/irdb/ctrlm_irdb_plugin.h b/src/irdb/ctrlm_irdb_plugin.h index 7e1ced22..2262ca5d 100644 --- a/src/irdb/ctrlm_irdb_plugin.h +++ b/src/irdb/ctrlm_irdb_plugin.h @@ -24,18 +24,7 @@ #include #include - -typedef enum { - CTRLM_IRDB_MODE_OFFLINE, - CTRLM_IRDB_MODE_ONLINE, - CTRLM_IRDB_MODE_HYBRID -} ctrlm_irdb_mode_t; - -typedef enum { - CTRLM_IRDB_DEV_TYPE_TV, - CTRLM_IRDB_DEV_TYPE_AVR, - CTRLM_IRDB_DEV_TYPE_INVALID -} ctrlm_irdb_dev_type_t; +#include "ctrlm_irdb.h" typedef enum { CTRLM_IRDB_KEY_POWER_OFF = 0, @@ -54,26 +43,14 @@ typedef struct { unsigned char rcu_support_bitmask; } ctrlm_irdb_vendor_info_t; -typedef std::vector ctrlm_irdb_manufacturer_list_t; -typedef std::vector ctrlm_irdb_model_list_t; -typedef std::vector ctrlm_irdb_entry_id_list_t; +//typedef std::vector ctrlm_irdb_manufacturer_list_t; +//typedef std::vector ctrlm_irdb_model_list_t; +//typedef std::vector ctrlm_irdb_entry_id_list_t; typedef std::map> ctrlm_irdb_ir_waveforms_t; -typedef struct { - ctrlm_irdb_dev_type_t type; - std::string id; - ctrlm_irdb_ir_waveforms_t waveforms; -} ctrlm_irdb_ir_code_set_t; - -typedef struct { - std::string manufacturer; - std::string model; - std::string id; - int rank; -} ctrlm_irdb_autolookup_entry_ranked_t; -typedef std::vector ctrlm_irdb_autolookup_ranked_list_t; +//typedef std::vector ctrlm_irdb_autolookup_ranked_list_t; #ifdef __cplusplus @@ -108,4 +85,4 @@ bool ctrlm_irdb_get_ir_codes_by_cec(ctrlm_irdb_autolookup_ranked_list_t &codes, } #endif -#endif \ No newline at end of file +#endif diff --git a/src/voice/ctrlm_voice_obj.cpp b/src/voice/ctrlm_voice_obj.cpp index 2491ae9a..c8c7ee13 100644 --- a/src/voice/ctrlm_voice_obj.cpp +++ b/src/voice/ctrlm_voice_obj.cpp @@ -284,10 +284,12 @@ ctrlm_voice_t::~ctrlm_voice_t() { for(uint32_t group = VOICE_SESSION_GROUP_DEFAULT; group < VOICE_SESSION_GROUP_QTY; group++) { ctrlm_voice_session_t *session = &this->voice_session[group]; if(session->audio_pipe[PIPE_READ] >= 0) { + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_READ]); close(session->audio_pipe[PIPE_READ]); session->audio_pipe[PIPE_READ] = -1; } if(session->audio_pipe[PIPE_WRITE] >= 0) { + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_WRITE]); close(session->audio_pipe[PIPE_WRITE]); session->audio_pipe[PIPE_WRITE] = -1; } @@ -1489,7 +1491,9 @@ ctrlm_voice_session_response_status_t ctrlm_voice_t::voice_session_req(ctrlm_net XLOGD_TELEMETRY("Failed to acquire voice session"); this->voice_session_notify_abort(network_id, controller_id, 0, CTRLM_VOICE_SESSION_ABORT_REASON_BUSY); if(create_pipe) { + XLOGD_INFO("closing fd <%d>", fds[PIPE_WRITE]); close(fds[PIPE_WRITE]); + XLOGD_INFO("closing fd <%d>", fds[PIPE_READ]); close(fds[PIPE_READ]); } return(VOICE_SESSION_RESPONSE_BUSY); @@ -1803,11 +1807,13 @@ bool ctrlm_voice_t::voice_session_data(ctrlm_network_id_t network_id, ctrlm_cont } else { if(session->audio_pipe[PIPE_READ] >= 0) { XLOGD_INFO("Closing previous pipe - READ fd <%d>", session->audio_pipe[PIPE_READ]); + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_READ]); close(session->audio_pipe[PIPE_READ]); session->audio_pipe[PIPE_READ] = -1; } if(session->audio_pipe[PIPE_WRITE] >= 0) { XLOGD_INFO("Closing previous pipe - WRITE fd <%d>", session->audio_pipe[PIPE_WRITE]); + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_WRITE]); close(session->audio_pipe[PIPE_WRITE]); session->audio_pipe[PIPE_WRITE] = -1; } @@ -1925,6 +1931,7 @@ void ctrlm_voice_t::voice_session_end(ctrlm_voice_session_t *session, ctrlm_voic if(session->audio_pipe[PIPE_WRITE] >= 0) { XLOGD_INFO("Close write pipe - fd <%d>", session->audio_pipe[PIPE_WRITE]); + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_WRITE]); close(session->audio_pipe[PIPE_WRITE]); session->audio_pipe[PIPE_WRITE] = -1; } diff --git a/src/voice/ctrlm_voice_obj_generic.cpp b/src/voice/ctrlm_voice_obj_generic.cpp index 340b295d..977bf04a 100644 --- a/src/voice/ctrlm_voice_obj_generic.cpp +++ b/src/voice/ctrlm_voice_obj_generic.cpp @@ -123,6 +123,7 @@ void ctrlm_voice_generic_t::voice_sdk_close() { if(session->audio_pipe[PIPE_WRITE] >= 0) { // close the audio input source XLOGD_WARN("Closing audio write pipe <%d>", session->audio_pipe[PIPE_WRITE]); + XLOGD_INFO("closing fd <%d>", session->audio_pipe[PIPE_WRITE]); close(session->audio_pipe[PIPE_WRITE]); session->audio_pipe[PIPE_WRITE] = -1; } diff --git a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp index ad9cc5db..a45a0a17 100644 --- a/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp +++ b/src/voice/ipc/ctrlm_voice_ipc_iarm_thunder.cpp @@ -736,6 +736,7 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) XLOGD_ERROR("zero length audio data <%s>", str_audio_file.c_str()); result = false; } + XLOGD_INFO("closing fd <%d>", audio_fd); close(audio_fd); } } @@ -765,6 +766,7 @@ IARM_Result_t ctrlm_voice_ipc_iarm_thunder_t::voice_session_request(void *data) voice_status != VOICE_SESSION_RESPONSE_AVAILABLE_PAR_VOICE) { XLOGD_ERROR("Failed opening voice session <%s>", ctrlm_voice_session_response_status_str(voice_status)); if(fd >= 0) { + XLOGD_INFO("closing fd <%d>", fd); close(fd); } result = false;