From c48d8f2357122787277455b26f0f6bb4aea4f2ef Mon Sep 17 00:00:00 2001 From: dp0000 <53818367+dp0000@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:59:16 +0530 Subject: [PATCH 1/5] Update InterfacePlayerRDK.cpp --- middleware/InterfacePlayerRDK.cpp | 60 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/middleware/InterfacePlayerRDK.cpp b/middleware/InterfacePlayerRDK.cpp index 2de82fccc1..a3e580d7d0 100644 --- a/middleware/InterfacePlayerRDK.cpp +++ b/middleware/InterfacePlayerRDK.cpp @@ -69,13 +69,12 @@ static const char* GstPluginNameVMX = "verimatrixdecryptor"; /*InterfacePlayerRDK constructor*/ InterfacePlayerRDK::InterfacePlayerRDK(bool isRialto) : -mProtectionLock(), mPauseInjector(false), mSourceSetupMutex(), stopCallback(NULL), tearDownCb(NULL), notifyFirstFrameCallback(NULL), +mPauseInjector(false), mSourceSetupMutex(), stopCallback(NULL), tearDownCb(NULL), notifyFirstFrameCallback(NULL), mSourceSetupCV(), mScheduler(), callbackMap(), setupStreamCallbackMap(), mDrmSystem(NULL), mEncrypt(NULL), mDRMSessionManager(NULL) { interfacePlayerPriv = new InterfacePlayerPriv(isRialto); m_gstConfigParam = new Configs(); m_gstConfigParam->framesToQueue = SocUtils::RequiredQueuedFrames(); - pthread_mutex_init(&mProtectionLock, NULL); for (int i = 0; i < GST_TRACK_COUNT; i++) pthread_mutex_init(&interfacePlayerPriv->gstPrivateContext->stream[i].sourceLock, NULL); // start Scheduler Worker for task handling @@ -97,7 +96,6 @@ InterfacePlayerRDK::~InterfacePlayerRDK() { pthread_mutex_destroy(&interfacePlayerPriv->gstPrivateContext->stream[i].sourceLock); } - pthread_mutex_destroy(&mProtectionLock); delete interfacePlayerPriv; } @@ -2723,23 +2721,31 @@ void InterfacePlayerPriv::SendGstEvents(int mediaType, GstClockTime pts, int ena // There is a possibility that only single protection event is queued for multiple type // since they are encrypted using same id. Hence check if protection event is queued for // other types - GstEvent* event = gstPrivateContext->protectionEvent[mediaType]; - if (event == NULL) + GstEvent* event = NULL; { - // Check protection event for other types - for (int i = 0; i < GST_TRACK_COUNT; i++) + std::lock_guard lock(gstPrivateContext->protectionEventMutex); + event = gstPrivateContext->protectionEvent[mediaType]; + if (event == NULL) { - if (i != mediaType && gstPrivateContext->protectionEvent[i] != NULL) + // Check protection event for other types + for (int i = 0; i < GST_TRACK_COUNT; i++) { - event = gstPrivateContext->protectionEvent[i]; - break; + if (i != mediaType && gstPrivateContext->protectionEvent[i] != NULL) + { + event = gstPrivateContext->protectionEvent[i]; + break; + } } } + if (event) + { + event = gst_event_ref(event); + } } if(event) { MW_LOG_MIL("pushing protection event! mediatype: %d", type); - if (!gst_pad_push_event(sourceEleSrcPad, gst_event_ref(event))) + if (!gst_pad_push_event(sourceEleSrcPad, event)) { MW_LOG_ERR("push protection event failed!"); } @@ -3564,29 +3570,29 @@ void InterfacePlayerRDK::QueueProtectionEvent(const std::string& formatType, con * Don't worry if you see only one protection event queued here. */ GstMediaType type = static_cast(mediaType); - pthread_mutex_lock(&mProtectionLock); - if (interfacePlayerPriv->gstPrivateContext->protectionEvent[type] != NULL) - { - MW_LOG_MIL("Previously cached protection event is present for type(%d), clearing!", type); - gst_event_unref(interfacePlayerPriv->gstPrivateContext->protectionEvent[type]); - interfacePlayerPriv->gstPrivateContext->protectionEvent[type] = NULL; - } - pthread_mutex_unlock(&mProtectionLock); MW_LOG_MIL("Queueing protection event for type(%d) keysystem(%s) initData(%p) initDataSize(%zu)", type, protSystemId, initData, initDataSize); /* Giving invalid initData into ProtectionEvent causing "GStreamer-CRITICAL" assertion error. So if the initData is valid then its good to call the ProtectionEvent further. */ + GstEvent *newEvent = NULL; if (initData && initDataSize) { GstBuffer *pssi; pssi = gst_buffer_new_wrapped(PLAYER_G_MEMDUP (initData, initDataSize), (gsize)initDataSize); - pthread_mutex_lock(&mProtectionLock); - interfacePlayerPriv->gstPrivateContext->protectionEvent[type] = gst_event_new_protection (protSystemId, pssi, formatType.c_str()); - pthread_mutex_unlock(&mProtectionLock); + newEvent = gst_event_new_protection (protSystemId, pssi, formatType.c_str()); gst_buffer_unref (pssi); } + + GstPlayerPriv *context = interfacePlayerPriv->gstPrivateContext; + std::lock_guard lock(context->protectionEventMutex); + if (context->protectionEvent[type] != NULL) + { + MW_LOG_MIL("Previously cached protection event is present for type(%d), clearing!", type); + gst_event_unref(context->protectionEvent[type]); + } + context->protectionEvent[type] = newEvent; } /** @@ -3594,17 +3600,17 @@ void InterfacePlayerRDK::QueueProtectionEvent(const std::string& formatType, con */ void InterfacePlayerRDK::ClearProtectionEvent() { - pthread_mutex_lock(&mProtectionLock); + GstPlayerPriv *context = interfacePlayerPriv->gstPrivateContext; + std::lock_guard lock(context->protectionEventMutex); for (int i = 0; i < GST_TRACK_COUNT; i++) { - if(interfacePlayerPriv->gstPrivateContext->protectionEvent[i]) + if(context->protectionEvent[i]) { MW_LOG_MIL("removing protection event! "); - gst_event_unref (interfacePlayerPriv->gstPrivateContext->protectionEvent[i]); - interfacePlayerPriv->gstPrivateContext->protectionEvent[i] = NULL; + gst_event_unref(context->protectionEvent[i]); + context->protectionEvent[i] = NULL; } } - pthread_mutex_unlock(&mProtectionLock); } /** * @brief Validate pipeline state transition within a max timeout From d468cb6936b90c31f532c8718d1305ada9aee7b3 Mon Sep 17 00:00:00 2001 From: dp0000 <53818367+dp0000@users.noreply.github.com> Date: Mon, 26 Oct 2026 14:08:15 +0530 Subject: [PATCH 2/5] Update InterfacePlayerPriv.h --- middleware/InterfacePlayerPriv.h | 1 + 1 file changed, 1 insertion(+) diff --git a/middleware/InterfacePlayerPriv.h b/middleware/InterfacePlayerPriv.h index cd5bc97e0c..67da6db2c6 100755 --- a/middleware/InterfacePlayerPriv.h +++ b/middleware/InterfacePlayerPriv.h @@ -195,6 +195,7 @@ struct GstPlayerPriv bool decoderHandleNotified; /**< Flag that denotes if decoder handle was notified. */ guint firstFrameCallbackIdleTaskId; /**< ID of idle handler created for notifying first frame event. */ GstEvent *protectionEvent[GST_TRACK_COUNT]; /**< GstEvent holding the pssi data to be sent downstream. */ + std::mutex protectionEventMutex; std::atomic firstFrameCallbackIdleTaskPending; /**< Set if any first frame callback is pending. */ bool using_westerossink; /**< true if westeros sink is used as video sink */ bool usingRialtoSink; /**< true if rialto sink is used for video and audio sinks */ From debea8a8c24f83414c7a34675ea366dd384fddb4 Mon Sep 17 00:00:00 2001 From: dp0000 <53818367+dp0000@users.noreply.github.com> Date: Mon, 26 Oct 2026 14:09:51 +0530 Subject: [PATCH 3/5] Update InterfacePlayerRDK.h --- middleware/InterfacePlayerRDK.h | 1 - 1 file changed, 1 deletion(-) diff --git a/middleware/InterfacePlayerRDK.h b/middleware/InterfacePlayerRDK.h index e15d5d569a..e71060b5b2 100644 --- a/middleware/InterfacePlayerRDK.h +++ b/middleware/InterfacePlayerRDK.h @@ -300,7 +300,6 @@ class InterfacePlayerRDK std::function tearDownCb; std::function notifyFirstFrameCallback; std::function gstCbExportYUVFrame; - pthread_mutex_t mProtectionLock; bool mFirstFrameRequired; bool mPauseInjector; bool mResumeInjector; From 87c52272e55efdbc9f5612c1ee0f87b9c7951bc8 Mon Sep 17 00:00:00 2001 From: dp0000 <53818367+dp0000@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:39:41 +0530 Subject: [PATCH 4/5] Update InterfacePlayerRDK.cpp --- middleware/InterfacePlayerRDK.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/middleware/InterfacePlayerRDK.cpp b/middleware/InterfacePlayerRDK.cpp index 8234269f9a..eacb3481ff 100644 --- a/middleware/InterfacePlayerRDK.cpp +++ b/middleware/InterfacePlayerRDK.cpp @@ -2750,6 +2750,7 @@ void InterfacePlayerPriv::SendGstEvents(int mediaType, GstClockTime pts, int ena // since they are encrypted using same id. Hence check if protection event is queued for // other types GstEvent* event = NULL; + int cachedType = mediaType; { std::lock_guard lock(gstPrivateContext->protectionEventMutex); event = gstPrivateContext->protectionEvent[mediaType]; @@ -2761,21 +2762,28 @@ void InterfacePlayerPriv::SendGstEvents(int mediaType, GstClockTime pts, int ena if (i != mediaType && gstPrivateContext->protectionEvent[i] != NULL) { event = gstPrivateContext->protectionEvent[i]; + cachedType = i; break; } } } if (event) { + MW_LOG_MIL("ProtectionEvent selected for send: requestedType=%d cachedType=%d event=%p; acquiring reference", mediaType, cachedType, static_cast(event)); event = gst_event_ref(event); + MW_LOG_MIL("ProtectionEvent reference acquired: requestedType=%d cachedType=%d event=%p", mediaType, cachedType, static_cast(event)); } } if(event) { - MW_LOG_MIL("pushing protection event! mediatype: %d", type); + MW_LOG_MIL("Pushing protection event: mediaType=%d cachedType=%d event=%p", type, cachedType, static_cast(event)); if (!gst_pad_push_event(sourceEleSrcPad, event)) { - MW_LOG_ERR("push protection event failed!"); + MW_LOG_ERR("ProtectionEvent push failed: mediaType=%d cachedType=%d", type, cachedType); + } + else + { + MW_LOG_MIL("ProtectionEvent push succeeded: mediaType=%d cachedType=%d", type, cachedType); } } } @@ -3612,15 +3620,17 @@ void InterfacePlayerRDK::QueueProtectionEvent(const std::string& formatType, con gst_buffer_unref (pssi); } + MW_LOG_MIL("ProtectionEvent created for cache: type=%d event=%p", type, static_cast(newEvent)); GstPlayerPriv *context = interfacePlayerPriv->gstPrivateContext; std::lock_guard lock(context->protectionEventMutex); if (context->protectionEvent[type] != NULL) { - MW_LOG_MIL("Previously cached protection event is present for type(%d), clearing!", type); + MW_LOG_MIL("Replacing cached ProtectionEvent: type=%d oldEvent=%p newEvent=%p", type, static_cast(context->protectionEvent[type]), static_cast(newEvent)); gst_event_unref(context->protectionEvent[type]); } context->protectionEvent[type] = newEvent; + MW_LOG_MIL("ProtectionEvent cached: type=%d event=%p", type, static_cast(context->protectionEvent[type])); } /** @@ -3630,11 +3640,12 @@ void InterfacePlayerRDK::ClearProtectionEvent() { GstPlayerPriv *context = interfacePlayerPriv->gstPrivateContext; std::lock_guard lock(context->protectionEventMutex); + MW_LOG_MIL("ProtectionEvent cache clear requested"); for (int i = 0; i < GST_TRACK_COUNT; i++) { if(context->protectionEvent[i]) { - MW_LOG_MIL("removing protection event! "); + MW_LOG_MIL("Removing cached ProtectionEvent: type=%d event=%p", i, static_cast(context->protectionEvent[i])); gst_event_unref(context->protectionEvent[i]); context->protectionEvent[i] = NULL; } From ff73a02bc2192a4128f31ed408a25a03aaa7ab69 Mon Sep 17 00:00:00 2001 From: dp0000 <53818367+dp0000@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:47:53 +0530 Subject: [PATCH 5/5] Update InterfacePlayerRDK.cpp --- middleware/InterfacePlayerRDK.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/InterfacePlayerRDK.cpp b/middleware/InterfacePlayerRDK.cpp index eacb3481ff..a306127db9 100644 --- a/middleware/InterfacePlayerRDK.cpp +++ b/middleware/InterfacePlayerRDK.cpp @@ -71,7 +71,7 @@ static const char* GstPluginNameVMX = "verimatrixdecryptor"; /*InterfacePlayerRDK constructor*/ InterfacePlayerRDK::InterfacePlayerRDK(bool isRialto) : mPauseInjector(false), mSourceSetupMutex(), stopCallback(NULL), tearDownCb(NULL), notifyFirstFrameCallback(NULL), -mSourceSetupCV(), mScheduler(), callbackMap(), setupStreamCallbackMap(), mDrmSystem(NULL), mEncrypt(NULL), mDRMSessionManager(NULL) +mSourceSetupCV(), callbackMap(), setupStreamCallbackMap(), mDrmSystem(NULL), mEncrypt(NULL), mDRMSessionManager(NULL) { interfacePlayerPriv = new InterfacePlayerPriv(isRialto); m_gstConfigParam = new Configs();