RDK Documentation (Open Sourced RDK Components)
MediaStreamContext Class Reference

MPD media track. More...

#include <MediaStreamContext.h>

Inheritance diagram for MediaStreamContext:
Inheritance graph
Collaboration diagram for MediaStreamContext:
Collaboration graph

Public Member Functions

 MediaStreamContext (AampLogManager *logObj, TrackType type, StreamAbstractionAAMP_MPD *ctx, PrivateInstanceAAMP *aamp, const char *name)
 MediaStreamContext Constructor. More...
 
 ~MediaStreamContext ()
 MediaStreamContext Destructor.
 
 MediaStreamContext (const MediaStreamContext &)=delete
 MediaStreamContext Copy Constructor.
 
MediaStreamContextoperator= (const MediaStreamContext &)=delete
 MediaStreamContext Assignment operator overloading.
 
StreamAbstractionAAMPGetContext ()
 Get the context of media track. To be implemented by subclasses. More...
 
void InjectFragmentInternal (CachedFragment *cachedFragment, bool &fragmentDiscarded)
 Receives cached fragment and injects to sink. More...
 
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. More...
 
bool CacheFragmentChunk (MediaType actualType, char *ptr, size_t size, std::string remoteUrl, long long dnldStartTime)
 Cache Fragment Chunk. More...
 
void ABRProfileChanged (void)
 Listener to ABR profile change.
 
double GetBufferedDuration ()
 Get duration of buffer.
 
void SignalTrickModeDiscontinuity ()
 Notify discontinuity during trick-mode as PTS re-stamping is done in sink. More...
 
bool IsAtEndOfTrack ()
 Returns if the end of track reached. More...
 
- Public Member Functions inherited from MediaTrack
 MediaTrack (AampLogManager *logObj, TrackType type, PrivateInstanceAAMP *aamp, const char *name)
 MediaTrack Constructor.
 
virtual ~MediaTrack ()
 MediaTrack Destructor.
 
 MediaTrack (const MediaTrack &)=delete
 MediaTrack Copy Constructor.
 
MediaTrackoperator= (const MediaTrack &)=delete
 MediaTrack assignment operator overloading.
 
void StartInjectLoop ()
 Start fragment injector loop. More...
 
void StartInjectChunkLoop ()
 Start fragment Chunk injector loop. More...
 
void StopInjectLoop ()
 Stop fragment injector loop. More...
 
void StopInjectChunkLoop ()
 Stop fragment chunk injector loop of track. More...
 
bool Enabled ()
 Check if a track is enabled. More...
 
bool InjectFragment ()
 Inject fragment into the gstreamer. More...
 
bool ProcessFragmentChunk ()
 Process next cached fragment chunk.
 
bool InjectFragmentChunk ()
 Inject fragment Chunk into the gstreamer. More...
 
double GetTotalInjectedDuration ()
 Get total fragment injected duration. More...
 
double GetTotalInjectedChunkDuration ()
 Get total fragment chunk injected duration. More...
 
void RunInjectLoop ()
 Injection loop - use internally by injection logic. More...
 
void RunInjectChunkLoop ()
 Run fragment injector loop. Injection loop - use internally by injection logic. More...
 
void UpdateTSAfterFetch ()
 Updates internal state after a fragment fetch. More...
 
void UpdateTSAfterChunkFetch ()
 Updates internal state after a fragment fetch. More...
 
bool WaitForFreeFragmentAvailable (int timeoutMs=-1)
 Wait until a free fragment is available. More...
 
void AbortWaitForCachedAndFreeFragment (bool immediate)
 Abort the waiting for cached fragments and free fragment slot. More...
 
int GetTotalFragmentsFetched ()
 Get number of fragments dpownloaded. More...
 
CachedFragmentGetFetchBuffer (bool initialize)
 Get buffer to store the downloaded fragment content to cache next fragment. More...
 
CachedFragmentChunkGetFetchChunkBuffer (bool initialize)
 Get buffer to fetch and cache next fragment chunk. More...
 
