RDK Documentation (Open Sourced RDK Components)
tsprocessor.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21 * @file tsprocessor.h
22 * @brief Header file for play context
23 */
24 
25 #ifndef _TSPROCESSOR_H
26 #define _TSPROCESSOR_H
27 
28 #include "mediaprocessor.h"
29 #include "uint33_t.h"
30 #include <stdio.h>
31 #include <pthread.h>
32 
33 #include <vector>
34 
35 #define MAX_PIDS (8) //PMT Parsing
36 
37 /**
38 * @struct RecordingComponent
39 * @brief Stores information of a audio/video component.
40 */
42 {
43  int siType; /**< Service information type such as PAT, PMT, NIT, SDT, BAT, etc */
44  int elemStreamType; /**< Elementary stream type of Audio or Video, such as 1B=H.264, 0x01=MPEG1, 0x10=MPEG4, 0x03=MPEG1 Audio, 0x04=MPEG2 Audio, etc */
45  int pid; /**< PID associated to the audio, video or data component */
46  char *associatedLanguage; /**< Language such as eng, hin, etc */
47  unsigned int descriptorTags; /**< Descriptor tags, each byte value will represent one descriptor tag up to max MAX_DESCRIPTOR (4)*/
48 };
49 
50 
51 // Maximum number of bytes needed to examine in a start code
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
56 #else
57 #define MAX_SCAN_REMAINDER_SIZE SCAN_REMAINDER_SIZE_H264
58 #endif
59 
60 class Demuxer;
61 
62 /**
63  * @enum StreamOperation
64  * @brief Operation done by TSProcessor
65  */
66 typedef enum
67 {
68  eStreamOp_NONE, /**< Normal operation when no demuxing is required. Used with playersinkbin */
69  eStreamOp_DEMUX_AUDIO, /**< Demux and inject audio only*/
70  eStreamOp_DEMUX_VIDEO, /**< Demux and inject video only*/
71  eStreamOp_DEMUX_ALL, /**< Demux and inject audio and video*/
72  eStreamOp_QUEUE_AUDIO, /**< When video contains PAT/PMT, audio needs to be queued until video is processed
73  used with playersinkbin*/
74  eStreamOp_SEND_VIDEO_AND_QUEUED_AUDIO, /**< Send queued audio after video*/
75  eStreamOp_DEMUX_AUX, /**< Demux and inject auxiliary audio only*/
76  eStreamOp_DEMUX_VIDEO_AND_AUX /**< Demux and inject auxiliary audio and video*/
77 
79 
80 /**
81  * @enum TrackToDemux
82  * @brief Track to demux
83  */
84 typedef enum
85 {
86  ePC_Track_Video, /**< Demux and send video only*/
87  ePC_Track_Audio, /**< Demux and send audio only*/
88  ePC_Track_Both /**< Demux and send audio and video*/
90 
91 /**
92 * @class TSProcessor
93 * @brief MPEG TS Processor. Supports software Demuxer/ PTS re-stamping for trickmode.
94 */
96 {
97  public:
98  /**
99  * @fn TSProcessor
100  * @param[in] aamp Pointer to aamp associated with this TSProcessor
101  * @param[in] streamOperation Operation to be done on injected data.
102  * @param[in] track MediaType to be operated on. Not relavent for demux operation
103  * @param[in] peerTSProcessor Peer TSProcessor used along with this in case of separate audio/video playlists
104  */
105  TSProcessor(AampLogManager *logObj, class PrivateInstanceAAMP *aamp, StreamOperation streamOperation, int track = 0, TSProcessor* peerTSProcessor = NULL, TSProcessor* auxTSProcessor = NULL);
106  /**
107  * @brief Copy constructor disabled
108  *
109  */
110  TSProcessor(const TSProcessor&) = delete;
111  /**
112  * @brief assignment operator disabled
113  *
114  */
115  TSProcessor& operator=(const TSProcessor&) = delete;
116  /**
117  * @fn ~TSProcessor
118  */
119  ~TSProcessor();
120  /**
121  * @fn sendSegment
122  * @param[in] segment Buffer containing the data segment
123  * @param[in] size Specifies size of the segment in bytes.
124  * @param[in] position Position of the segment in seconds
125  * @param[in] duration Duration of the segment in seconds
126  * @param[in] discontinuous true if fragment is discontinuous
127  * @param[out] true on PTS error
128  */
129  bool sendSegment( char *segment, size_t& size, double position, double duration, bool discontinuous, bool &ptsError);
130  /**
131  * @fn setRate
132  *
133  * @param[in] rate play rate could be 1.0=Normal Playback, 0.0=Pause, etc
134  * @param[in] mode play mode such as PlayMode_normal, PlayMode_retimestamp_Ionly,
135  * PlayMode_retimestamp_IPB, PlayMode_retimestamp_IandP or PlayMode_reverse_GOP.
136  *
137  */
138  void setRate(double rate, PlayMode mode);
139  /**
140  * @fn setThrottleEnable
141  * @param[in] enable true to enable throttle, false to disable
142  */
143  void setThrottleEnable(bool enable);
144  /**
145  * @brief Set frame rate for trick mode
146  * @param[in] frameRate rate per second
147  */
148  void setFrameRateForTM( int frameRate)
149  {
150  m_apparentFrameRate = frameRate;
151  }
152  /**
153  * @fn abort
154  */
155  void abort();
156  /**
157  * @fn reset
158  */
159  void reset();
160  /**
161  * @fn flush
162  */
163  void flush();
164 
165  /**
166  * @fn Change Muxed Audio Track
167  * @param[in] AudioTrackIndex
168  */
169  void ChangeMuxedAudioTrack(unsigned char index);
170 
171  /**
172  * @fn Select Audio Track
173  * @param[out] bestTrackIndex
174  */
175  int SelectAudioIndexToPlay();
176 
177  /**
178  * @brief Function to filter the audio codec based on the configuration
179  * @param[in] audioFormat
180  * @param[out] bool ignoreProfile - true/false
181  */
183 
184  /**
185  * @brief Function to get the language code
186  * @param[in] string - language
187  */
188  void GetLanguageCode(std::string& lang);
189 
190  /**
191  * @brief Function to set the group-ID
192  * @param[in] string - id
193  */
194  void SetAudioGroupId(std::string& id);
195  /**
196  * @brief Function to set a flag to identify both the av tracks are in TS format or not
197  * @param[in] bool - true/false
198  */
199  void setApplyOffsetFlag(bool enable);
200 
201  protected:
202  /**
203  * @fn getAudioComponents
204  * @param[out] audioComponentsPtr pointer to audio component array
205  * @param[out] count Number of audio components
206  */
207  void getAudioComponents(const RecordingComponent** audioComponentsPtr, int &count);
208  /**
209  * @fn sendQueuedSegment
210  * @param[in] basepts new base pts to be set. Valid only for eStreamOp_DEMUX_AUDIO.
211  * @param[in] updatedStartPositon New start position of queued segment.
212  */
213  void sendQueuedSegment(long long basepts = 0, double updatedStartPositon = -1);
214  /**
215  * @fn setBasePTS
216  * @param[in] position start position of fragment
217  * @param[in] pts base pts for demux operations.
218  */
219  void setBasePTS(double position, long long pts);
220 
221  private:
222  class PrivateInstanceAAMP *aamp;
223  /**
224  * @fn setPlayMode
225  *
226  * @param[in] mode play mode such as PlayMode_normal, PlayMode_retimestamp_Ionly,
227  * PlayMode_retimestamp_IPB, PlayMode_retimestamp_IandP or PlayMode_reverse_GOP.
228  */
229  void setPlayMode( PlayMode mode );
230  /**
231  * @fn processPMTSection
232  * @param[in] section character buffer containing PMT section
233  * @param[in] sectionLength length of PMT section
234  */
235  void processPMTSection( unsigned char* section, int sectionLength );
236  /**
237  * @fn reTimestamp
238  * @param[in,out] packet TS data to re-stamp
239  * @param[in] length[in] TS data size
240  */
241  void reTimestamp( unsigned char *&packet, int length );
242  /**
243  * @fn insertPatPmt
244  *
245  * @param[out] buffer PAT and PMT is copied to this buffer
246  * @param[in] trick true on trick mode, false on normal playback
247  * @param[in] bufferSize size of buffer
248  */
249  int insertPatPmt( unsigned char *buffer, bool trick, int bufferSize );
250  /**
251  * @fn insertPCR
252  * @param[in] packet[in,out] buffer to which PCR to be inserted
253  * @param[in] pid[in] pcr pid
254  */
255  void insertPCR( unsigned char *packet, int pid );
256  /**
257  * @fn generatePATandPMT
258  * @param[in] trick true on trickmode
259  * @param[out] buff PAT and PMT copied to this buffer
260  * @param[out] buflen Length of buff
261  * @param[in] bHandleMCTrick true if audio pid is same as PCR pid
262  */
263  bool generatePATandPMT( bool trick, unsigned char **buff, int *bufflen, bool bHandleMCTrick = false);
264  /**
265  * @fn putPmtByte
266  * @param[in,out] pmt buffer in which PMT is being constructed
267  * @param[in,out] index current index of PMT construction.
268  * @param[in] byte byte to be written at index
269  * @param[in] pmtPid PID of PMT
270  */
271  void putPmtByte( unsigned char* &pmt, int& index, unsigned char byte, int pmtPid );
272  /**
273  * @fn processStartCode
274  * @param[in] buffer buffer containing start code
275  * @param[in] keepScanning true to keep on scanning
276  * @param[in] length size of the buffer
277  * @param[in] base Not used
278  */
279  bool processStartCode( unsigned char *buffer, bool& keepScanning, int length, int base );
280  /**
281  * @fn checkIfInterlaced
282  * @param[in] packet buffer containing TS packet
283  * @param[in] length length of buffer
284  */
285  void checkIfInterlaced( unsigned char *packet, int length );
286  /**
287  * @fn readTimeStamp
288  * @param[in] p buffer position containing time-stamp
289  * @param[out] TS time-stamp
290  */
291  bool readTimeStamp( unsigned char *p, long long &value );
292  /**
293  * @fn writeTimeStamp
294  * @param[out] p buffer to which TS to be written
295  * @param[in] prefix of time-stamp
296  * @param[in] TS time-stamp
297  */
298  void writeTimeStamp( unsigned char *p, int prefix, long long TS );
299  /**
300  * @fn readPCR
301  * @param[in] p start of PCR data
302  */
303  long long readPCR( unsigned char *p );
304  /**
305  * @fn writePCR
306  * @param[out] p buffer to write PCR
307  * @param[in] PCR timestamp to be written
308  * @param[in] clearExtension clear PCR extension
309  */
310  void writePCR( unsigned char *p, long long PCR, bool clearExtension );
311  /**
312  * @fn createNullPFrame
313  * @param[in] width width of P frame to be constructed
314  * @param[in] height height of P frame
315  * @param[out] nullPFrameLen length of constructed p frame
316  */
317  unsigned char* createNullPFrame( int width, int height, int *nullPFrameLen );
318  /**
319  * @fn processSeqParameterSet
320  * @param[in] p pointer containing SPS
321  * @param[in] length size of SPS
322  */
323  bool processSeqParameterSet( unsigned char *p, int length );
324  /**
325  * @fn processPictureParameterSet
326  * @param[in] p buffer containing PPS
327  * @param[in] length size of PPS
328  */
329  void processPictureParameterSet( unsigned char *p, int length );
330  /**
331  * @fn processScalingList
332  * @param[in] p buffer containing scaling list
333  * @param[in] mask mask
334  * @param[in] size lenght of scaling list
335  */
336  void processScalingList( unsigned char *& p, int& mask, int size );
337  /**
338  * @fn getBits
339  * @param[in,out] p pointer being processed, updated internally
340  * @param[in,out] mask mask to be applied
341  * @param[in] bitCount Number of bits to be processed.
342  */
343  unsigned int getBits( unsigned char *& p, int& mask, int bitCount );
344  /**
345  * @fn putBits
346  * @param[in,out] p reference of buffer to which bits to be put
347  * @param[in,out] mask mask to be applied
348  * @param[in] bitCount count of bits to be put
349  * @param[in] value bits to be put
350  */
351  void putBits( unsigned char *& p, int& mask, int bitCount, unsigned int value );
352  /**
353  * @fn getUExpGolomb
354  * @param[in,out] p buffer
355  * @param[in,out] mask bitmask
356  * @retval Unsigned EXP Golomb
357  */
358  unsigned int getUExpGolomb( unsigned char *& p, int& mask );
359  /**
360  * @fn getSExpGolomb
361  * @param[in,out] p buffer
362  * @param[in,out] bit mask
363  * @retval signed EXP Golomb
364  */
365  int getSExpGolomb( unsigned char *& p, int& mask );
366  /**
367  * @fn updatePATPMT
368  */
369  void updatePATPMT();
370  /**
371  * @fn abortUnlocked
372  */
373  void abortUnlocked();
374 
375  bool m_needDiscontinuity;
376  long long m_currStreamOffset;
377  long long m_currPTS;
378  long long m_currTimeStamp;
379  int m_currFrameNumber;
380  int m_currFrameLength;
381  long long m_currFrameOffset;
382 
383  bool m_trickExcludeAudio;
384  int m_PatPmtLen;
385  unsigned char *m_PatPmt;
386  int m_PatPmtTrickLen;
387  unsigned char *m_PatPmtTrick;
388  int m_PatPmtPcrLen;
389  unsigned char *m_PatPmtPcr;
390  int m_patCounter;
391  int m_pmtCounter;
392 
393  PlayMode m_playMode;
394  PlayMode m_playModeNext;
395  double m_playRate;
396  double m_absPlayRate;
397  double m_playRateNext;
398  double m_apparentFrameRate;
399  int m_packetSize;
400  int m_ttsSize;
401  int m_pcrPid;
402  int m_videoPid;
403  bool m_haveBaseTime;
404  bool m_haveEmittedIFrame;
405  bool m_haveUpdatedFirstPTS;
406  int m_pcrPerPTSCount;
407  long long m_baseTime;
408  long long m_segmentBaseTime;
409  long long m_basePCR;
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];
416 
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;
423  int m_frameWidth;
424  int m_frameHeight;
425  bool m_scanForFrameSize;
426  int m_scanRemainderSize;
427  int m_scanRemainderLimit;
428  unsigned char m_scanRemainder[MAX_SCAN_REMAINDER_SIZE*3];
429  bool m_isH264;
430  bool m_isMCChannel;
431  bool m_isInterlaced;
432  bool m_isInterlacedKnown;
433  bool m_throttle;
434  bool m_haveThrottleBase;
435  long long m_lastThrottleContentTime;
436  long long m_lastThrottleRealTime;
437  long long m_baseThrottleContentTime;
438  long long m_baseThrottleRealTime;
439  uint33_t m_throttlePTS;
440  bool m_insertPCR;
441  int m_emulationPreventionCapacity;
442  int m_emulationPreventionOffset;
443  unsigned char * m_emulationPrevention;
444  bool m_scanSkipPacketsEnabled;
445  bool m_applyOffset; /*If false, no need to apply offset when doing pts restamping since audio track is not in mpegts format */
446 
447  /**
448  * @struct _H264SPS
449  * @brief Holds SPS parameters
450  */
451  typedef struct _H264SPS
452  {
453  int picOrderCountType;
454  int maxPicOrderCount;
455  int log2MaxFrameNumMinus4;
456  int log2MaxPicOrderCntLsbMinus4;
457  int separateColorPlaneFlag;
458  int frameMBSOnlyFlag;
459  } H264SPS;
460 
461  /**
462  * @struct _H264PPS
463  * @brief Holds PPS parameters
464  */
465  typedef struct _H264PPS
466  {
467  int spsId;
468  } H264PPS;
469 
470  H264SPS m_SPS[32];
471  H264PPS m_PPS[256];
472  int m_currSPSId;
473  int m_picOrderCount;
474  bool m_updatePicOrderCount;
475  /**
476  * @fn processBuffer
477  * @param[in] buffer contains TS data
478  * @param[in] size lenght of the buffer
479  * @param[out] insPatPmt indicates if PAT and PMT needs to inserted
480  */
481  bool processBuffer(unsigned char *buffer, int size, bool &insPatPmt);
482  /**
483  * @fn getCurrentTime
484  */
485  long long getCurrentTime();
486  /**
487  * @fn throttle
488  */
489  bool throttle();
490  /**
491  * @fn sendDiscontinuity
492  * @param[in] position position in seconds
493  */
494  void sendDiscontinuity(double position);
495  /**
496  * @fn setupThrottle
497  * @param[in] segmentDurationMsSigned Duration of segment
498  */
499  void setupThrottle(int segmentDurationMs);
500  /**
501  * @fn demuxAndSend
502  * @param[in] ptr buffer containing TS data
503  * @param[in] len lenght of buffer
504  * @param[in] position position of segment in seconds
505  * @param[in] duration duration of segment in seconds
506  * @param[in] discontinuous true if segment is discontinous
507  * @param[in] trackToDemux media track to do the operation
508  */
509  bool demuxAndSend(const void *ptr, size_t len, double fTimestamp, double fDuration, bool discontinuous, TrackToDemux trackToDemux = ePC_Track_Both);
510  /**
511  * @fn msleep
512  * @param[in] throttleDiff time in milliseconds
513  * @retval true on abort
514  */
515  bool msleep(long long throttleDiff);
516 
517  bool m_havePAT; //!< Set to 1 when PAT buffer examined and loaded all program specific information
518  int m_versionPAT; //!< Pat Version number
519  int m_program; //!< Program number in the corresponding program map table
520  int m_pmtPid; //!< For which PID the program information is available such as, audio pid, video pid, stream types, etc
521 
522  bool m_havePMT; //!< When PMT buffer examined the value is set to 1
523  int m_versionPMT; //!< Version number for PMT which is being examined
524 
525  bool m_indexAudio; //!< If PCR Pid matches with any Audio PIDs associated for a recording, the value will be set to 1
526  bool m_haveAspect; //!< Set to 1 when it found aspect ratio of current video
527  bool m_haveFirstPTS; //!< The value is set to 1 if first PTS found from a recording after examining few KB of initial data
528  uint33_t m_currentPTS; //!< Store the current PTS value of a recording
529  int m_pmtCollectorNextContinuity; //!< Keeps next continuity counter for PMT packet at the time of examine the TS Buffer
530  int m_pmtCollectorSectionLength; //!< Update section length while examining PMT table
531  int m_pmtCollectorOffset; //!< If it is set, process subsequent parts of multi-packet PMT
532  unsigned char *m_pmtCollector; //!< A buffer pointer to hold PMT data at the time of examining TS buffer
533  bool m_scrambledWarningIssued;
534  bool m_checkContinuity;
535  int videoComponentCount, audioComponentCount;
536  RecordingComponent videoComponents[MAX_PIDS], audioComponents[MAX_PIDS];
537  bool m_dsmccComponentFound; //!< True if DSMCC found
538  RecordingComponent m_dsmccComponent; //!< Digital storage media command and control (DSM-CC) Component
539 
540  uint33_t m_actualStartPTS;
541 
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;
549  bool m_enabled;
550  bool m_processing;
551  int m_framesProcessedInSegment;
552  long long m_lastPTSOfSegment;
553  StreamOperation m_streamOperation;
554  Demuxer* m_vidDemuxer;
555  Demuxer* m_audDemuxer;
556  Demuxer* m_dsmccDemuxer;
557  bool m_demux;
558  TSProcessor* m_peerTSProcessor;
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;
566  int m_track;
567  long long m_last_frame_time;
568  bool m_demuxInitialized;
569  long long m_basePTSFromPeer;
570  unsigned char m_AudioTrackIndexToPlay;
571  TSProcessor* m_auxTSProcessor;
572  bool m_auxiliaryAudio;
573  AampLogManager *mLogObj;
574  std::string m_audioGroupId;
575 };
576 
577 #endif
578 
TSProcessor::insertPCR
void insertPCR(unsigned char *packet, int pid)
insert PCR to the packet in case of PTS restamping
Definition: tsprocessor.cpp:1047
TSProcessor::getBits
unsigned int getBits(unsigned char *&p, int &mask, int bitCount)
get bits based on mask and count
Definition: tsprocessor.cpp:4482
StreamOutputFormat
StreamOutputFormat
Media output format.
Definition: main_aamp.h:106
RecordingComponent::elemStreamType
int elemStreamType
Definition: tsprocessor.h:44
RecordingComponent::siType
int siType
Definition: tsprocessor.h:43
TSProcessor::flush
void flush()
Flush all buffered data to sink.
Definition: tsprocessor.cpp:2344
TSProcessor::_H264SPS
Holds SPS parameters.
Definition: tsprocessor.h:451
TSProcessor::processSeqParameterSet
bool processSeqParameterSet(unsigned char *p, int length)
process sequence parameter set and update state variables
Definition: tsprocessor.cpp:4226
TSProcessor::~TSProcessor
~TSProcessor()
TSProcessor Destructor.
Definition: tsprocessor.cpp:939
TSProcessor::setApplyOffsetFlag
void setApplyOffsetFlag(bool enable)
Function to set a flag to identify both the av tracks are in TS format or not.
Definition: tsprocessor.cpp:3993
TSProcessor::throttle
bool throttle()
Blocks based on PTS. Can be used for pacing injection.
Definition: tsprocessor.cpp:1553
TSProcessor::processPMTSection
void processPMTSection(unsigned char *section, int sectionLength)
process PMT section and update media components.
Definition: tsprocessor.cpp:1080
mediaprocessor.h
Header file for base class of media container processor.
StreamOperation
StreamOperation
Operation done by TSProcessor.
Definition: tsprocessor.h:66
RecordingComponent
Stores information of a audio/video component.
Definition: tsprocessor.h:41
TSProcessor::m_pmtCollector
unsigned char * m_pmtCollector
A buffer pointer to hold PMT data at the time of examining TS buffer.
Definition: tsprocessor.h:532
TSProcessor::abort
void abort()
Abort current operations and return all blocking calls immediately.
Definition: tsprocessor.cpp:3427
TSProcessor::setFrameRateForTM
void setFrameRateForTM(int frameRate)
Set frame rate for trick mode.
Definition: tsprocessor.h:148
TSProcessor::_H264PPS
Holds PPS parameters.
Definition: tsprocessor.h:465
TSProcessor::FilterAudioCodecBasedOnConfig
bool FilterAudioCodecBasedOnConfig(StreamOutputFormat audioFormat)
Function to filter the audio codec based on the configuration.
Definition: tsprocessor.cpp:4657
TSProcessor::m_dsmccComponentFound
bool m_dsmccComponentFound
True if DSMCC found.
Definition: tsprocessor.h:537
TSProcessor::msleep
bool msleep(long long throttleDiff)
sleep used internal by throttle logic
Definition: tsprocessor.cpp:1515
ePC_Track_Audio
@ ePC_Track_Audio
Definition: tsprocessor.h:87
TSProcessor::m_pmtPid
int m_pmtPid
For which PID the program information is available such as, audio pid, video pid, stream types,...
Definition: tsprocessor.h:520
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
eStreamOp_DEMUX_AUDIO
@ eStreamOp_DEMUX_AUDIO
Definition: tsprocessor.h:69
TSProcessor::reset
void reset()
Reset TS processor state.
Definition: tsprocessor.cpp:2316
TSProcessor::processBuffer
bool processBuffer(unsigned char *buffer, int size, bool &insPatPmt)
Process buffers and update internal states related to media components.
Definition: tsprocessor.cpp:1672
uint33_t.h
Custom int variable to handle 33 bit.
eStreamOp_DEMUX_VIDEO
@ eStreamOp_DEMUX_VIDEO
Definition: tsprocessor.h:70
RecordingComponent::pid
int pid
Definition: tsprocessor.h:45
TSProcessor::sendSegment
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.
Definition: tsprocessor.cpp:2436
TSProcessor::m_haveFirstPTS
bool m_haveFirstPTS
The value is set to 1 if first PTS found from a recording after examining few KB of initial data.
Definition: tsprocessor.h:527
TSProcessor::insertPatPmt
int insertPatPmt(unsigned char *buffer, bool trick, int bufferSize)
Insert PAT and PMT sections.
Definition: tsprocessor.cpp:1011
TSProcessor::abortUnlocked
void abortUnlocked()
Abort TSProcessor operations and return blocking calls immediately.
Definition: tsprocessor.cpp:3412
RecordingComponent::descriptorTags
unsigned int descriptorTags
Definition: tsprocessor.h:47
TSProcessor::updatePATPMT
void updatePATPMT()
Generate and update PAT and PMT sections.
Definition: tsprocessor.cpp:1358
TrackToDemux
TrackToDemux
Track to demux.
Definition: tsprocessor.h:84
TSProcessor::operator=
TSProcessor & operator=(const TSProcessor &)=delete
assignment operator disabled
TSProcessor::m_pmtCollectorSectionLength
int m_pmtCollectorSectionLength
Update section length while examining PMT table.
Definition: tsprocessor.h:530
TSProcessor::writeTimeStamp
void writeTimeStamp(unsigned char *p, int prefix, long long TS)
Write time-stamp to buffer.
Definition: tsprocessor.cpp:3948
TSProcessor::processPictureParameterSet
void processPictureParameterSet(unsigned char *p, int length)
Parse through the picture parameter set to get required items.
Definition: tsprocessor.cpp:4446
TSProcessor::m_indexAudio
bool m_indexAudio
If PCR Pid matches with any Audio PIDs associated for a recording, the value will be set to 1.
Definition: tsprocessor.h:525
eStreamOp_DEMUX_VIDEO_AND_AUX
@ eStreamOp_DEMUX_VIDEO_AND_AUX
Definition: tsprocessor.h:76
TSProcessor::m_havePAT
bool m_havePAT
Set to 1 when PAT buffer examined and loaded all program specific information.
Definition: tsprocessor.h:517
TSProcessor::getCurrentTime
long long getCurrentTime()
Get current time stamp in milliseconds.
Definition: tsprocessor.cpp:1500
TSProcessor::getSExpGolomb
int getSExpGolomb(unsigned char *&p, int &mask)
Getss signed EXP Golomb.
Definition: tsprocessor.cpp:4564
TSProcessor::m_pmtCollectorOffset
int m_pmtCollectorOffset
If it is set, process subsequent parts of multi-packet PMT.
Definition: tsprocessor.h:531
TSProcessor::checkIfInterlaced
void checkIfInterlaced(unsigned char *packet, int length)
Updates state variables depending on interlaced.
Definition: tsprocessor.cpp:2893
TSProcessor::m_havePMT
bool m_havePMT
When PMT buffer examined the value is set to 1.
Definition: tsprocessor.h:522
TSProcessor::readPCR
long long readPCR(unsigned char *p)
Read PCR from a buffer.
Definition: tsprocessor.cpp:3960
uint33_t
Uint with size of 33 bits.
Definition: uint33_t.h:36
TSProcessor::reTimestamp
void reTimestamp(unsigned char *&packet, int length)
Does PTS re-stamping.
Definition: tsprocessor.cpp:3037
RecordingComponent::associatedLanguage
char * associatedLanguage
Definition: tsprocessor.h:46
TSProcessor::setRate
void setRate(double rate, PlayMode mode)
Set the playback rate.
Definition: tsprocessor.cpp:3439
TSProcessor::generatePATandPMT
bool generatePATandPMT(bool trick, unsigned char **buff, int *bufflen, bool bHandleMCTrick=false)
generate PAT and PMT based on media components
Definition: tsprocessor.cpp:3466
TSProcessor::sendDiscontinuity
void sendDiscontinuity(double position)
Send discontinuity packet. Not relevant for demux operations.
Definition: tsprocessor.cpp:1386
ePC_Track_Video
@ ePC_Track_Video
Definition: tsprocessor.h:86
TSProcessor::writePCR
void writePCR(unsigned char *p, long long PCR, bool clearExtension)
Write PCR to a buffer.
Definition: tsprocessor.cpp:3973
eStreamOp_DEMUX_ALL
@ eStreamOp_DEMUX_ALL
Definition: tsprocessor.h:71
TSProcessor::m_versionPMT
int m_versionPMT
Version number for PMT which is being examined.
Definition: tsprocessor.h:523
TSProcessor::putPmtByte
void putPmtByte(unsigned char *&pmt, int &index, unsigned char byte, int pmtPid)
Appends a byte to PMT buffer.
Definition: tsprocessor.cpp:3870
TSProcessor
MPEG TS Processor. Supports software Demuxer/ PTS re-stamping for trickmode.
Definition: tsprocessor.h:95
ePC_Track_Both
@ ePC_Track_Both
Definition: tsprocessor.h:88
TSProcessor::GetLanguageCode
void GetLanguageCode(std::string &lang)
Function to get the language code.
Definition: tsprocessor.cpp:4700
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
TSProcessor::setPlayMode
void setPlayMode(PlayMode mode)
Set to the playback mode.
Definition: tsprocessor.cpp:3398
TSProcessor::m_program
int m_program
Program number in the corresponding program map table.
Definition: tsprocessor.h:519
eStreamOp_NONE
@ eStreamOp_NONE
Definition: tsprocessor.h:68
TSProcessor::m_pmtCollectorNextContinuity
int m_pmtCollectorNextContinuity
Keeps next continuity counter for PMT packet at the time of examine the TS Buffer.
Definition: tsprocessor.h:529
Demuxer
Software demuxer of MPEGTS.
Definition: tsprocessor.cpp:230
TSProcessor::demuxAndSend
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.
Definition: tsprocessor.cpp:2121
TSProcessor::TSProcessor
TSProcessor(AampLogManager *logObj, class PrivateInstanceAAMP *aamp, StreamOperation streamOperation, int track=0, TSProcessor *peerTSProcessor=NULL, TSProcessor *auxTSProcessor=NULL)
TSProcessor Constructor.
Definition: tsprocessor.cpp:856
MediaProcessor
Base Class for Media Container Processor.
Definition: mediaprocessor.h:47
TSProcessor::m_haveAspect
bool m_haveAspect
Set to 1 when it found aspect ratio of current video.
Definition: tsprocessor.h:526
TSProcessor::sendQueuedSegment
void sendQueuedSegment(long long basepts=0, double updatedStartPositon=-1)
Send queued segment.
Definition: tsprocessor.cpp:2371
eStreamOp_DEMUX_AUX
@ eStreamOp_DEMUX_AUX
Definition: tsprocessor.h:75
TSProcessor::setThrottleEnable
void setThrottleEnable(bool enable)
Enable/ disable throttle.
Definition: tsprocessor.cpp:3457
TSProcessor::m_currentPTS
uint33_t m_currentPTS
Store the current PTS value of a recording.
Definition: tsprocessor.h:528
TSProcessor::m_versionPAT
int m_versionPAT
Pat Version number.
Definition: tsprocessor.h:518
TSProcessor::createNullPFrame
unsigned char * createNullPFrame(int width, int height, int *nullPFrameLen)
Create a Null P frame.
Definition: tsprocessor.cpp:4075
TSProcessor::processStartCode
bool processStartCode(unsigned char *buffer, bool &keepScanning, int length, int base)
Process ES start code.
Definition: tsprocessor.cpp:2622
TSProcessor::processScalingList
void processScalingList(unsigned char *&p, int &mask, int size)
Consume all bits used by the scaling list.
Definition: tsprocessor.cpp:4463
TSProcessor::SetAudioGroupId
void SetAudioGroupId(std::string &id)
Function to set the group-ID.
Definition: tsprocessor.cpp:4709
eStreamOp_QUEUE_AUDIO
@ eStreamOp_QUEUE_AUDIO
Definition: tsprocessor.h:72
eStreamOp_SEND_VIDEO_AND_QUEUED_AUDIO
@ eStreamOp_SEND_VIDEO_AND_QUEUED_AUDIO
Definition: tsprocessor.h:74
TSProcessor::getAudioComponents
void getAudioComponents(const RecordingComponent **audioComponentsPtr, int &count)
Get audio components.
Definition: tsprocessor.cpp:4578
TSProcessor::putBits
void putBits(unsigned char *&p, int &mask, int bitCount, unsigned int value)
Put bits based on mask and count.
Definition: tsprocessor.cpp:4506
TSProcessor::getUExpGolomb
unsigned int getUExpGolomb(unsigned char *&p, int &mask)
Gets unsigned EXP Golomb.
Definition: tsprocessor.cpp:4532
TSProcessor::readTimeStamp
bool readTimeStamp(unsigned char *p, long long &value)
Read time-stamp at the point.
Definition: tsprocessor.cpp:3905
TSProcessor::setBasePTS
void setBasePTS(double position, long long pts)
set base PTS for demux operations
Definition: tsprocessor.cpp:2415
TSProcessor::setupThrottle
void setupThrottle(int segmentDurationMs)
Update internal state variables to set up throttle.
Definition: tsprocessor.cpp:2107
TSProcessor::m_dsmccComponent
RecordingComponent m_dsmccComponent
Digital storage media command and control (DSM-CC) Component.
Definition: tsprocessor.h:538