RDK Documentation (Open Sourced RDK Components)
tsprocessor.cpp File Reference

Source file for player context. More...

#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <sys/time.h>
#include "priv_aamp.h"
#include "StreamAbstractionAAMP.h"
#include "tsprocessor.h"
#include "AampUtils.h"
Include dependency graph for tsprocessor.cpp:

Go to the source code of this file.

Data Structures

class  Demuxer
 Software demuxer of MPEGTS. More...
 
struct  MBAddrIncCode
 holds macro block address increment codes More...
 

Macros

#define TRACE1   print_nop
 
#define TRACE2   print_nop
 
#define TRACE3   print_nop
 
#define TRACE4   print_nop
 
#define DEBUG   print_nop
 
#define INFO   print_nop
 
#define LOG_WARNINGS_AND_ERRORS
 
#define NOTICE(FORMAT, ...)   AAMPLOG(mLogObj, eLOGLEVEL_INFO, "INFO", FORMAT, ##__VA_ARGS__)
 
#define WARNING(FORMAT, ...)   AAMPLOG(mLogObj, eLOGLEVEL_WARN, "WARN", FORMAT, ##__VA_ARGS__)
 
#define ERROR(FORMAT, ...)   AAMPLOG(mLogObj, eLOGLEVEL_ERROR, "ERROR", FORMAT, ##__VA_ARGS__)
 
#define DUMP_PACKET   0
 
#define PACKET_SIZE   (188)
 
#define MAX_PACKET_SIZE   (208)
 
#define FIXED_FRAME_RATE   (10)
 
#define FRAME_WIDTH_MAX   (1920)
 
#define FRAME_HEIGHT_MAX   (1080)
 
#define WAIT_FOR_DATA_MILLISEC   100
 
#define WAIT_FOR_DATA_MAX_RETRIES   1
 
#define MAX_PMT_SECTION_SIZE   (1021)
 
#define PATPMT_MAX_SIZE   (2*1024)
 
#define PAT_SPTS_SIZE   (13)
 
#define PAT_TABLE_ENTRY_SIZE   (4)
 
#define MAX_PTS   (uint33_t::max_value().value)
 
#define MAX_DESCRIPTOR   (4)
 
#define I_FRAME   (0x1)
 
#define P_FRAME   (0x2)
 
#define B_FRAME   (0x4)
 
#define ALL_FRAMES   (0x7)
 
#define SEQ_START   (0x10)
 
#define IDX_BUFF_SIZE   (128*1024)
 
#define DEFAULT_THROTTLE_MAX_DELAY_MS   500
 
#define DEFAULT_THROTTLE_MAX_DIFF_SEGMENTS_MS   400
 
#define DEFAULT_THROTTLE_DELAY_IGNORED_MS   200
 
#define DEFAULT_THROTTLE_DELAY_FOR_DISCONTINUITY_MS   2000
 
#define PES_STATE_WAITING_FOR_HEADER   0
 
#define PES_STATE_GETTING_HEADER   1
 
#define PES_STATE_GETTING_HEADER_EXTENSION   2
 
#define PES_STATE_GETTING_ES   3
 
#define PAYLOAD_UNIT_START(packetStart)   ( packetStart[1] & 0x40)
 
#define CONTAINS_PAYLOAD(packetStart)   ( packetStart[3] & 0x10)
 
#define IS_PES_PACKET_START(a)   ( (a[0] == 0 )&& (a[1] == 0 ) &&(a[2] == 1 ))
 
#define PES_OPTIONAL_HEADER_PRESENT(pesStart)   ( ( pesStart[6] & 0xC0) == 0x80 )
 
#define PES_HEADER_LENGTH   6
 
#define PES_OPTIONAL_HEADER_LENGTH(pesStart)   (pesStart[PES_HEADER_LENGTH+2])
 
#define PES_MIN_DATA   (PES_HEADER_LENGTH+3)
 
#define ADAPTATION_FIELD_PRESENT(mpegbuf)   ((mpegbuf[3] & 0x20) == 0x20)
 
#define PES_PAYLOAD_LENGTH(pesStart)   (pesStart[4]<<8|pesStart[5])
 
#define MAX_FIRST_PTS_OFFSET   (uint33_t{45000}) /*500 ms*/
 
#define DESCRIPTOR_TAG_SUBTITLE   0x59
 
