vdr 2.8.3
remux.h File Reference
#include "channels.h"
#include "tools.h"

Go to the source code of this file.

Classes

class  cRemux
class  cTsPayload
class  cPatPmtGenerator
class  cPatPmtParser
class  cEitGenerator
class  cTsToPes
class  cFrameChecker
class  cFrameDetector

Macros

#define TS_SYNC_BYTE   0x47
#define TS_SIZE   188
#define TS_ERROR   0x80
#define TS_PAYLOAD_START   0x40
#define TS_TRANSPORT_PRIORITY   0x20
#define TS_PID_MASK_HI   0x1F
#define TS_SCRAMBLING_CONTROL   0xC0
#define TS_ADAPT_FIELD_EXISTS   0x20
#define TS_PAYLOAD_EXISTS   0x10
#define TS_CONT_CNT_MASK   0x0F
#define TS_ADAPT_DISCONT   0x80
#define TS_ADAPT_RANDOM_ACC   0x40
#define TS_ADAPT_ELEM_PRIO   0x20
#define TS_ADAPT_PCR   0x10
#define TS_ADAPT_OPCR   0x08
#define TS_ADAPT_SPLICING   0x04
#define TS_ADAPT_TP_PRIVATE   0x02
#define TS_ADAPT_EXTENSION   0x01
#define PATPID   0x0000
#define CATPID   0x0001
#define EITPID   0x0012
#define MAXPID   0x2000
#define PTSTICKS   90000
#define PCRFACTOR   300
#define MAX33BIT   0x00000001FFFFFFFFLL
#define MAX27MHZ   ((MAX33BIT + 1) * PCRFACTOR - 1)
#define TS_SYNC(Data, Length)
#define MAX_SECTION_SIZE   4096
#define MAX_PMT_TS   (MAX_SECTION_SIZE / TS_SIZE + 1)
#define MAX_PMT_PIDS   32
#define MIN_TS_PACKETS_FOR_FRAME_DETECTOR   100

Enumerations

enum  ePesHeader { phNeedMoreData = -1 , phInvalid = 0 , phMPEG1 = 1 , phMPEG2 = 2 }
enum  eScanType { stUnknown = 0 , stProgressive = 1 , stInterlaced = 2 , stMax }
enum  eAspectRatio {
  arUnknown = 0 , ar_1_1 = 1 , ar_4_3 = 2 , ar_16_9 = 3 ,
  ar_2_21_1 = 4 , arMax
}

Functions

ePesHeader AnalyzePesHeader (const uchar *Data, int Count, int &PesPayloadOffset, bool *ContinuationHeader=NULL)
bool TsHasPayload (const uchar *p)
bool TsHasAdaptationField (const uchar *p)
bool TsPayloadStart (const uchar *p)
bool TsError (const uchar *p)
int TsPid (const uchar *p)
void TsSetPid (uchar *p, int Pid)
bool TsIsScrambled (const uchar *p)
uchar TsContinuityCounter (const uchar *p)
void TsSetContinuityCounter (uchar *p, uchar Counter)
int TsPayloadOffset (const uchar *p)
int TsGetPayload (const uchar **p)
int64_t TsGetPcr (const uchar *p)
void TsHidePayload (uchar *p)
void TsSetPcr (uchar *p, int64_t Pcr)
int TsSync (const uchar *Data, int Length, const char *File=NULL, const char *Function=NULL, int Line=0)
int64_t TsGetPts (const uchar *p, int l, int Pid=-1)
int64_t TsGetDts (const uchar *p, int l)
void TsSetPts (uchar *p, int l, int64_t Pts)
void TsSetDts (uchar *p, int l, int64_t Dts)
bool PesLongEnough (int Length)
bool PesHasLength (const uchar *p)
int PesLength (const uchar *p)
int PesPayloadOffset (const uchar *p)
bool PesHasPts (const uchar *p)
bool PesHasDts (const uchar *p)
int64_t PesGetPts (const uchar *p)
int64_t PesGetDts (const uchar *p)
void PesSetPts (uchar *p, int64_t Pts)
void PesSetDts (uchar *p, int64_t Dts)
int64_t PtsAdd (int64_t Pts1, int64_t Pts2)
int64_t PtsDiff (int64_t Pts1, int64_t Pts2)
void BlockDump (const char *Name, const u_char *Data, int Length)
void TsDump (const char *Name, const u_char *Data, int Length)
void PesDump (const char *Name, const u_char *Data, int Length)

