Skip to content

RDKEMW-28121: Pass buffers by reference to avoid unnecessary copies - #320

Open
jaihere4u wants to merge 1 commit into
developfrom
RDKEMW-28121
Open

jaihere4u wants to merge 1 commit into
developfrom
RDKEMW-28121

Conversation

@jaihere4u

Copy link
Copy Markdown
  • PlayerScheduler::ScheduleTask: move the by-value PlayerAsyncTaskObj into the queue instead of copying it.
  • DrmSessionManager::IsKeyIdProcessed and initializeDrmSession: take const references; both are read-only over the parameter.
  • DrmHelper::transformLicenseResponse (ClearKeyHelper, VerimatrixHelper): take const std::shared_ptr& to avoid an atomic ref-count bump per license-response transform.
  • GetAudioTracksOta / GetTextTracksOta: changed to non-const out-references. These were passed by value but filled inside; the populated track data never reached callers and every call copied.
  • PlayerThunderAccess::StartRmf url param: read-only, now const ref.
  • BusMessageCallback typedef: pass BusEventData by const ref, avoiding a copy of the event payload on every GStreamer bus-message dispatch.

StartOta intentionally left by value: its parameters are forwarded with std::move into the SetPreferredAudioLanguages_OTA sink, so the by-value + move idiom is already optimal there.

- PlayerScheduler::ScheduleTask: move the by-value PlayerAsyncTaskObj
  into the queue instead of copying it.
- DrmSessionManager::IsKeyIdProcessed and initializeDrmSession: take
  const references; both are read-only over the parameter.
- DrmHelper::transformLicenseResponse (ClearKeyHelper, VerimatrixHelper):
  take const std::shared_ptr<DrmData>& to avoid an atomic ref-count
  bump per license-response transform.
- GetAudioTracksOta / GetTextTracksOta: changed to non-const
  out-references. These were passed by value but filled inside; the
  populated track data never reached callers and every call copied.
- PlayerThunderAccess::StartRmf url param: read-only, now const ref.
- BusMessageCallback typedef: pass BusEventData by const ref, avoiding
  a copy of the event payload on every GStreamer bus-message dispatch.

StartOta intentionally left by value: its parameters are forwarded
with std::move into the SetPreferredAudioLanguages_OTA sink, so the
by-value + move idiom is already optimal there.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 31, 2026 03:54
@jaihere4u
jaihere4u requested a review from a team as a code owner October 31, 2026 03:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Outdated overrides break compilation, and reused output vectors can retain stale tracks and produce incorrect results.

5 open issues
What changed in this PR

This PR aims to reduce unnecessary copies across scheduling, DRM, and Thunder integration, while allowing over-the-air track queries to populate caller-owned vectors.

Changes:

  • Uses const references for read-only DRM parameters, RMF URLs, and bus-event payloads.
  • Changes audio and text track vectors to output references across Thunder interfaces.
  • Adds std::move when enqueueing scheduled tasks.
File Description
test/​utests/​fakes/​FakePlayerThunderInterface.cpp Aligns fake method signatures with the interface changes.
PlayerScheduler.cpp Adds move syntax when enqueueing tasks.
InterfacePlayerRDK.h Passes bus-event payloads by const reference.
externals/​rdk/​PlayerThunderAccess.h Updates track-output and RMF URL declarations.
externals/​rdk/​PlayerThunderAccess.cpp Applies reference parameters to Thunder implementations.
externals/​PlayerThunderInterface.h Exposes the updated reference-based signatures.
externals/​PlayerThunderInterface.cpp Forwards track vectors and URLs by reference.
externals/​PlayerThunderAccessBase.h Updates the abstract Thunder contract.
drm/​helper/​VerimatrixHelper.h Updates the license-response parameter declaration.
drm/​helper/​VerimatrixHelper.cpp Receives the license-response pointer by const reference.
drm/​helper/​DrmHelper.h Updates the virtual license-response signature.
drm/​helper/​ClearKeyHelper.h Aligns the ClearKey override declaration.
drm/​helper/​ClearKeyHelper.cpp Receives the license-response pointer by const reference.
drm/​DrmSessionManager.h Declares const-reference key and helper parameters.
drm/​DrmSessionManager.cpp Applies const references to key lookup and session initialization.

Review effort: Balanced

Comment thread drm/helper/DrmHelper.h
* @param licenseResponse license response from the server to transform
*/
virtual void transformLicenseResponse(std::shared_ptr<DrmData> licenseResponse) const {}
virtual void transformLicenseResponse(const std::shared_ptr<DrmData> &licenseResponse) const {}
* @return string of current track pk
*/
virtual std::string GetAudioTracksOta(std::vector<PlayerAudioData> audData) = 0;
virtual std::string GetAudioTracksOta(std::vector<PlayerAudioData> &audData) = 0;
Comment on lines +717 to 718
std::string PlayerThunderAccess::GetAudioTracksOta(std::vector<PlayerAudioData> &audData)
{
Comment on lines +792 to 793
bool PlayerThunderAccess::GetTextTracksOta(std::vector<PlayerTextData> &txtData)
{
Comment thread PlayerScheduler.cpp
}
obj.mId = id;
mTaskQueue.push_back(obj);
mTaskQueue.push_back(std::move(obj));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants