Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion AampConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
{MAX_GST_AUDIO_BUFFER_BYTES,"gstAudioBufBytes", eAAMPConfig_GstAudioBufBytes,true},
{DEFAULT_LATENCY_MONITOR_DELAY_MS,"latencyMonitorDelayMs",eAAMPConfig_LatencyMonitorDelayMs,false},
{DEFAULT_LATENCY_MONITOR_INTERVAL_MS,"latencyMonitorIntervalMs",eAAMPConfig_LatencyMonitorIntervalMs,false},
{DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK,"downloadBufferChunks",eAAMPConfig_MaxFragmentChunkCached,false},
{DEFAULT_LLD_CACHED_FRAGMENTS_PER_TRACK,"downloadBufferChunks",eAAMPConfig_MaxLLDFragmentCached,false},
{DEFAULT_AAMP_ABR_CHUNK_THRESHOLD_SIZE,"abrChunkThresholdSize",eAAMPConfig_ABRChunkThresholdSize,false},
{MAX_SEG_DOWNLOAD_FAIL_COUNT,"fragmentDownloadFailThreshold",eAAMPConfig_FragmentDownloadFailThreshold,false,eCONFIG_RANGE_DOWNLOAD_ERROR_THRESHOLD },
{MAX_INIT_FRAGMENT_CACHE_PER_TRACK,"maxInitFragCachePerTrack",eAAMPConfig_MaxInitFragCachePerTrack,true, eCONFIG_RANGE_INIT_FRAGMENT_CACHE },
Expand Down
2 changes: 1 addition & 1 deletion AampConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ typedef enum
eAAMPConfig_GstAudioBufBytes, /**< Gstreamer Max Audio buffering bytes*/
eAAMPConfig_LatencyMonitorDelayMs, /**< Latency Monitor Delay */
eAAMPConfig_LatencyMonitorIntervalMs, /**< Latency Monitor Interval */
eAAMPConfig_MaxFragmentChunkCached, /**< fragment chunk cache length*/
eAAMPConfig_MaxLLDFragmentCached, /**< LLD fragment cache length */
eAAMPConfig_ABRChunkThresholdSize, /**< AAMP ABR Chunk threshold size*/
eAAMPConfig_FragmentDownloadFailThreshold, /**< Retry attempts for non-init fragment curl timeout failures*/
eAAMPConfig_MaxInitFragCachePerTrack, /**< Max no of Init fragment cache per track */
Expand Down
2 changes: 1 addition & 1 deletion AampDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
#define AAMP_FOG_TSB_URL_KEYWORD "tsb?" /**< AAMP expect this keyword in URL to identify it is FOG url */