Variables

const char * ScanTypeChars
const char * AspectRatioTexts []

Macro Definition Documentation

◆ CATPID

#define CATPID   0x0001

Definition at line 53 of file remux.h.

Referenced by cCaPidReceiver::cCaPidReceiver(), and cCaPidReceiver::Receive().

◆ EITPID

#define EITPID   0x0012

Definition at line 54 of file remux.h.

Referenced by cEitGenerator::Generate(), and cDvbDevice::OpenFilter().

◆ MAX27MHZ

#define MAX27MHZ   ((MAX33BIT + 1) * PCRFACTOR - 1)

Definition at line 60 of file remux.h.

Referenced by cCuttingThread::FixFrame().

◆ MAX33BIT

#define MAX33BIT   0x00000001FFFFFFFFLL

Definition at line 59 of file remux.h.

Referenced by cCuttingThread::FixFrame(), PtsAdd(), and PtsDiff().

◆ MAX_PMT_PIDS

#define MAX_PMT_PIDS   32

Definition at line 355 of file remux.h.

Referenced by cPatPmtParser::ParsePat().

◆ MAX_PMT_TS

#define MAX_PMT_TS   (MAX_SECTION_SIZE / TS_SIZE + 1)

Definition at line 296 of file remux.h.

◆ MAX_SECTION_SIZE

#define MAX_SECTION_SIZE   4096

Definition at line 295 of file remux.h.

Referenced by cDvbDevice::OpenFilter(), and cPatPmtGenerator::SetPids().

◆ MAXPID

#define MAXPID   0x2000

Definition at line 55 of file remux.h.

Referenced by cPatPmtGenerator::GeneratePmtPid().

◆ MIN_TS_PACKETS_FOR_FRAME_DETECTOR

#define MIN_TS_PACKETS_FOR_FRAME_DETECTOR   100

◆ PATPID

◆ PCRFACTOR

#define PCRFACTOR   300

Definition at line 58 of file remux.h.

Referenced by cCuttingThread::FixFrame(), TsGetPcr(), and TsSetPcr().

◆ PTSTICKS

#define PTSTICKS   90000

Definition at line 57 of file remux.h.

Referenced by cFrameDetector::Analyze(), and cCuttingThread::cCuttingThread().

◆ TS_ADAPT_DISCONT

#define TS_ADAPT_DISCONT   0x80

Definition at line 43 of file remux.h.

◆ TS_ADAPT_ELEM_PRIO

#define TS_ADAPT_ELEM_PRIO   0x20

Definition at line 45 of file remux.h.

◆ TS_ADAPT_EXTENSION

#define TS_ADAPT_EXTENSION   0x01

Definition at line 50 of file remux.h.

◆ TS_ADAPT_FIELD_EXISTS

#define TS_ADAPT_FIELD_EXISTS   0x20

Definition at line 40 of file remux.h.

Referenced by TsHasAdaptationField(), and TsHidePayload().

◆ TS_ADAPT_OPCR

#define TS_ADAPT_OPCR   0x08

Definition at line 47 of file remux.h.

◆ TS_ADAPT_PCR

#define TS_ADAPT_PCR   0x10

Definition at line 46 of file remux.h.

Referenced by TsGetPcr(), and TsSetPcr().

◆ TS_ADAPT_RANDOM_ACC

#define TS_ADAPT_RANDOM_ACC   0x40

Definition at line 44 of file remux.h.

◆ TS_ADAPT_SPLICING

#define TS_ADAPT_SPLICING   0x04

Definition at line 48 of file remux.h.

◆ TS_ADAPT_TP_PRIVATE

#define TS_ADAPT_TP_PRIVATE   0x02

Definition at line 49 of file remux.h.

◆ TS_CONT_CNT_MASK

#define TS_CONT_CNT_MASK   0x0F

◆ TS_ERROR

#define TS_ERROR   0x80

Definition at line 35 of file remux.h.

Referenced by TsError().

◆ TS_PAYLOAD_EXISTS

#define TS_PAYLOAD_EXISTS   0x10

Definition at line 41 of file remux.h.

Referenced by TsHasPayload(), and TsHidePayload().

◆ TS_PAYLOAD_START

◆ TS_PID_MASK_HI

#define TS_PID_MASK_HI   0x1F

Definition at line 38 of file remux.h.

Referenced by TsPid(), and TsSetPid().

◆ TS_SCRAMBLING_CONTROL