#define DESCRIPTOR_TAG_AC3   0x6A
 
#define DESCRIPTOR_TAG_EAC3   0x7A
 
#define DEBUG_DEMUX   DEBUG
 
#define rmf_osal_memcpy(d, s, n, dc, sc)   memcpy(d, s, n)
 
#define BUFFER_POOL_SIZE   (10)
 
#define PLAY_BUFFER_AUDIO_MAX_PACKETS   (100)
 
#define PLAY_BUFFER_MAX_PACKETS   (512)
 
#define PLAY_BUFFER_SIZE   (PLAY_BUFFER_MAX_PACKETS*MAX_PACKET_SIZE)
 
#define POOL_BUFFER_ALIGNMENT   (16)
 
#define PLAY_BUFFER_CTX_OFFSET   (0)
 
#define PLAY_BUFFER_SIGNATURE   (('P')|(('L')<<8)|(('A')<<16)|(('Y')<<24))
 
#define MICROSECONDS_PER_SECOND   1000000L
 
#define HEADER_SIZE   4
 
#define INDEX(i)   (base+i < m_packetSize-m_ttsSize-HEADER_SIZE) ? i : i+m_ttsSize+HEADER_SIZE
 
#define FLUSH_SLICE_BITS()
 
#define FLUSH_ALL_SLICE_BITS()
 

Enumerations

enum  StreamType
 Types of streams. More...
 

Functions

void print_nop (const char *format,...)
 NOP function used to controll logging. More...
 
void tsdemuxer_InduceRollover (bool enable)
 
static uint33_t Extract33BitTimestamp (const unsigned char *ptr)
 extract 33 bit timestamp from ts packet header More...
 
template<class T , class U = T>
exchange (T &obj, U &&new_value)
 std::exchange for pre-c++14 compiler More...
 
static void init_crc32 ()
 Init CRC32 table.
 
static uint32_t get_crc32 (unsigned char *data, int size, uint32_t initial=0xffffffff)
 Get 32 bit CRC value. More...
 
static void dumpPacket (unsigned char *packet, int packetSize)
 Dump TS packet. More...
 
static void dumpPackets (unsigned char *packets, int len, int packetSize)
 dump TS packets More...
 
static StreamOutputFormat getStreamFormatForCodecType (int streamType)
 Get the format for a stream type. More...
 

Variables

static unsigned long long mTimeAdjust
 
static bool mbInduceRollover
 
static unsigned long crc32_table [256]
 
static int crc32_initialized = 0
 
static MBAddrIncCode macroblockAddressIncrementCodes [34]
 
static unsigned char nullPFrameHeader []
 

yes

Source file for player context.

Definition in file tsprocessor.cpp.


Data Structure Documentation

◆ MBAddrIncCode

struct MBAddrIncCode

holds macro block address increment codes

Definition at line 4002 of file tsprocessor.cpp.

Collaboration diagram for MBAddrIncCode:
Collaboration graph
Data Fields
int numBits
int code

Macro Definition Documentation

◆ MAX_PTS

#define MAX_PTS   (uint33_t::max_value().value)

Maximum PTS value

Definition at line 97 of file tsprocessor.cpp.

◆ MAX_DESCRIPTOR

#define MAX_DESCRIPTOR   (4)

Maximum descriptor present for a elementary stream

Definition at line 100 of file tsprocessor.cpp.

◆ FLUSH_SLICE_BITS

#define FLUSH_SLICE_BITS ( )
Value:
while ( bitcount > 8 ) \
{ \
slice[i]= (((accum<<(32-bitcount))>>24)&0xFF); \
++i; \
bitcount -= 8; \
}

Definition at line 4056 of file tsprocessor.cpp.

◆ FLUSH_ALL_SLICE_BITS

#define FLUSH_ALL_SLICE_BITS ( )
Value:
while ( bitcount > 0 ) \
{ \
slice[i]= (((accum<<(32-bitcount))>>24)&0xFF); \
++i; \
bitcount -= 8; \
}

Definition at line 4063 of file tsprocessor.cpp.

Enumeration Type Documentation

◆ StreamType

enum StreamType

Types of streams.

Enumerator
eSTREAM_TYPE_MPEG2_VIDEO 

MPEG2 Video

eSTREAM_TYPE_MPEG1_AUDIO 