#define DEFAULT_INITIAL_RATE_CORRECTION_SPEED 1.000001f /**< Initial rate correction speed to avoid audio drop */
#define DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK 20 /**< Default cached fragment chunks per track */
#define DEFAULT_LLD_CACHED_FRAGMENTS_PER_TRACK 20 /**< Default LLD cached fragments per track */
#define DEFAULT_AAMP_ABR_CHUNK_THRESHOLD_SIZE (DEFAULT_AAMP_ABR_THRESHOLD_SIZE) /**< aamp abr Chunk threshold size */
#define DEFAULT_ABR_CHUNK_SPEEDCNT 10 /**< Chunk Speed Count Store Size */
#define DEFAULT_ABR_ELAPSED_MILLIS_FOR_ESTIMATE 100 /**< Duration(ms) to check Chunk Speed */
Expand Down
16 changes: 8 additions & 8 deletions MediaStreamContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ bool MediaStreamContext::CacheFragmentChunk(AampMediaType actualType, const uint
return false;
}
bool ret = true;
if (WaitForCachedFragmentChunkInjected())
if (WaitForCachedFragmentInjected())
{
CachedFragment *cachedFragment = NULL;
cachedFragment = GetFetchChunkBuffer(true);
cachedFragment = GetFetchBuffer(true);
if (NULL == cachedFragment)
{
AAMPLOG_WARN("[%s] Something Went wrong - Can't get FetchChunkBuffer", name);
Expand Down Expand Up @@ -254,11 +254,11 @@ bool MediaStreamContext::CacheFragmentChunk(AampMediaType actualType, const uint
cachedFragment->PTSOffsetSec = GetContext()->mPTSOffset.inSeconds();

AAMPLOG_TRACE("[%s] cachedFragment %p ptr %p", name, cachedFragment, cachedFragment->fragment.data());
UpdateTSAfterChunkFetch();
UpdateTSAfterFetch();
}
else
{
AAMPLOG_TRACE("[%s] WaitForCachedFragmentChunkInjected aborted", name);
AAMPLOG_TRACE("[%s] WaitForCachedFragmentInjected aborted", name);
ret = false;
}
return ret;
Expand Down Expand Up @@ -627,13 +627,13 @@ bool MediaStreamContext::CacheTsbFragment(std::shared_ptr<CachedFragment>&& frag
// FN_TRACE_F_MPD( __FUNCTION__ );
std::lock_guard<std::mutex> lock(fetchChunkBufferMutex);
bool ret = false;
if(!fragment->fragment.empty() && WaitForCachedFragmentChunkInjected())
if(!fragment->fragment.empty() && WaitForCachedFragmentInjected())
{
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);
CachedFragment* cachedFragment = GetFetchBuffer(true);
if(!cachedFragment)
{
AAMPLOG_ERR("[%s] GetFetchChunkBuffer returned null", name);
AAMPLOG_ERR("[%s] GetFetchBuffer returned null", name);
return false;
}
if(!cachedFragment->fragment.empty())
Expand All @@ -645,7 +645,7 @@ bool MediaStreamContext::CacheTsbFragment(std::shared_ptr<CachedFragment>&& frag
if(!cachedFragment->fragment.empty())
{
ret = true;
UpdateTSAfterChunkFetch();
UpdateTSAfterFetch();
}
else
{
Expand Down
88 changes: 39 additions & 49 deletions StreamAbstractionAAMP.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's license file the

Check failure on line 2 in StreamAbstractionAAMP.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID Detected License Issue

Snippet with 'Apache-2.0' file license found (275 lines) Location: https://github.com/pxscene/pxCore2/blob/2.1.0.0/examples/pxScene2d/external/aamp/StreamAbstractionAAMP.h#L2 Component: pkg:github/pxscene/pxcore2@2.1.0.0 Download: https://github.com/pxscene/pxCore2/archive/refs/tags/2.1.0.0.tar.gz
* following copyright and licenses apply:
*
* Copyright 2018 RDK Management
Expand Down Expand Up @@ -32,6 +32,7 @@
#include <map>
#include <iterator>
#include <vector>
#include <array>
#include <condition_variable>

#include <glib.h>
Expand Down Expand Up @@ -181,11 +182,11 @@
uint32_t GetManifestUpdateCounter();

/**
* @fn AbortWaitForCachedFragmentChunk
* @fn AbortWaitForCachedFragmentInjected
*
* @return void
*/
void AbortWaitForCachedFragmentChunk();
void AbortWaitForCachedFragmentInjected();

/**
* @fn WaitForManifestUpdate
Expand Down Expand Up @@ -346,13 +347,6 @@
*/
void UpdateInjectedDuration(double surplusDuration);

/**
* @brief Get total fragment chunk injected duration
*
* @return Total duration in seconds
*/
double GetTotalInjectedChunkDuration() { return totalInjectedChunksDuration; };

/**
* @fn RunInjectLoop
*
Expand All @@ -369,11 +363,11 @@
void UpdateTSAfterFetchStats(CachedFragment* cachedFragment, bool isInitSegment);

/**
* @fn UpdateTSAfterChunkFetch
* @fn UpdateTSAfterFetch
*
* @return void
*/
void UpdateTSAfterChunkFetch();
void UpdateTSAfterFetch();

/**
* @fn WaitForFreeFragmentAvailable
Expand All @@ -383,10 +377,10 @@
bool WaitForFreeFragmentAvailable( int timeoutMs = -1);

/**
* @fn WaitForCachedFragmentChunkInjected
* @retval true if fragment chunk injected , false on abort.
* @fn WaitForCachedFragmentInjected
* @retval true if fragment injected, false on abort.
*/
bool WaitForCachedFragmentChunkInjected(int timeoutMs = -1);
bool WaitForCachedFragmentInjected(int timeoutMs = -1);

/**
* @fn AbortWaitForCachedAndFreeFragment
Expand Down Expand Up @@ -439,11 +433,11 @@
virtual double GetBufferedDuration (void) = 0;

/**
* @fn GetFetchChunkBuffer
* @param[in] initialize true to initialize the fragment chunk
* @retval Pointer to fragment chunk buffer.
* @fn GetFetchBuffer
* @param[in] initialize true to initialize the fragment slot
* @retval Pointer to the next fragment fetch slot.
*/
CachedFragment *GetFetchChunkBuffer(bool initialize);
CachedFragment *GetFetchBuffer(bool initialize);

/**
* @brief Check if the fragment cache buffer is full
Expand Down Expand Up @@ -478,14 +472,14 @@
*
* @return Total duration in seconds
*/
double GetTotalFetchedDuration() { return totalFetchedDuration; };
double GetTotalFetchedDuration();

/**
* @brief Get total duration of fetched fragments
* @brief Get total duration of injected fragment chunks (LLD chunk mode)
*
* @return Total duration in seconds
*/
double GetTotalInjectedChunksDuration() { return totalInjectedChunksDuration; };
double GetTotalInjectedChunksDuration() { return totalInjectedChunksDuration; }

/**
* @brief Check if discontinuity is being processed
Expand Down Expand Up @@ -583,12 +577,6 @@
*/
void FlushFragments();

/**
* @fn FlushFragmentChunks
*
* @return void
*/
void FlushFragmentChunks();
/**
* @brief API to wait thread until the fragment cached after audio reconfiguration
*/
Expand Down Expand Up @@ -620,18 +608,18 @@
bool SignalIfEOSReached();

/**
* @brief GetCachedFragmentChunksSize - Getter for fragment chunks cache size
* @brief GetCachedFragmentSize - Getter for fragment cache active window size
*
* @return size_t
*/
std::size_t GetCachedFragmentChunksSize() { return mCachedFragmentChunksSize; }
std::size_t GetCachedFragmentSize() { return mCachedFragmentSize; }

/**
* @brief SetCachedFragmentChunksSize - Setter for fragment chunks cache size
* @brief SetCachedFragmentSize - Setter for fragment cache active window size
*
* @param[in] size Size for fragment chunks cache
* @param[in] size Active window size (must be > 0 and <= DEFAULT_LLD_CACHED_FRAGMENTS_PER_TRACK)
*/
void SetCachedFragmentChunksSize(size_t size);
void SetCachedFragmentSize(size_t size);

void SourceFormat(StreamOutputFormat fmt) { mSourceFormat = fmt; }

Expand Down Expand Up @@ -681,14 +669,14 @@
*
* @return void
*/
void UpdateTSAfterChunkInject();
void UpdateTSAfterInject();

/**
* @fn WaitForCachedFragmentChunkAvailable
* @fn WaitForCachedFragmentAvailable
*
* @return TRUE if fragment chunk available, FALSE if aborted/fragment chunk not available.
* @return TRUE if fragment available, FALSE if aborted or not available.
*/
bool WaitForCachedFragmentChunkAvailable();
bool WaitForCachedFragmentAvailable();

/**
* @brief Get the context of media track. To be implemented by subclasses
Expand Down Expand Up @@ -793,7 +781,7 @@
public:
bool eosReached; /**< set to true when a vod asset has been played to completion */
bool enabled; /**< set to true if track is enabled */
int numberOfFragmentChunksCached; /**< Number of fragments cached in this track*/
int numberOfFragmentsCached; /**< Number of fragments cached in this track*/
const char* name; /**< Track name used for debugging*/
double fragmentDurationSeconds; /**< duration in seconds for current fragment-of-interest */
int segDLFailCount; /**< Segment download fail count*/
Expand All @@ -803,8 +791,8 @@
std::unique_ptr<SubtitleParser> mSubtitleParser; /**< Parser for subtitle data*/
bool refreshSubtitles; /**< Switch subtitle track in the FetchLoop */
bool refreshAudio; /** Switch audio track in the FetcherLoop */
int maxCachedFragmentChunksPerTrack;
std::condition_variable fragmentChunkFetched;/**< Signaled after a fragment Chunk is fetched*/
int maxLLDCachedFragmentsPerTrack;
std::condition_variable fragmentFetched;/**< Signaled after a fragment is fetched*/
int noMDATCount; /**< MDAT Chunk Not Found count continuously while chunk buffer processing*/
double m_totalDurationForPtsRestamping;
std::shared_ptr<MediaProcessor> playContext; /**< state for s/w demuxer / pts/pcr restamper module */
Expand All @@ -815,7 +803,9 @@
protected:
PrivateInstanceAAMP* aamp; /**< Pointer to the PrivateInstanceAAMP*/
std::shared_ptr<IsoBmffHelper> mIsoBmffHelper; /**< Helper class for ISO BMFF parsing */
CachedFragment mCachedFragmentChunks[DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK];
/** Per-track ring buffer; static capacity sized for live LLD chunks.
* The active window is `mCachedFragmentSize`, which never exceeds the array size. */
std::array<CachedFragment, DEFAULT_LLD_CACHED_FRAGMENTS_PER_TRACK> mCachedFragment{};
std::vector<uint8_t> unparsedBufferChunk{}; /**< Unparsed buffer chunk for ISOBMFF chunk processing */
std::vector<uint8_t> parsedBufferChunk{}; /**< Parsed buffer chunk for ISOBMFF chunk processing */
bool abort; /**< Abort all operations if flag is set*/
Expand All @@ -826,8 +816,8 @@
bool loadNewAudio; /**< Flag to indicate new audio loading started on seamless audio switch */
std::mutex subtitleMutex;
bool loadNewSubtitle;
int fragmentChunkIdxToInject; /**< Write position */
int fragmentChunkIdxToFetch; /**< Read position */
int fragmentIdxToInject; /**< Write position */
int fragmentIdxToFetch; /**< Read position */

StreamOutputFormat mSourceFormat {StreamOutputFormat::FORMAT_INVALID};
std::shared_ptr<aamp::AampTimeBasedBufferManager> mTimeBasedBufferManager; /**< Time based buffer for managing fragment download and playback */
Expand All @@ -843,7 +833,7 @@

std::mutex injectorStartMutex; /**< Mutex to protect injector start */
std::thread fragmentInjectorThreadID; /**< Fragment injector thread id*/
std::condition_variable fragmentChunkInjected; /**< Signaled after a fragment is injected*/
std::condition_variable fragmentInjected; /**< Signaled after a fragment is injected*/
std::thread bufferMonitorThreadID; /**< Buffer Monitor thread id */
std::thread subtitleClockThreadID; /**< subtitle clock synchronisation thread id */
int totalFragmentsDownloaded; /**< Total fragments downloaded since start by track*/
Expand All @@ -865,14 +855,14 @@
bool abortPlaylistDownloader; /**< Flag used to abort playlist downloader*/
std::condition_variable plDownloadWait; /**< Conditional variable for signaling timed wait*/
std::mutex dwnldMutex; /**< Download mutex for conditional timed wait, used for playlist and fragment downloads*/
uint32_t mManifestUpdateCounter; /**< Monotonically increasing counter incremented by AbortWaitForManifestUpdate. */
uint32_t mManifestUpdateCounter; /**< Monotonically increasing counter incremented by AbortWaitForManifestUpdate. */
std::condition_variable mManifestUpdateWait; /**< Conditional variable for signaling manifest update */
std::condition_variable audioFragmentCached; /**< Signal after a audio fragment cached after reconfigure */
double lastInjectedPosition; /**< Last injected position */
double lastInjectedDuration; /**< Last injected fragment end position */
double lastInjectedPosition; /**< Last injected position */
double lastInjectedDuration; /**< Last injected fragment end position */
std::condition_variable subtitleFragmentCached;
std::atomic_bool mIsLocalTSBInjection;
size_t mCachedFragmentChunksSize; /**< Size of fragment chunks cache */
size_t mCachedFragmentSize; /**< Active window size of the fragment ring buffer */
AampTime mLastFragmentPts; /**< pts of the previous fragment, used in trick modes */
AampTime mRestampedPts; /**< Restamped Pts of the segment, used in trick modes */
AampTime mRestampedDuration; /**< Restamped segment duration, used in trick modes */
Expand Down Expand Up @@ -1822,11 +1812,11 @@
}

/**
* @fn UnblockWaitForCachedFragmentChunk
* @fn UnblockWaitForCachedFragmentInjected
*
* @return void
*/
void UnblockWaitForCachedFragmentChunk();
void UnblockWaitForCachedFragmentInjected();

/**
* @brief Get available thumbnail bitrates.
Expand Down
24 changes: 12 additions & 12 deletions fragmentcollector_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,10 +1293,10 @@ bool TrackState::FetchFragmentHelper(int &http_error, bool &decryption_error, bo
if (!mInjectInitFragment && !fragmentURI.empty() && !bSegmentRepeated)
{
std::string fragmentUrl;
CachedFragment* cachedFragment = GetFetchChunkBuffer(true);
CachedFragment* cachedFragment = GetFetchBuffer(true);
if (!cachedFragment)
{
AAMPLOG_WARN("[%s] GetFetchChunkBuffer returned null", name);
AAMPLOG_WARN("[%s] GetFetchBuffer returned null", name);
ReleasePlaylistLock();
return false;
}
Expand Down Expand Up @@ -1665,10 +1665,10 @@ void TrackState::FetchFragment()
context->mRampDownCount = 0;
}

CachedFragment* cachedFragment = GetFetchChunkBuffer(false);
CachedFragment* cachedFragment = GetFetchBuffer(false);
if (!cachedFragment)
{
AAMPLOG_WARN("[%s] GetFetchChunkBuffer returned null in FetchFragment", name);
AAMPLOG_WARN("[%s] GetFetchBuffer returned null in FetchFragment", name);
return;
}
if (cachedFragment->fragment.capacity() != 0)
Expand Down Expand Up @@ -1734,11 +1734,11 @@ void TrackState::FetchFragment()
AAMPLOG_WARN("%s cachedFragment->fragment has no allocated data buffer", name);
}
mSkipAbr = false; //To enable ABR since we have cached fragment after init fragment
// Order matters: UpdateTSAfterChunkFetch() increments numberOfFragmentChunksCached,
// Order matters: UpdateTSAfterFetch() increments numberOfFragmentsCached,
// which UpdateTSAfterFetchStats() then reads for its cache-full / caching-complete
// decision. Calling the stats function first would observe a stale (pre-increment)
// count and miss the "chunk cache is full" abort trigger on the slot-filling fragment.
UpdateTSAfterChunkFetch();
UpdateTSAfterFetch();
UpdateTSAfterFetchStats(cachedFragment, false);
}
}
Expand Down Expand Up @@ -6084,10 +6084,10 @@ void TrackState::FetchInitFragment()
{
aamp->profiler.ProfileEnd(bucketType);

CachedFragment *cachedFragment = GetFetchChunkBuffer(false);
CachedFragment *cachedFragment = GetFetchBuffer(false);
if (!cachedFragment)
{
AAMPLOG_WARN("[%s] GetFetchChunkBuffer returned null for init fragment in FetchFragment", name);
AAMPLOG_WARN("[%s] GetFetchBuffer returned null for init fragment in FetchFragment", name);
mInjectInitFragment = true; // mark for retry
return;
}
Expand All @@ -6108,10 +6108,10 @@ void TrackState::FetchInitFragment()
mSkipAbr = true; // Skip ABR, since last fragment cached is init fragment.
mCheckForInitialFragEnc = false; // Push encrypted header is a one-time operation
mFirstEncInitFragmentInfo = NULL; // reset init fragment, since encrypted header already pushed
// Order matters: UpdateTSAfterChunkFetch() increments numberOfFragmentChunksCached,
// Order matters: UpdateTSAfterFetch() increments numberOfFragmentsCached,
// which UpdateTSAfterFetchStats() reads for cache-full / caching-complete handling.
// Kept consistent with FetchFragment() to avoid divergent stale-count behaviour.
UpdateTSAfterChunkFetch();
UpdateTSAfterFetch();
UpdateTSAfterFetchStats(cachedFragment, true);
}
else if (type == eTRACK_VIDEO && aamp->CheckABREnabled() && !context->CheckForRampDownLimitReached())
Expand Down Expand Up @@ -6246,10 +6246,10 @@ bool TrackState::FetchInitFragmentHelper(int &http_code, bool forcePushEncrypted
std::string fragmentUrl;
aamp_ResolveURL(fragmentUrl, mEffectiveUrl, uri.c_str(), ISCONFIGSET(eAAMPConfig_PropagateURIParam));
std::string tempEffectiveUrl;
CachedFragment* cachedFragment = GetFetchChunkBuffer(true);
CachedFragment* cachedFragment = GetFetchBuffer(true);
if (!cachedFragment)
{
AAMPLOG_WARN("[%s] GetFetchChunkBuffer returned null in FetchInitFragmentHelper", name);
AAMPLOG_WARN("[%s] GetFetchBuffer returned null in FetchInitFragmentHelper", name);
return false;
}
AAMPLOG_WARN("TrackState::[%s] init-fragment = %s", name, fragmentUrl.c_str());
Expand Down
Loading
Loading