diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e8ed66..69c599b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ set(LIBPLAYERGSTINTERFACE_HEADERS gstplayertaskpool.h GstHandlerControl.h InterfacePlayerRDK.h + PlayerTelemetry.h drm/DrmUtils.h drm/aes/Aes.h drm/HlsDrmBase.h @@ -172,6 +173,7 @@ install(FILES closedcaptions/CCTrackInfo.h gstplayertaskpool.h GstHandlerControl.h InterfacePlayerRDK.h + PlayerTelemetry.h SocUtils.h drm/DrmUtils.h GstUtils.h @@ -219,6 +221,11 @@ set(SOURCES ProcessHandler.cpp ) +if(CMAKE_PLAYER_TELEMETRY_SUPPORT) + list(APPEND SOURCES PlayerTelemetry.cpp) + add_definitions(-DPLAYER_TELEMETRY_SUPPORT) +endif() + if(NOT (CMAKE_PLATFORM_UBUNTU OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")) list(APPEND SOURCES vendor/amlogic/AmlogicSocInterface.cpp diff --git a/InterfacePlayerRDK.cpp b/InterfacePlayerRDK.cpp index a7d138b2..adb96321 100644 --- a/InterfacePlayerRDK.cpp +++ b/InterfacePlayerRDK.cpp @@ -35,6 +35,9 @@ #include "player-xternal-stats.h" #endif #include "PlayerUtils.h" +#ifdef PLAYER_TELEMETRY_SUPPORT +#include "PlayerTelemetry.h" +#endif #define DEFAULT_BUFFERING_TO_MS 10 /**< TimeOut interval to check buffer fullness */ #define DEFAULT_BUFFERING_MAX_MS (1000) /**< max buffering time */ @@ -1280,9 +1283,35 @@ static GstStateChangeReturn SetStateWithWarnings(GstElement *element, GstState t case GST_STATE_CHANGE_FAILURE: MW_LOG_ERR("InterfacePlayerRDK: %s is in FAILURE state : current %s pending %s", SafeName(element).c_str(),gst_element_state_get_name(current), gst_element_state_get_name(pending)); LogStatus(element); +#ifdef PLAYER_TELEMETRY_SUPPORT + { + std::map i; + std::map s; + std::map f; + s["cur"] = gst_element_state_get_name(current); + s["pen"] = gst_element_state_get_name(pending); + // GstState is an enum; transmit numeric value (stable for decoding on the backend) + i["tgt"] = static_cast(targetState); + PlayerTelemetry2 telemetry; + telemetry.send("MW_PIPELINE_STATE_CHANGE_FAILURE", i, s, f); + } +#endif break; case GST_STATE_CHANGE_SUCCESS: MW_LOG_DEBUG("InterfacePlayerRDK: %s is in success state : current %s pending %s", SafeName(element).c_str(),gst_element_state_get_name(current), gst_element_state_get_name(pending)); +#ifdef PLAYER_TELEMETRY_SUPPORT + { + std::map i; + std::map s; + std::map f; + s["cur"] = gst_element_state_get_name(current); + s["pen"] = gst_element_state_get_name(pending); + // GstState is an enum; transmit numeric value (stable for decoding on the backend) + i["tgt"] = static_cast(targetState); + PlayerTelemetry2 telemetry; + telemetry.send("MW_PIPELINE_STATE_CHANGE_SUCCESS", i, s, f); + } +#endif break; case GST_STATE_CHANGE_ASYNC: if(syncOnlyTransition) @@ -1290,9 +1319,35 @@ static GstStateChangeReturn SetStateWithWarnings(GstElement *element, GstState t MW_LOG_MIL("InterfacePlayerRDK: %s state is changing asynchronously : current %s pending %s", SafeName(element).c_str(),gst_element_state_get_name(current), gst_element_state_get_name(pending)); LogStatus(element); } +#ifdef PLAYER_TELEMETRY_SUPPORT + { + std::map i; + std::map s; + std::map f; + s["cur"] = gst_element_state_get_name(current); + s["pen"] = gst_element_state_get_name(pending); + // GstState is an enum; transmit numeric value (stable for decoding on the backend) + i["tgt"] = static_cast(targetState); + PlayerTelemetry2 telemetry; + telemetry.send("MW_PIPELINE_STATE_CHANGE_ASYNC", i, s, f); + } +#endif break; default: MW_LOG_ERR("InterfacePlayerRDK: %s is in an unknown state", SafeName(element).c_str()); +#ifdef PLAYER_TELEMETRY_SUPPORT + { + std::map i; + std::map s; + std::map f; + s["cur"] = gst_element_state_get_name(current); + s["pen"] = gst_element_state_get_name(pending); + // GstState is an enum; transmit numeric value (stable for decoding on the backend) + i["tgt"] = static_cast(targetState); + PlayerTelemetry2 telemetry; + telemetry.send("MW_PIPELINE_STATE_CHANGE_UNKNOWN", i, s, f); + } +#endif break; } diff --git a/PlayerTelemetry.cpp b/PlayerTelemetry.cpp new file mode 100644 index 00000000..63a61c64 --- /dev/null +++ b/PlayerTelemetry.cpp @@ -0,0 +1,46 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2025 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. + */ + +/** + * @file PlayerTelemetry.cpp + * @brief Implementation of telemetry support for the player interface. + */ + +#include "PlayerTelemetry.h" +#include "PlayerLogManager.h" + +void PlayerTelemetry2::send(const std::string& marker, + const std::map& iMap, + const std::map& sMap, + const std::map& fMap) +{ + MW_LOG_MIL("PlayerTelemetry2: %s", marker.c_str()); + for (const auto& kv : iMap) + { + MW_LOG_MIL("PlayerTelemetry2: int[%s]=%d", kv.first.c_str(), kv.second); + } + for (const auto& kv : sMap) + { + MW_LOG_MIL("PlayerTelemetry2: str[%s]=%s", kv.first.c_str(), kv.second.c_str()); + } + for (const auto& kv : fMap) + { + MW_LOG_MIL("PlayerTelemetry2: float[%s]=%f", kv.first.c_str(), kv.second); + } +} diff --git a/PlayerTelemetry.h b/PlayerTelemetry.h new file mode 100644 index 00000000..94bc89b5 --- /dev/null +++ b/PlayerTelemetry.h @@ -0,0 +1,51 @@ +/* + * If not stated otherwise in this file or this component's license file the + * following copyright and licenses apply: + * + * Copyright 2025 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. + */ + +#ifndef PLAYER_TELEMETRY_H +#define PLAYER_TELEMETRY_H + +/** + * @file PlayerTelemetry.h + * @brief Telemetry support for the player interface. + */ + +#include +#include + +/** + * @brief Class for sending player telemetry events with typed key-value maps. + */ +class PlayerTelemetry2 +{ +public: + /** + * @brief Sends a telemetry event with associated data maps. + * + * @param[in] marker The telemetry event name/marker. + * @param[in] iMap Integer key-value pairs associated with the event. + * @param[in] sMap String key-value pairs associated with the event. + * @param[in] fMap Float key-value pairs associated with the event. + */ + void send(const std::string& marker, + const std::map& iMap, + const std::map& sMap, + const std::map& fMap); +}; + +#endif // PLAYER_TELEMETRY_H