|
RDK Documentation (Open Sourced RDK Components)
|
Go to the documentation of this file.
25 #ifndef _TSPROCESSOR_H
26 #define _TSPROCESSOR_H
35 #define MAX_PIDS (8) //PMT Parsing
52 #define SCAN_REMAINDER_SIZE_MPEG2 (7)
53 #define SCAN_REMAINDER_SIZE_H264 (29)
54 #if (SCAN_REMAINDER_SIZE_MPEG2 > SCAN_REMAINDER_SIZE_H264)
55 #define MAX_SCAN_REMAINDER_SIZE SCAN_REMAINDER_SIZE_MPEG2
57 #define MAX_SCAN_REMAINDER_SIZE SCAN_REMAINDER_SIZE_H264
129 bool sendSegment(
char *segment,
size_t& size,
double position,
double duration,
bool discontinuous,
bool &ptsError);
138 void setRate(
double rate, PlayMode mode);
150 m_apparentFrameRate = frameRate;
169 void ChangeMuxedAudioTrack(
unsigned char index);
175 int SelectAudioIndexToPlay();
219 void setBasePTS(
double position,
long long pts);
241 void reTimestamp(
unsigned char *&packet,
int length );
249 int insertPatPmt(
unsigned char *buffer,
bool trick,
int bufferSize );
255 void insertPCR(
unsigned char *packet,
int pid );
263 bool generatePATandPMT(
bool trick,
unsigned char **buff,
int *bufflen,
bool bHandleMCTrick =
false);
271 void putPmtByte(
unsigned char* &pmt,
int& index,
unsigned char byte,
int pmtPid );
279 bool processStartCode(
unsigned char *buffer,
bool& keepScanning,
int length,
int base );
298 void writeTimeStamp(
unsigned char *p,
int prefix,
long long TS );
303 long long readPCR(
unsigned char *p );
310 void writePCR(
unsigned char *p,
long long PCR,
bool clearExtension );
317 unsigned char*
createNullPFrame(
int width,
int height,
int *nullPFrameLen );
343 unsigned int getBits(
unsigned char *& p,
int& mask,
int bitCount );
351 void putBits(
unsigned char *& p,
int& mask,
int bitCount,
unsigned int value );
375 bool m_needDiscontinuity;
376 long long m_currStreamOffset;
378 long long m_currTimeStamp;
379 int m_currFrameNumber;
380 int m_currFrameLength;
381 long long m_currFrameOffset;
383 bool m_trickExcludeAudio;
385 unsigned char *m_PatPmt;
386 int m_PatPmtTrickLen;
387 unsigned char *m_PatPmtTrick;
389 unsigned char *m_PatPmtPcr;
394 PlayMode m_playModeNext;
396 double m_absPlayRate;
397 double m_playRateNext;
398 double m_apparentFrameRate;
404 bool m_haveEmittedIFrame;
405 bool m_haveUpdatedFirstPTS;
406 int m_pcrPerPTSCount;
407 long long m_baseTime;
408 long long m_segmentBaseTime;
410 long long m_prevRateAdjustedPCR;
411 long long m_currRateAdjustedPCR;
412 long long m_currRateAdjustedPTS;
413 unsigned char m_continuityCounters[8192];
414 unsigned char m_pidFilter[8192];
415 unsigned char m_pidFilterTrick[8192];
417 unsigned char *m_nullPFrame;
418 int m_nullPFrameLength;
419 int m_nullPFrameNextCount;
420 int m_nullPFrameOffset;
421 int m_nullPFrameWidth;
422 int m_nullPFrameHeight;
425 bool m_scanForFrameSize;
426 int m_scanRemainderSize;
427 int m_scanRemainderLimit;
428 unsigned char m_scanRemainder[MAX_SCAN_REMAINDER_SIZE*3];
432 bool m_isInterlacedKnown;
434 bool m_haveThrottleBase;
435 long long m_lastThrottleContentTime;
436 long long m_lastThrottleRealTime;
437 long long m_baseThrottleContentTime;
438 long long m_baseThrottleRealTime;
441 int m_emulationPreventionCapacity;
442 int m_emulationPreventionOffset;
443 unsigned char * m_emulationPrevention;
444 bool m_scanSkipPacketsEnabled;
453 int picOrderCountType;
454 int maxPicOrderCount;
455 int log2MaxFrameNumMinus4;
456 int log2MaxPicOrderCntLsbMinus4;
457 int separateColorPlaneFlag;
458 int frameMBSOnlyFlag;
474 bool m_updatePicOrderCount;
481 bool processBuffer(
unsigned char *buffer,
int size,
bool &insPatPmt);
515 bool msleep(
long long throttleDiff);
533 bool m_scrambledWarningIssued;
534 bool m_checkContinuity;
535 int videoComponentCount, audioComponentCount;
542 int m_throttleMaxDelayMs;
543 int m_throttleMaxDiffSegments;
544 int m_throttleDelayIgnoredMs;
545 int m_throttleDelayForDiscontinuityMs;
546 pthread_cond_t m_throttleCond;
547 pthread_cond_t m_basePTSCond;
548 pthread_mutex_t m_mutex;
551 int m_framesProcessedInSegment;
552 long long m_lastPTSOfSegment;
559 int m_packetStartAfterFirstPTS;
560 unsigned char * m_queuedSegment;
561 double m_queuedSegmentPos;
562 double m_queuedSegmentDuration;
563 size_t m_queuedSegmentLen;
564 bool m_queuedSegmentDiscontinuous;
565 double m_startPosition;
567 long long m_last_frame_time;
568 bool m_demuxInitialized;
569 long long m_basePTSFromPeer;
570 unsigned char m_AudioTrackIndexToPlay;
572 bool m_auxiliaryAudio;
574 std::string m_audioGroupId;
void insertPCR(unsigned char *packet, int pid)
insert PCR to the packet in case of PTS restamping
unsigned int getBits(unsigned char *&p, int &mask, int bitCount)
get bits based on mask and count
StreamOutputFormat
Media output format.
void flush()
Flush all buffered data to sink.
bool processSeqParameterSet(unsigned char *p, int length)
process sequence parameter set and update state variables
~TSProcessor()
TSProcessor Destructor.
void setApplyOffsetFlag(bool enable)
Function to set a flag to identify both the av tracks are in TS format or not.
bool throttle()
Blocks based on PTS. Can be used for pacing injection.
void processPMTSection(unsigned char *section, int sectionLength)
process PMT section and update media components.
StreamOperation
Operation done by TSProcessor.
Stores information of a audio/video component.
unsigned char * m_pmtCollector
A buffer pointer to hold PMT data at the time of examining TS buffer.
void abort()
Abort current operations and return all blocking calls immediately.
void setFrameRateForTM(int frameRate)
Set frame rate for trick mode.
bool FilterAudioCodecBasedOnConfig(StreamOutputFormat audioFormat)
Function to filter the audio codec based on the configuration.
bool m_dsmccComponentFound
True if DSMCC found.
bool msleep(long long throttleDiff)
sleep used internal by throttle logic
int m_pmtPid
For which PID the program information is available such as, audio pid, video pid, stream types,...
void reset()
Reset TS processor state.
bool processBuffer(unsigned char *buffer, int size, bool &insPatPmt)
Process buffers and update internal states related to media components.
Custom int variable to handle 33 bit.
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.
bool m_haveFirstPTS
The value is set to 1 if first PTS found from a recording after examining few KB of initial data.
int insertPatPmt(unsigned char *buffer, bool trick, int bufferSize)
Insert PAT and PMT sections.
void abortUnlocked()
Abort TSProcessor operations and return blocking calls immediately.
unsigned int descriptorTags
void updatePATPMT()
Generate and update PAT and PMT sections.
TrackToDemux
Track to demux.
TSProcessor & operator=(const TSProcessor &)=delete
assignment operator disabled
int m_pmtCollectorSectionLength
Update section length while examining PMT table.
void writeTimeStamp(unsigned char *p, int prefix, long long TS)
Write time-stamp to buffer.
void processPictureParameterSet(unsigned char *p, int length)
Parse through the picture parameter set to get required items.
bool m_indexAudio
If PCR Pid matches with any Audio PIDs associated for a recording, the value will be set to 1.
@ eStreamOp_DEMUX_VIDEO_AND_AUX
bool m_havePAT
Set to 1 when PAT buffer examined and loaded all program specific information.
long long getCurrentTime()
Get current time stamp in milliseconds.
int getSExpGolomb(unsigned char *&p, int &mask)
Getss signed EXP Golomb.
int m_pmtCollectorOffset
If it is set, process subsequent parts of multi-packet PMT.
void checkIfInterlaced(unsigned char *packet, int length)
Updates state variables depending on interlaced.
bool m_havePMT
When PMT buffer examined the value is set to 1.
long long readPCR(unsigned char *p)
Read PCR from a buffer.
Uint with size of 33 bits.
void reTimestamp(unsigned char *&packet, int length)
Does PTS re-stamping.
char * associatedLanguage
void setRate(double rate, PlayMode mode)
Set the playback rate.
bool generatePATandPMT(bool trick, unsigned char **buff, int *bufflen, bool bHandleMCTrick=false)
generate PAT and PMT based on media components
void sendDiscontinuity(double position)
Send discontinuity packet. Not relevant for demux operations.
void writePCR(unsigned char *p, long long PCR, bool clearExtension)
Write PCR to a buffer.
int m_versionPMT
Version number for PMT which is being examined.
void putPmtByte(unsigned char *&pmt, int &index, unsigned char byte, int pmtPid)
Appends a byte to PMT buffer.
MPEG TS Processor. Supports software Demuxer/ PTS re-stamping for trickmode.
void GetLanguageCode(std::string &lang)
Function to get the language code.
Class representing the AAMP player's private instance, which is not exposed to outside world.
void setPlayMode(PlayMode mode)
Set to the playback mode.
int m_program
Program number in the corresponding program map table.
int m_pmtCollectorNextContinuity
Keeps next continuity counter for PMT packet at the time of examine the TS Buffer.
Software demuxer of MPEGTS.
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.
TSProcessor(AampLogManager *logObj, class PrivateInstanceAAMP *aamp, StreamOperation streamOperation, int track=0, TSProcessor *peerTSProcessor=NULL, TSProcessor *auxTSProcessor=NULL)
TSProcessor Constructor.
bool m_haveAspect
Set to 1 when it found aspect ratio of current video.
void sendQueuedSegment(long long basepts=0, double updatedStartPositon=-1)
Send queued segment.
void setThrottleEnable(bool enable)
Enable/ disable throttle.
uint33_t m_currentPTS
Store the current PTS value of a recording.
int m_versionPAT
Pat Version number.
unsigned char * createNullPFrame(int width, int height, int *nullPFrameLen)
Create a Null P frame.
bool processStartCode(unsigned char *buffer, bool &keepScanning, int length, int base)
Process ES start code.
void processScalingList(unsigned char *&p, int &mask, int size)
Consume all bits used by the scaling list.
void SetAudioGroupId(std::string &id)
Function to set the group-ID.
@ eStreamOp_SEND_VIDEO_AND_QUEUED_AUDIO
void getAudioComponents(const RecordingComponent **audioComponentsPtr, int &count)
Get audio components.
void putBits(unsigned char *&p, int &mask, int bitCount, unsigned int value)
Put bits based on mask and count.
unsigned int getUExpGolomb(unsigned char *&p, int &mask)
Gets unsigned EXP Golomb.
bool readTimeStamp(unsigned char *p, long long &value)
Read time-stamp at the point.
void setBasePTS(double position, long long pts)
set base PTS for demux operations
void setupThrottle(int segmentDurationMs)
Update internal state variables to set up throttle.
RecordingComponent m_dsmccComponent
Digital storage media command and control (DSM-CC) Component.