mpegts.c File Reference

Go to the source code of this file.

Classes

struct  dvb_caption_info_t
struct  pmt_entry_t
struct  MpegTSPESFilter
struct  MpegTSSectionFilter
struct  MpegTSFilter
struct  MpegTSService
struct  MpegTSContext
struct  PESContext
struct  SectionContext
struct  SectionHeader

Typedefs

typedef struct PESContext PESContext
typedef struct SectionContext SectionContext
typedef void PESCallback (void *opaque, const uint8_t *buf, int len, int is_start, int64_t startpos)
typedef void SectionCallback (void *opaque, const uint8_t *buf, int len)
typedef void SetServiceCallback (void *opaque, int ret)

Enumerations

enum  MpegTSFilterType { MPEGTS_PES, MPEGTS_SECTION }
enum  MpegTSState { MPEGTS_HEADER = 0, MPEGTS_PESHEADER_FILL, MPEGTS_PAYLOAD, MPEGTS_SKIP }

Functions

static PESContextadd_pes_stream (MpegTSContext *ts, int pid, int stream_type)
static AVStreamnew_pes_av_stream (PESContext *pes, uint32_t code)
static AVStreamnew_section_av_stream (SectionContext *sect, uint32_t code)
static SectionContextadd_section_stream (MpegTSContext *ts, int pid, int stream_type)
static void mpegts_cleanup_streams (MpegTSContext *ts)
static int is_desired_stream (int type)
static int find_in_list (const int *pids, int pid)
static int mpegts_parse_desc (dvb_caption_info_t *dvbci, uint8_t **p, uint8_t *p_end, int *stream_type)
static int is_pat_same (MpegTSContext *mpegts_ctx, int *pmt_pnums, int *pmts_pids, uint pmt_count)
static void mpegts_add_stream (MpegTSContext *ts, pmt_entry_t *item)
static int is_pmt_same (MpegTSContext *mpegts_ctx, pmt_entry_t *items, int item_cnt)
static void mpegts_close_filter (MpegTSContext *ts, MpegTSFilter *filter)
static void write_section_data (AVFormatContext *s, MpegTSFilter *tss1, const uint8_t *buf, int buf_size, int is_start)
 Assembles PES packets out of TS packets, and then calls the "section_cb" function when they are complete.