void SetCurrentBandWidth (int bandwidthBps)
 Set current bandwidth of track. More...
 
int GetProfileIndexForBW (long mTsbBandwidth)
 Get profile index for TsbBandwidth. More...
 
int GetCurrentBandWidth ()
 Get current bandwidth in bps. More...
 
double GetTotalFetchedDuration ()
 Get total duration of fetched fragments. More...
 
double GetTotalInjectedChunksDuration ()
 Get total duration of fetched fragments. More...
 
bool IsDiscontinuityProcessed ()
 Check if discontinuity is being processed. More...
 
bool isFragmentInjectorThreadStarted ()
 
void MonitorBufferHealth ()
 
void ScheduleBufferHealthMonitor ()
 
BufferHealthStatus GetBufferStatus ()
 Get buffer Status of track. More...
 
BufferHealthStatus GetBufferHealthStatus ()
 Get buffer health status. More...
 
void AbortWaitForCachedFragment ()
 Abort the waiting for cached fragments immediately. More...
 
bool IsInjectionAborted ()
 Check whether track data injection is aborted. More...
 
bool CheckForFutureDiscontinuity (double &cacheDuration)
 To check for discontinuity in future fragments. More...
 
void OnSinkBufferFull ()
 Called if sink buffer is full. More...
 
void FlushFragments ()
 Flushes all cached fragments Flushes all media fragments and resets all relevant counters Only intended for use on subtitle streams. More...
 
void FlushFragmentChunks ()
 Flushes all cached fragment Chunks. More...
 

Data Fields

MediaType mediaType
 
CMCDHeaders * pCMCDMetrics
 
struct FragmentDescriptor fragmentDescriptor
 
const IAdaptationSet * adaptationSet
 
const IRepresentation * representation
 
int fragmentIndex
 
int timeLineIndex
 
int fragmentRepeatCount
 
uint64_t fragmentOffset
 
bool eos
 
bool profileChanged
 
bool discontinuity
 
GrowableBuffer mDownloadedFragment
 
double fragmentTime
 
double downloadedDuration
 
double periodStartOffset
 
uint64_t timeStampOffset
 
char * index_ptr
 
size_t index_len
 
uint64_t lastSegmentTime
 
uint64_t lastSegmentNumber
 
uint64_t lastSegmentDuration
 
int adaptationSetIdx
 
int representationIndex
 
StreamAbstractionAAMP_MPDcontext
 
std::string initialization
 
uint32_t adaptationSetId
 
bool mSkipSegmentOnError
 
double scaledPTO
 
bool failAdjacentSegment
 
long httpErrorCode
 
- Data Fields inherited from MediaTrack
bool eosReached
 
bool enabled
 
int numberOfFragmentsCached
 
int numberOfFragmentChunksCached
 
const char * name
 
double fragmentDurationSeconds
 
int segDLFailCount
 
int segDrmDecryptFailCount
 
int mSegInjectFailCount
 
TrackType type
 
std::unique_ptr< SubtitleParsermSubtitleParser
 
bool refreshSubtitles
 
int maxCachedFragmentsPerTrack
 
int maxCachedFragmentChunksPerTrack
 
pthread_cond_t fragmentChunkFetched
 
uint32_t totalMdatCount
 
int noMDATCount
 

Additional Inherited Members

- Protected Member Functions inherited from MediaTrack
void UpdateTSAfterInject ()
 Update segment cache and inject buffer to gstreamer. More...
 
void UpdateTSAfterChunkInject ()
 Update segment cache and inject buffer to gstreamer. More...
 
bool WaitForCachedFragmentAvailable ()
 Wait till cached fragment available. More...
 
bool WaitForCachedFragmentChunkInjected (int timeoutMs=-1)
 Wait until a cached fragment chunk is Injected. More...
 
bool WaitForCachedFragmentChunkAvailable ()
 Wait till cached fragment chunk available. More...
 