MPEG1 Audio

eSTREAM_TYPE_MPEG2_AUDIO 

MPEG2 Audio

eSTREAM_TYPE_PES_PRIVATE 

PES packets containing private data

eSTREAM_TYPE_AAC_ADTS 

MPEG2 AAC Audio

eSTREAM_TYPE_AAC_LATM 

MPEG4 LATM AAC Audio

eSTREAM_TYPE_DSM_CC 

ISO/IEC13818-6 DSM CC deferred association tag with ID3 metadata

eSTREAM_TYPE_H264 

H.264 Video

eSTREAM_TYPE_HEVC_VIDEO 

HEVC video

eSTREAM_TYPE_ATSC_VIDEO 

ATSC Video

eSTREAM_TYPE_ATSC_AC3 

ATSC AC3 Audio

eSTREAM_TYPE_HDMV_DTS 

HDMV DTS Audio

eSTREAM_TYPE_LPCM_AUDIO 

LPCM Audio

eSTREAM_TYPE_ATSC_AC3PLUS 

SDDS Audio

eSTREAM_TYPE_DTSHD_AUDIO 

DTS-HD Audio

eSTREAM_TYPE_ATSC_EAC3 

ATSC E-AC3 Audio

eSTREAM_TYPE_DTS_AUDIO 

DTS Audio

eSTREAM_TYPE_AC3_AUDIO 

A52b/AC3 Audio

eSTREAM_TYPE_SDDS_AUDIO1 

SDDS Audio

Definition at line 156 of file tsprocessor.cpp.

Function Documentation

◆ print_nop()

void print_nop ( const char *  format,
  ... 
)

NOP function used to controll logging.

Parameters
[in]formatprintf style format string

Definition at line 44 of file tsprocessor.cpp.

◆ Extract33BitTimestamp()

static uint33_t Extract33BitTimestamp ( const unsigned char *  ptr)
static

extract 33 bit timestamp from ts packet header

Parameters
ptrpointer to first of five bytes encoding a 33 bit PTS timestamp
Returns
33 bit unsigned integer (which fits in long long)

Definition at line 192 of file tsprocessor.cpp.

◆ exchange()

template<class T , class U = T>
T exchange ( T &  obj,
U &&  new_value 
)

std::exchange for pre-c++14 compiler

Parameters
obj- object whose value to replace
new_value- the value to assign to obj
Returns
The old value of obj

Definition at line 219 of file tsprocessor.cpp.

◆ get_crc32()

static uint32_t get_crc32 ( unsigned char *  data,
int  size,
uint32_t  initial = 0xffffffff 
)
static

Get 32 bit CRC value.

Parameters
[in]databuffer containing data
[in]sizelength of data
[in]initialinitial CRC
Return values
32bit CRC value

Definition at line 738 of file tsprocessor.cpp.

◆ dumpPacket()

static void dumpPacket ( unsigned char *  packet,
int  packetSize 
)
static

Dump TS packet.

Parameters
[in]packetbuffer containing packet
[in]packetSizelength of packet

Definition at line 756 of file tsprocessor.cpp.

◆ dumpPackets()

static void dumpPackets ( unsigned char *  packets,
int  len,
int  packetSize 
)
static

dump TS packets

Parameters
[in]packetsbuffer containing packets
[in]lenlength of packets
[in]packetSizesize of TS packet

Definition at line 792 of file tsprocessor.cpp.

◆ getStreamFormatForCodecType()

static StreamOutputFormat getStreamFormatForCodecType ( int  streamType)
static

Get the format for a stream type.

Parameters
[in]streamTypestream type
Returns
StreamOutputFormat format for input stream type

Definition at line 807 of file tsprocessor.cpp.

Variable Documentation

◆ nullPFrameHeader

unsigned char nullPFrameHeader[]
static
Initial value:
=
{
0x47, 0x40, 0x00, 0x10, 0x00, 0x00, 0x01, 0xE0,
0x00, 0x00, 0x84, 0xC0, 0x0A, 0x31, 0x00, 0x01,
0x00, 0x01, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x01, 0x00, 0x01, 0xD7, 0xFF, 0xFB, 0x80,
0x00, 0x00, 0x01, 0xB5, 0x83, 0x3F, 0xF3, 0x5D,
0x80
}

Definition at line 4046 of file tsprocessor.cpp.