|
RDK Documentation (Open Sourced RDK Components)
|
Go to the documentation of this file.
48 fragmentDiscarded =
false;
55 bool MediaStreamContext::CacheFragment(std::string fragmentUrl,
unsigned int curlInstance,
double position,
double duration,
const char *range,
bool initSegment,
bool discontinuity
56 ,
bool playingAd,
double pto, uint32_t scale,
bool overWriteTrackId)
60 AAMPLOG_TRACE(
"Type[%d] fragmentUrl %s fragmentTime %f discontinuity %d pto %f scale %u duration %f",
type, fragmentUrl.c_str(), position, discontinuity, pto, scale, duration);
66 double downloadTime = 0;
72 if(!initSegment && mDownloadedFragment.
ptr)
82 std::string effectiveUrl;
85 bool bReadfromcache =
false;
95 if ( initSegment && ret )
99 if (iCurrentRate != AAMP_NORMAL_PLAY_RATE)
122 buffer.parseBuffer();
123 uint32_t track_id = 0;
124 buffer.getTrack_id(track_id);
129 AAMPLOG_INFO(
"Video track_id read from init fragment: %d ", track_id);
130 bool trackIdUpdated =
false;
137 AAMPLOG_WARN(
"Video track_id of the current track is overwritten as init fragment is pushing only for DRM purpose, track id: %d ", track_id);
138 trackIdUpdated =
true;
143 AAMPLOG_WARN(
"TrackId mismatch detected for video, current track_id: %d, next period track_id: %d",
aamp->
mCurrentVideoTrackId, track_id);
154 bool trackIdUpdated =
false;
155 AAMPLOG_INFO(
"Audio track_id read from init fragment: %d ", track_id);
161 AAMPLOG_WARN(
"Audio track_id of the current track is overwritten as init fragment is pushing only for DRM purpose, track id: %d ", track_id);
162 trackIdUpdated =
true;
167 AAMPLOG_WARN(
"TrackId mismatch detected for audio, current track_id: %d, next period track_id: %d",
aamp->
mCurrentAudioTrackId, track_id);
182 bitrate? bitrate : fragmentDescriptor.Bandwidth,
183 (iFogError > 0 ? iFogError : httpErrorCode),effectiveUrl,duration, downloadTime);
188 if(bitrate > 0 && bitrate != fragmentDescriptor.Bandwidth)
190 AAMPLOG_INFO(
"Bitrate changed from %u to %ld",fragmentDescriptor.Bandwidth, bitrate);
191 fragmentDescriptor.Bandwidth = bitrate;
201 AAMPLOG_INFO(
"fragment fetch failed - Free cachedFragment");
205 AAMPLOG_WARN(
"%sfragment fetch failed -- fragmentUrl %s", (initSegment)?
"Init ":
" ", fragmentUrl.c_str());
206 if (mSkipSegmentOnError)
215 mSkipSegmentOnError =
true;
217 int FragmentDownloadFailThreshold;
225 AAMPLOG_ERR(
"Not able to download fragments; reached failure threshold sending tune failed event");
231 AAMPLOG_ERR(
"Not able to download init fragments; reached failure threshold sending tune failed event");
247 mSkipSegmentOnError =
false;
249 AAMPLOG_WARN(
"StreamAbstractionAAMP_MPD::Error while fetching fragment:%s, failedCount:%d. decrementing profile",
254 if(!playingAd && initSegment)
257 AAMPLOG_ERR(
"Not able to download init fragments; reached failure threshold sending tune failed event");
262 AAMPLOG_WARN(
"StreamAbstractionAAMP_MPD::Already at the lowest profile, skipping segment");
267 else if (AAMP_IS_LOG_WORTHY_ERROR(httpErrorCode))
269 AAMPLOG_WARN(
"StreamAbstractionAAMP_MPD::Error on fetching %s fragment. failedCount:%d",
272 if(!playingAd && initSegment)
284 #ifdef AAMP_DEBUG_INJECT
287 AAMPLOG_WARN(
"Discontinuous fragment");
289 if ((1 <<
type) & AAMP_DEBUG_INJECT)
311 AAMPLOG_TRACE(
"[%s] Chunk Buffer Length %zu Remote URL %s",
name, size, remoteUrl.c_str());
318 if(NULL == cachedFragmentChunk)
320 AAMPLOG_WARN(
"[%s] Something Went wrong - Can't get FetchChunkBuffer",
name);
323 cachedFragmentChunk->
type = actualType;
333 AAMPLOG_WARN(
"[%s] WaitForCachedFragmentChunkInjected aborted",
name);
347 int adaptIdxFromProfile = profileMap.adaptationSetIndex;
348 int reprIdxFromProfile = profileMap.representationIndex;
349 if (!((adaptationSetIdx == adaptIdxFromProfile) && (representationIndex == reprIdxFromProfile)))
352 IRepresentation *pNewRepresentation = pNewAdaptationSet->GetRepresentation().at(reprIdxFromProfile);
353 if(representation != NULL)
355 AAMPLOG_WARN(
"StreamAbstractionAAMP_MPD: ABR %dx%d[%d] -> %dx%d[%d]",
356 representation->GetWidth(), representation->GetHeight(), representation->GetBandwidth(),
357 pNewRepresentation->GetWidth(), pNewRepresentation->GetHeight(), pNewRepresentation->GetBandwidth());
358 adaptationSetIdx = adaptIdxFromProfile;
359 adaptationSet = pNewAdaptationSet;
360 adaptationSetId = adaptationSet->GetId();
361 representationIndex = reprIdxFromProfile;
362 representation = pNewRepresentation;
364 dash::mpd::IMPD *mpd = context->GetMPD();
365 IPeriod *period = context->GetPeriod();
366 fragmentDescriptor.ClearMatchingBaseUrl();
367 fragmentDescriptor.AppendMatchingBaseUrl( &mpd->GetBaseUrls() );
368 fragmentDescriptor.AppendMatchingBaseUrl( &period->GetBaseURLs() );
369 fragmentDescriptor.AppendMatchingBaseUrl( &adaptationSet->GetBaseURLs() );
370 fragmentDescriptor.AppendMatchingBaseUrl( &representation->GetBaseURLs() );
372 fragmentDescriptor.Bandwidth = representation->GetBandwidth();
373 fragmentDescriptor.RepresentationID.assign(representation->GetId());
374 profileChanged =
true;
378 AAMPLOG_WARN(
"representation is null");
383 AAMPLOG_TRACE(
"StreamAbstractionAAMP_MPD:: Not switching ABR %dx%d[%d] ",
384 representation->GetWidth(), representation->GetHeight(), representation->GetBandwidth());
395 if(downloadedDuration >= position)
398 return (downloadedDuration - position);
405 downloadedDuration = 0;
406 return downloadedDuration;
void aamp_Free(void *ptr)
wrapper for g_free, used for segment allocation
GrowableBuffer fragmentChunk
void SignalTrickModeDiscontinuity()
Signal trick mode discontinuity to stream sink.
struct ProfileInfo GetAdaptationSetAndRepresetationIndicesForProfile(int profileIndex)
Get Adaptation Set and Representation Index for given profile.
long long downloadStartTime
Manifest file adaptation and representation info.
void SendDownloadErrorEvent(AAMPTuneFailure tuneFailure, long error_code)
Handles download errors and sends events to application if required.
@ AAMP_TUNE_INIT_FRAGMENT_DOWNLOAD_FAILURE
void SetTsbBandwidth(long tsbBandwidth)
When TSB is involved, use this to set bandwidth to be reported.
bool CacheFragment(std::string fragmentUrl, unsigned int curlInstance, double position, double duration, const char *range=NULL, bool initSegment=false, bool discontinuity=false, bool playingAd=false, double pto=0, uint32_t scale=0, bool overWriteTrackId=false)
Fetch and cache a fragment.
AampCacheHandler * getAampCacheHandler()
Get AampCacheHandler instance.
void ProcessID3Metadata(char *segment, size_t size, MediaType type, uint64_t timestampOffset=0)
Process the ID3 metadata from segment.
void UpdateVideoEndMetrics(MediaType mediaType, long bitrate, int curlOrHTTPCode, std::string &strUrl, double curlDownloadTime, ManifestData *manifestData=NULL)
updates download metrics to VideoStat object, this is used for VideoFragment as it takes duration for...
void SendStreamTransfer(MediaType mediaType, GrowableBuffer *buffer, double fpts, double fdts, double fDuration, bool initFragment=0)
API to send audio/video stream into the sink.
Structure of cached fragment data Holds information about a cached fragment.
bool CacheFragmentChunk(MediaType actualType, char *ptr, size_t size, std::string remoteUrl, long long dnldStartTime)
Cache Fragment Chunk.
Handles operations for Media stream context.
@ eAAMPConfig_FragmentDownloadFailThreshold
void ABRProfileChanged(void)
Listener to ABR profile change.
bool RetrieveFromInitFragCache(const std::string url, GrowableBuffer *buffer, std::string &effectiveUrl)
Retrieve init fragment from cache.
bool CheckForRampDownProfile(long http_error)
Check for ramdown profile.
Header file of helper functions for memory management.
void SignalTrickModeDiscontinuity()
Notify discontinuity during trick-mode as PTS re-stamping is done in sink.
@ AAMP_TUNE_FRAGMENT_DOWNLOAD_FAILURE
Class for ISO BMFF Buffer.
CMCDHeaders * pCMCDMetrics
void InsertToInitFragCache(const std::string url, const GrowableBuffer *buffer, std::string effectiveUrl, MediaType fileType)
Insert init fragment into cache table.
bool CheckForRampDownLimitReached()
Check for ramp down limit reached by player.
long long GetPositionMs(void)
Get current stream position.
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
const IAdaptationSet * GetAdaptationSetAtIndex(int idx)
Get Adaptation Set at given index for the current period.
Header file for ISO Base Media File Format Buffer.
Structure of GrowableBuffer.
void InjectFragmentInternal(CachedFragment *cachedFragment, bool &fragmentDiscarded)
Receives cached fragment and injects to sink.
ProfilerBucketType
Bucket types of AAMP profiler.
void aamp_AppendBytes(struct GrowableBuffer *buffer, const void *ptr, size_t len)
append data to GrowableBuffer ADT
bool IsAtEndOfTrack()
Returns if the end of track reached.
bool DownloadsAreEnabled(void)
Check if downloads are enabled.
Structure of cached fragment data Holds information about a cached fragment.
AampLLDashServiceData * GetLLDashServiceData(void)
Gets Low Latency Service Data.
double GetBufferedDuration()
Get duration of buffer.
char * LoadFragment(ProfilerBucketType bucketType, std::string fragmentUrl, std::string &effectiveUrl, size_t *len, unsigned int curlInstance=0, const char *range=NULL, long *http_code=NULL, double *downloadTime=NULL, MediaType fileType=eMEDIATYPE_MANIFEST, int *fogError=NULL)
Fetch a file from CDN and update profiler.
ProfilerBucketType GetProfilerBucketForMedia(MediaType mediaType, bool isInitializationSegment)
Get profiler bucket type.