Skip to content

Commit

Permalink
Merge pull request rdkcentral#4548 from VenkateshUmmadiSetty/framerat…
Browse files Browse the repository at this point in the history
…e-main

RDKDEV-796: RDKCOM-4076: [RDKServices]: Failed to get Event "client.e…
  • Loading branch information
apatel859 authored Nov 3, 2023
2 parents 791611e + acd6c76 commit b918879
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 43 deletions.
4 changes: 4 additions & 0 deletions FrameRate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

## [1.0.5] - 2023-11-03
### Changed
- Sending FrameRate plugin onDisplayFrameRateChanging and onDisplayFrameRateChanged events to wpeframework log with displayFrameRate params

## [1.0.4] - 2023-09-12
### Added
- Implement Thunder Plugin Configuration for Kirkstone builds(CMake-3.20 & above)
Expand Down
29 changes: 25 additions & 4 deletions FrameRate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,34 @@ set_target_properties(${MODULE_NAME} PROPERTIES

target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME})

find_package(DS)
if (NOT RDK_SERVICES_TEST)
target_compile_options(${MODULE_NAME} PRIVATE -Wno-error)
endif ()

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/")

find_package(IARMBus)
if (IARMBus_FOUND)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES})
else (IARMBus_FOUND)
message ("Module IARMBus required.")
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES})
endif(IARMBus_FOUND)

add_definitions(-DDS_FOUND)
find_package(DS)
if (DS_FOUND)
find_package(IARMBus)
add_definitions(-DDS_FOUND)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES})
else (DS_FOUND)
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins)
endif(DS_FOUND)

target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS})
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_include_directories(${MODULE_NAME} PRIVATE ../helpers)

set_source_files_properties(FrameRate.cpp PROPERTIES COMPILE_FLAGS "-fexceptions")
Expand Down
40 changes: 33 additions & 7 deletions FrameRate/FrameRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 0
#define API_VERSION_NUMBER_PATCH 3
#define API_VERSION_NUMBER_PATCH 5

namespace WPEFramework
{
Expand Down Expand Up @@ -455,28 +455,54 @@ namespace WPEFramework

void FrameRate::FrameRatePreChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
char dispFrameRate[20] ={0};
if (strcmp(owner, IARM_BUS_DSMGR_NAME) == 0)
{
switch (eventId) {
case IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE:
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
strcpy(dispFrameRate,eventData->data.DisplayFrameRateChange.framerate);
break;
}
}

if(FrameRate::_instance)
{
FrameRate::_instance->frameRatePreChange();
FrameRate::_instance->frameRatePreChange(dispFrameRate);
}
}

void FrameRate::frameRatePreChange()
void FrameRate::frameRatePreChange(char *displayFrameRate)
{
sendNotify(EVENT_FRAMERATE_PRECHANGE, JsonObject());
JsonObject params;
params["displayFrameRate"] = std::string(displayFrameRate);
sendNotify(EVENT_FRAMERATE_PRECHANGE, params);
}

void FrameRate::FrameRatePostChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
char dispFrameRate[20] ={0};
if (strcmp(owner, IARM_BUS_DSMGR_NAME) == 0)
{
switch (eventId) {
case IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE:
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
strcpy(dispFrameRate,eventData->data.DisplayFrameRateChange.framerate);
break;
}
}

if(FrameRate::_instance)
{
FrameRate::_instance->frameRatePostChange();
FrameRate::_instance->frameRatePostChange(dispFrameRate);
}
}

void FrameRate::frameRatePostChange()
void FrameRate::frameRatePostChange(char *displayFrameRate)
{
sendNotify(EVENT_FRAMERATE_POSTCHANGE, JsonObject());
JsonObject params;
params["displayFrameRate"] = std::string(displayFrameRate);
sendNotify(EVENT_FRAMERATE_POSTCHANGE, params);
}


Expand Down
4 changes: 2 additions & 2 deletions FrameRate/FrameRate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ namespace WPEFramework {
void InitializeIARM();
void DeinitializeIARM();

void frameRatePreChange();
void frameRatePreChange(char *displayFrameRate);
static void FrameRatePreChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len);

void frameRatePostChange();
void frameRatePostChange(char *displayFrameRate);
static void FrameRatePostChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len);