MpegTSFiltermpegts_open_section_filter (MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc)
MpegTSFiltermpegts_open_pes_filter (MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque)
static int analyze (const uint8_t *buf, int size, int packet_size, int *index)
static int get_packet_size (const uint8_t *buf, int size)
static int get8 (const uint8_t **pp, const uint8_t *p_end)
static int get16 (const uint8_t **pp, const uint8_t *p_end)
static char * getstr8 (const uint8_t **pp, const uint8_t *p_end)
static int parse_section_header (SectionHeader *h, const uint8_t **pp, const uint8_t *p_end)
static MpegTSServicenew_service (MpegTSContext *ts, int sid, int pid, char *provider_name, char *name)
static int mpegts_parse_program_info_length (uint8_t **p, uint8_t *p_end)
static int mpegts_parse_pcrpid (MpegTSContext *mpegts_ctx, uint8_t **p, uint8_t *p_end)
static void pmt_cb (void *opaque, const uint8_t *section, int section_len)
void mpegts_remove_stream (MpegTSContext *ts, int pid)
static void pat_cb (void *opaque, const uint8_t *section, int section_len)
static void pat_scan_cb (void *opaque, const uint8_t *section, int section_len)
static void sdt_cb (void *opaque, const uint8_t *section, int section_len)
void mpegts_scan_sdt (MpegTSContext *ts)
void mpegts_scan_pat (MpegTSContext *ts)
static int64_t get_pts (const uint8_t *p)
static void init_stream (AVStream *st, int stream_type, int code)
static void mpegts_push_data (void *opaque, const uint8_t *buf, int buf_size, int is_start, int64_t position)
static void mpegts_push_section (void *opaque, const uint8_t *section, int section_len)
static void handle_packet (MpegTSContext *ts, const uint8_t *packet, int64_t position)
static int mpegts_resync (ByteIOContext *pb)
static int read_packet (ByteIOContext *pb, uint8_t *buf, int raw_packet_size, int64_t *position)
static int handle_packets (MpegTSContext *ts, int nb_packets)
static int mpegts_probe (AVProbeData *p)
static void set_service_cb (void *opaque, int ret)
static int parse_pcr (int64_t *ppcr_high, int *ppcr_low, const uint8_t *packet)
static int mpegts_read_header (AVFormatContext *s, AVFormatParameters *ap)
static int mpegts_raw_read_packet (AVFormatContext *s, AVPacket *pkt)
static int mpegts_read_packet (AVFormatContext *s, AVPacket *pkt)
static int mpegts_read_close (AVFormatContext *s)
static int64_t mpegts_get_pcr (AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
static int read_seek (AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
MpegTSContextmpegts_parse_open (AVFormatContext *s)
int mpegts_parse_packet (MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
void mpegts_parse_close (MpegTSContext *ts)

Variables

pthread_mutex_t avcodeclock
AVInputFormat mpegts_demuxer


Typedef Documentation

typedef struct PESContext PESContext

Definition at line 41 of file mpegts.c.

Definition at line 42 of file mpegts.c.

typedef void PESCallback(void *opaque, const uint8_t *buf, int len, int is_start, int64_t startpos)

Definition at line 89 of file mpegts.c.

typedef void SectionCallback(void *opaque, const uint8_t *buf, int len)

Definition at line 97 of file mpegts.c.

typedef void SetServiceCallback(void *opaque, int ret)

Definition at line 99 of file mpegts.c.


Enumeration Type Documentation

Enumerator:
MPEGTS_PES 
MPEGTS_SECTION 

Definition at line 54 of file mpegts.c.

Enumerator:
MPEGTS_HEADER 
MPEGTS_PESHEADER_FILL 
MPEGTS_PAYLOAD 
MPEGTS_SKIP 

Definition at line 207 of file mpegts.c.


Function Documentation

static PESContext * add_pes_stream ( MpegTSContext ts,
int  pid,
int  stream_type 
) [static]

Definition at line 1628 of file mpegts.c.

Referenced by handle_packet(), and mpegts_add_stream().

static AVStream * new_pes_av_stream ( PESContext pes,
uint32_t  code 
) [static]

Definition at line 1476 of file mpegts.c.

Referenced by mpegts_add_stream(), and mpegts_push_data().

static AVStream * new_section_av_stream ( SectionContext sect,
uint32_t  code 
) [static]

Definition at line 1489 of file mpegts.c.

Referenced by mpegts_add_stream().

static SectionContext * add_section_stream ( MpegTSContext ts,
int  pid,
int  stream_type 
) [static]

Definition at line 1709 of file mpegts.c.

Referenced by mpegts_add_stream().

static void mpegts_cleanup_streams ( MpegTSContext ts  )  [static]

Definition at line 968 of file mpegts.c.

Referenced by pmt_cb().

static int is_desired_stream ( int  type  )  [static]

Definition at line 854 of file mpegts.c.

Referenced by pmt_cb().

static int find_in_list ( const int *  pids,
int  pid 
) [static]

Definition at line 565 of file mpegts.c.

Referenced by is_pmt_same(), and mpegts_remove_stream().

static int mpegts_parse_desc ( dvb_caption_info_t dvbci,
uint8_t **  p,
uint8_t *  p_end,
int *  stream_type 
) [static]

Definition at line 882 of file mpegts.c.

Referenced by pmt_cb().

static int is_pat_same ( MpegTSContext mpegts_ctx,
int *  pmt_pnums,
int *  pmts_pids,
uint  pmt_count 
) [static]

Definition at line 741 of file mpegts.c.

Referenced by pat_cb().

static void mpegts_add_stream ( MpegTSContext ts,
pmt_entry_t item 
) [static]

Definition at line 988 of file mpegts.c.

Referenced by pmt_cb().

static int is_pmt_same ( MpegTSContext mpegts_ctx,
pmt_entry_t items,
int  item_cnt 
) [static]

Definition at line 757 of file mpegts.c.

Referenced by pmt_cb().

void mpegts_close_filter ( MpegTSContext ts,
MpegTSFilter filter 
) [static]

write_section_data ( AVFormatContext s,
MpegTSFilter tss1,
const uint8_t *  buf,
int  buf_size,
int  is_start 
) [static]

Assembles PES packets out of TS packets, and then calls the "section_cb" function when they are complete.

NOTE: "DVB Section" is DVB terminology for an MPEG PES packet.

Definition at line 253 of file mpegts.c.

Referenced by handle_packet().

MpegTSFilter* mpegts_open_section_filter ( MpegTSContext ts,
unsigned int  pid,
SectionCallback section_cb,
void *  opaque,
int  check_crc 
)

MpegTSFilter* mpegts_open_pes_filter ( MpegTSContext ts,
unsigned int  pid,
PESCallback pes_cb,
void *  opaque 
)

Definition at line 341 of file mpegts.c.

Referenced by add_pes_stream().

static int analyze ( const uint8_t *  buf,
int  size,
int  packet_size,
int *  index 
) [static]

Definition at line 395 of file mpegts.c.

Referenced by get_packet_size(), main(), and mpegts_probe().

static int get_packet_size ( const uint8_t *  buf,
int  size 
) [static]

Definition at line 420 of file mpegts.c.

Referenced by mpegts_read_header().

static int get8 ( const uint8_t **  pp,
const uint8_t *  p_end 
) [inline, static]

Definition at line 447 of file mpegts.c.

Referenced by getstr8(), mpegts_parse_desc(), parse_section_header(), pmt_cb(), and sdt_cb().

static int get16 ( const uint8_t **  pp,
const uint8_t *  p_end 
) [inline, static]

static char* getstr8 ( const uint8_t **  pp,
const uint8_t *  p_end 
) [static]

Definition at line 475 of file mpegts.c.

Referenced by sdt_cb().

static int parse_section_header ( SectionHeader h,
const uint8_t **  pp,
const uint8_t *  p_end 
) [static]

Definition at line 497 of file mpegts.c.

Referenced by mpegts_push_section(), pat_cb(), pat_scan_cb(), pmt_cb(), and sdt_cb().

static MpegTSService* new_service ( MpegTSContext ts,
int  sid,
int  pid,
char *  provider_name,
char *  name 
) [static]

Definition at line 531 of file mpegts.c.

Referenced by pat_cb(), pat_scan_cb(), and sdt_cb().

static int mpegts_parse_program_info_length ( uint8_t **  p,
uint8_t *  p_end 
) [static]

Definition at line 553 of file mpegts.c.

Referenced by pmt_cb().

static int mpegts_parse_pcrpid ( MpegTSContext mpegts_ctx,
uint8_t **  p,
uint8_t *  p_end 
) [static]

Definition at line 573 of file mpegts.c.

Referenced by pmt_cb().

static void pmt_cb ( void *  opaque,
const uint8_t *  section,
int  section_len 
) [static]

Definition at line 594 of file mpegts.c.

Referenced by pat_cb().

void mpegts_remove_stream ( MpegTSContext ts,
int  pid 
)

Definition at line 1076 of file mpegts.c.

Referenced by av_remove_stream(), and mpegts_cleanup_streams().

static void pat_cb ( void *  opaque,
const uint8_t *  section,
int  section_len 
) [static]

Definition at line 1097 of file mpegts.c.

Referenced by handle_packet(), and mpegts_read_header().

static void pat_scan_cb ( void *  opaque,
const uint8_t *  section,
int  section_len 
) [static]

Definition at line 1239 of file mpegts.c.

Referenced by mpegts_scan_pat().

static void sdt_cb ( void *  opaque,
const uint8_t *  section,
int  section_len 
) [static]

Definition at line 1296 of file mpegts.c.

Referenced by mpegts_scan_sdt().

void mpegts_scan_sdt ( MpegTSContext ts  ) 

Definition at line 1376 of file mpegts.c.

void mpegts_scan_pat ( MpegTSContext ts  ) 

Definition at line 1386 of file mpegts.c.

static int64_t get_pts ( const uint8_t *  p  )  [static]

Definition at line 1393 of file mpegts.c.

static void init_stream ( AVStream st,
int  stream_type,
int  code 
) [static]

Definition at line 1407 of file mpegts.c.

Referenced by new_pes_av_stream(), and new_section_av_stream().

static void mpegts_push_data ( void *  opaque,
const uint8_t *  buf,
int  buf_size,
int  is_start,
int64_t  position 
) [static]

Definition at line 1504 of file mpegts.c.

Referenced by add_pes_stream().

static void mpegts_push_section ( void *  opaque,
const uint8_t *  section,
int  section_len 
) [static]

Definition at line 1667 of file mpegts.c.

Referenced by add_section_stream().

static void handle_packet ( MpegTSContext ts,
const uint8_t *  packet,
int64_t  position 
) [static]

Definition at line 1745 of file mpegts.c.

Referenced by handle_packets(), and mpegts_parse_packet().

static int mpegts_resync ( ByteIOContext pb  )  [static]

Definition at line 1822 of file mpegts.c.

Referenced by read_packet().

static int read_packet ( ByteIOContext pb,
uint8_t *  buf,
int  raw_packet_size,
int64_t position 
) [static]

Definition at line 1840 of file mpegts.c.

static int handle_packets ( MpegTSContext ts,
int  nb_packets 
) [static]

Definition at line 1868 of file mpegts.c.

Referenced by mpegts_read_header(), and mpegts_read_packet().

static int mpegts_probe ( AVProbeData p  )  [static]

Definition at line 1892 of file mpegts.c.

static void set_service_cb ( void *  opaque,
int  ret 
) [static]

Definition at line 1927 of file mpegts.c.

static int parse_pcr ( int64_t ppcr_high,
int *  ppcr_low,
const uint8_t *  packet 
) [static]

Definition at line 1937 of file mpegts.c.

Referenced by mpegts_get_pcr(), mpegts_raw_read_packet(), and mpegts_read_header().

static int mpegts_read_header ( AVFormatContext s,
AVFormatParameters ap 
) [static]

Definition at line 1964 of file mpegts.c.

static int mpegts_raw_read_packet ( AVFormatContext s,
AVPacket pkt 
) [static]

Definition at line 2137 of file mpegts.c.

Referenced by mpegts_read_packet().

static int mpegts_read_packet ( AVFormatContext s,
AVPacket pkt 
) [static]

Definition at line 2180 of file mpegts.c.

static int mpegts_read_close ( AVFormatContext s  )  [static]

Definition at line 2193 of file mpegts.c.

static int64_t mpegts_get_pcr ( AVFormatContext s,
int  stream_index,
int64_t ppos,
int64_t  pos_limit 
) [static]

Definition at line 2210 of file mpegts.c.

static int read_seek ( AVFormatContext s,
int  stream_index,
int64_t  target_ts,
int  flags 
) [static]

Definition at line 2251 of file mpegts.c.

MpegTSContext* mpegts_parse_open ( AVFormatContext s  ) 

Definition at line 2277 of file mpegts.c.

Referenced by rtp_parse_open().

int mpegts_parse_packet ( MpegTSContext ts,
AVPacket pkt,
const uint8_t *  buf,
int  len 
)

Definition at line 2293 of file mpegts.c.

Referenced by rtp_parse_packet().

void mpegts_parse_close ( MpegTSContext ts  ) 

Definition at line 2319 of file mpegts.c.

Referenced by rtp_parse_close().


Variable Documentation

pthread_mutex_t avcodeclock

Initial value:

 {
    "mpegts",
    "MPEG2 transport stream format",
    sizeof(MpegTSContext),
    mpegts_probe,
    mpegts_read_header,
    mpegts_read_packet,
    mpegts_read_close,
    read_seek,
    mpegts_get_pcr,
    .flags = AVFMT_SHOW_IDS,
}

Definition at line 2328 of file mpegts.c.


Generated on Sat Dec 18 05:15:54 2010 for MythTV by  doxygen 1.5.5