From c51c3d17b73870804d2f7fbebfbe7ee139363ec3 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Tue, 2 Apr 2024 13:55:03 +0000 Subject: [PATCH 1/3] 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 61e66f9326166f5f18e299fb1c10e85d9a249965 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Tue, 2 Apr 2024 18:28:27 +0000 Subject: [PATCH 2/3] 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 e6a172324e1a6569db135b5cbfb404803ee6750f Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 3 Apr 2024 04:10:27 +0000 Subject: [PATCH 3/3] 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; }