RDK Documentation (Open Sourced RDK Components)
|
MPEG TS Processor. Supports software Demuxer/ PTS re-stamping for trickmode. More...
#include <tsprocessor.h>
Data Structures | |
struct | _H264PPS |
Holds PPS parameters. More... | |
struct | _H264SPS |
Holds SPS parameters. More... | |
Public Member Functions | |
TSProcessor (AampLogManager *logObj, class PrivateInstanceAAMP *aamp, StreamOperation streamOperation, int track=0, TSProcessor *peerTSProcessor=NULL, TSProcessor *auxTSProcessor=NULL) | |
TSProcessor Constructor. | |
TSProcessor (const TSProcessor &)=delete | |
Copy constructor disabled. More... | |
TSProcessor & | operator= (const TSProcessor &)=delete |
assignment operator disabled More... | |
~TSProcessor () | |
TSProcessor Destructor. | |
bool | sendSegment (char *segment, size_t &size, double position, double duration, bool discontinuous, bool &ptsError) |
Does configured operation on the segment and injects data to sink Process and send media fragment. More... | |
void | setRate (double rate, PlayMode mode) |
Set the playback rate. More... | |
void | setThrottleEnable (bool enable) |
Enable/ disable throttle. More... | |
void | setFrameRateForTM (int frameRate) |
Set frame rate for trick mode. More... | |
void | abort () |
Abort current operations and return all blocking calls immediately. | |
void | reset () |
Reset TS processor state. | |
void | flush () |
Flush all buffered data to sink. More... | |
void | ChangeMuxedAudioTrack (unsigned char index) |
int | SelectAudioIndexToPlay () |
bool | FilterAudioCodecBasedOnConfig (StreamOutputFormat audioFormat) |
Function to filter the audio codec based on the configuration. More... | |
void | GetLanguageCode (std::string &lang) |
Function to get the language code. More... | |
void | SetAudioGroupId (std::string &id) |
Function to set the group-ID. More... | |
void | setApplyOffsetFlag (bool enable) |
Function to set a flag to identify both the av tracks are in TS format or not. More... | |
Public Member Functions inherited from MediaProcessor | |
MediaProcessor () | |
MediaProcessor constructor. | |
virtual | ~MediaProcessor () |
MediaProcessor destructor. | |
MediaProcessor (const MediaProcessor &)=delete | |
MediaProcessor & | operator= (const MediaProcessor &)=delete |
Protected Member Functions | |
void | getAudioComponents (const RecordingComponent **audioComponentsPtr, int &count) |
Get audio components. More... | |
void | sendQueuedSegment (long long basepts=0, double updatedStartPositon=-1) |
Send queued segment. More... | |
void | setBasePTS (double position, long long pts) |
set base PTS for demux operations More... | |
Private Types | |
typedef struct TSProcessor::_H264SPS | H264SPS |
typedef struct TSProcessor::_H264PPS | H264PPS |
Private Member Functions | |
void | setPlayMode (PlayMode mode) |
Set to the playback mode. More... | |
void | processPMTSection (unsigned char *section, int sectionLength) |
process PMT section and update media components. More... | |
void | reTimestamp (unsigned char *&packet, int length) |
Does PTS re-stamping. More... | |
int | insertPatPmt (unsigned char *buffer, bool trick, int bufferSize) |
Insert PAT and PMT sections. More... | |
void | insertPCR (unsigned char *packet, int pid) |
insert PCR to the packet in case of PTS restamping More... | |
bool | generatePATandPMT (bool trick, unsigned char **buff, int *bufflen, bool bHandleMCTrick=false) |
generate PAT and PMT based on media components More... | |
void | putPmtByte (unsigned char *&pmt, int &index, unsigned char byte, int pmtPid) |
Appends a byte to PMT buffer. More... | |
bool | processStartCode (unsigned char *buffer, bool &keepScanning, int length, int base) |
Process ES start code. More... | |
void | checkIfInterlaced (unsigned char *packet, int length) |
Updates state variables depending on interlaced. More... | |
bool | readTimeStamp (unsigned char *p, long long &value) |
Read time-stamp at the point. More... | |
void | writeTimeStamp (unsigned char *p, int prefix, long long TS) |
Write time-stamp to buffer. More... | |
long long | readPCR (unsigned char *p) |
Read PCR from a buffer. More... | |
void | writePCR (unsigned char *p, long long PCR, bool clearExtension) |
Write PCR to a buffer. More... | |
unsigned char * | createNullPFrame (int width, int height, int *nullPFrameLen) |
Create a Null P frame. More... | |
bool | processSeqParameterSet (unsigned char *p, int length) |
process sequence parameter set and update state variables More... | |
void | processPictureParameterSet (unsigned char *p, int length) |
Parse through the picture parameter set to get required items. More... | |
void | processScalingList (unsigned char *&p, int &mask, int size) |
Consume all bits used by the scaling list. More... | |
unsigned int | getBits (unsigned char *&p, int &mask, int bitCount) |
get bits based on mask and count More... | |
void | putBits (unsigned char *&p, int &mask, int bitCount, unsigned int value) |
Put bits based on mask and count. More... | |
unsigned int | getUExpGolomb (unsigned char *&p, int &mask) |
Gets unsigned EXP Golomb. More... | |
int | getSExpGolomb (unsigned char *&p, int &mask) |
Getss signed EXP Golomb. More... | |
void | updatePATPMT () |
Generate and update PAT and PMT sections. | |
void | abortUnlocked () |
Abort TSProcessor operations and return blocking calls immediately. More... | |
bool | processBuffer (unsigned char *buffer, int size, bool &insPatPmt) |
Process buffers and update internal states related to media components. More... | |
long long | getCurrentTime () |
Get current time stamp in milliseconds. More... | |
bool | throttle () |
Blocks based on PTS. Can be used for pacing injection. More... | |
void | sendDiscontinuity (double position) |
Send discontinuity packet. Not relevant for demux operations. More... | |
void | setupThrottle (int segmentDurationMs) |
Update internal state variables to set up throttle. More... | |
bool | demuxAndSend (const void *ptr, size_t len, double fTimestamp, double fDuration, bool discontinuous, TrackToDemux trackToDemux=ePC_Track_Both) |
Demux TS and send elementary streams. More... | |
bool | msleep (long long throttleDiff) |
sleep used internal by throttle logic More... | |
Private Attributes | |
class PrivateInstanceAAMP * | aamp |
bool | m_needDiscontinuity |
long long | m_currStreamOffset |
long long | m_currPTS |
long long | m_currTimeStamp |
int | m_currFrameNumber |
int | m_currFrameLength |
long long | m_currFrameOffset |
bool | m_trickExcludeAudio |
int | m_PatPmtLen |
unsigned char * | m_PatPmt |
int | m_PatPmtTrickLen |
unsigned char * | m_PatPmtTrick |
int | m_PatPmtPcrLen |
unsigned char * | m_PatPmtPcr |
int | m_patCounter |
int | m_pmtCounter |
PlayMode | m_playMode |
PlayMode | m_playModeNext |
double | m_playRate |
double | m_absPlayRate |
double | m_playRateNext |
double | m_apparentFrameRate |
int | m_packetSize |
int | m_ttsSize |
int | m_pcrPid |
int | m_videoPid |
bool | m_haveBaseTime |
bool | m_haveEmittedIFrame |
bool | m_haveUpdatedFirstPTS |
int | m_pcrPerPTSCount |
long long | m_baseTime |
long long | m_segmentBaseTime |
long long | m_basePCR |
long long | m_prevRateAdjustedPCR |
long long | m_currRateAdjustedPCR |
long long | m_currRateAdjustedPTS |
unsigned char | m_continuityCounters [8192] |
unsigned char | m_pidFilter [8192] |
unsigned char | m_pidFilterTrick [8192] |
unsigned char * | m_nullPFrame |
int | m_nullPFrameLength |
int | m_nullPFrameNextCount |
int | m_nullPFrameOffset |
int | m_nullPFrameWidth |
int | m_nullPFrameHeight |
int | m_frameWidth |
int | m_frameHeight |
bool | m_scanForFrameSize |
int | m_scanRemainderSize |
int | m_scanRemainderLimit |
unsigned char | m_scanRemainder [(29) *3] |
bool | m_isH264 |
bool | m_isMCChannel |
bool | m_isInterlaced |
bool | m_isInterlacedKnown |
bool | m_throttle |
bool | m_haveThrottleBase |
long long | m_lastThrottleContentTime |
long long | m_lastThrottleRealTime |
long long | m_baseThrottleContentTime |
long long | m_baseThrottleRealTime |
uint33_t | m_throttlePTS |
bool | m_insertPCR |
int | m_emulationPreventionCapacity |
int | m_emulationPreventionOffset |
unsigned char * | m_emulationPrevention |
bool | m_scanSkipPacketsEnabled |
bool | m_applyOffset |
H264SPS | m_SPS [32] |
H264PPS | m_PPS [256] |
int | m_currSPSId |
int | m_picOrderCount |
bool | m_updatePicOrderCount |
bool | m_havePAT |
Set to 1 when PAT buffer examined and loaded all program specific information. | |
int | m_versionPAT |
Pat Version number. | |
int | m_program |
Program number in the corresponding program map table. | |
int | m_pmtPid |
For which PID the program information is available such as, audio pid, video pid, stream types, etc. | |
bool | m_havePMT |
When PMT buffer examined the value is set to 1. | |
int | m_versionPMT |
Version number for PMT which is being examined. | |
bool | m_indexAudio |
If PCR Pid matches with any Audio PIDs associated for a recording, the value will be set to 1. | |
bool | m_haveAspect |
Set to 1 when it found aspect ratio of current video. | |
bool | m_haveFirstPTS |
The value is set to 1 if first PTS found from a recording after examining few KB of initial data. | |
uint33_t | m_currentPTS |
Store the current PTS value of a recording. | |
int | m_pmtCollectorNextContinuity |
Keeps next continuity counter for PMT packet at the time of examine the TS Buffer. | |
int | m_pmtCollectorSectionLength |
Update section length while examining PMT table. | |
int | m_pmtCollectorOffset |
If it is set, process subsequent parts of multi-packet PMT. | |
unsigned char * | m_pmtCollector |
A buffer pointer to hold PMT data at the time of examining TS buffer. | |
bool | m_scrambledWarningIssued |
bool | m_checkContinuity |
int | videoComponentCount |
int | audioComponentCount |
RecordingComponent | videoComponents [(8)] |
RecordingComponent | audioComponents [(8)] |
bool | m_dsmccComponentFound |
True if DSMCC found. | |
RecordingComponent | m_dsmccComponent |
Digital storage media command and control (DSM-CC) Component. | |
uint33_t | m_actualStartPTS |
int | m_throttleMaxDelayMs |
int | m_throttleMaxDiffSegments |
int | m_throttleDelayIgnoredMs |
int | m_throttleDelayForDiscontinuityMs |
pthread_cond_t | m_throttleCond |
pthread_cond_t | m_basePTSCond |
pthread_mutex_t | m_mutex |
bool | m_enabled |
bool | m_processing |
int | m_framesProcessedInSegment |
long long | m_lastPTSOfSegment |
StreamOperation | m_streamOperation |
Demuxer * | m_vidDemuxer |
Demuxer * | m_audDemuxer |
Demuxer * | m_dsmccDemuxer |
bool | m_demux |
TSProcessor * | m_peerTSProcessor |
int | m_packetStartAfterFirstPTS |
unsigned char * | m_queuedSegment |
double | m_queuedSegmentPos |
double | m_queuedSegmentDuration |
size_t | m_queuedSegmentLen |
bool | m_queuedSegmentDiscontinuous |
double | m_startPosition |
int | m_track |
long long | m_last_frame_time |
bool | m_demuxInitialized |
long long | m_basePTSFromPeer |
unsigned char | m_AudioTrackIndexToPlay |
TSProcessor * | m_auxTSProcessor |
bool | m_auxiliaryAudio |
AampLogManager * | mLogObj |
std::string | m_audioGroupId |
MPEG TS Processor. Supports software Demuxer/ PTS re-stamping for trickmode.
Definition at line 95 of file tsprocessor.h.
struct TSProcessor::_H264PPS |
Holds PPS parameters.
Definition at line 465 of file tsprocessor.h.
Data Fields | ||
---|---|---|
int | spsId |
struct TSProcessor::_H264SPS |
Holds SPS parameters.
Definition at line 451 of file tsprocessor.h.
Data Fields | ||
---|---|---|
int | picOrderCountType | |
int | maxPicOrderCount | |
int | log2MaxFrameNumMinus4 | |
int | log2MaxPicOrderCntLsbMinus4 | |
int | separateColorPlaneFlag | |
int | frameMBSOnlyFlag |
|
delete |
Copy constructor disabled.
|
delete |
assignment operator disabled
|
virtual |
Does configured operation on the segment and injects data to sink Process and send media fragment.
[in] | segment | Buffer containing the data segment |
[in] | size | Specifies size of the segment in bytes. |
[in] | position | Position of the segment in seconds |
[in] | duration | Duration of the segment in seconds |
[in] | discontinuous | true if fragment is discontinuous |
[out] | true | on PTS error |
Implements MediaProcessor.
Definition at line 2436 of file tsprocessor.cpp.
|
virtual |
Set the playback rate.
[in] | rate | play rate could be 1.0=Normal Playback, 0.0=Pause, etc |
[in] | mode | play mode such as PlayMode_normal, PlayMode_retimestamp_Ionly, PlayMode_retimestamp_IPB, PlayMode_retimestamp_IandP or PlayMode_reverse_GOP. |
Implements MediaProcessor.
Definition at line 3439 of file tsprocessor.cpp.
|
virtual |
Enable/ disable throttle.
[in] | enable | true to enable throttle, false to disable |
Implements MediaProcessor.
Definition at line 3457 of file tsprocessor.cpp.
|
inlinevirtual |
Set frame rate for trick mode.
[in] | frameRate | rate per second |
Implements MediaProcessor.
Definition at line 148 of file tsprocessor.h.
TSProcessor::flush | ( | ) |
Flush all buffered data to sink.
Definition at line 2344 of file tsprocessor.cpp.
bool TSProcessor::FilterAudioCodecBasedOnConfig | ( | StreamOutputFormat | audioFormat | ) |
Function to filter the audio codec based on the configuration.
[in] | audioFormat | |
[out] | bool | ignoreProfile - true/false |
Definition at line 4657 of file tsprocessor.cpp.
void TSProcessor::GetLanguageCode | ( | std::string & | lang | ) |
Function to get the language code.
[in] | string | - language |
Definition at line 4700 of file tsprocessor.cpp.
|
virtual |
Function to set the group-ID.
[in] | string | - id |
Reimplemented from MediaProcessor.
Definition at line 4709 of file tsprocessor.cpp.
|
virtual |
Function to set a flag to identify both the av tracks are in TS format or not.
Function to set offsetflag. if the value is fasle, no need to apply offset while doing pts restamping.
[in] | bool | - true/false |
Reimplemented from MediaProcessor.
Definition at line 3993 of file tsprocessor.cpp.
|
protected |
Get audio components.
[out] | audioComponentsPtr | pointer to audio component array |
[out] | count | Number of audio components |
Definition at line 4578 of file tsprocessor.cpp.
|
protected |
Send queued segment.
[in] | basepts | new base pts to be set. Valid only for eStreamOp_DEMUX_AUDIO. |
[in] | updatedStartPositon | New start position of queued segment. |
Definition at line 2371 of file tsprocessor.cpp.
|
protected |
set base PTS for demux operations
[in] | position | start position of fragment |
[in] | pts | base pts for demux operations. |
Definition at line 2415 of file tsprocessor.cpp.
|
private |
Set to the playback mode.
[in] | mode | play mode such as PlayMode_normal, PlayMode_retimestamp_Ionly, PlayMode_retimestamp_IPB, PlayMode_retimestamp_IandP or PlayMode_reverse_GOP. |
Definition at line 3398 of file tsprocessor.cpp.
|
private |
process PMT section and update media components.
[in] | section | character buffer containing PMT section |
[in] | sectionLength | length of PMT section |
Definition at line 1080 of file tsprocessor.cpp.
|
private |
Does PTS re-stamping.
[in,out] | packet | TS data to re-stamp |
[in] | length[in] | TS data size |
Definition at line 3037 of file tsprocessor.cpp.
|
private |
Insert PAT and PMT sections.
length | of output buffer |
[out] | buffer | PAT and PMT is copied to this buffer |
[in] | trick | true on trick mode, false on normal playback |
[in] | bufferSize | size of buffer |
Definition at line 1011 of file tsprocessor.cpp.
|
private |
insert PCR to the packet in case of PTS restamping
[in] | packet[in,out] | buffer to which PCR to be inserted |
[in] | pid[in] | pcr pid |
Definition at line 1047 of file tsprocessor.cpp.
|
private |
generate PAT and PMT based on media components
[in] | trick | true on trickmode |
[out] | buff | PAT and PMT copied to this buffer |
[out] | buflen | Length of buff |
[in] | bHandleMCTrick | true if audio pid is same as PCR pid |
Definition at line 3466 of file tsprocessor.cpp.
|
private |
Appends a byte to PMT buffer.
[in,out] | pmt | buffer in which PMT is being constructed |
[in,out] | index | current index of PMT construction. |
[in] | byte | byte to be written at index |
[in] | pmtPid | PID of PMT |
Definition at line 3870 of file tsprocessor.cpp.
|
private |
Process ES start code.
[in] | buffer | buffer containing start code |
[in] | keepScanning | true to keep on scanning |
[in] | length | size of the buffer |
[in] | base | Not used |
Definition at line 2622 of file tsprocessor.cpp.
|
private |
Updates state variables depending on interlaced.
[in] | packet | buffer containing TS packet |
[in] | length | length of buffer |
Definition at line 2893 of file tsprocessor.cpp.
|
private |
Read time-stamp at the point.
true | if time-stamp is present. |
[in] | p | buffer position containing time-stamp |
[out] | TS | time-stamp |
Definition at line 3905 of file tsprocessor.cpp.
|
private |
Write time-stamp to buffer.
[out] | p | buffer to which TS to be written |
[in] | prefix | of time-stamp |
[in] | TS | time-stamp |
Definition at line 3948 of file tsprocessor.cpp.
|
private |
Read PCR from a buffer.
[in] | p | start of PCR data |
Definition at line 3960 of file tsprocessor.cpp.
|
private |
Write PCR to a buffer.
[out] | p | buffer to write PCR |
[in] | PCR | timestamp to be written |
[in] | clearExtension | clear PCR extension |
Definition at line 3973 of file tsprocessor.cpp.
|
private |
Create a Null P frame.
Buffer | containing P frame |
[in] | width | width of P frame to be constructed |
[in] | height | height of P frame |
[out] | nullPFrameLen | length of constructed p frame |
Definition at line 4075 of file tsprocessor.cpp.
|
private |
process sequence parameter set and update state variables
true | if SPS is processed successfully |
[in] | p | pointer containing SPS |
[in] | length | size of SPS |
Definition at line 4226 of file tsprocessor.cpp.
|
private |
Parse through the picture parameter set to get required items.
[in] | p | buffer containing PPS |
[in] | length | size of PPS |
Definition at line 4446 of file tsprocessor.cpp.
|
private |
Consume all bits used by the scaling list.
[in] | p | buffer containing scaling list |
[in] | mask | mask |
[in] | size | lenght of scaling list |
Definition at line 4463 of file tsprocessor.cpp.
|
private |
get bits based on mask and count
value | of bits |
[in,out] | p | pointer being processed, updated internally |
[in,out] | mask | mask to be applied |
[in] | bitCount | Number of bits to be processed. |
Definition at line 4482 of file tsprocessor.cpp.
|
private |
Put bits based on mask and count.
[in,out] | p | reference of buffer to which bits to be put |
[in,out] | mask | mask to be applied |
[in] | bitCount | count of bits to be put |
[in] | value | bits to be put |
Definition at line 4506 of file tsprocessor.cpp.
|
private |
Gets unsigned EXP Golomb.
[in,out] | p | buffer |
[in,out] | mask | bitmask |
Unsigned | EXP Golomb |
Definition at line 4532 of file tsprocessor.cpp.
|
private |
Getss signed EXP Golomb.
[in,out] | p | buffer |
[in,out] | bit | mask |
signed | EXP Golomb |
Definition at line 4564 of file tsprocessor.cpp.
|
private |
Abort TSProcessor operations and return blocking calls immediately.
Definition at line 3412 of file tsprocessor.cpp.
|
private |
Process buffers and update internal states related to media components.
false | if operation is aborted. |
[in] | buffer | contains TS data |
[in] | size | lenght of the buffer |
[out] | insPatPmt | indicates if PAT and PMT needs to inserted |
Definition at line 1672 of file tsprocessor.cpp.
|
private |
Get current time stamp in milliseconds.
time | stamp in milliseconds |
Definition at line 1500 of file tsprocessor.cpp.
|
private |
Blocks based on PTS. Can be used for pacing injection.
true | if aborted |
Definition at line 1553 of file tsprocessor.cpp.
|
private |
Send discontinuity packet. Not relevant for demux operations.
[in] | position | position in seconds |
Definition at line 1386 of file tsprocessor.cpp.
|
private |
Update internal state variables to set up throttle.
[in] | segmentDurationMsSigned | Duration of segment |
Definition at line 2107 of file tsprocessor.cpp.
|
private |
Demux TS and send elementary streams.
true | on success, false on PTS error |
[in] | ptr | buffer containing TS data |
[in] | len | lenght of buffer |
[in] | position | position of segment in seconds |
[in] | duration | duration of segment in seconds |
[in] | discontinuous | true if segment is discontinous |
[in] | trackToDemux | media track to do the operation |
Definition at line 2121 of file tsprocessor.cpp.
|
private |
sleep used internal by throttle logic
[in] | throttleDiff | time in milliseconds |
true | on abort |
Definition at line 1515 of file tsprocessor.cpp.