Expand Down
26 changes: 23 additions & 3 deletions FrameRate/FrameRate.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,30 @@
},
"events":{
"onDisplayFrameRateChanging":{
"summary": "Triggered when the framerate changes started"
"summary": "Triggered when the framerate changes started",
"params": {
"type":"object",
"properties": {
"displayFrameRate": {
"summary": "Video Display FrameRate changing",
"type": "string",
"example": "1920x1080x60"
}
}
}
},
"onDisplayFrameRateChanged":{
"summary": "Triggered when the framerate changed"
"summary": "Triggered when the framerate changed",
"params": {
"type":"object",
"properties": {
"displayFrameRate": {
"summary": "Video Display FrameRate changed",
"type": "string",
"example": "1920x1080x60"
}
}
}
},
"onFpsEvent":{
"summary": "Triggered at the end of each interval as defined by the `setCollectionFrequency` method and once after the `stopFpsCollection` method is invoked.",
Expand Down Expand Up @@ -197,4 +217,4 @@
}
}
}
}
}
51 changes: 51 additions & 0 deletions FrameRate/cmake/FindDS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 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.

# - Try to find Display Settings library
# Once done this will define
# DS_FOUND - System has DS
# DS_INCLUDE_DIRS - The DS include directories
# DS_LIBRARIES - The libraries needed to use DS
# DS_FLAGS - The flags needed to use DS
#

find_package(PkgConfig)

find_library(DS_LIBRARIES NAMES ds)
find_library(DSHAL_LIBRARIES NAMES dshalcli)
find_library(OEMHAL_LIBRARIES NAMES ds-hal)
find_library(IARMBUS_LIBRARIES NAMES IARMBus)
find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds)
find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/ds-hal)
find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc)

set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES})
set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library")
set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS})
set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include")



include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES)

mark_as_advanced(
DS_FOUND
DS_INCLUDE_DIRS
DS_LIBRARIES
DS_LIBRARY_DIRS
DS_FLAGS)
46 changes: 46 additions & 0 deletions FrameRate/cmake/FindIARMBus.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 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.

# - Try to find IARMBus
# Once done this will define
# IARMBUS_FOUND - System has IARMBus
# IARMBUS_INCLUDE_DIRS - The IARMBus include directories
# IARMBUS_LIBRARIES - The libraries needed to use IARMBus
# IARMBUS_FLAGS - The flags needed to use IARMBus
#

find_package(PkgConfig)

find_library(IARMBUS_LIBRARIES NAMES IARMBus)
find_path(IARMBUS_INCLUDE_DIRS NAMES libIARM.h PATH_SUFFIXES rdk/iarmbus)
find_path(IARMIR_INCLUDE_DIRS NAMES irMgr.h PATH_SUFFIXES rdk/iarmmgrs/ir)
find_path(IARMRECEIVER_INCLUDE_DIRS NAMES receiverMgr.h PATH_SUFFIXES rdk/iarmmgrs/receiver)
find_path(IARMPWR_INCLUDE_DIRS NAMES pwrMgr.h PATH_SUFFIXES rdk/iarmmgrs-hal)

set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library")
set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS})
set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS} CACHE PATH "Path to IARMBus include")

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES)

mark_as_advanced(
IARMBUS_FOUND
IARMBUS_INCLUDE_DIRS
IARMBUS_LIBRARIES
IARMBUS_LIBRARY_DIRS
IARMBUS_FLAGS)
3 changes: 3 additions & 0 deletions Tests/mocks/devicesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ typedef struct _DSMgr_EventData_t {
int audio_output_delay;
int video_latency;
}hdmi_in_av_latency; /*HDMI in AVLatency change*/
struct _DISPLAY_FRAMERATE_CHANGE {
char framerate[20];
}DisplayFrameRateChange;
} data;
} IARM_Bus_DSMgr_EventData_t;

Expand Down
47 changes: 25 additions & 22 deletions Tests/tests/test_FrameRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "IarmBusMock.h"
#include "ServiceMock.h"
#include "VideoDeviceMock.h"
#include "devicesettings.h"
#include "dsMgr.h"

using namespace WPEFramework;
Expand All @@ -32,8 +33,8 @@ class FrameRateTest : public ::testing::Test {
class FrameRateInitializedTest : public FrameRateTest {
protected:
NiceMock<IarmBusImplMock> iarmBusImplMock;
IARM_EventHandler_t handlerOnDisplayFrameRateChanging;
IARM_EventHandler_t handlerOnDisplayFrameRateChanged;
IARM_EventHandler_t FrameRatePreChange;
IARM_EventHandler_t FrameRatePostChange;

FrameRateInitializedTest()
: FrameRateTest()
Expand All @@ -43,11 +44,11 @@ class FrameRateInitializedTest : public FrameRateTest {
ON_CALL(iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_))
.WillByDefault(::testing::Invoke(
[&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) {
if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE)) {
handlerOnDisplayFrameRateChanging = handler;
if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE)) {
FrameRatePreChange = handler;
}
if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE)) {
handlerOnDisplayFrameRateChanged = handler;
if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE)) {
FrameRatePostChange = handler;
}
return IARM_RESULT_SUCCESS;
}));
Expand Down Expand Up @@ -199,7 +200,7 @@ TEST_F(FrameRateDsTest, DISABLED_getDisplayFrameRate)