void InjectFragmentChunkInternal (MediaType mediaType, GrowableBuffer *buffer, double fpts, double fdts, double fDuration)
 To be implemented by derived classes to receive cached fragment Chunk Receives cached fragment and injects to sink. More...
 
- Static Protected Member Functions inherited from MediaTrack
static int GetDeferTimeMs (long maxTimeSeconds)
 
- Protected Attributes inherited from MediaTrack
AampLogManagermLogObj
 
PrivateInstanceAAMPaamp
 
CachedFragmentcachedFragment
 
CachedFragmentChunk cachedFragmentChunks [20]
 
GrowableBuffer unparsedBufferChunk
 
GrowableBuffer parsedBufferChunk
 
bool abort
 
pthread_mutex_t mutex
 
bool ptsError
 
bool abortInject
 
bool abortInjectChunk
 

yes

MPD media track.

Definition at line 35 of file MediaStreamContext.h.

Constructor & Destructor Documentation

◆ MediaStreamContext()

MediaStreamContext::MediaStreamContext ( AampLogManager logObj,
TrackType  type,
StreamAbstractionAAMP_MPD ctx,
PrivateInstanceAAMP aamp,
const char *  name 
)
inline

MediaStreamContext Constructor.

Parameters
typeType of track
ctxcontext MPD collector context
aampPointer to associated aamp instance
nameName of the track

Definition at line 45 of file MediaStreamContext.h.

Member Function Documentation

◆ GetContext()

StreamAbstractionAAMP* MediaStreamContext::GetContext ( )
inlinevirtual

Get the context of media track. To be implemented by subclasses.

Return values
Contextof track.

Implements MediaTrack.

Definition at line 94 of file MediaStreamContext.h.

◆ InjectFragmentInternal()

MediaStreamContext::InjectFragmentInternal ( CachedFragment cachedFragment,
bool &  fragmentDiscarded 
)
virtual

Receives cached fragment and injects to sink.

Parameters
[in]cachedFragment- contains fragment to be processed and injected
[out]fragmentDiscarded- true if fragment is discarded.

Implements MediaTrack.

Definition at line 33 of file MediaStreamContext.cpp.

◆ CacheFragment()

MediaStreamContext::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.

Parameters
fragmentUrlurl of fragment
curlInstancecurl instance to be used to fetch
positionposition of fragment in seconds
durationduration of fragment in seconds
rangebyte range
initSegmenttrue if fragment is init fragment
discontinuitytrue if fragment is discontinuous
playingAdflag if playing Ad
ptounscaled pto value from mpd
scaletimeScale value from mpd
overWriteTrackIdflag to overwrite the trackID of the init fragment with the current one if those are different
Return values
trueon success

Definition at line 55 of file MediaStreamContext.cpp.

◆ CacheFragmentChunk()

bool MediaStreamContext::CacheFragmentChunk ( MediaType  actualType,
char *  ptr,
size_t  size,
std::string  remoteUrl,
long long  dnldStartTime 
)

Cache Fragment Chunk.

Parameters
actualTypeMediaType type of cached media
ptrCURL provided chunk data
sizeCURL provided chunk data size
remoteUrlurl of fragment
dnldStartTimeof the download

Definition at line 309 of file MediaStreamContext.cpp.

◆ SignalTrickModeDiscontinuity()

MediaStreamContext::SignalTrickModeDiscontinuity ( )
virtual

Notify discontinuity during trick-mode as PTS re-stamping is done in sink.

Returns
void

Reimplemented from MediaTrack.

Definition at line 413 of file MediaStreamContext.cpp.

◆ IsAtEndOfTrack()

MediaStreamContext::IsAtEndOfTrack ( )
virtual

Returns if the end of track reached.

Returns
true - If yes

Reimplemented from MediaTrack.

Definition at line 422 of file MediaStreamContext.cpp.

Field Documentation

◆ pCMCDMetrics

CMCDHeaders* MediaStreamContext::pCMCDMetrics

pointer object to class CMCDHeaders

Definition at line 156 of file MediaStreamContext.h.


The documentation for this class was generated from the following files: