|
RDK Documentation (Open Sourced RDK Components)
|
Go to the documentation of this file.
35 #ifndef FRAGMENTCOLLECTOR_HLS_H
36 #define FRAGMENTCOLLECTOR_HLS_H
44 #define MAX_PROFILE 128 // TODO: remove limitation
45 #define FOG_FRAG_BW_IDENTIFIER "bandwidth-"
46 #define FOG_FRAG_BW_IDENTIFIER_LEN 10
47 #define FOG_FRAG_BW_DELIMITER "-"
48 #define CHAR_CR 0x0d // '\r'
49 #define CHAR_LF 0x0a // '\n'
50 #define BOOLSTR(boolValue) (boolValue?"true":"false")
51 #define PLAYLIST_TIME_DIFF_THRESHOLD_SECONDS (0.1f)
52 #define MAX_MANIFEST_DOWNLOAD_RETRY 3
53 #define MAX_DELAY_BETWEEN_PLAYLIST_UPDATE_MS (6*1000)
54 #define MIN_DELAY_BETWEEN_PLAYLIST_UPDATE_MS (500) // 500mSec
57 #define MAX_SEQ_NUMBER_LAG_COUNT 50
58 #define MAX_SEQ_NUMBER_DIFF_FOR_SEQ_NUM_BASED_SYNC 2
59 #define MAX_PLAYLIST_REFRESH_FOR_DISCONTINUITY_CHECK_EVENT 5
60 #define MAX_PLAYLIST_REFRESH_FOR_DISCONTINUITY_CHECK_LIVE 3
61 #define MAX_PDT_DISCONTINUITIY_DELTA_LIMIT 1.0f
217 void Stop(
bool clearDRM =
false);
312 bool HasDiscontinuityAroundPosition(
double position,
bool useStartTime,
double &diffBetweenDiscontinuities,
double playPosition,
double inputCulledSec,
double inputProgramDateTime,
bool &isDiffChkReq);
414 bool FetchFragmentHelper(
long &http_error,
bool &decryption_error,
bool & bKeyChanged,
int * fogError,
double &downloadTime);
454 void ProcessDrmMetadata();
458 void ComputeDeferredKeyRequestTime();
462 void InitiateDRMKeyAcquisition(
int indexPosn=-1);
480 double mProgramDateTime;
495 double playTargetBufferCalc;
518 bool mDiscontinuityCheckingOn;
521 typedef std::vector<KeyTagStruct>::iterator KeyHashTableIter;
533 std::shared_ptr<HlsDrmBase>
mDrm;
610 void Start()
override;
616 void Stop(
bool clearChannelData)
override;
699 void SeekPosUpdate(
double secondsRelativeToTuneTime)
override;
749 std::vector<ThumbnailData>
GetThumbnailRangeData(
double,
double, std::string*,
int*,
int*,
int*,
int*)
override;
754 std::map<std::string,double> GetImageRangeString(
double*, std::string,
TileInfo*,
double);
767 std::vector<StreamInfo*> GetAvailableVideoTracks(
void)
override;
776 virtual bool Is4KStream(
int &height,
long &bandwidth)
override;
935 #endif // FRAGMENTCOLLECTOR_HLS_H
const char * GetPlaylistURI(TrackType trackType, StreamOutputFormat *format=NULL)
Function to get playlist URI based on media selection.
@ eDRM_KEY_METHOD_UNKNOWN
int mDrmMetaDataIndexPosition
DrmReturn
Return values of various functions.
GrowableBuffer mainManifest
bool mSyncAfterDiscontinuityInProgress
void FetchPlaylist()
Function to fetch playlist file.
void StopDiscontinuityCheckWait()
Stop the wait for discontinuity check in each track.
StreamOutputFormat
Media output format.
HlsStreamInfo structure for stream related information.
char * FindMediaForSequenceNumber()
Get fragment tag based on media sequence number Function to find the media sequence after refresh for...
Structure holding the information of a stream.
HlsStreamInfo structure for stream related information.
char * GetNextFragmentUriFromPlaylist(bool ignoreDiscontinuity=false)
Function to get next fragment URI from playlist based on playtarget.
void ChangeMuxedAudioTrackIndex(std::string &index) override
Change muxed audio track index.
void ABRProfileChanged(void)
Function to handle Profile change after ABR.
pthread_mutex_t mDiscoCheckMutex
AAMPStatusType Init(TuneType tuneType) override
Function to initialize member variables,download main manifest and parse.
int segDrmDecryptFailCount
void FetchFragment()
Function to Fetch the fragment and inject for playback.
@ eDRM_KEY_METHOD_AES_128
Holds data regarding drm session.
MediaProcessor * playContext
HLS Stream handler class.
PrivateInstanceAAMP * aamp
double GetBufferedDuration() override
Function to get the buffer duration of stream.
void SeekPosUpdate(double secondsRelativeToTuneTime) override
Function to update seek position.
Base classes of HLS/MPD collectors. Implements common caching/injection logic.
char * GetFragmentUriFromIndex(bool &bSegmentRepeated)
Function to get fragment URI from index count.
void StartInjection(void) override
starts fragment injection
std::string GetLanguageCode(int iMedia)
Function to get the language code.
void Start() override
Function to start track initiaziation.
void UpdateDrmCMSha1Hash(const char *ptr)
Function to Update SHA1 Id for DRM Metadata.
std::vector< KeyTagStruct > KeyHashTable
@ eDRM_KEY_METHOD_SAMPLE_AES_CTR
double targetDurationSeconds
double lastDownloadedIFrameTarget
std::shared_ptr< HlsDrmBase > mDrm
void RestoreDrmState()
Restore DRM states.
void SetDrmContext()
Function to set DRM Context when KeyTag changes.
double GetStreamPosition() override
Get current stream position.
float maxIntervalBtwPlaylistUpdateMs
StreamOutputFormat audioFormat
const char * mFirstEncInitFragmentInfo
bool HasDiscontinuityAroundPosition(double position, bool useStartTime, double &diffBetweenDiscontinuities, double playPosition, double inputCulledSec, double inputProgramDateTime, bool &isDiffChkReq)
Check if discontinuity present around given position.
void SwitchSubtitleTrack()
Flushes out all old segments and sets up new playlist Used to switch subtitle tracks without restarti...
StreamOutputFormat audioFormat
void PreCachePlaylist()
Function to initiate precaching of playlist.
int lastSelectedProfileIndex
StreamInfo * GetStreamInfo(int idx) override
Get stream information of a profile from subclass.
bool FetchInitFragmentHelper(long &http_code, bool forcePushEncryptedHeader=false)
Helper to fetch init fragment for fragmented mp4 format.
void ConfigureAudioTrack()
Function to select the audio track and update AudioProfileIndex.
double GetPeriodStartPosition(int periodIdx)
Function to get Period start position for given period index,to handle discontinuity.
double mLastMatchedDiscontPosition
double GetBufferedDuration()
Function to retune buffered duration.
bool mByteOffsetCalculation
bool CreateInitVectorByMediaSeqNo(unsigned int ui32Seqno)
Function to create init vector using current media sequence number.
TileInfo structure for Thumbnail data.
void StartSubtitleParser() override
Signal start of subtitle renderering - should be sent at start of video presentation.
StreamOutputFormat GetStreamOutputFormatForTrack(TrackType type)
Function to get output format for audio track.
bool mForceProcessDrmMetadata
GrowableBuffer mDrmMetaDataIndex
StreamAbstraction class of AAMP.
void GetStreamFormat(StreamOutputFormat &primaryOutputFormat, StreamOutputFormat &audioOutputFormat, StreamOutputFormat &auxOutputFormat, StreamOutputFormat &subOutputFormat) override
Get output format of stream.
void CancelDrmOperation(bool clearDRM)
Cancel all DRM operations.
void Stop(bool clearChannelData) override
Function to stop the HLS streaming Function to handle stop processing of all tracks within stream.
void DumpProfiles(void) override
Function to log all debug information on Stream/Media information.
void CheckDiscontinuityAroundPlaytarget(void)
Function to update play target based on audio video exact discontinuity positions.
bool fragmentCollectorThreadStarted
DrmReturn DrmDecrypt(CachedFragment *cachedFragment, ProfilerBucketType bucketType)
Function to decrypt the fragment for playback.
std::set< std::string > mLangList
int mDeferredDrmKeyMaxTime
std::vector< TileInfo > indexedTileInfo
DRM information required to decrypt.
void StopInjection(void)
Stop fragment injection.
TrackType
Media Track Types.
void PauseSubtitleParser(bool pause) override
Set subtitle pause state.
double mCulledSecondsAtStart
void StopWaitForPlaylistRefresh()
Stop wait for playlist refresh.
int mDrmMetaDataIndexCount
const char * closedCaptions
GrowableBuffer mDiscontinuityIndex
GrowableBuffer thumbnailManifest
CMCDHeaders * pCMCDMetrics
bool mCheckForInitialFragEnc
int GetBestAudioTrackByLanguage(void)
Function to get best audio track based on the profile availability and language setting.
HlsStreamInfo streamInfo[128]
StreamOutputFormat streamOutputFormat
void FindTimedMetadata(bool reportbulk=false, bool bInitCall=false)
Function to search playlist for subscribed tags.
StreamAbstractionAAMP_HLS * context
bool IsLive()
Function to check if both tracks in demuxed HLS are in live mode Function to check for live status co...
bool SetThumbnailTrack(int) override
Function to set thumbnail track for processing.
void RefreshPlaylist(void)
Function to redownload playlist after refresh interval .
void GetNextFragmentPeriodInfo(int &periodIdx, double &offsetFromPeriodStart, int &fragmentIdx)
Function to get next playback position from start, to handle discontinuity.
bool firstFragmentDecrypted
TrackState * trackState[4]
pthread_cond_t mPlaylistIndexed
StreamAbstractionAAMP * GetContext()
Function to get current StreamAbstractionAAMP instance value.
int GetNumberOfPeriods()
Function to return number of periods stored in playlist.
void ConfigureTextTrack()
Function to select the text track and update TextTrackProfileIndex.
struct DrmSessionParams * drmData
bool FetchFragmentHelper(long &http_error, bool &decryption_error, bool &bKeyChanged, int *fogError, double &downloadTime)
Helper function to download fragment.
int GetBWIndex(long bitrate) override
Function to get bandwidth index corresponding to bitrate.
pthread_mutex_t mPlaylistMutex
void RunFetchLoop()
Fragment collector thread execution function to download fragments.
long long lastPlaylistDownloadTimeMS
StreamAbstractionAAMP_HLS(AampLogManager *logObj, class PrivateInstanceAAMP *aamp, double seekpos, float rate)
Constructor function.
void FlushIndex()
Function to flush all stored data before refresh and stop.
Structure of GrowableBuffer.
Class representing the AAMP player's private instance, which is not exposed to outside world.
const char * pFragmentInfo
const char * mInitFragmentInfo
std::vector< StreamInfo * > GetAvailableThumbnailTracks(void) override
Function to get available thumbnail tracks.
pthread_t fragmentCollectorThreadID
KeyTagStruct structure to store all Keytags with Hash.
CMCDHeaders * pCMCDMetrics
ProfilerBucketType
Bucket types of AAMP profiler.
double GetFirstPTS() override
Function to return first PTS.
long long nextMediaSequenceNumber
AAMPStatusType
AAMP Function return values.
void StopInjection(void) override
Function to stop fragment injection.
bool FilterAudioCodecBasedOnConfig(StreamOutputFormat audioFormat)
Function to filter the audio codec based on the configuration.
pthread_mutex_t mTrackDrmMutex
std::vector< long > GetVideoBitrates(void) override
Get available video bitrates.
std::vector< long > GetAudioBitrates(void) override
Function to get available audio bitrates.
const char * characteristics
Declaration common to various HLS DRM implementations.
pthread_cond_t mDiscoCheckComplete
void PopulateAudioAndTextTracks()
Function to populate available audio and text tracks info from manifest.
double startTimeForPlaylistSync
std::vector< ThumbnailData > GetThumbnailRangeData(double, double, std::string *, int *, int *, int *, int *) override
Function to fetch the thumbnail data.
const char * initFragmentPtr
std::string mEffectiveUrl
AAMPStatusType SyncTracksForDiscontinuity()
Function to synchronize time between audio & video for VOD stream with discontinuities and uneven tra...
void IndexPlaylist(bool IsRefresh, double &culledSec)
Function to to handle parse and indexing of individual tracks.
virtual bool Is4KStream(int &height, long &bandwidth) override
Check whether stream is 4K stream or not.
~TrackState()
Destructor function.
long long indexFirstMediaSequenceNumber
double completionTimeSecondsFromStart
PlaylistType
Playlist Types.
State Machine for each Media Track.
IndexNode structure for Node/DRM Index.
AAMPStatusType SyncTracks(void)
Function to synchronize time between A/V for Live/Event assets.
Structure of cached fragment data Holds information about a cached fragment.
void NotifyFirstVideoPTS(unsigned long long pts, unsigned long timeScale) override
Function to notify first video pts value from tsprocessor/demux Kept public as its called from outsid...
void ConfigureVideoProfiles()
Function to select the best match video profiles based on audio and filters.
MediaTrack * GetMediaTrack(TrackType type) override
Function to get Media information for track type.
double GetStartTimeOfFirstPTS() override
Get Start time PTS of first sample.
DrmKeyMethod
Enum for various EXT-X-KEY:METHOD= values.
Index Node structure for Discontinuity Index.
void FetchInitFragment()
Function to fetch init fragment.
int GetMediaIndexForLanguage(std::string lang, TrackType type)
Function to get matching mediaInfo index for a language and track type.
void UpdateDrmIV(const char *ptr)
Function to update IV from DRM.
TrackState(AampLogManager *logObj, TrackType type, class StreamAbstractionAAMP_HLS *parent, PrivateInstanceAAMP *aamp, const char *name)
TrackState Constructor.
void StartInjection()
Function to start fragment injection.
void InjectFragmentInternal(CachedFragment *cachedFragment, bool &fragmentDiscarded)
Injected decrypted fragment for playback.
void Stop(bool clearDRM=false)
Function to stop track download/playback.
std::string mFragmentURIFromIndex
PlaylistType mPlaylistType
AAMPStatusType ParseMainManifest()
Function to parse main manifest.
bool mDrmLicenseRequestPending
void Start()
Function to create threads for track donwload.
@ eDRM_KEY_METHOD_SAMPLE_AES
int mDiscontinuityIndexCount
~StreamAbstractionAAMP_HLS()
Destructor function for StreamAbstractionAAMP_HLS.