diff --git a/CMakeLists.txt b/CMakeLists.txt index eb66410b7..25962f6c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,7 @@ if( NATIVE_BUILD ) add_subdirectory( stubs/opencdm ) add_subdirectory( stubs/wpeframework-core ) add_subdirectory( stubs/wpeframework-com ) + add_subdirectory( stubs/rdk_perf ) add_compile_options(-DFREE_MEM_BEFORE_EXIT) add_compile_options(-ggdb) diff --git a/media/server/CMakeLists.txt b/media/server/CMakeLists.txt index 05d4ec2a2..a8855817b 100644 --- a/media/server/CMakeLists.txt +++ b/media/server/CMakeLists.txt @@ -47,6 +47,7 @@ target_include_directories ( $ $ $ + $ ) set_target_properties( @@ -61,6 +62,7 @@ target_link_libraries( RialtoServerIpc RialtoServerMain RialtoServerService + RialtoWrappers protobuf::libprotobuf ) diff --git a/media/server/gstplayer/include/GstGenericPlayer.h b/media/server/gstplayer/include/GstGenericPlayer.h index 93e163f5a..cb8892470 100644 --- a/media/server/gstplayer/include/GstGenericPlayer.h +++ b/media/server/gstplayer/include/GstGenericPlayer.h @@ -31,6 +31,7 @@ #include "IGstProtectionMetadataHelperFactory.h" #include "IGstSrc.h" #include "IGstWrapper.h" +#include "IRdkPerfWrapper.h" #include "ITimer.h" #include "IWorkerThread.h" #include "tasks/IGenericPlayerTaskFactory.h" @@ -80,6 +81,8 @@ class GstGenericPlayer : public IGstGenericPlayer, public IGstGenericPlayerPriva * @param[in] videoRequirements : The video requirements for the playback. * @param[in] gstWrapper : The gstreamer wrapper. * @param[in] glibWrapper : The glib wrapper. + * @param[in] rdkGstreamerUtilsWrapper : The rdk gstreamer utils wrapper + * @param[in] rdkPerfWrapperFactory : The rdk perf wrapper factory * @param[in] gstInitialiser : The gst initialiser * @param[in] flushWatcher : The flush watcher * @param[in] gstSrcFactory : The gstreamer rialto src factory. @@ -87,12 +90,14 @@ class GstGenericPlayer : public IGstGenericPlayer, public IGstGenericPlayerPriva * @param[in] taskFactory : The task factory * @param[in] workerThreadFactory : The worker thread factory * @param[in] gstDispatcherThreadFactory : The gst dispatcher thread factory + * @param[in] gstProtectionMetadataFactory : The gst protection metadata helper factory */ GstGenericPlayer(IGstGenericPlayerClient *client, IDecryptionService &decryptionService, MediaType type, const VideoRequirements &videoRequirements, const std::shared_ptr &gstWrapper, const std::shared_ptr &glibWrapper, const std::shared_ptr &rdkGstreamerUtilsWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, const IGstInitialiser &gstInitialiser, std::unique_ptr &&flushWatcher, const std::shared_ptr &gstSrcFactory, std::shared_ptr timerFactory, @@ -431,6 +436,11 @@ class GstGenericPlayer : public IGstGenericPlayer, public IGstGenericPlayerPriva */ std::shared_ptr m_rdkGstreamerUtilsWrapper; + /** + * @brief The rdk perf wrapper factory object + */ + std::shared_ptr m_rdkPerfWrapperFactory; + /** * @brief Thread for handling player tasks. */ diff --git a/media/server/gstplayer/include/tasks/generic/GenericPlayerTaskFactory.h b/media/server/gstplayer/include/tasks/generic/GenericPlayerTaskFactory.h index 79e31838b..74eb02b8f 100644 --- a/media/server/gstplayer/include/tasks/generic/GenericPlayerTaskFactory.h +++ b/media/server/gstplayer/include/tasks/generic/GenericPlayerTaskFactory.h @@ -26,6 +26,7 @@ #include "IGstTextTrackSinkFactory.h" #include "IGstWrapper.h" #include "IMediaPipeline.h" +#include "IRdkPerfWrapper.h" #include #include @@ -38,6 +39,7 @@ class GenericPlayerTaskFactory : public IGenericPlayerTaskFactory IGstGenericPlayerClient *client, const std::shared_ptr &gstWrapper, const std::shared_ptr &glibWrapper, const std::shared_ptr &rdkGstreamerUtilsWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, const std::shared_ptr &gstTextTrackSinkFactory); ~GenericPlayerTaskFactory() override = default; @@ -140,6 +142,7 @@ class GenericPlayerTaskFactory : public IGenericPlayerTaskFactory std::shared_ptr m_gstWrapper; std::shared_ptr m_glibWrapper; std::shared_ptr m_rdkGstreamerUtilsWrapper; + std::shared_ptr m_rdkPerfWrapperFactory; std::shared_ptr m_gstTextTrackSinkFactory; }; } // namespace firebolt::rialto::server diff --git a/media/server/gstplayer/include/tasks/generic/ReadShmDataAndAttachSamples.h b/media/server/gstplayer/include/tasks/generic/ReadShmDataAndAttachSamples.h index 4f26fad65..6b9b17668 100644 --- a/media/server/gstplayer/include/tasks/generic/ReadShmDataAndAttachSamples.h +++ b/media/server/gstplayer/include/tasks/generic/ReadShmDataAndAttachSamples.h @@ -25,6 +25,7 @@ #include "IGstGenericPlayerPrivate.h" #include "IGstWrapper.h" #include "IPlayerTask.h" +#include "IRdkPerfWrapper.h" #include namespace firebolt::rialto::server::tasks::generic @@ -32,9 +33,10 @@ namespace firebolt::rialto::server::tasks::generic class ReadShmDataAndAttachSamples : public IPlayerTask { public: - ReadShmDataAndAttachSamples(GenericPlayerContext &context, - const std::shared_ptr &gstWrapper, - IGstGenericPlayerPrivate &player, const std::shared_ptr &dataReader); + ReadShmDataAndAttachSamples( + GenericPlayerContext &context, const std::shared_ptr &gstWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, + IGstGenericPlayerPrivate &player, const std::shared_ptr &dataReader); ~ReadShmDataAndAttachSamples() override; void execute() const override; @@ -42,6 +44,7 @@ class ReadShmDataAndAttachSamples : public IPlayerTask void attachData(const firebolt::rialto::MediaSourceType mediaType, GstBuffer *buffer) const; GenericPlayerContext &m_context; std::shared_ptr m_gstWrapper; + std::shared_ptr m_rdkPerfWrapperFactory; IGstGenericPlayerPrivate &m_player; std::shared_ptr m_dataReader; }; diff --git a/media/server/gstplayer/source/GstGenericPlayer.cpp b/media/server/gstplayer/source/GstGenericPlayer.cpp index 248cedc4a..54e6e4b40 100644 --- a/media/server/gstplayer/source/GstGenericPlayer.cpp +++ b/media/server/gstplayer/source/GstGenericPlayer.cpp @@ -89,6 +89,7 @@ std::unique_ptr GstGenericPlayerFactory::createGstGenericPlay { auto gstWrapperFactory = firebolt::rialto::wrappers::IGstWrapperFactory::getFactory(); auto glibWrapperFactory = firebolt::rialto::wrappers::IGlibWrapperFactory::getFactory(); + auto rdkPerfWrapperFactory = firebolt::rialto::wrappers::IRdkPerfWrapperFactory::createFactory(); std::shared_ptr gstWrapper; std::shared_ptr glibWrapper; std::shared_ptr rdkGstreamerUtilsWrapper; @@ -105,12 +106,17 @@ std::unique_ptr GstGenericPlayerFactory::createGstGenericPlay { throw std::runtime_error("Cannot create RdkGstreamerUtilsWrapper"); } + if (!rdkPerfWrapperFactory) + { + throw std::runtime_error("Cannot create RdkPerfWrapperFactory"); + } gstPlayer = std::make_unique< GstGenericPlayer>(client, decryptionService, type, videoRequirements, gstWrapper, glibWrapper, - rdkGstreamerUtilsWrapper, IGstInitialiser::instance(), std::make_unique(), - IGstSrcFactory::getFactory(), common::ITimerFactory::getFactory(), + rdkGstreamerUtilsWrapper, rdkPerfWrapperFactory, IGstInitialiser::instance(), + std::make_unique(), IGstSrcFactory::getFactory(), + common::ITimerFactory::getFactory(), std::make_unique(client, gstWrapper, glibWrapper, - rdkGstreamerUtilsWrapper, + rdkGstreamerUtilsWrapper, rdkPerfWrapperFactory, IGstTextTrackSinkFactory::createFactory()), std::make_unique(), std::make_unique(), IGstProtectionMetadataHelperFactory::createFactory()); @@ -129,14 +135,15 @@ GstGenericPlayer::GstGenericPlayer( const std::shared_ptr &gstWrapper, const std::shared_ptr &glibWrapper, const std::shared_ptr &rdkGstreamerUtilsWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, const IGstInitialiser &gstInitialiser, std::unique_ptr &&flushWatcher, const std::shared_ptr &gstSrcFactory, std::shared_ptr timerFactory, std::unique_ptr taskFactory, std::unique_ptr workerThreadFactory, std::unique_ptr gstDispatcherThreadFactory, std::shared_ptr gstProtectionMetadataFactory) : m_gstPlayerClient(client), m_gstWrapper{gstWrapper}, m_glibWrapper{glibWrapper}, - m_rdkGstreamerUtilsWrapper{rdkGstreamerUtilsWrapper}, m_timerFactory{timerFactory}, - m_taskFactory{std::move(taskFactory)}, m_flushWatcher{std::move(flushWatcher)} + m_rdkGstreamerUtilsWrapper{rdkGstreamerUtilsWrapper}, m_rdkPerfWrapperFactory{rdkPerfWrapperFactory}, + m_timerFactory{timerFactory}, m_taskFactory{std::move(taskFactory)}, m_flushWatcher{std::move(flushWatcher)} { RIALTO_SERVER_LOG_DEBUG("GstGenericPlayer is constructed."); @@ -1471,6 +1478,7 @@ void GstGenericPlayer::pushSampleIfRequired(GstElement *source, const std::strin // GstAppSrc does not replace segment, if it's the same as previous one. // It causes problems with position reporing in amlogic devices, so we need to push // two segments with different reset time value. + auto perf = m_rdkPerfWrapperFactory->createRdkPerfWrapper(__FUNCTION__); pushAdditionalSegmentIfRequired(source); for (const auto &[position, resetTime, appliedRate, stopPosition] : initialPosition->second) diff --git a/media/server/gstplayer/source/tasks/generic/GenericPlayerTaskFactory.cpp b/media/server/gstplayer/source/tasks/generic/GenericPlayerTaskFactory.cpp index a7886a335..a465472dd 100644 --- a/media/server/gstplayer/source/tasks/generic/GenericPlayerTaskFactory.cpp +++ b/media/server/gstplayer/source/tasks/generic/GenericPlayerTaskFactory.cpp @@ -66,9 +66,11 @@ GenericPlayerTaskFactory::GenericPlayerTaskFactory( IGstGenericPlayerClient *client, const std::shared_ptr &gstWrapper, const std::shared_ptr &glibWrapper, const std::shared_ptr &rdkGstreamerUtilsWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, const std::shared_ptr &gstTextTrackSinkFactory) : m_client{client}, m_gstWrapper{gstWrapper}, m_glibWrapper{glibWrapper}, - m_rdkGstreamerUtilsWrapper{rdkGstreamerUtilsWrapper}, m_gstTextTrackSinkFactory{gstTextTrackSinkFactory} + m_rdkGstreamerUtilsWrapper{rdkGstreamerUtilsWrapper}, m_rdkPerfWrapperFactory{rdkPerfWrapperFactory}, + m_gstTextTrackSinkFactory{gstTextTrackSinkFactory} { } @@ -144,7 +146,8 @@ std::unique_ptr GenericPlayerTaskFactory::createPlay(IGstGenericPla std::unique_ptr GenericPlayerTaskFactory::createReadShmDataAndAttachSamples( GenericPlayerContext &context, IGstGenericPlayerPrivate &player, const std::shared_ptr &dataReader) const { - return std::make_unique(context, m_gstWrapper, player, dataReader); + return std::make_unique(context, m_gstWrapper, m_rdkPerfWrapperFactory, + player, dataReader); } std::unique_ptr GenericPlayerTaskFactory::createReportPosition(GenericPlayerContext &context, diff --git a/media/server/gstplayer/source/tasks/generic/ReadShmDataAndAttachSamples.cpp b/media/server/gstplayer/source/tasks/generic/ReadShmDataAndAttachSamples.cpp index 1df7213a7..304e74fb1 100644 --- a/media/server/gstplayer/source/tasks/generic/ReadShmDataAndAttachSamples.cpp +++ b/media/server/gstplayer/source/tasks/generic/ReadShmDataAndAttachSamples.cpp @@ -29,8 +29,10 @@ namespace firebolt::rialto::server::tasks::generic { ReadShmDataAndAttachSamples::ReadShmDataAndAttachSamples( GenericPlayerContext &context, const std::shared_ptr &gstWrapper, + const std::shared_ptr &rdkPerfWrapperFactory, IGstGenericPlayerPrivate &player, const std::shared_ptr &dataReader) - : m_context{context}, m_gstWrapper{gstWrapper}, m_player{player}, m_dataReader{dataReader} + : m_context{context}, m_gstWrapper{gstWrapper}, m_rdkPerfWrapperFactory{rdkPerfWrapperFactory}, m_player{player}, + m_dataReader{dataReader} { RIALTO_SERVER_LOG_DEBUG("Constructing ReadShmDataAndAttachSamples"); } @@ -43,6 +45,7 @@ ReadShmDataAndAttachSamples::~ReadShmDataAndAttachSamples() void ReadShmDataAndAttachSamples::execute() const { RIALTO_SERVER_LOG_DEBUG("Executing ReadShmDataAndAttachSamples"); + auto perf = m_rdkPerfWrapperFactory->createRdkPerfWrapper(__FUNCTION__); // Read media segments from shared memory IMediaPipeline::MediaSegmentVector mediaSegments = m_dataReader->readData(); diff --git a/media/server/service/source/main.cpp b/media/server/service/source/main.cpp index 94c7e5138..e421929ca 100644 --- a/media/server/service/source/main.cpp +++ b/media/server/service/source/main.cpp @@ -22,6 +22,7 @@ #include "IApplicationSessionServer.h" #include "IGstInitialiser.h" +#include "IRdkPerfWrapper.h" #include "RialtoServerLogging.h" // NOLINT(build/filename_format) @@ -31,6 +32,7 @@ int main(int argc, char *argv[]) const char kSrcRev[] = SRCREV; const char kTags[] = TAGS; + auto perf = firebolt::rialto::wrappers::IRdkPerfWrapperFactory::createFactory()->createRdkPerfWrapper(__FUNCTION__); if (std::strlen(kSrcRev) > 0) { if (std::strlen(kTags) > 0) diff --git a/stubs/rdk_perf/CMakeLists.txt b/stubs/rdk_perf/CMakeLists.txt new file mode 100644 index 000000000..69f20f016 --- /dev/null +++ b/stubs/rdk_perf/CMakeLists.txt @@ -0,0 +1,44 @@ +# +# If not stated otherwise in this file or this component's LICENSE file the +# following copyright and licenses apply: +# +# Copyright 2026 Sky UK +# +# 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. +# + +set( CMAKE_CXX_STANDARD 17 ) + +set( CMAKE_CXX_STANDARD_REQUIRED ON ) +include( CheckCXXCompilerFlag ) +include( GNUInstallDirs ) +include(ExternalProject) + +add_library( + rdkperf + + STATIC + rdk_perf.cpp +) + +target_include_directories( + rdkperf + + PUBLIC + . +) + +install ( + TARGETS rdkperf LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} +) \ No newline at end of file diff --git a/stubs/rdk_perf/rdk_perf.cpp b/stubs/rdk_perf/rdk_perf.cpp new file mode 100644 index 000000000..780a6f65f --- /dev/null +++ b/stubs/rdk_perf/rdk_perf.cpp @@ -0,0 +1,22 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 "rdk_perf.h" + +RDKPerf::RDKPerf(const char *szName) {} diff --git a/stubs/rdk_perf/rdk_perf.h b/stubs/rdk_perf/rdk_perf.h new file mode 100644 index 000000000..e3b0ba02b --- /dev/null +++ b/stubs/rdk_perf/rdk_perf.h @@ -0,0 +1,27 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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. + */ + +#pragma once + +class RDKPerf +{ +public: + explicit RDKPerf(const char *szName); + ~RDKPerf() = default; +}; diff --git a/tests/common/externalLibraryMocks/RdkPerfWrapperFactoryMock.h b/tests/common/externalLibraryMocks/RdkPerfWrapperFactoryMock.h new file mode 100644 index 000000000..a167b19e1 --- /dev/null +++ b/tests/common/externalLibraryMocks/RdkPerfWrapperFactoryMock.h @@ -0,0 +1,36 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_FACTORY_MOCK_H_ +#define FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_FACTORY_MOCK_H_ + +#include "IRdkPerfWrapper.h" +#include +#include + +namespace firebolt::rialto::wrappers +{ +class RdkPerfWrapperFactoryMock : public IRdkPerfWrapperFactory +{ +public: + MOCK_METHOD(std::unique_ptr, createRdkPerfWrapper, (const char *), (const, override)); +}; +} // namespace firebolt::rialto::wrappers + +#endif // FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_FACTORY_MOCK_H_ diff --git a/tests/componenttests/server/fixtures/RialtoServerComponentTest.cpp b/tests/componenttests/server/fixtures/RialtoServerComponentTest.cpp index 20df2972b..88610920e 100644 --- a/tests/componenttests/server/fixtures/RialtoServerComponentTest.cpp +++ b/tests/componenttests/server/fixtures/RialtoServerComponentTest.cpp @@ -31,6 +31,7 @@ using testing::_; using testing::AtLeast; +using testing::Invoke; using testing::Return; using testing::StrEq; @@ -66,6 +67,7 @@ RialtoServerComponentTest::~RialtoServerComponentTest() wrappers::IFactoryAccessor::instance().ocdmFactory() = nullptr; wrappers::IFactoryAccessor::instance().ocdmSystemFactory() = nullptr; wrappers::IFactoryAccessor::instance().rdkGstreamerUtilsWrapperFactory() = nullptr; + wrappers::IFactoryAccessor::instance().rdkPerfWrapperFactory() = nullptr; wrappers::IFactoryAccessor::instance().textTrackPluginWrapperFactory() = nullptr; wrappers::IFactoryAccessor::instance().thunderWrapperFactory() = nullptr; } @@ -136,12 +138,16 @@ void RialtoServerComponentTest::configureWrappers() const EXPECT_CALL(*m_thunderWrapperFactoryMock, getThunderWrapper()) .Times(AtLeast(0)) .WillRepeatedly(Return(m_thunderWrapperMock)); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)) + .Times(AtLeast(0)) + .WillRepeatedly(Invoke([](const char *perfName) { return nullptr; })); wrappers::IFactoryAccessor::instance().glibWrapperFactory() = m_glibWrapperFactoryMock; wrappers::IFactoryAccessor::instance().gstWrapperFactory() = m_gstWrapperFactoryMock; wrappers::IFactoryAccessor::instance().linuxWrapperFactory() = m_linuxWrapperFactoryMock; wrappers::IFactoryAccessor::instance().ocdmFactory() = m_ocdmFactoryMock; wrappers::IFactoryAccessor::instance().ocdmSystemFactory() = m_ocdmSystemFactoryMock; wrappers::IFactoryAccessor::instance().rdkGstreamerUtilsWrapperFactory() = m_rdkGstreamerUtilsWrapperFactoryMock; + wrappers::IFactoryAccessor::instance().rdkPerfWrapperFactory() = m_rdkPerfWrapperFactoryMock; wrappers::IFactoryAccessor::instance().textTrackPluginWrapperFactory() = m_textTrackPluginWrapperFactoryMock; wrappers::IFactoryAccessor::instance().thunderWrapperFactory() = m_thunderWrapperFactoryMock; } diff --git a/tests/componenttests/server/fixtures/RialtoServerComponentTest.h b/tests/componenttests/server/fixtures/RialtoServerComponentTest.h index 94795a579..0115b5183 100644 --- a/tests/componenttests/server/fixtures/RialtoServerComponentTest.h +++ b/tests/componenttests/server/fixtures/RialtoServerComponentTest.h @@ -38,6 +38,7 @@ #include "OcdmSystemMock.h" #include "RdkGstreamerUtilsWrapperFactoryMock.h" #include "RdkGstreamerUtilsWrapperMock.h" +#include "RdkPerfWrapperFactoryMock.h" #include "ServerManagerStub.h" #include "TextTrackPluginWrapperFactoryMock.h" #include "TextTrackPluginWrapperMock.h" @@ -111,6 +112,8 @@ class RialtoServerComponentTest : public ::testing::Test std::make_shared>()}; std::shared_ptr> m_textTrackPluginWrapperFactoryMock{ std::make_shared>()}; + std::shared_ptr> m_rdkPerfWrapperFactoryMock{ + std::make_shared>()}; std::shared_ptr> m_textTrackPluginWrapperMock{ std::make_shared>()}; std::shared_ptr> m_textTrackWrapperMock{ diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/CreateTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/CreateTest.cpp index 901d222ad..3e618f6e8 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/CreateTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/CreateTest.cpp @@ -71,13 +71,14 @@ class RialtoServerCreateGstGenericPlayerTest : public GstGenericPlayerTestCommon gstPlayerWillBeCreated(); EXPECT_NO_THROW( - m_gstPlayer = - std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, - m_gstWrapperMock, m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, - m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, - m_timerFactoryMock, std::move(m_taskFactory), - std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), - m_gstProtectionMetadataFactoryMock)); + m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, + m_videoReq, m_gstWrapperMock, m_glibWrapperMock, + m_rdkGstreamerUtilsWrapperMock, m_rdkPerfWrapperFactoryMock, + m_gstInitialiserMock, std::move(m_flushWatcher), + m_gstSrcFactoryMock, m_timerFactoryMock, + std::move(m_taskFactory), std::move(workerThreadFactory), + std::move(gstDispatcherThreadFactory), + m_gstProtectionMetadataFactoryMock)); EXPECT_NE(m_gstPlayer, nullptr); } @@ -129,6 +130,7 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, FactoryCreatesObject) IFactoryAccessor::instance().gstWrapperFactory() = m_gstWrapperFactoryMock; IFactoryAccessor::instance().glibWrapperFactory() = m_glibWrapperFactoryMock; IFactoryAccessor::instance().rdkGstreamerUtilsWrapperFactory() = m_rdkGstreamerUtilsWrapperFactoryMock; + IFactoryAccessor::instance().rdkPerfWrapperFactory() = m_rdkPerfWrapperFactoryMock; // Create expectations EXPECT_CALL(*m_gstWrapperFactoryMock, getGstWrapper()).WillRepeatedly(Return(m_gstWrapperMock)); @@ -163,6 +165,7 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, FactoryCreatesObject) IFactoryAccessor::instance().gstWrapperFactory() = nullptr; IFactoryAccessor::instance().glibWrapperFactory() = nullptr; IFactoryAccessor::instance().rdkGstreamerUtilsWrapperFactory() = nullptr; + IFactoryAccessor::instance().rdkPerfWrapperFactory() = nullptr; } /** @@ -337,7 +340,8 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, CreateWesterossinkFailsCreateCont EXPECT_CALL(*m_gstWrapperMock, gstContextNew(StrEq("erm"), false)).WillOnce(Return(nullptr)); EXPECT_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, + m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, m_timerFactoryMock, std::move(m_taskFactory), std::move(workerThreadFactory), @@ -355,7 +359,8 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, GstSrcFactoryNull) EXPECT_CALL(m_gstInitialiserMock, waitForInitialisation()); EXPECT_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, + m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, std::move(m_flushWatcher), nullptr, m_timerFactoryMock, std::move(m_taskFactory), std::move(workerThreadFactory), @@ -375,7 +380,8 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, TimerFactoryFails) EXPECT_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, + m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, nullptr, std::move(m_taskFactory), std::move(workerThreadFactory), @@ -395,7 +401,8 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, GstSrcFactoryFails) EXPECT_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, + m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, m_timerFactoryMock, std::move(m_taskFactory), std::move(workerThreadFactory), @@ -422,9 +429,10 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, UnknownMediaType) EXPECT_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, MediaType::UNKNOWN, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, - m_gstInitialiserMock, std::move(m_flushWatcher), - m_gstSrcFactoryMock, m_timerFactoryMock, - std::move(m_taskFactory), std::move(workerThreadFactory), + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, + std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), m_gstProtectionMetadataFactoryMock), std::runtime_error); @@ -455,14 +463,15 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, PlaysinkNotFound) EXPECT_CALL(*m_gstWrapperMock, gstElementSetState(&m_pipeline, GST_STATE_READY)) .WillOnce(Return(GST_STATE_CHANGE_FAILURE)); - EXPECT_NO_THROW( - m_gstPlayer = - std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, - m_gstWrapperMock, m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, - m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, - m_timerFactoryMock, std::move(m_taskFactory), - std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), - m_gstProtectionMetadataFactoryMock)); + EXPECT_NO_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, + m_type, m_videoReq, m_gstWrapperMock, + m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, + std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), + std::move(gstDispatcherThreadFactory), + m_gstProtectionMetadataFactoryMock)); EXPECT_NE(m_gstPlayer, nullptr); executeTaskWhenEnqueued(); @@ -491,14 +500,15 @@ TEST_F(RialtoServerCreateGstGenericPlayerTest, SetNativeAudioForBrcmAudioSink) EXPECT_CALL(*m_gstProtectionMetadataFactoryMock, createProtectionMetadataWrapper(_)) .WillOnce(Return(ByMove(std::move(m_gstProtectionMetadataWrapper)))); - EXPECT_NO_THROW( - m_gstPlayer = - std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, m_type, m_videoReq, - m_gstWrapperMock, m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, - m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, - m_timerFactoryMock, std::move(m_taskFactory), - std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), - m_gstProtectionMetadataFactoryMock)); + EXPECT_NO_THROW(m_gstPlayer = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, + m_type, m_videoReq, m_gstWrapperMock, + m_glibWrapperMock, m_rdkGstreamerUtilsWrapperMock, + m_rdkPerfWrapperFactoryMock, m_gstInitialiserMock, + std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), + std::move(gstDispatcherThreadFactory), + m_gstProtectionMetadataFactoryMock)); EXPECT_NE(m_gstPlayer, nullptr); executeTaskWhenEnqueued(); diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/GstDispatcherThreadClientTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/GstDispatcherThreadClientTest.cpp index ed883ce93..02d3dd9f2 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/GstDispatcherThreadClientTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/GstDispatcherThreadClientTest.cpp @@ -39,10 +39,10 @@ class GstDispatcherThreadClientTest : public GstGenericPlayerTestCommon gstPlayerWillBeCreated(); m_sut = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, MediaType::MSE, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, - std::move(m_flushWatcher), m_gstSrcFactoryMock, m_timerFactoryMock, - std::move(m_taskFactory), std::move(workerThreadFactory), - std::move(gstDispatcherThreadFactory), + m_rdkGstreamerUtilsWrapperMock, m_rdkPerfWrapperFactoryMock, + m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), m_gstProtectionMetadataFactoryMock); } diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp index 9db981f26..26255237d 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp @@ -119,10 +119,10 @@ class GstGenericPlayerPrivateTest : public GstGenericPlayerTestCommon gstPlayerWillBeCreated(); m_sut = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, MediaType::MSE, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, - std::move(m_flushWatcher), m_gstSrcFactoryMock, m_timerFactoryMock, - std::move(m_taskFactory), std::move(workerThreadFactory), - std::move(gstDispatcherThreadFactory), + m_rdkGstreamerUtilsWrapperMock, m_rdkPerfWrapperFactoryMock, + m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), m_gstProtectionMetadataFactoryMock); m_realElement = initRealElement(); } @@ -891,6 +891,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldAttachAudioDataWhenAttachingSampleFail SegmentData{kPosition, kResetTime, kAppliedRate, kStopPosition}); context.streamInfo[firebolt::rialto::MediaSourceType::VIDEO].appSrc = GST_ELEMENT(&videoSrc); }); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentNew()).WillOnce(Return(&segment)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentInit(&segment, GST_FORMAT_TIME)); EXPECT_CALL(*m_gstWrapperMock, @@ -926,6 +927,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldAttachAudioSample) SegmentData{kPosition, kDoNotResetTime, kAppliedRate, kStopPosition}); context.streamInfo[firebolt::rialto::MediaSourceType::VIDEO].appSrc = GST_ELEMENT(&videoSrc); }); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstAppSrcGetCaps(&audioSrc)).WillOnce(Return(&caps)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentNew()).WillOnce(Return(&segment)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentInit(&segment, GST_FORMAT_TIME)); @@ -969,6 +971,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldAttachAdditionalAudioSample) context.currentPosition[GST_ELEMENT(&audioSrc)] = SegmentData{kPosition, kResetTime, kAppliedRate, kStopPosition}; }); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstAppSrcGetCaps(&audioSrc)).WillRepeatedly(Return(&caps)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentNew()).WillRepeatedly(Return(&segment)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentInit(&segment, GST_FORMAT_TIME)).Times(2); @@ -1013,6 +1016,7 @@ TEST_F(GstGenericPlayerPrivateTest, undefinedStopPositionInSetSourcePosition) SegmentData{kPosition, kDoNotResetTime, kAppliedRate, kUndefinedPosition}); context.streamInfo[firebolt::rialto::MediaSourceType::VIDEO].appSrc = GST_ELEMENT(&videoSrc); }); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstAppSrcGetCaps(&audioSrc)).WillOnce(Return(&caps)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentNew()).WillOnce(Return(&segment)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentInit(&segment, GST_FORMAT_TIME)); @@ -1152,6 +1156,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldAttachVideoSample) SegmentData{kPosition, kResetTime, kAppliedRate, kStopPosition}); context.streamInfo[firebolt::rialto::MediaSourceType::AUDIO].appSrc = GST_ELEMENT(&audioSrc); }); + EXPECT_CALL(*m_rdkPerfWrapperFactoryMock, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstAppSrcGetCaps(&videoSrc)).WillOnce(Return(&caps)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentNew()).WillOnce(Return(&segment)); EXPECT_CALL(*m_gstWrapperMock, gstSegmentInit(&segment, GST_FORMAT_TIME)); diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerTest.cpp index c658a080d..28b9879c1 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerTest.cpp @@ -53,10 +53,10 @@ class GstGenericPlayerTest : public GstGenericPlayerTestCommon gstPlayerWillBeCreated(); m_sut = std::make_unique(&m_gstPlayerClient, m_decryptionServiceMock, MediaType::MSE, m_videoReq, m_gstWrapperMock, m_glibWrapperMock, - m_rdkGstreamerUtilsWrapperMock, m_gstInitialiserMock, - std::move(m_flushWatcher), m_gstSrcFactoryMock, m_timerFactoryMock, - std::move(m_taskFactory), std::move(workerThreadFactory), - std::move(gstDispatcherThreadFactory), + m_rdkGstreamerUtilsWrapperMock, m_rdkPerfWrapperFactoryMock, + m_gstInitialiserMock, std::move(m_flushWatcher), m_gstSrcFactoryMock, + m_timerFactoryMock, std::move(m_taskFactory), + std::move(workerThreadFactory), std::move(gstDispatcherThreadFactory), m_gstProtectionMetadataFactoryMock); m_element = fakeElement(); } diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.cpp index 13da7fecc..26f5c35ed 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.cpp @@ -3067,10 +3067,16 @@ void GenericTasksTestsBase::shouldNotAttachUnknownSamples() EXPECT_CALL(testContext->m_gstPlayer, notifyNeedMediaData(MediaSourceType::UNKNOWN)); } +void GenericTasksTestsBase::shouldCreatePerfWrapper() +{ + EXPECT_CALL(*testContext->m_rdkPerfWrapperFactory, createRdkPerfWrapper(_)).WillOnce(Return(nullptr)); +} + void GenericTasksTestsBase::triggerReadShmDataAndAttachSamplesAudio() { firebolt::rialto::server::tasks::generic::ReadShmDataAndAttachSamples task{testContext->m_context, testContext->m_gstWrapper, + testContext->m_rdkPerfWrapperFactory, testContext->m_gstPlayer, testContext->m_dataReader}; task.execute(); @@ -3084,6 +3090,7 @@ void GenericTasksTestsBase::triggerReadShmDataAndAttachSamplesVideo() { firebolt::rialto::server::tasks::generic::ReadShmDataAndAttachSamples task{testContext->m_context, testContext->m_gstWrapper, + testContext->m_rdkPerfWrapperFactory, testContext->m_gstPlayer, testContext->m_dataReader}; task.execute(); @@ -3096,6 +3103,7 @@ void GenericTasksTestsBase::triggerReadShmDataAndAttachSamples() { firebolt::rialto::server::tasks::generic::ReadShmDataAndAttachSamples task{testContext->m_context, testContext->m_gstWrapper, + testContext->m_rdkPerfWrapperFactory, testContext->m_gstPlayer, testContext->m_dataReader}; task.execute(); diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.h b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.h index fc875a400..12723fe96 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.h +++ b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.h @@ -398,6 +398,7 @@ class GenericTasksTestsBase : public ::testing::Test void shouldReadSubtitleData(); void shouldReadUnknownData(); void shouldNotAttachUnknownSamples(); + void shouldCreatePerfWrapper(); void triggerReadShmDataAndAttachSamplesAudio(); void triggerReadShmDataAndAttachSamplesVideo(); void triggerReadShmDataAndAttachSamples(); diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsContext.h b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsContext.h index e51d1095e..42b82e510 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsContext.h +++ b/tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsContext.h @@ -30,6 +30,7 @@ #include "GstTextTrackSinkFactoryMock.h" #include "GstWrapperMock.h" #include "RdkGstreamerUtilsWrapperMock.h" +#include "RdkPerfWrapperFactoryMock.h" #include #include @@ -61,6 +62,8 @@ class GenericTasksTestsContext std::make_shared>()}; std::shared_ptr m_gstTextTrackSinkFactoryMock{ std::make_shared>()}; + std::shared_ptr> m_rdkPerfWrapperFactory{ + std::make_shared>()}; // Gstreamer members GstElement *m_element{}; diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.h b/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.h index d8e72efaf..a7266c4d3 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.h +++ b/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.h @@ -35,6 +35,7 @@ #include "GstSrcMock.h" #include "GstWrapperMock.h" #include "RdkGstreamerUtilsWrapperMock.h" +#include "RdkPerfWrapperFactoryMock.h" #include "TimerFactoryMock.h" #include "WorkerThreadFactoryMock.h" #include "WorkerThreadMock.h" @@ -73,6 +74,8 @@ class GstGenericPlayerTestCommon : public ::testing::Test std::shared_ptr> m_glibWrapperMock{std::make_shared>()}; std::shared_ptr> m_rdkGstreamerUtilsWrapperMock{ std::make_shared>()}; + std::shared_ptr> m_rdkPerfWrapperFactoryMock{ + std::make_shared>()}; std::shared_ptr> m_gstSrcFactoryMock{std::make_shared>()}; std::shared_ptr> m_gstSrcMock{std::make_shared>()}; std::shared_ptr> m_timerFactoryMock{std::make_shared>()}; diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/GenericPlayerTaskFactoryTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/GenericPlayerTaskFactoryTest.cpp index d25627cda..451c1cf20 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/GenericPlayerTaskFactoryTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/GenericPlayerTaskFactoryTest.cpp @@ -28,6 +28,7 @@ #include "GstWrapperMock.h" #include "HeartbeatHandlerMock.h" #include "RdkGstreamerUtilsWrapperMock.h" +#include "RdkPerfWrapperFactoryMock.h" #include "tasks/IPlayerTask.h" #include "tasks/generic/AttachSamples.h" #include "tasks/generic/AttachSource.h" @@ -87,11 +88,17 @@ class GenericPlayerTaskFactoryTest : public testing::Test std::make_shared>()}; std::shared_ptr m_rdkGstreamerUtilsWrapper{ std::make_shared>()}; + std::shared_ptr> m_rdkPerfWrapperFactoryMock{ + std::make_shared>()}; std::shared_ptr m_gstTextTrackSinkFactoryMock{ std::make_shared>()}; StrictMock m_flushWatcherMock; - firebolt::rialto::server::GenericPlayerTaskFactory m_sut{&m_gstPlayerClient, m_gstWrapper, m_glibWrapper, - m_rdkGstreamerUtilsWrapper, m_gstTextTrackSinkFactoryMock}; + firebolt::rialto::server::GenericPlayerTaskFactory m_sut{&m_gstPlayerClient, + m_gstWrapper, + m_glibWrapper, + m_rdkGstreamerUtilsWrapper, + m_rdkPerfWrapperFactoryMock, + m_gstTextTrackSinkFactoryMock}; }; TEST_F(GenericPlayerTaskFactoryTest, ShouldCreateAttachSamples) diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/ReadShmDataAndAttachSamplesTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/ReadShmDataAndAttachSamplesTest.cpp index 1b7663034..883a51ca4 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/ReadShmDataAndAttachSamplesTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/ReadShmDataAndAttachSamplesTest.cpp @@ -31,6 +31,7 @@ class ReadShmDataAndAttachSamplesTest : public GenericTasksTestsBase TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllAudioSamples) { + shouldCreatePerfWrapper(); shouldReadAudioData(); shouldAttachAllAudioSamples(); triggerReadShmDataAndAttachSamplesAudio(); @@ -38,6 +39,7 @@ TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllAudioSamples) TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllVideoSamples) { + shouldCreatePerfWrapper(); shouldReadVideoData(); shouldAttachAllVideoSamples(); triggerReadShmDataAndAttachSamplesVideo(); @@ -46,6 +48,7 @@ TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllVideoSamples) TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllSubtitleSamples) { setContextStreamInfo(firebolt::rialto::MediaSourceType::SUBTITLE); + shouldCreatePerfWrapper(); shouldReadSubtitleData(); shouldAttachAllSubtitleSamples(); triggerReadShmDataAndAttachSamples(); @@ -54,6 +57,7 @@ TEST_F(ReadShmDataAndAttachSamplesTest, shouldAttachAllSubtitleSamples) TEST_F(ReadShmDataAndAttachSamplesTest, shouldSkipAttachingSubtitleSamples) { + shouldCreatePerfWrapper(); shouldReadSubtitleData(); shouldSkipAttachingSubtitleSamples(); triggerReadShmDataAndAttachSamples(); @@ -61,6 +65,7 @@ TEST_F(ReadShmDataAndAttachSamplesTest, shouldSkipAttachingSubtitleSamples) TEST_F(ReadShmDataAndAttachSamplesTest, shouldSkipAttachingUnknownSamples) { + shouldCreatePerfWrapper(); shouldReadUnknownData(); shouldNotAttachUnknownSamples(); triggerReadShmDataAndAttachSamples(); diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index 3be841fd1..14df15ee6 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -56,6 +56,7 @@ if( NOT CMAKE_BUILD_FLAG STREQUAL "UnitTests" AND NOT CMAKE_BUILD_FLAG STREQUAL ${OCdm_INCLUDE_DIRS} ${WPEFRAMEWORK_CORE_INCLUDE_DIRS} ${WPEFRAMEWORK_COM_INCLUDE_DIRS} + ${rdkperf_INCLUDE_DIRS} ) set(WRAPPER_LIBS @@ -63,6 +64,7 @@ if( NOT CMAKE_BUILD_FLAG STREQUAL "UnitTests" AND NOT CMAKE_BUILD_FLAG STREQUAL ocdm::ocdm WPEFrameworkCore::WPEFrameworkCore WPEFrameworkCOM::WPEFrameworkCOM + rdkperf ${CMAKE_DL_LIBS}) set(WRAPPER_SOURCES @@ -76,7 +78,8 @@ if( NOT CMAKE_BUILD_FLAG STREQUAL "UnitTests" AND NOT CMAKE_BUILD_FLAG STREQUAL source/RdkGstreamerUtilsWrapper.cpp source/TextTrackPluginWrapper.cpp source/TextTrackWrapper.cpp - source/ThunderWrapper.cpp) + source/ThunderWrapper.cpp + source/RdkPerfWrapper.cpp) endif() add_library( @@ -92,6 +95,7 @@ add_library( source/RdkGstreamerUtilsWrapperAccessor.cpp source/TextTrackPluginWrapperFactoryAccessor.cpp source/ThunderWrapperFactoryAccessor.cpp + source/RdkPerfWrapperFactoryAccessor.cpp ${WRAPPER_SOURCES} ${JSONCPP_WRAPPER_SOURCE_FILES} ) diff --git a/wrappers/include/FactoryAccessor.h b/wrappers/include/FactoryAccessor.h index 16f338ecc..2ce18fda0 100644 --- a/wrappers/include/FactoryAccessor.h +++ b/wrappers/include/FactoryAccessor.h @@ -39,6 +39,7 @@ class FactoryAccessor : public IFactoryAccessor std::shared_ptr &rdkGstreamerUtilsWrapperFactory() override; std::shared_ptr &textTrackPluginWrapperFactory() override; std::shared_ptr &thunderWrapperFactory() override; + std::shared_ptr &rdkPerfWrapperFactory() override; private: std::shared_ptr m_glibWrapperFactory{nullptr}; @@ -49,6 +50,7 @@ class FactoryAccessor : public IFactoryAccessor std::shared_ptr m_rdkGstreamerUtilsWrapperFactory{nullptr}; std::shared_ptr m_textTrackPluginWrapperFactory{nullptr}; std::shared_ptr m_thunderWrapperFactory{nullptr}; + std::shared_ptr m_rdkPerfWrapperFactory{nullptr}; }; } // namespace firebolt::rialto::wrappers diff --git a/wrappers/include/RdkPerfWrapper.h b/wrappers/include/RdkPerfWrapper.h new file mode 100644 index 000000000..f03379eb7 --- /dev/null +++ b/wrappers/include/RdkPerfWrapper.h @@ -0,0 +1,49 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_H_ +#define FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_H_ + +#include "IRdkPerfWrapper.h" +#include "rdk_perf.h" +#include + +namespace firebolt::rialto::wrappers +{ +class RdkPerfWrapperFactory : public IRdkPerfWrapperFactory +{ +public: + RdkPerfWrapperFactory() = default; + ~RdkPerfWrapperFactory() override = default; + + std::unique_ptr createRdkPerfWrapper(const char *szName) const override; +}; + +class RdkPerfWrapper : public IRdkPerfWrapper +{ +public: + explicit RdkPerfWrapper(const char *szName); + ~RdkPerfWrapper() override = default; + +private: + RDKPerf m_perf; +}; +} // namespace firebolt::rialto::wrappers + +#endif // FIREBOLT_RIALTO_WRAPPERS_RDK_PERF_WRAPPER_H_ diff --git a/wrappers/interface/IFactoryAccessor.h b/wrappers/interface/IFactoryAccessor.h index bc60cd06b..ddbf50b4c 100644 --- a/wrappers/interface/IFactoryAccessor.h +++ b/wrappers/interface/IFactoryAccessor.h @@ -26,6 +26,7 @@ #include "IOcdm.h" #include "IOcdmSystem.h" #include "IRdkGstreamerUtilsWrapper.h" +#include "IRdkPerfWrapper.h" #include "ITextTrackPluginWrapper.h" #include "IThunderWrapper.h" #include @@ -110,6 +111,13 @@ class IFactoryAccessor */ virtual std::shared_ptr &thunderWrapperFactory() = 0; + /** + * @brief Access the IRdkPerfWrapperFactory instance. + * + * @retval non-const (by purpose) reference to the factory instance ptr + */ + virtual std::shared_ptr &rdkPerfWrapperFactory() = 0; + protected: /** * @brief Default constructor diff --git a/wrappers/interface/IRdkPerfWrapper.h b/wrappers/interface/IRdkPerfWrapper.h new file mode 100644 index 000000000..26a6dcdf6 --- /dev/null +++ b/wrappers/interface/IRdkPerfWrapper.h @@ -0,0 +1,66 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 FIREBOLT_RIALTO_WRAPPERS_I_RDK_PERF_WRAPPER_H_ +#define FIREBOLT_RIALTO_WRAPPERS_I_RDK_PERF_WRAPPER_H_ + +#include + +namespace firebolt::rialto::wrappers +{ +class IRdkPerfWrapper; + +/** + * @brief IRdkPerfWrapperFactory factory class, returns a concrete implementation of IRdkPerfWrapper + */ +class IRdkPerfWrapperFactory +{ +public: + IRdkPerfWrapperFactory() = default; + virtual ~IRdkPerfWrapperFactory() = default; + + /** + * @brief Creates a IRdkPerfWrapperFactory instance. + * + * @retval the factory instance or null on error. + */ + static std::shared_ptr createFactory(); + + /** + * @brief Creates an IRdkPerfWrapper object. + * + * @retval the new RDK Perf wrapper instance or null on error. + */ + virtual std::unique_ptr createRdkPerfWrapper(const char *szName) const = 0; +}; + +class IRdkPerfWrapper +{ +public: + IRdkPerfWrapper() = default; + virtual ~IRdkPerfWrapper() = default; + + IRdkPerfWrapper(const IRdkPerfWrapper &) = delete; + IRdkPerfWrapper &operator=(const IRdkPerfWrapper &) = delete; + IRdkPerfWrapper(IRdkPerfWrapper &&) = delete; + IRdkPerfWrapper &operator=(IRdkPerfWrapper &&) = delete; +}; +} // namespace firebolt::rialto::wrappers + +#endif // FIREBOLT_RIALTO_WRAPPERS_I_RDK_PERF_WRAPPER_H_ diff --git a/wrappers/source/FactoryAccessor.cpp b/wrappers/source/FactoryAccessor.cpp index 6857f1e79..6e5442856 100644 --- a/wrappers/source/FactoryAccessor.cpp +++ b/wrappers/source/FactoryAccessor.cpp @@ -26,6 +26,7 @@ #include "Ocdm.h" #include "OcdmSystem.h" #include "RdkGstreamerUtilsWrapper.h" +#include "RdkPerfWrapper.h" #include "TextTrackPluginWrapperFactory.h" #include "ThunderWrapper.h" #endif // WRAPPERS_ENABLED @@ -125,4 +126,15 @@ std::shared_ptr &FactoryAccessor::thunderWrapperFactory( #endif // WRAPPERS_ENABLED return m_thunderWrapperFactory; } + +std::shared_ptr &FactoryAccessor::rdkPerfWrapperFactory() +{ +#ifdef WRAPPERS_ENABLED + if (!m_rdkPerfWrapperFactory) + { + m_rdkPerfWrapperFactory = std::make_shared(); + } +#endif // WRAPPERS_ENABLED + return m_rdkPerfWrapperFactory; +} } // namespace firebolt::rialto::wrappers diff --git a/wrappers/source/RdkPerfWrapper.cpp b/wrappers/source/RdkPerfWrapper.cpp new file mode 100644 index 000000000..4393f4926 --- /dev/null +++ b/wrappers/source/RdkPerfWrapper.cpp @@ -0,0 +1,31 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 "RdkPerfWrapper.h" +#include + +namespace firebolt::rialto::wrappers +{ +std::unique_ptr RdkPerfWrapperFactory::createRdkPerfWrapper(const char *szName) const +{ + return std::make_unique(szName); +} + +RdkPerfWrapper::RdkPerfWrapper(const char *szName) : m_perf(szName) {} +} // namespace firebolt::rialto::wrappers diff --git a/wrappers/source/RdkPerfWrapperFactoryAccessor.cpp b/wrappers/source/RdkPerfWrapperFactoryAccessor.cpp new file mode 100644 index 000000000..407ba6ed7 --- /dev/null +++ b/wrappers/source/RdkPerfWrapperFactoryAccessor.cpp @@ -0,0 +1,29 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2026 Sky UK + * + * 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 "IFactoryAccessor.h" +#include "IRdkPerfWrapper.h" + +namespace firebolt::rialto::wrappers +{ +std::shared_ptr IRdkPerfWrapperFactory::createFactory() +{ + return IFactoryAccessor::instance().rdkPerfWrapperFactory(); +} +} // namespace firebolt::rialto::wrappers