From a1ccfaff2ad08dd52db723e927a08a484899fd8b Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Tue, 2 Apr 2024 13:55:03 +0000 Subject: [PATCH 1/6] RDK-48709 - Synchronizing the enable/disbable the MiracastService discovery Signed-off-by: yuvaramachandran_gurusamy --- .../MiracastService/MiracastController.cpp | 27 +++++++++++-------- Miracast/include/MiracastController.h | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Miracast/MiracastService/MiracastController.cpp b/Miracast/MiracastService/MiracastController.cpp index 7b787b2db3..53808ada4e 100644 --- a/Miracast/MiracastService/MiracastController.cpp +++ b/Miracast/MiracastService/MiracastController.cpp @@ -637,7 +637,6 @@ void MiracastController::Controller_Thread(void *args) CONTROLLER_MSGQ_STRUCT controller_msgq_data = {0}; bool new_thunder_req_client_connection_sent = false, another_thunder_req_client_connection_sent = false, - start_discovering_enabled = false, session_restart_required = false, p2p_group_instance_alive = false; @@ -1067,7 +1066,7 @@ void MiracastController::Controller_Thread(void *args) m_notify_handler->onMiracastServiceClientConnectionError( mac_address , device_name , error_code ); } MIRACASTLOG_INFO("!!! Restarting Session !!!"); - restart_session(start_discovering_enabled); + restart_session(m_start_discovering_enabled); session_restart_required = false; } } @@ -1140,14 +1139,14 @@ void MiracastController::Controller_Thread(void *args) MIRACASTLOG_INFO("CONTROLLER_START_DISCOVERING Received\n"); set_WFDParameters(); discover_devices(); - start_discovering_enabled = true; + m_start_discovering_enabled = true; } break; case CONTROLLER_STOP_DISCOVERING: { MIRACASTLOG_INFO("CONTROLLER_STOP_DISCOVERING Received\n"); stop_session(true); - start_discovering_enabled = false; + m_start_discovering_enabled = false; } break; case CONTROLLER_RESTART_DISCOVERING: @@ -1163,7 +1162,7 @@ void MiracastController::Controller_Thread(void *args) reset_NewSourceName(); MIRACASTLOG_INFO("[%s] Cached Device info removed...",cached_mac_address.c_str()); } - restart_session(start_discovering_enabled); + restart_session(m_start_discovering_enabled); new_thunder_req_client_connection_sent = false; another_thunder_req_client_connection_sent = false; session_restart_required = true; @@ -1244,7 +1243,7 @@ void MiracastController::Controller_Thread(void *args) { MIRACASTLOG_INFO("TEARDOWN request sent to RTSP handler\n"); //stop_streaming(CONTROLLER_TEARDOWN_REQ_FROM_THUNDER); - restart_session(start_discovering_enabled); + restart_session(m_start_discovering_enabled); } break; default: @@ -1557,16 +1556,22 @@ void MiracastController::send_thundermsg_to_controller_thread(MIRACAST_SERVICE_S void MiracastController::set_enable(bool is_enabled) { - MIRACAST_SERVICE_STATES state = MIRACAST_SERVICE_WFD_STOP; - MIRACASTLOG_TRACE("Entering..."); if ( true == is_enabled) { - state = MIRACAST_SERVICE_WFD_START; + MIRACASTLOG_INFO("MIRACAST_SERVICE_WFD_START Received"); + set_WFDParameters(); + discover_devices(); + m_start_discovering_enabled = true; } - - send_thundermsg_to_controller_thread(state); + else + { + MIRACASTLOG_INFO("MIRACAST_SERVICE_WFD_STOP Received"); + stop_session(true); + m_start_discovering_enabled = false; + } + //send_thundermsg_to_controller_thread(state); MIRACASTLOG_TRACE("Exiting..."); } diff --git a/Miracast/include/MiracastController.h b/Miracast/include/MiracastController.h index 7e1aad5967..e94e865c51 100644 --- a/Miracast/include/MiracastController.h +++ b/Miracast/include/MiracastController.h @@ -137,6 +137,7 @@ class MiracastController GroupInfo *m_groupInfo; bool m_connectionStatus; bool m_p2p_backend_discovery{false}; + bool m_start_discovering_enabled{false}; std::string m_current_device_name; std::string m_current_device_mac_addr; From 716b243810e200d4ecca25419ce35056d0b4957a Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Tue, 2 Apr 2024 18:28:27 +0000 Subject: [PATCH 2/6] RDK-48709 - Synchronizing the enable/disbable the MiracastService discovery - Added the opt flag to use P2P_STOP_FIND or P2P_EXT_LISTEN 0 0 with microseconds delay Signed-off-by: yuvaramachandran_gurusamy --- Miracast/P2P/MiracastP2P.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Miracast/P2P/MiracastP2P.cpp b/Miracast/P2P/MiracastP2P.cpp index 29d5e18673..ac0b5c2e1d 100644 --- a/Miracast/P2P/MiracastP2P.cpp +++ b/Miracast/P2P/MiracastP2P.cpp @@ -457,7 +457,7 @@ void MiracastP2P::reset_WFDParameters(void) MiracastError MiracastP2P::discover_devices(void) { MiracastError ret = MIRACAST_FAIL; - std::string command, retBuffer,opt_flag_buffer; + std::string command, retBuffer; MIRACASTLOG_TRACE("Entering.."); /*Start Passive Scanning*/ @@ -478,13 +478,29 @@ MiracastError MiracastP2P::stop_discover_devices(void) std::string command, retBuffer; MIRACASTLOG_TRACE("Entering..."); + std::string opt_flag_buffer = MiracastCommon::parse_opt_flag( "/opt/miracast_custom_stop_discovery" , true ); + /*Stop Passive Scanning*/ - command = "P2P_EXT_LISTEN 0 0"; + if (opt_flag_buffer.empty()) + { + command = "P2P_STOP_FIND"; + } + else + { + command = "P2P_EXT_LISTEN 0 0"; + } + ret = executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); if (ret != MIRACAST_OK) { MIRACASTLOG_ERROR("Failed to Stop discovering devices"); } + + if (!opt_flag_buffer.empty()) + { + usleep(std::stoul(opt_flag_buffer)); + MIRACASTLOG_INFO("micro sleep[%s]",opt_flag_buffer); + } MIRACASTLOG_TRACE("Exiting..."); return ret; } From fe64910818473b083256359d6dc46c0818c2ded3 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 3 Apr 2024 04:10:27 +0000 Subject: [PATCH 3/6] RDK-48709 - Synchronizing the enable/disbable the MiracastService discovery - Removed the opt flag and directly used the P2P_STOP_FIND to stop the Discovery Signed-off-by: yuvaramachandran_gurusamy --- Miracast/P2P/MiracastP2P.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Miracast/P2P/MiracastP2P.cpp b/Miracast/P2P/MiracastP2P.cpp index ac0b5c2e1d..327cf2ecf4 100644 --- a/Miracast/P2P/MiracastP2P.cpp +++ b/Miracast/P2P/MiracastP2P.cpp @@ -478,17 +478,8 @@ MiracastError MiracastP2P::stop_discover_devices(void) std::string command, retBuffer; MIRACASTLOG_TRACE("Entering..."); - std::string opt_flag_buffer = MiracastCommon::parse_opt_flag( "/opt/miracast_custom_stop_discovery" , true ); - /*Stop Passive Scanning*/ - if (opt_flag_buffer.empty()) - { - command = "P2P_STOP_FIND"; - } - else - { - command = "P2P_EXT_LISTEN 0 0"; - } + command = "P2P_STOP_FIND"; ret = executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); if (ret != MIRACAST_OK) @@ -496,11 +487,6 @@ MiracastError MiracastP2P::stop_discover_devices(void) MIRACASTLOG_ERROR("Failed to Stop discovering devices"); } - if (!opt_flag_buffer.empty()) - { - usleep(std::stoul(opt_flag_buffer)); - MIRACASTLOG_INFO("micro sleep[%s]",opt_flag_buffer); - } MIRACASTLOG_TRACE("Exiting..."); return ret; } From 1b31b8074ee93c7d6c7f74cc205b9f3aa61e390b Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 3 Apr 2024 20:20:00 +0000 Subject: [PATCH 4/6] RDK-48709 - Synchronizing the enable/disbable the MiracastService discovery - updated the CHANGELOG.md and version Signed-off-by: yuvaramachandran_gurusamy --- Miracast/CHANGELOG.md | 4 ++++ Miracast/MiracastService/MiracastService.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Miracast/CHANGELOG.md b/Miracast/CHANGELOG.md index beeb725cd7..84fdb12285 100644 --- a/Miracast/CHANGELOG.md +++ b/Miracast/CHANGELOG.md @@ -13,6 +13,10 @@ All notable changes to this RDK Service will be documented in this file. 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. For more details, refer to versioning section under Main README. +## [1.0.5] - 2024-04-04 +### Fixed +- Added the synchronization the enable/disbable the MiracastService discovery. + ## [1.0.4] - 2024-03-06 ### Fixed - Added the timer to get and update the friendlyName for Miracast if it fails get it from SystemServices. diff --git a/Miracast/MiracastService/MiracastService.cpp b/Miracast/MiracastService/MiracastService.cpp index ac5f976f19..9b4fddb8d7 100644 --- a/Miracast/MiracastService/MiracastService.cpp +++ b/Miracast/MiracastService/MiracastService.cpp @@ -47,7 +47,7 @@ using namespace std; #define API_VERSION_NUMBER_MAJOR 1 #define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 4 +#define API_VERSION_NUMBER_PATCH 5 #define SERVER_DETAILS "127.0.0.1:9998" #define SYSTEM_CALLSIGN "org.rdk.System" From 8dfe748717da9e01af7785d15f7b0e67fbc436e6 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Fri, 5 Apr 2024 19:34:17 +0000 Subject: [PATCH 5/6] RDKTV-30015 - [miracast] TV is discoverable when casting option is off resulting random ENT errors Signed-off-by: yuvaramachandran_gurusamy --- Miracast/MiracastService/MiracastController.cpp | 3 +-- Miracast/MiracastService/MiracastService.cpp | 6 +++++- Miracast/P2P/MiracastP2P.cpp | 10 ++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Miracast/MiracastService/MiracastController.cpp b/Miracast/MiracastService/MiracastController.cpp index 53808ada4e..3cc84e146d 100644 --- a/Miracast/MiracastService/MiracastController.cpp +++ b/Miracast/MiracastService/MiracastController.cpp @@ -462,8 +462,7 @@ void MiracastController::event_handler(P2P_EVENTS eventId, void *data, size_t le event_buffer = (char *)data; free(data); - std::string opt_flag_buffer = MiracastCommon::parse_opt_flag("/opt/miracast_suppress_p2p_events"); - if (!opt_flag_buffer.empty()) + if ( false == m_start_discovering_enabled ) { MIRACASTLOG_TRACE("Exiting..."); return; diff --git a/Miracast/MiracastService/MiracastService.cpp b/Miracast/MiracastService/MiracastService.cpp index 9b4fddb8d7..6c45a46b10 100644 --- a/Miracast/MiracastService/MiracastService.cpp +++ b/Miracast/MiracastService/MiracastService.cpp @@ -298,7 +298,11 @@ namespace WPEFramework } else { - if (m_isServiceEnabled) + if ( MIRACAST_SERVICE_STATE_PLAYER_LAUNCHED == m_eService_state ) + { + response["message"] = "Failed as MiracastPlayer already Launched"; + } + else if (m_isServiceEnabled) { m_miracast_ctrler_obj->set_enable(is_enabled); success = true; diff --git a/Miracast/P2P/MiracastP2P.cpp b/Miracast/P2P/MiracastP2P.cpp index 327cf2ecf4..652e676352 100644 --- a/Miracast/P2P/MiracastP2P.cpp +++ b/Miracast/P2P/MiracastP2P.cpp @@ -422,7 +422,7 @@ MiracastError MiracastP2P::set_WFDParameters(void) { command = "SET config_methods pbc"; } - executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); + executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); set_FriendlyName(get_FriendlyName() , true); /* Set Device type */ @@ -479,8 +479,14 @@ MiracastError MiracastP2P::stop_discover_devices(void) MIRACASTLOG_TRACE("Entering..."); /*Stop Passive Scanning*/ - command = "P2P_STOP_FIND"; + command = "P2P_EXT_LISTEN 0 0"; + ret = executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); + if (ret != MIRACAST_OK) + { + MIRACASTLOG_ERROR("Failed to stop discovering devices"); + } + command = "P2P_STOP_FIND"; ret = executeCommand(command, NON_GLOBAL_INTERFACE, retBuffer); if (ret != MIRACAST_OK) { From 547dc5010e4e78f9ca5b42cc1de23fc937c70824 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Fri, 5 Apr 2024 19:56:54 +0000 Subject: [PATCH 6/6] Updated the CHANGELOG.md Signed-off-by: yuvaramachandran_gurusamy --- Miracast/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Miracast/CHANGELOG.md b/Miracast/CHANGELOG.md index 84fdb12285..dcd8c15c8b 100644 --- a/Miracast/CHANGELOG.md +++ b/Miracast/CHANGELOG.md @@ -15,7 +15,8 @@ All notable changes to this RDK Service will be documented in this file. For more details, refer to versioning section under Main README. ## [1.0.5] - 2024-04-04 ### Fixed -- Added the synchronization the enable/disbable the MiracastService discovery. +- Added the synchronization for enable/disable the MiracastService discovery. +- Added the check to avoid the P2P events when MiracastService discovery not enabled. ## [1.0.4] - 2024-03-06 ### Fixed