TEST_F(FrameRateInitializedEventTest, onDisplayFrameRateChanging)
{
ASSERT_TRUE(handlerOnDisplayFrameRateChanging != nullptr);
ASSERT_TRUE(FrameRatePreChange != nullptr);
EXPECT_CALL(service, Submit(::testing::_, ::testing::_))
.Times(1)
.WillOnce(::testing::Invoke(
Expand All @@ -208,22 +209,23 @@ TEST_F(FrameRateInitializedEventTest, onDisplayFrameRateChanging)
EXPECT_TRUE(json->ToString(text));
EXPECT_EQ(text, string(_T("{"
"\"jsonrpc\":\"2.0\","
"\"method\":\"org.rdk.FrameRate.onDisplayFrameRateChanging\","
"\"params\":{}"
"\"method\":\"client.events.onDisplayFrameRateChanging.onDisplayFrameRateChanging\","
"\"params\":{\"displayFrameRate\":\"3840x2160px48\"}"
"}")));

return Core::ERROR_NONE;
}));
IARM_Bus_DSMgr_EventData_t eventData;
strcpy(eventData.data.DisplayFrameRateChange.framerate,"3840x2160px48");

ASSERT_TRUE(handlerOnDisplayFrameRateChanging != nullptr);
handler.Subscribe(0, _T("onDisplayFrameRateChanging"), _T("org.rdk.FrameRate"), message);
handlerOnDisplayFrameRateChanging(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE, nullptr, 0);
handler.Unsubscribe(0, _T("onDisplayFrameRateChanging"), _T("org.rdk.FrameRate"), message);
ASSERT_TRUE(FrameRatePreChange != nullptr);
handler.Subscribe(0, _T("onDisplayFrameRateChanging"), _T("client.events.onDisplayFrameRateChanging"), message);
FrameRatePreChange(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE, &eventData , sizeof(eventData));
handler.Unsubscribe(0, _T("onDisplayFrameRateChanging"), _T("client.events.onDisplayFrameRateChanging"), message);
}

TEST_F(FrameRateInitializedEventTest, onDisplayFrameRateChanged)
{
ASSERT_TRUE(handlerOnDisplayFrameRateChanged != nullptr);
ASSERT_TRUE(FrameRatePostChange != nullptr);
EXPECT_CALL(service, Submit(::testing::_, ::testing::_))
.Times(1)
.WillOnce(::testing::Invoke(
Expand All @@ -232,15 +234,16 @@ TEST_F(FrameRateInitializedEventTest, onDisplayFrameRateChanged)
EXPECT_TRUE(json->ToString(text));
EXPECT_EQ(text, string(_T("{"
"\"jsonrpc\":\"2.0\","
"\"method\":\"org.rdk.FrameRate.onDisplayFrameRateChanged\","
"\"params\":{}"
"\"method\":\"client.events.onDisplayFrameRateChanged.onDisplayFrameRateChanged\","
"\"params\":{\"displayFrameRate\":\"3840x2160px48\"}"
"}")));

return Core::ERROR_NONE;
}));
IARM_Bus_DSMgr_EventData_t eventData;
strcpy(eventData.data.DisplayFrameRateChange.framerate,"3840x2160px48");

ASSERT_TRUE(handlerOnDisplayFrameRateChanged != nullptr);
handler.Subscribe(0, _T("onDisplayFrameRateChanged"), _T("org.rdk.FrameRate"), message);
handlerOnDisplayFrameRateChanged(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE, nullptr, 0);
handler.Unsubscribe(0, _T("onDisplayFrameRateChanged"), _T("org.rdk.FrameRate"), message);
ASSERT_TRUE(FrameRatePostChange != nullptr);
handler.Subscribe(0, _T("onDisplayFrameRateChanged"), _T("client.events.onDisplayFrameRateChanged"), message);
FrameRatePostChange(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE, &eventData , sizeof(eventData));
handler.Unsubscribe(0, _T("onDisplayFrameRateChanged"), _T("client.events.onDisplayFrameRateChanged"), message);
}
Loading

0 comments on commit b918879

Please sign in to comment.