#define TS_SCRAMBLING_CONTROL   0xC0

Definition at line 39 of file remux.h.

Referenced by TsIsScrambled().

◆ TS_SIZE

◆ TS_SYNC

#define TS_SYNC ( Data,
Length )
Value:
(*Data == TS_SYNC_BYTE ? 0 : TsSync(Data, Length, __FILE__, __FUNCTION__, __LINE__))
int TsSync(const uchar *Data, int Length, const char *File, const char *Function, int Line)
Definition remux.c:147
#define TS_SYNC_BYTE
Definition remux.h:33

Definition at line 149 of file remux.h.

Referenced by cFrameDetector::Analyze(), cMtdCamSlot::Decrypt(), cDevice::PlayTs(), and cMtdHandler::Put().

◆ TS_SYNC_BYTE

◆ TS_TRANSPORT_PRIORITY

#define TS_TRANSPORT_PRIORITY   0x20

Definition at line 37 of file remux.h.

Enumeration Type Documentation

◆ eAspectRatio

Enumerator
arUnknown 
ar_1_1 
ar_4_3 
ar_16_9 
ar_2_21_1 
arMax 

Definition at line 518 of file remux.h.

◆ ePesHeader

enum ePesHeader
Enumerator
phNeedMoreData 
phInvalid 
phMPEG1 
phMPEG2 

Definition at line 16 of file remux.h.

◆ eScanType

enum eScanType
Enumerator
stUnknown 
stProgressive 
stInterlaced 
stMax 

Definition at line 511 of file remux.h.

Function Documentation

◆ AnalyzePesHeader()

ePesHeader AnalyzePesHeader ( const uchar * Data,
int Count,
int & PesPayloadOffset,
bool * ContinuationHeader = NULL )

◆ BlockDump()

void BlockDump ( const char * Name,
const u_char * Data,
int Length )

Definition at line 1159 of file remux.c.

References BlockDump().

Referenced by BlockDump().

◆ PesDump()

void PesDump ( const char * Name,
const u_char * Data,
int Length )

Definition at line 1185 of file remux.c.

References PesDump(), and TsDump().

Referenced by PesDump().

◆ PesGetDts()

int64_t PesGetDts ( const uchar * p)
inline

Definition at line 202 of file remux.h.

References PesGetDts().

Referenced by PesGetDts(), and TsGetDts().

◆ PesGetPts()

◆ PesHasDts()

bool PesHasDts ( const uchar * p)
inline

Definition at line 188 of file remux.h.

References PesHasDts().

Referenced by PesHasDts(), TsGetDts(), and TsSetDts().

◆ PesHasLength()

bool PesHasLength ( const uchar * p)
inline

Definition at line 168 of file remux.h.

References PesHasLength().

Referenced by cTsToPes::GetPes(), and PesHasLength().

◆ PesHasPts()

◆ PesLength()

int PesLength ( const uchar * p)
inline

Definition at line 173 of file remux.h.

References PesLength().

Referenced by cPes2TsConverter::ConvertPesFrame(), cTsToPes::GetPes(), PesLength(), and cDevice::PlayPes().

◆ PesLongEnough()

bool PesLongEnough ( int Length)
inline

Definition at line 163 of file remux.h.

References PesLongEnough().

Referenced by cTsToPes::GetPes(), PesLongEnough(), and cPesSubtitleAssembler::Put().

◆ PesPayloadOffset()

◆ PesSetDts()

void PesSetDts ( uchar * p,
int64_t Dts )

Definition at line 227 of file remux.c.

References PesSetDts().

Referenced by PesSetDts(), and TsSetDts().

◆ PesSetPts()

void PesSetPts ( uchar * p,
int64_t Pts )

Definition at line 218 of file remux.c.

References PesSetPts().

Referenced by PesSetPts(), and TsSetPts().

◆ PtsAdd()

int64_t PtsAdd ( int64_t Pts1,
int64_t Pts2 )
inline

Adds the given PTS values, taking into account the 33bit wrap around.

Definition at line 216 of file remux.h.

References MAX33BIT, and PtsAdd().

Referenced by cPtsChecker::AddPts(), cCuttingThread::FixFrame(), and PtsAdd().

◆ PtsDiff()

int64_t PtsDiff ( int64_t Pts1,
int64_t Pts2 )

Returns the difference between two PTS values.

