Skip to content

Commit

Permalink
Merge pull request rdkcentral#5111 from yuvaramachandran-gurusamy/rel…
Browse files Browse the repository at this point in the history
…ease/xumo_2/RDK-48709

RDK-48709: Synchronize the MiracastService discovery
  • Loading branch information
apatel859 authored Apr 8, 2024
2 parents 259e4a3 + 547dc50 commit 3f5a280
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
5 changes: 5 additions & 0 deletions Miracast/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ 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 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
- Added the timer to get and update the friendlyName for Miracast if it fails get it from SystemServices.
Expand Down
30 changes: 17 additions & 13 deletions Miracast/MiracastService/MiracastController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -637,7 +636,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;

Expand Down Expand Up @@ -1067,7 +1065,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;
}
}
Expand Down Expand Up @@ -1140,14 +1138,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:
Expand All @@ -1163,7 +1161,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;
Expand Down Expand Up @@ -1244,7 +1242,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:
Expand Down Expand Up @@ -1557,16 +1555,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...");
}

Expand Down
8 changes: 6 additions & 2 deletions Miracast/MiracastService/MiracastService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions Miracast/P2P/MiracastP2P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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*/
Expand All @@ -482,9 +482,17 @@ MiracastError MiracastP2P::stop_discover_devices(void)
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)
{
MIRACASTLOG_ERROR("Failed to Stop discovering devices");
}

MIRACASTLOG_TRACE("Exiting...");
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions Miracast/include/MiracastController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3f5a280

Please sign in to comment.