Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d9785d1
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 16, 2026
ca31d25
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 16, 2026
a3c4894
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 16, 2026
e47a738
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 16, 2026
68351de
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 17, 2026
58ef3c0
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13040_GrowableBuffe…
DomSyna Mar 17, 2026
fb2f628
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 17, 2026
98725ce
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13040_GrowableBuffe…
DomSyna Mar 17, 2026
955b80e
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 17, 2026
fe0309b
VPLAY-13054 copilot-instructions.md update - c++11 -> c++17 (#1191)
pstroffolino Mar 17, 2026
b9d2a35
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13040_GrowableBuffe…
DomSyna Mar 18, 2026
09b4fad
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 18, 2026
36b7d10
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 18, 2026
34686cd
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13040_GrowableBuffe…
DomSyna Mar 19, 2026
a44e966
VPLAY-13040 move AampGrowableBuffer to std::vector in AampMediaSample…
DomSyna Mar 19, 2026
7a312dd
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13040_GrowableBuffe…
pstroffolino Mar 19, 2026
b1630db
Apply suggestions from code review
pstroffolino Mar 19, 2026
6c9f7b8
Potential fix for pull request finding
pstroffolino Mar 19, 2026
e32c5d0
Potential fix for pull request finding
pstroffolino Mar 19, 2026
fb86f19
Potential fix for pull request finding
pstroffolino Mar 19, 2026
c762945
VPLAY-13071 Enforce move semantics on AampMediaSample send APIs
pstroffolino Mar 19, 2026
30d9f82
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13071
pstroffolino Mar 19, 2026
3e35b06
Merge branch 'dev_sprint_25_2' into feature/VPLAY-13071
pstroffolino Mar 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions AampDemuxDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,25 @@

#include <string>
#include <vector>
#include <cstring> // for std::memset
#include "AampGrowableBuffer.h" // for AampGrowableBuffer
#include <cstdint>
#include "DemuxDataTypes.h" // for MediaDrmMetadata

/*
/**
* @struct AampMediaSample
* @brief Media sample structure
* @brief Media sample structure.
*
* In future, we can consider unifying this with MediaSample in DemuxDataTypes.h
*/
struct AampMediaSample
{
// For lifetime management of sample data, we are using AampGrowableBuffer
AampGrowableBuffer mData;
double mPts;
double mDts;
double mDuration;

MediaDrmMetadata mDrmMetadata; // DRM metadata for encrypted samples

/**
* @brief Constructor for AampMediaSample
*/
AampMediaSample() : mData("AampMediaSample"), mPts(0), mDts(0), mDuration(0), mDrmMetadata()
{
}
std::vector<uint8_t> mData{}; /**< Sample data buffer */
double mPts{0.0};
double mDts{0.0};
double mDuration{0.0};
MediaDrmMetadata mDrmMetadata{}; /**< DRM metadata for encrypted samples */

// Move constructor and move assignment (allow efficient transfers)
AampMediaSample() = default;
AampMediaSample(AampMediaSample&&) = default;
AampMediaSample& operator=(AampMediaSample&&) = default;

Expand Down
2 changes: 1 addition & 1 deletion AampStreamSinkInactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AampStreamSinkInactive : public StreamSink
* @fn SendSample
* @brief stub implementation for Inactive aamp instance
*/
virtual bool SendSample( AampMediaType mediaType, AampMediaSample& sample)
virtual bool SendSample( AampMediaType mediaType, AampMediaSample&& sample)
{
AAMPLOG_WARN("Called AAMPGstPlayer()::%s stub", __FUNCTION__);
return false;
Expand Down
9 changes: 4 additions & 5 deletions FragmentCacheDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#ifndef FRAGMENT_CACHE_DESCRIPTOR_H
#define FRAGMENT_CACHE_DESCRIPTOR_H

#include "AampGrowableBuffer.h"
#include "AampMediaType.h"
#include <cstdint>
#include <string>
#include <vector>

/**
* @struct FragmentCacheDescriptor
Expand All @@ -48,10 +48,10 @@ struct FragmentCacheDescriptor
const char* chunkPayload;

/**
* @brief Fragment mode buffer (for ZERO-COPY move)
* Ownership transferred via std::move() to CachedFragment
* @brief Fragment mode buffer holding downloaded fragment data
* May be copied by the caching layer depending on API semantics
*/
AampGrowableBuffer* downloadBuffer;
std::vector<uint8_t> downloadBuffer;

/**
* @brief Size of payload in bytes
Expand Down Expand Up @@ -162,7 +162,6 @@ struct FragmentCacheDescriptor
*/
FragmentCacheDescriptor()
: chunkPayload(nullptr)
, downloadBuffer(nullptr)
, payloadSize(0)
, url()
, position(0.0)
Expand Down
69 changes: 30 additions & 39 deletions MediaStreamContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool MediaStreamContext::CacheFragment(std::string fragmentUrl, unsigned int cur
maxInitDownloadTimeMS, initSegment, aamp->mTsbDepthMs, (unsigned long long)dnldInstance->GetPublishTime(), fragmentTime);
}

ret = aamp->GetFile(fragmentUrl, actualType, mTempFragment, effectiveUrl, &httpErrorCode, &downloadTimeS, range, curlInstance, true/*resetBuffer*/, &bitrate, &iFogError, fragmentDurationS, bucketType, maxInitDownloadTimeMS);
ret = aamp->GetFile(fragmentUrl, actualType, mTempFragment, effectiveUrl, httpErrorCode, &downloadTimeS, range, curlInstance, true/*resetBuffer*/, &bitrate, &iFogError, fragmentDurationS, bucketType, maxInitDownloadTimeMS);
if (initSegment && ret)
{
aamp->getAampCacheHandler()->InsertToInitFragCache(fragmentUrl, mTempFragment, effectiveUrl, actualType);
Expand Down Expand Up @@ -610,11 +610,11 @@ bool MediaStreamContext::CacheTsbFragment(std::shared_ptr<CachedFragment> fragme
// FN_TRACE_F_MPD( __FUNCTION__ );
std::lock_guard<std::mutex> lock(fetchChunkBufferMutex);
bool ret = false;
if(fragment->fragment.capacity() != 0 && WaitForCachedFragmentChunkInjected())
if(!fragment->fragment.empty() && WaitForCachedFragmentChunkInjected())
{
AAMPLOG_TRACE("Type[%s] fragmentTime %f discontinuity %d duration %f initFragment:%d", name, fragment->position, fragment->discontinuity, fragment->duration, fragment->initFragment);
CachedFragment* cachedFragment = GetFetchChunkBuffer(true);
if(cachedFragment->fragment.capacity() != 0)
if(!cachedFragment->fragment.empty())
{
// If following log is coming, possible memory leak. Need to clear the data first before slot reuse.
AAMPLOG_WARN("Fetch buffer has junk data, Need to free this up");
Expand Down Expand Up @@ -971,58 +971,49 @@ bool MediaStreamContext::DownloadFragment(DownloadInfoPtr dlInfo)
}

// Handle change in bandwidth for segmentBase streams, so need to load new range
if((dlInfo->bandwidth != fragmentDescriptor.Bandwidth) && IDX.capacity() != 0 && uriInfo.range.empty())
if((dlInfo->bandwidth != fragmentDescriptor.Bandwidth) && !IDX.empty() && uriInfo.range.empty())
{
// If the bandwidth is different, then set the range
if (dlInfo->bandwidth > 0)
{
dlInfo->fragmentOffset = 0;
dlInfo->fragmentOffset++; // first byte following packed index
if (IDX.capacity() != 0)
unsigned int firstOffset = 0;
if (ParseSegmentIndexBox(IDX.data(),
IDX.size(),
0,
NULL,
NULL,
&firstOffset))
{
unsigned int firstOffset;
ParseSegmentIndexBox(
IDX.data(),
IDX.size(),
0,
NULL,
NULL,
&firstOffset);
dlInfo->fragmentOffset += firstOffset;
}
if (dlInfo->fragmentOffset != 0 && IDX.capacity() != 0)
unsigned int referenced_size = 0;
float fragmentDuration = 0.0f;
AAMPLOG_DEBUG("current fragmentIndex = %d", dlInfo->fragmentIndex);
// Find the offset of previous fragment in new representation
for (int i = 0; i < dlInfo->fragmentIndex; i++)
{
unsigned int referenced_size;
float fragmentDuration;
AAMPLOG_DEBUG("current fragmentIndex = %d", dlInfo->fragmentIndex);
//Find the offset of previous fragment in new representation
for (int i = 0; i < dlInfo->fragmentIndex; i++)
if (ParseSegmentIndexBox(IDX.data(),
IDX.size(),
i,
&referenced_size,
&fragmentDuration,
NULL))
{
if (ParseSegmentIndexBox(
IDX.data(),
IDX.size(),
i,
&referenced_size,
&fragmentDuration,
NULL))
{
dlInfo->fragmentOffset += referenced_size;
}
dlInfo->fragmentOffset += referenced_size;
}
}
unsigned int referenced_size;
float fragmentDuration;
if (ParseSegmentIndexBox(
IDX.data(),
IDX.size(),
dlInfo->fragmentIndex,
&referenced_size,
&fragmentDuration,
NULL) )
if (ParseSegmentIndexBox(IDX.data(),
IDX.size(),
dlInfo->fragmentIndex,
&referenced_size,
&fragmentDuration,
NULL))
{
char range[MAX_RANGE_STRING_CHARS];
snprintf(range, sizeof(range), "%" PRIu64 "-%" PRIu64 "", dlInfo->fragmentOffset, dlInfo->fragmentOffset + referenced_size - 1);
AAMPLOG_INFO("%s [%s]",GetMediaTypeName(dlInfo->mediaType), range);
AAMPLOG_INFO("%s [%s]", GetMediaTypeName(dlInfo->mediaType), range);
uriInfo.range = range;
dlInfo->fragmentDurationSec = fragmentDuration;
}
Expand Down
19 changes: 8 additions & 11 deletions MediaStreamContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ class MediaStreamContext : public MediaTrack
MediaStreamContext(TrackType type, StreamAbstractionAAMP_MPD* ctx,
PrivateInstanceAAMP* aamp, const char* name) :
MediaTrack(type, aamp, name),
mediaType((AampMediaType)type), adaptationSet(NULL),
representation(NULL), fragmentIndex(0), timeLineIndex(0),
fragmentRepeatCount(0), fragmentOffset(0), eos(false),
fragmentTime(0), periodStartOffset(0), timeStampOffset(0),
IDX("fragment-IDX"), lastSegmentTime(0), lastSegmentNumber(0),
lastSegmentDuration(0), adaptationSetIdx(0),
representationIndex(0), profileChanged(true), adaptationSetId(0),
fragmentDescriptor(), context(ctx), initialization(""),
mediaType((AampMediaType)type), adaptationSet(NULL), representation(NULL),
fragmentIndex(0), timeLineIndex(0), fragmentRepeatCount(0), fragmentOffset(0),
eos(false), fragmentTime(0), periodStartOffset(0), timeStampOffset(0),
lastSegmentTime(0), lastSegmentNumber(0), lastSegmentDuration(0), adaptationSetIdx(0), representationIndex(0), profileChanged(true),
adaptationSetId(0), fragmentDescriptor(), context(ctx), initialization(""),
discontinuity(false), mSkipSegmentOnError(true),
lastDownloadedPosition(0), // ,mCMCDNetworkMetrics{-1,-1,-1}
scaledPTO(0), failAdjacentSegment(false), httpErrorCode(0),
Expand Down Expand Up @@ -326,14 +323,14 @@ bool CacheFragmentData(const FragmentCacheDescriptor& desc);
bool eos;
bool profileChanged;
bool discontinuity;
std::vector<uint8_t> mDownloadedFragment; /**< Fragment stored across ABR profile changes */
std::vector<uint8_t> mTempFragment; /**< Scratch buffer for init/download fragments */
std::vector<uint8_t> mDownloadedFragment{}; /**< Fragment stored across ABR profile changes */
std::vector<uint8_t> mTempFragment{}; /**< Scratch buffer for init/download fragments */

double fragmentTime; // Absolute Fragment time from Availability start
std::atomic<double> lastDownloadedPosition;
double periodStartOffset;
uint64_t timeStampOffset;
AampGrowableBuffer IDX;
std::vector<uint8_t> IDX{}; /**< Index data buffer for DASH byte-range segments */
uint64_t lastSegmentTime; // zeroed at start of period and also 0 when first segment of an ad has been sent otherwise fragmentDescriptor.Time
uint64_t lastSegmentNumber;
uint64_t lastSegmentDuration; //lastSegmentTime+ duration of that segment
Expand Down
7 changes: 5 additions & 2 deletions StreamSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ class StreamSink
/**
* @brief API to send audio/video sample into the sink.
*
* Ownership of the sample's payload is transferred to the sink.
* The caller must not access the sample after this call.
*
* @param[in] mediaType - Type of the media.
* @param[in] sample - Media sample
* @param[in] sample - Media sample (consumed on call)
* @return void
*/
virtual bool SendSample( AampMediaType mediaType, AampMediaSample& sample ) = 0;
virtual bool SendSample( AampMediaType mediaType, AampMediaSample&& sample ) = 0;
Comment on lines 94 to +98
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The Doxygen for SendSample still says "@return void" but the method returns bool. Please update the documentation to describe the boolean return value (and what true/false means), especially since this change is clarifying ownership/consumption semantics.

Copilot uses AI. Check for mistakes.

/**
* @brief Checks pipeline is configured for media type
Expand Down
4 changes: 2 additions & 2 deletions aampgstplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,9 +1351,9 @@ void AAMPGstPlayer::SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo
* @param[in,out] sample - Media sample to inject
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The SendSample Doxygen comment still marks the sample parameter as "[in,out]", but the API now takes an rvalue reference and explicitly consumes the sample. Please update the comment to reflect that the sample is input-only and is moved/consumed by the call.

Suggested change
* @param[in,out] sample - Media sample to inject
* @param[in] sample - Media sample to inject; ownership is transferred and
* its contents are moved/consumed by this call

Copilot uses AI. Check for mistakes.
* @return true if sample is successfully injected, false otherwise
*/
bool AAMPGstPlayer::SendSample(AampMediaType mediaType, AampMediaSample& sample)
bool AAMPGstPlayer::SendSample(AampMediaType mediaType, AampMediaSample&& sample)
{
MediaSample gstSample(sample.mData.ExtractVector(), sample.mPts, sample.mDts, sample.mDuration, 0.0);
MediaSample gstSample(std::move(sample.mData), sample.mPts, sample.mDts, sample.mDuration, 0.0);
gstSample.mDrmMetadata = std::move(sample.mDrmMetadata);

return SendHelper(mediaType, std::move(gstSample));
Expand Down
4 changes: 2 additions & 2 deletions aampgstplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class AAMPGstPlayer : public StreamSink
/**
* @fn SendSample
* @param[in] mediaType stream type
* @param[in] sample media sample
* @param[in] sample media sample (consumed on call)
*/
bool SendSample(AampMediaType mediaType, AampMediaSample& sample) override;
bool SendSample(AampMediaType mediaType, AampMediaSample&& sample) override;

/**
* @fn PipelineConfiguredForMedia
Expand Down
6 changes: 3 additions & 3 deletions admanager_mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ MPD* PrivateCDAIObjectMPD::GetAdMPD(std::string &manifestUrl, bool &finalManifes
AampGrowableBuffer manifest("adMPD_CDN");
bool gotManifest = false;
std::string effectiveUrl;
gotManifest = mAamp->GetFile(manifestUrl, eMEDIATYPE_MANIFEST, manifest.GetVector(), effectiveUrl, &http_error, &downloadTime, NULL, eCURLINSTANCE_DAI);
gotManifest = mAamp->GetFile(manifestUrl, eMEDIATYPE_MANIFEST, manifest.GetVector(), effectiveUrl, http_error, &downloadTime, NULL, eCURLINSTANCE_DAI);
if (gotManifest)
{
AAMPLOG_TRACE("PrivateCDAIObjectMPD:: manifest download success");
Expand Down Expand Up @@ -1010,7 +1010,7 @@ MPD* PrivateCDAIObjectMPD::GetAdMPD(std::string &manifestUrl, bool &finalManifes

AampGrowableBuffer fogManifest("adMPD_FOG");
http_error = 0;
mAamp->GetFile(effectiveUrl, eMEDIATYPE_MANIFEST, fogManifest.GetVector(), effectiveUrl, &http_error, &downloadTime, NULL, eCURLINSTANCE_DAI);
mAamp->GetFile(effectiveUrl, eMEDIATYPE_MANIFEST, fogManifest.GetVector(), effectiveUrl, http_error, &downloadTime, NULL, eCURLINSTANCE_DAI);
if(200 == http_error || 204 == http_error)
{
manifestUrl = std::move(effectiveUrl);
Expand Down Expand Up @@ -1897,7 +1897,7 @@ bool PrivateCDAIObjectMPD::FetchAndCacheInitHeaders(std::string& manifestStr, st
bool gotInit = mAamp->getAampCacheHandler()->RetrieveFromInitFragmentCache(fragmentUrl, adInit->GetVector(), fragmentUrl);
if(!gotInit)
{
gotInit = mAamp->GetFile(fragmentUrl, actualMediaType, adInit->GetVector(), fragmentUrl, &segment_http_error, &segment_downloadTime, nullptr, eCURLINSTANCE_DAI);
gotInit = mAamp->GetFile(fragmentUrl, actualMediaType, adInit->GetVector(), fragmentUrl, segment_http_error, &segment_downloadTime, nullptr, eCURLINSTANCE_DAI);
mAamp->UpdateVideoEndMetrics(actualMediaType, fragmentDescriptor->Bandwidth, segment_http_error, fragmentUrl, 0, segment_downloadTime);
}
if (gotInit)
Expand Down
12 changes: 6 additions & 6 deletions drm/DrmInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "DrmInterface.h"
#include "Aes.h"
#include "HlsOcdmBridgeInterface.h"
#include "AampGrowableBuffer.h"
#include "HlsDrmSessionManager.h"
#include "AampDRMLicManager.h"
#define AES_128_KEY_LEN_BYTES 16
Expand Down Expand Up @@ -86,10 +85,9 @@ void registerCallbackForHls(DrmInterface* _this, PlayerHlsDrmSessionInterface* i
/*
* @brief DrmInterface constructor
* */
DrmInterface::DrmInterface(PrivateInstanceAAMP* aamp):mAesKeyBuf("aesKeyBuf")
DrmInterface::DrmInterface(PrivateInstanceAAMP* aamp)
: mpAamp(aamp)
{

mpAamp = aamp;
}

/*
Expand Down Expand Up @@ -165,20 +163,21 @@ void DrmInterface::ProfileUpdateDrmDecrypt(bool type, int bucketType)
*/
void DrmInterface::GetAccessKey(std::string &keyURI, std::string& tempEffectiveUrl, int& http_error, double& downloadTime,unsigned int curlInstance, bool &keyAcquisitionStatus, int &failureReason, char** ptr)
{
bool fetched = mpAamp->GetFile(keyURI, (AampMediaType)eMEDIATYPE_LICENCE, mAesKeyBuf.GetVector(), tempEffectiveUrl, &http_error, &downloadTime, NULL, curlInstance, true);
*ptr = reinterpret_cast<char*>(mAesKeyBuf.data());
bool fetched = mpAamp->GetFile(keyURI, (AampMediaType)eMEDIATYPE_LICENCE, mAesKeyBuf, tempEffectiveUrl, http_error, &downloadTime, NULL, curlInstance, true);

if (fetched)
{
if (AES_128_KEY_LEN_BYTES == mAesKeyBuf.size() )
{
AAMPLOG_WARN("Key fetch success len = %d", (int)mAesKeyBuf.size());
keyAcquisitionStatus = true;
*ptr = reinterpret_cast<char*>(mAesKeyBuf.data());
}
else
{
AAMPLOG_ERR("Error Key fetch - size %d", (int)mAesKeyBuf.size() );
failureReason = AAMP_TUNE_INVALID_DRM_KEY;
*ptr = nullptr;
}
}
else
Expand All @@ -192,6 +191,7 @@ void DrmInterface::GetAccessKey(std::string &keyURI, std::string& tempEffective
{
failureReason = AAMP_TUNE_LICENCE_REQUEST_FAILED;
}
*ptr = nullptr;
}
}

Expand Down
5 changes: 3 additions & 2 deletions drm/DrmInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <stddef.h>
#include <memory>
#include <vector>
#include <condition_variable>
#include <priv_aamp.h>
#include <AampCurlDefine.h>
Expand Down Expand Up @@ -96,8 +97,8 @@ class DrmInterface
/**
* Storing aamp instance */
PrivateInstanceAAMP* mpAamp;
/**Storing AampGrowableBuffer */
AampGrowableBuffer mAesKeyBuf;
/** AES key buffer for HLS AES-128 decryption */
std::vector<uint8_t> mAesKeyBuf{};

/**
* @fn GetAccessKey
Expand Down
Loading
Loading