vdr  2.0.6
remux.h
Go to the documentation of this file.
1 /*
2  * remux.h: Tools for detecting frames and handling PAT/PMT
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: remux.h 2.37.1.2 2014/01/28 12:36:26 kls Exp $
8  */
9 
10 #ifndef __REMUX_H
11 #define __REMUX_H
12 
13 #include "channels.h"
14 #include "tools.h"
15 
16 enum ePesHeader {
18  phInvalid = 0,
19  phMPEG1 = 1,
20  phMPEG2 = 2
21  };
22 
23 ePesHeader AnalyzePesHeader(const uchar *Data, int Count, int &PesPayloadOffset, bool *ContinuationHeader = NULL);
24 
25 class cRemux {
26 public:
27  static void SetBrokenLink(uchar *Data, int Length);
28  };
29 
30 // Some TS handling tools.
31 // The following functions all take a pointer to one complete TS packet.
32 
33 #define TS_SYNC_BYTE 0x47
34 #define TS_SIZE 188
35 #define TS_ERROR 0x80
36 #define TS_PAYLOAD_START 0x40
37 #define TS_TRANSPORT_PRIORITY 0x20
38 #define TS_PID_MASK_HI 0x1F
39 #define TS_SCRAMBLING_CONTROL 0xC0
40 #define TS_ADAPT_FIELD_EXISTS 0x20
41 #define TS_PAYLOAD_EXISTS 0x10
42 #define TS_CONT_CNT_MASK 0x0F
43 #define TS_ADAPT_DISCONT 0x80
44 #define TS_ADAPT_RANDOM_ACC 0x40 // would be perfect for detecting independent frames, but unfortunately not used by all broadcasters
45 #define TS_ADAPT_ELEM_PRIO 0x20
46 #define TS_ADAPT_PCR 0x10
47 #define TS_ADAPT_OPCR 0x08
48 #define TS_ADAPT_SPLICING 0x04
49 #define TS_ADAPT_TP_PRIVATE 0x02
50 #define TS_ADAPT_EXTENSION 0x01
51 
52 #define PATPID 0x0000 // PAT PID (constant 0)
53 #define MAXPID 0x2000 // for arrays that use a PID as the index
54 
55 #define PTSTICKS 90000 // number of PTS ticks per second
56 #define PCRFACTOR 300 // conversion from 27MHz PCR extension to 90kHz PCR base
57 #define MAX33BIT 0x00000001FFFFFFFFLL // max. possible value with 33 bit
58 #define MAX27MHZ ((MAX33BIT + 1) * PCRFACTOR - 1) // max. possible PCR value
59 
60 inline bool TsHasPayload(const uchar *p)
61 {
62  return p[3] & TS_PAYLOAD_EXISTS;
63 }
64 
65 inline bool TsHasAdaptationField(const uchar *p)
66 {
67  return p[3] & TS_ADAPT_FIELD_EXISTS;
68 }
69 
70 inline bool TsPayloadStart(const uchar *p)
71 {
72  return p[1] & TS_PAYLOAD_START;
73 }
74 
75 inline bool TsError(const uchar *p)
76 {
77  return p[1] & TS_ERROR;
78 }
79 
80 inline int TsPid(const uchar *p)
81 {
82  return (p[1] & TS_PID_MASK_HI) * 256 + p[2];
83 }
84 
85 inline bool TsIsScrambled(const uchar *p)
86 {
87  return p[3] & TS_SCRAMBLING_CONTROL;
88 }
89 
91 {
92  return p[3] & TS_CONT_CNT_MASK;
93 }
94 
95 inline void TsSetContinuityCounter(uchar *p, uchar Counter)
96 {
97  p[3] = (p[3] & ~TS_CONT_CNT_MASK) | (Counter & TS_CONT_CNT_MASK);
98 }
99 
100 inline int TsPayloadOffset(const uchar *p)
101 {
102  int o = TsHasAdaptationField(p) ? p[4] + 5 : 4;
103  return o <= TS_SIZE ? o : TS_SIZE;
104 }
105 
106 inline int TsGetPayload(const uchar **p)
107 {
108  if (TsHasPayload(*p)) {
109  int o = TsPayloadOffset(*p);
110  *p += o;
111  return TS_SIZE - o;
112  }
113  return 0;
114 }
115 
116 inline int TsContinuityCounter(const uchar *p)
117 {
118  return p[3] & TS_CONT_CNT_MASK;
119 }
120 
121 inline int64_t TsGetPcr(const uchar *p)
122 {
123  if (TsHasAdaptationField(p)) {
124  if (p[4] >= 7 && (p[5] & TS_ADAPT_PCR)) {
125  return ((((int64_t)p[ 6]) << 25) |
126  (((int64_t)p[ 7]) << 17) |
127  (((int64_t)p[ 8]) << 9) |
128  (((int64_t)p[ 9]) << 1) |
129  (((int64_t)p[10]) >> 7)) * PCRFACTOR +
130  (((((int)p[10]) & 0x01) << 8) |
131  ( ((int)p[11])));
132  }
133  }
134  return -1;
135 }
136 
137 void TsHidePayload(uchar *p);
138 void TsSetPcr(uchar *p, int64_t Pcr);
139 
140 // The following functions all take a pointer to a sequence of complete TS packets.
141 
142 int64_t TsGetPts(const uchar *p, int l);
143 int64_t TsGetDts(const uchar *p, int l);
144 void TsSetPts(uchar *p, int l, int64_t Pts);
145 void TsSetDts(uchar *p, int l, int64_t Dts);
146 
147 // Some PES handling tools:
148 // The following functions that take a pointer to PES data all assume that
149 // there is enough data so that PesLongEnough() returns true.
150 
151 inline bool PesLongEnough(int Length)
152 {
153  return Length >= 6;
154 }
155 
156 inline bool PesHasLength(const uchar *p)
157 {
158  return p[4] | p[5];
159 }
160 
161 inline int PesLength(const uchar *p)
162 {
163  return 6 + p[4] * 256 + p[5];
164 }
165 
166 inline int PesPayloadOffset(const uchar *p)
167 {
168  return 9 + p[8];
169 }
170 
171 inline bool PesHasPts(const uchar *p)
172 {
173  return (p[7] & 0x80) && p[8] >= 5;
174 }
175 
176 inline bool PesHasDts(const uchar *p)
177 {
178  return (p[7] & 0x40) && p[8] >= 10;
179 }
180 
181 inline int64_t PesGetPts(const uchar *p)
182 {
183  return ((((int64_t)p[ 9]) & 0x0E) << 29) |
184  (( (int64_t)p[10]) << 22) |
185  ((((int64_t)p[11]) & 0xFE) << 14) |
186  (( (int64_t)p[12]) << 7) |
187  ((((int64_t)p[13]) & 0xFE) >> 1);
188 }
189 
190 inline int64_t PesGetDts(const uchar *p)
191 {
192  return ((((int64_t)p[14]) & 0x0E) << 29) |
193  (( (int64_t)p[15]) << 22) |
194  ((((int64_t)p[16]) & 0xFE) << 14) |
195  (( (int64_t)p[17]) << 7) |
196  ((((int64_t)p[18]) & 0xFE) >> 1);
197 }
198 
199 void PesSetPts(uchar *p, int64_t Pts);
200 void PesSetDts(uchar *p, int64_t Dts);
201 
202 // PTS handling:
203 
204 inline int64_t PtsAdd(int64_t Pts1, int64_t Pts2) { return (Pts1 + Pts2) & MAX33BIT; }
206 int64_t PtsDiff(int64_t Pts1, int64_t Pts2);
211 
212 // A transprent TS payload handler:
213 
214 class cTsPayload {
215 private:
217  int length;
218  int pid;
219  int index; // points to the next byte to process
220  int numPacketsPid; // the number of TS packets with the given PID (for statistical purposes)
221  int numPacketsOther; // the number of TS packets with other PIDs (for statistical purposes)
222  uchar SetEof(void);
223 protected:
224  void Reset(void);
225 public:
226  cTsPayload(void);
227  cTsPayload(uchar *Data, int Length, int Pid = -1);
229  void Setup(uchar *Data, int Length, int Pid = -1);
237  bool AtTsStart(void) { return index < length && (index % TS_SIZE) == 0; }
240  bool AtPayloadStart(void) { return AtTsStart() && TsPayloadStart(data + index); }
243  int Available(void) { return length - index; }
246  int Used(void) { return (index + TS_SIZE - 1) / TS_SIZE * TS_SIZE; }
250  bool Eof(void) const { return index >= length; }
252  void Statistics(void) const;
256  uchar GetByte(void);
258  bool SkipBytes(int Bytes);
261  bool SkipPesHeader(void);
263  int GetLastIndex(void);
266  void SetByte(uchar Byte, int Index);
271  bool Find(uint32_t Code);
279  };
280 
281 // PAT/PMT Generator:
282 
283 #define MAX_SECTION_SIZE 4096 // maximum size of an SI section
284 #define MAX_PMT_TS (MAX_SECTION_SIZE / TS_SIZE + 1)
285 
287 private:
288  uchar pat[TS_SIZE]; // the PAT always fits into a single TS packet
289  uchar pmt[MAX_PMT_TS][TS_SIZE]; // the PMT may well extend over several TS packets
295  int pmtPid;
297  void IncCounter(int &Counter, uchar *TsPacket);
298  void IncVersion(int &Version);
299  void IncEsInfoLength(int Length);
300 protected:
301  int MakeStream(uchar *Target, uchar Type, int Pid);
302  int MakeAC3Descriptor(uchar *Target, uchar Type);
303  int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId);
304  int MakeLanguageDescriptor(uchar *Target, const char *Language);
305  int MakeCRC(uchar *Target, const uchar *Data, int Length);
306  void GeneratePmtPid(const cChannel *Channel);
309  void GeneratePat(void);
311  void GeneratePmt(const cChannel *Channel);
314 public:
315  cPatPmtGenerator(const cChannel *Channel = NULL);
316  void SetVersions(int PatVersion, int PmtVersion);
325  void SetChannel(const cChannel *Channel);
327  uchar *GetPat(void);
330  uchar *GetPmt(int &Index);
335  };
336 
337 // PAT/PMT Parser:
338 
339 #define MAX_PMT_PIDS 32
340 
342 private:
344  int pmtSize;
347  int pmtPids[MAX_PMT_PIDS + 1]; // list is zero-terminated
348  int vpid;
349  int ppid;
350  int vtype;
351  int apids[MAXAPIDS + 1]; // list is zero-terminated
352  int atypes[MAXAPIDS + 1]; // list is zero-terminated
354  int dpids[MAXDPIDS + 1]; // list is zero-terminated
355  int dtypes[MAXDPIDS + 1]; // list is zero-terminated
357  int spids[MAXSPIDS + 1]; // list is zero-terminated
363 protected:
364  int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; }
365 public:
366  cPatPmtParser(bool UpdatePrimaryDevice = false);
367  void Reset(void);
370  void ParsePat(const uchar *Data, int Length);
373  void ParsePmt(const uchar *Data, int Length);
380  bool ParsePatPmt(const uchar *Data, int Length);
384  bool GetVersions(int &PatVersion, int &PmtVersion) const;
387  bool IsPmtPid(int Pid) const { for (int i = 0; pmtPids[i]; i++) if (pmtPids[i] == Pid) return true; return false; }
390  int Vpid(void) const { return vpid; }
393  int Ppid(void) const { return ppid; }
396  int Vtype(void) const { return vtype; }
399  const int *Apids(void) const { return apids; }
400  const int *Dpids(void) const { return dpids; }
401  const int *Spids(void) const { return spids; }
402  int Apid(int i) const { return (0 <= i && i < MAXAPIDS) ? apids[i] : 0; }
403  int Dpid(int i) const { return (0 <= i && i < MAXDPIDS) ? dpids[i] : 0; }
404  int Spid(int i) const { return (0 <= i && i < MAXSPIDS) ? spids[i] : 0; }
405  int Atype(int i) const { return (0 <= i && i < MAXAPIDS) ? atypes[i] : 0; }
406  int Dtype(int i) const { return (0 <= i && i < MAXDPIDS) ? dtypes[i] : 0; }
407  const char *Alang(int i) const { return (0 <= i && i < MAXAPIDS) ? alangs[i] : ""; }
408  const char *Dlang(int i) const { return (0 <= i && i < MAXDPIDS) ? dlangs[i] : ""; }
409  const char *Slang(int i) const { return (0 <= i && i < MAXSPIDS) ? slangs[i] : ""; }
410  uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS) ? subtitlingTypes[i] : uchar(0); }
411  uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? compositionPageIds[i] : uint16_t(0); }
412  uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? ancillaryPageIds[i] : uint16_t(0); }
413  };
414 
415 // TS to PES converter:
416 // Puts together the payload of several TS packets that form one PES
417 // packet.
418 
419 class cTsToPes {
420 private:
422  int size;
423  int length;
424  int offset;
428 public:
429  cTsToPes(void);
430  ~cTsToPes();
431  void PutTs(const uchar *Data, int Length);
441  const uchar *GetPes(int &Length);
455  void SetRepeatLast(void);
458  void Reset(void);
462  };
463 
464 // Some helper functions for debugging:
465 
466 void BlockDump(const char *Name, const u_char *Data, int Length);
467 void TsDump(const char *Name, const u_char *Data, int Length);
468 void PesDump(const char *Name, const u_char *Data, int Length);
469 
470 // Frame detector:
471 
472 #define MIN_TS_PACKETS_FOR_FRAME_DETECTOR 100
473 
474 class cFrameParser;
475 
477 private:
478  enum { MaxPtsValues = 150 };
479  int pid;
480  int type;
481  bool synced;
482  bool newFrame;
484  uint32_t ptsValues[MaxPtsValues]; // 32 bit is enough - we only need the delta
488  bool isVideo;
491  int framesPerPayloadUnit; // Some broadcasters send one frame per payload unit (== 1),
492  // while others put an entire GOP into one payload unit (> 1).
493  bool scanning;
495 public:
496  cFrameDetector(int Pid = 0, int Type = 0);
500  void SetPid(int Pid, int Type);
502  int Analyze(const uchar *Data, int Length);
508  bool Synced(void) { return synced; }
510  bool NewFrame(void) { return newFrame; }
513  bool IndependentFrame(void) { return independentFrame; }
517  double FramesPerSecond(void) { return framesPerSecond; }
520  };
521 
522 #endif // __REMUX_H
int framesInPayloadUnit
Definition: remux.h:490
bool ParsePatPmt(const uchar *Data, int Length)
Parses the given Data (which may consist of several TS packets, typically an entire frame) and extrac...
Definition: remux.c:868
unsigned char uchar
Definition: tools.h:30
void ParsePat(const uchar *Data, int Length)
Parses the PAT data from the single TS packet in Data.
Definition: remux.c:613
int64_t PtsAdd(int64_t Pts1, int64_t Pts2)
Adds the given PTS values, taking into account the 33bit wrap around.
Definition: remux.h:204
uchar * data
Definition: remux.h:216
int Used(void)
Returns the number of raw bytes that have already been used (e.g.
Definition: remux.h:246
uchar GetByte(void)
Gets the next byte of the TS payload, skipping any intermediate TS header data.
Definition: remux.c:267
bool repeatLast
Definition: remux.h:427
int vpid
Definition: remux.h:348
int index
Definition: remux.h:219
int pid
Definition: remux.h:218
uchar subtitlingTypes[MAXSPIDS]
Definition: remux.h:359
void SetVersions(int PatVersion, int PmtVersion)
Sets the version numbers for the generated PAT and PMT, in case this generator is used to...
Definition: remux.c:566
const char * Alang(int i) const
Definition: remux.h:407
bool TsError(const uchar *p)
Definition: remux.h:75
void SetPid(int Pid, int Type)
Sets the Pid and stream Type to detect frames for.
Definition: remux.c:1422
int PesPayloadOffset(const uchar *p)
Definition: remux.h:166
void IncCounter(int &Counter, uchar *TsPacket)
Definition: remux.c:358
bool SkipBytes(int Bytes)
Skips the given number of bytes in the payload and returns true if there is still data left to read...
Definition: remux.c:298
bool TsHasAdaptationField(const uchar *p)
Definition: remux.h:65
void ParsePmt(const uchar *Data, int Length)
Parses the PMT data from the single TS packet in Data.
Definition: remux.c:645
uint16_t ancillaryPageIds[MAXSPIDS]
Definition: remux.h:361
bool IsPmtPid(int Pid) const
Returns true if Pid the one of the PMT pids as defined by the current PAT.
Definition: remux.h:387
int framesPerPayloadUnit
Definition: remux.h:491
int pmtSize
Definition: remux.h:344
char alangs[MAXAPIDS][MAXLANGCODE2]
Definition: remux.h:353
#define MAX33BIT
Definition: remux.h:57
bool TsPayloadStart(const uchar *p)
Definition: remux.h:70
int64_t TsGetDts(const uchar *p, int l)
Definition: remux.c:160
int MakeLanguageDescriptor(uchar *Target, const char *Language)
Definition: remux.c:419
int Spid(int i) const
Definition: remux.h:404
uchar SubtitlingType(int i) const
Definition: remux.h:410
void GeneratePmtPid(const cChannel *Channel)
Generates a PMT pid that doesn't collide with any of the actual pids of the Channel.
Definition: remux.c:453
int64_t PesGetPts(const uchar *p)
Definition: remux.h:181
int Analyze(const uchar *Data, int Length)
Analyzes the TS packets pointed to by Data.
Definition: remux.c:1439
uchar pat[TS_SIZE]
Definition: remux.h:288
int numPacketsPid
Definition: remux.h:220
bool TsHasPayload(const uchar *p)
Definition: remux.h:60
void TsHidePayload(uchar *p)
Definition: remux.c:121
uint32_t ptsValues[MaxPtsValues]
Definition: remux.h:484
#define TS_ERROR
Definition: remux.h:35
char slangs[MAXSPIDS][MAXLANGCODE2]
Definition: remux.h:358
#define TS_SCRAMBLING_CONTROL
Definition: remux.h:39
#define TS_ADAPT_FIELD_EXISTS
Definition: remux.h:40
void IncEsInfoLength(int Length)
Definition: remux.c:371
int MakeCRC(uchar *Target, const uchar *Data, int Length)
Definition: remux.c:438
int Vpid(void) const
Returns the video pid as defined by the current PMT, or 0 if no video pid has been detected...
Definition: remux.h:390
int numFrames
Definition: remux.h:486
void BlockDump(const char *Name, const u_char *Data, int Length)
Definition: remux.c:1000
void SetChannel(const cChannel *Channel)
Sets the Channel for which the PAT/PMT shall be generated.
Definition: remux.c:572
void TsSetDts(uchar *p, int l, int64_t Dts)
Definition: remux.c:187
bool AtPayloadStart(void)
Returns true if this payload handler is currently pointing to the first byte of a TS packet that star...
Definition: remux.h:240
bool PesHasPts(const uchar *p)
Definition: remux.h:171
cPatPmtGenerator(const cChannel *Channel=NULL)
Definition: remux.c:348
uchar SetEof(void)
Definition: remux.c:246
int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId)
Definition: remux.c:402
int length
Definition: remux.h:423
void Setup(uchar *Data, int Length, int Pid=-1)
Sets up this TS payload handler with the given Data, which points to a sequence of Length bytes of co...
Definition: remux.c:259
bool isVideo
Definition: remux.h:488
int pmtVersion
Definition: remux.h:346
int numPtsValues
Definition: remux.h:485
bool independentFrame
Definition: remux.h:483
int lastLength
Definition: remux.h:426
int MakeAC3Descriptor(uchar *Target, uchar Type)
Definition: remux.c:392
void GeneratePat(void)
Generates a PAT section for later use with GetPat().
Definition: remux.c:468
bool Find(uint32_t Code)
Searches for the four byte sequence given in Code and returns true if it was found within the payload...
Definition: remux.c:321
int SectionLength(const uchar *Data, int Length)
Definition: remux.h:364
int Available(void)
Returns the number of raw bytes (including any TS headers) still available in the TS payload handler...
Definition: remux.h:243
int MakeStream(uchar *Target, uchar Type, int Pid)
Definition: remux.c:380
int patCounter
Definition: remux.h:291
bool Eof(void) const
Returns true if all available bytes of the TS payload have been processed.
Definition: remux.h:250
uchar pmt[MAX_PMT_TS][TS_SIZE]
Definition: remux.h:289
uchar * lastData
Definition: remux.h:425
bool Synced(void)
Returns true if the frame detector has synced on the data stream.
Definition: remux.h:508
bool PesLongEnough(int Length)
Definition: remux.h:151
int64_t TsGetPts(const uchar *p, int l)
Definition: remux.c:147
#define MAX_SECTION_SIZE
Definition: remux.h:283
int TsPid(const uchar *p)
Definition: remux.h:80
const char * Slang(int i) const
Definition: remux.h:409
cFrameDetector(int Pid=0, int Type=0)
Sets up a frame detector for the given Pid and stream Type.
Definition: remux.c:1402
double framesPerSecond
Definition: remux.h:489
#define TS_PAYLOAD_EXISTS
Definition: remux.h:41
int PesLength(const uchar *p)
Definition: remux.h:161
void TsSetPcr(uchar *p, int64_t Pcr)
Definition: remux.c:131
void PesDump(const char *Name, const u_char *Data, int Length)
Definition: remux.c:1026
Definition: remux.h:20
int Vtype(void) const
Returns the video stream type as defined by the current PMT, or 0 if no video stream type has been de...
Definition: remux.h:396
int ppid
Definition: remux.h:349
int TsContinuityCounter(const uchar *p)
Definition: remux.h:116
const int * Spids(void) const
Definition: remux.h:401
char dlangs[MAXDPIDS][MAXLANGCODE2]
Definition: remux.h:356
void Reset(void)
Resets the converter.
Definition: remux.c:990
bool synced
Definition: remux.h:481
uchar TsGetContinuityCounter(const uchar *p)
Definition: remux.h:90
bool PesHasDts(const uchar *p)
Definition: remux.h:176
void TsDump(const char *Name, const u_char *Data, int Length)
Definition: remux.c:1011
cPatPmtParser(bool UpdatePrimaryDevice=false)
Definition: remux.c:598
int GetLastIndex(void)
Returns the index into the TS data of the payload byte that has most recently been read...
Definition: remux.c:310
cTsPayload(void)
Definition: remux.c:233
int dtypes[MAXDPIDS+1]
Definition: remux.h:355
int dpids[MAXDPIDS+1]
Definition: remux.h:354
void PesSetDts(uchar *p, int64_t Dts)
Definition: remux.c:212
const int * Dpids(void) const
Definition: remux.h:400
void PutTs(const uchar *Data, int Length)
Puts the payload data of the single TS packet at Data into the converter.
Definition: remux.c:908
int Apid(int i) const
Definition: remux.h:402
int atypes[MAXAPIDS+1]
Definition: remux.h:352
uchar * GetPmt(int &Index)
Returns a pointer to the Index'th TS packet of the PMT section.
Definition: remux.c:587
void TsSetContinuityCounter(uchar *p, uchar Counter)
Definition: remux.h:95
int numPmtPackets
Definition: remux.h:290
int Dpid(int i) const
Definition: remux.h:403
~cTsToPes()
Definition: remux.c:903
int TsGetPayload(const uchar **p)
Definition: remux.h:106
int pmtCounter
Definition: remux.h:292
void GeneratePmt(const cChannel *Channel)
Generates a PMT section for the given Channel, for later use with GetPmt().
Definition: remux.c:497
uchar pmt[MAX_SECTION_SIZE]
Definition: remux.h:343
Definition: remux.h:25
int Dtype(int i) const
Definition: remux.h:406
int length
Definition: remux.h:217
#define TS_CONT_CNT_MASK
Definition: remux.h:42
uint16_t compositionPageIds[MAXSPIDS]
Definition: remux.h:360
void PesSetPts(uchar *p, int64_t Pts)
Definition: remux.c:203
#define MAXLANGCODE2
Definition: channels.h:40
int pmtPids[MAX_PMT_PIDS+1]
Definition: remux.h:347
const int * Apids(void) const
Definition: remux.h:399
static void SetBrokenLink(uchar *Data, int Length)
Definition: remux.c:102
void Statistics(void) const
May be called after a new frame has been detected, and will log a warning if the number of TS packets...
Definition: remux.c:338
int64_t TsGetPcr(const uchar *p)
Definition: remux.h:121
int patVersion
Definition: remux.h:293
cFrameParser * parser
Definition: remux.h:494
void TsSetPts(uchar *p, int l, int64_t Pts)
Definition: remux.c:173
int numPacketsOther
Definition: remux.h:221
#define MAXDPIDS
Definition: channels.h:35
int spids[MAXSPIDS+1]
Definition: remux.h:357
#define MAX_PMT_TS
Definition: remux.h:284
int size
Definition: remux.h:422
#define PCRFACTOR
Definition: remux.h:56
#define MAX_PMT_PIDS
Definition: remux.h:339
bool PesHasLength(const uchar *p)
Definition: remux.h:156
uint16_t CompositionPageId(int i) const
Definition: remux.h:411
bool NewFrame(void)
Returns true if the data given to the last call to Analyze() started a new frame. ...
Definition: remux.h:510
bool IndependentFrame(void)
Returns true if a new frame was detected and this is an independent frame (i.e.
Definition: remux.h:513
unsigned char u_char
Definition: headers.h:24
bool TsIsScrambled(const uchar *p)
Definition: remux.h:85
bool GetVersions(int &PatVersion, int &PmtVersion) const
Returns true if a valid PAT/PMT has been parsed and stores the current version numbers in the given v...
Definition: remux.c:887
int64_t PesGetDts(const uchar *p)
Definition: remux.h:190
ePesHeader
Definition: remux.h:16
void SetByte(uchar Byte, int Index)
Sets the TS data byte at the given Index to the value Byte.
Definition: remux.c:315
uchar * esInfoLength
Definition: remux.h:296
const char * Dlang(int i) const
Definition: remux.h:408
#define TS_PAYLOAD_START
Definition: remux.h:36
bool updatePrimaryDevice
Definition: remux.h:362
void Reset(void)
Definition: remux.c:252
double FramesPerSecond(void)
Returns the number of frames per second, or 0 if this information is not available.
Definition: remux.h:517
#define MAXSPIDS
Definition: channels.h:36
bool newFrame
Definition: remux.h:482
#define TS_SIZE
Definition: remux.h:34
Definition: remux.h:19
void IncVersion(int &Version)
Definition: remux.c:365
const uchar * GetPes(int &Length)
Gets a pointer to the complete PES packet, or NULL if the packet is not complete yet.
Definition: remux.c:937
uint16_t AncillaryPageId(int i) const
Definition: remux.h:412
int TsPayloadOffset(const uchar *p)
Definition: remux.h:100
bool scanning
Definition: remux.h:493
int offset
Definition: remux.h:424
#define TS_ADAPT_PCR
Definition: remux.h:46
int numIFrames
Definition: remux.h:487
void SetRepeatLast(void)
Makes the next call to GetPes() return exactly the same data as the last one (provided there was no c...
Definition: remux.c:985
int Ppid(void) const
Returns the PCR pid as defined by the current PMT, or 0 if no PCR pid has been detected, yet.
Definition: remux.h:393
bool AtTsStart(void)
Returns true if this payload handler is currently pointing to first byte of a TS packet.
Definition: remux.h:237
#define TS_PID_MASK_HI
Definition: remux.h:38
int Atype(int i) const
Definition: remux.h:405
int64_t PtsDiff(int64_t Pts1, int64_t Pts2)
Returns the difference between two PTS values.
Definition: remux.c:221
void Reset(void)
Resets the parser.
Definition: remux.c:604
uchar * data
Definition: remux.h:421
ePesHeader AnalyzePesHeader(const uchar *Data, int Count, int &PesPayloadOffset, bool *ContinuationHeader=NULL)
Definition: remux.c:32
uchar * GetPat(void)
Returns a pointer to the PAT section, which consists of exactly one TS packet.
Definition: remux.c:581
int patVersion
Definition: remux.h:345
int vtype
Definition: remux.h:350
int pmtVersion
Definition: remux.h:294
bool SkipPesHeader(void)
Skips all bytes belonging to the PES header of the payload.
Definition: remux.c:305
cTsToPes(void)
Definition: remux.c:896
int apids[MAXAPIDS+1]
Definition: remux.h:351
#define MAXAPIDS
Definition: channels.h:34