The result of Pts2 - Pts1 is the actual number of 90kHz time ticks that pass from Pts1 to Pts2, properly taking into account the 33bit wrap around. If Pts2 is "before" Pts1, the result is negative.

Definition at line 236 of file remux.c.

References MAX33BIT, and PtsDiff().

Referenced by cDvbPlayer::Action(), ComparePts(), cCuttingThread::FixFrame(), cRecorder::GetLastPts(), cCuttingThread::GetPendingPackets(), cPtsChecker::Process(), and PtsDiff().

◆ TsContinuityCounter()

uchar TsContinuityCounter ( const uchar * p)
inline

◆ TsDump()

void TsDump ( const char * Name,
const u_char * Data,
int Length )

Definition at line 1170 of file remux.c.

References max(), min(), and TsDump().

Referenced by PesDump(), and TsDump().

◆ TsError()

bool TsError ( const uchar * p)
inline

Definition at line 77 of file remux.h.

References TS_ERROR, and TsError().

Referenced by cTsChecker::CheckTs(), cTsPayload::GetByte(), cTsToPes::PutTs(), and TsError().

◆ TsGetDts()

int64_t TsGetDts ( const uchar * p,
int l )

Definition at line 175 of file remux.c.

References PesGetDts(), PesHasDts(), TS_SIZE, TsGetDts(), TsGetPayload(), and TsPayloadStart().

Referenced by cCuttingThread::FixFrame(), and TsGetDts().

◆ TsGetPayload()

int TsGetPayload ( const uchar ** p)
inline

◆ TsGetPcr()

int64_t TsGetPcr ( const uchar * p)
inline

Definition at line 124 of file remux.h.

References PCRFACTOR, TS_ADAPT_PCR, TsGetPcr(), and TsHasAdaptationField().

Referenced by cCuttingThread::FixFrame(), and TsGetPcr().

◆ TsGetPts()

◆ TsHasAdaptationField()

bool TsHasAdaptationField ( const uchar * p)
inline

Definition at line 67 of file remux.h.

References TS_ADAPT_FIELD_EXISTS, and TsHasAdaptationField().

Referenced by TsGetPcr(), TsHasAdaptationField(), TsPayloadOffset(), and TsSetPcr().

◆ TsHasPayload()

◆ TsHidePayload()

void TsHidePayload ( uchar * p)

◆ TsIsScrambled()

bool TsIsScrambled ( const uchar * p)
inline

◆ TsPayloadOffset()

◆ TsPayloadStart()

◆ TsPid()

◆ TsSetContinuityCounter()

void TsSetContinuityCounter ( uchar * p,
uchar Counter )
inline

Definition at line 103 of file remux.h.

References TS_CONT_CNT_MASK, and TsSetContinuityCounter().

Referenced by cCuttingThread::FixFrame(), and TsSetContinuityCounter().

◆ TsSetDts()

void TsSetDts ( uchar * p,
int l,
int64_t Dts )

Definition at line 202 of file remux.c.

References PesHasDts(), PesSetDts(), TS_SIZE, TsGetPayload(), TsPayloadStart(), and TsSetDts().

Referenced by cCuttingThread::FixFrame(), and TsSetDts().

◆ TsSetPcr()

void TsSetPcr ( uchar * p,
int64_t Pcr )

Definition at line 131 of file remux.c.

References PCRFACTOR, TS_ADAPT_PCR, TsHasAdaptationField(), and TsSetPcr().

Referenced by cCuttingThread::FixFrame(), and TsSetPcr().

◆ TsSetPid()

void TsSetPid ( uchar * p,
int Pid )
inline

Definition at line 87 of file remux.h.

References TS_PID_MASK_HI, and TsSetPid().

Referenced by cMtdCamSlot::Decrypt(), and TsSetPid().

◆ TsSetPts()

void TsSetPts ( uchar * p,
int l,
int64_t Pts )

Definition at line 188 of file remux.c.

References PesHasPts(), PesSetPts(), TS_SIZE, TsGetPayload(), TsPayloadStart(), and TsSetPts().

Referenced by cCuttingThread::FixFrame(), and TsSetPts().

◆ TsSync()

int TsSync ( const uchar * Data,
int Length,
const char * File = NULL,
const char * Function = NULL,
int Line = 0 )

Definition at line 147 of file remux.c.

References esyslog, TS_SIZE, TS_SYNC_BYTE, and TsSync().

Referenced by TsSync().

Variable Documentation

◆ AspectRatioTexts

◆ ScanTypeChars