libavformat/mpegts.c File Reference

#include "avformat.h"
#include "crc.h"
#include "mpegts.h"

Go to the source code of this file.

Data Structures

struct  MpegTSPESFilter
struct  MpegTSSectionFilter
struct  MpegTSFilter
struct  Program_t
struct  MpegTSContext
struct  PESContext
struct  SectionHeader

Defines

#define MAX_SCAN_PACKETS   32000
#define MAX_RESYNC_SIZE   4096
#define MAX_PIDS_PER_PROGRAM   64
#define PES_START_SIZE   9
#define MAX_PES_HEADER_SIZE   (9 + 255)
#define CHECK_COUNT   10
#define MAX_PACKET_READAHEAD   ((128 * 1024) / 188)

Typedefs

typedef struct PESContext PESContext
typedef struct MpegTSFilter MpegTSFilter
typedef void PESCallback (MpegTSFilter *f, const uint8_t *buf, int len, int is_start)
typedef void SectionCallback (MpegTSFilter *f, 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 pcr_pid, int stream_type)
static AVStreamnew_pes_av_stream (PESContext *pes, uint32_t code)
void av_set_program_name (AVProgram *program, char *provider_name, char *name)
void av_program_add_stream_index (AVFormatContext *ac, int progid, unsigned int idx)
static void clear_program (MpegTSContext *ts, unsigned int programid)
static void clear_programs (MpegTSContext *ts)
static void add_pat_entry (MpegTSContext *ts, unsigned int programid)
static void add_pid_to_pmt (MpegTSContext *ts, unsigned int programid, unsigned int pid)
static int discard_pid (MpegTSContext *ts, unsigned int pid)
 discard_pid() decides if the pid is to be discarded according to caller's programs selection
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.
static MpegTSFiltermpegts_open_section_filter (MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc)
static MpegTSFiltermpegts_open_pes_filter (MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque)
static void mpegts_close_filter (MpegTSContext *ts, MpegTSFilter *filter)
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 void pmt_cb (MpegTSFilter *filter, const uint8_t *section, int section_len)
static void pat_cb (MpegTSFilter *filter, const uint8_t *section, int section_len)
static void mpegts_set_service (MpegTSContext *ts)
static void sdt_cb (MpegTSFilter *filter, const uint8_t *section, int section_len)
static void mpegts_scan_sdt (MpegTSContext *ts)
static int64_t get_pts (const uint8_t *p)
static void mpegts_push_data (MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start)
static void handle_packet (MpegTSContext *ts, const uint8_t *packet)
static int mpegts_resync (ByteIOContext *pb)
static int read_packet (ByteIOContext *pb, uint8_t *buf, int raw_packet_size)
static int handle_packets (MpegTSContext *ts, int nb_packets)
static int mpegts_probe (AVProbeData *p)
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

AVInputFormat mpegts_demuxer
AVInputFormat mpegtsraw_demuxer


Define Documentation

#define CHECK_COUNT   10

#define MAX_PACKET_READAHEAD   ((128 * 1024) / 188)

Definition at line 1282 of file mpegts.c.

Referenced by mpegts_raw_read_packet().

#define MAX_PES_HEADER_SIZE   (9 + 255)

Definition at line 130 of file mpegts.c.

#define MAX_PIDS_PER_PROGRAM   64

Definition at line 80 of file mpegts.c.

Referenced by add_pid_to_pmt().

#define MAX_RESYNC_SIZE   4096

Definition at line 33 of file mpegts.c.

Referenced by mpegts_resync().

#define MAX_SCAN_PACKETS   32000

Definition at line 29 of file mpegts.c.

#define PES_START_SIZE   9

Definition at line 129 of file mpegts.c.

Referenced by mpegts_push_data().


Typedef Documentation

typedef struct MpegTSFilter MpegTSFilter

Definition at line 47 of file mpegts.c.

typedef void PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start)

Definition at line 49 of file mpegts.c.

typedef struct PESContext PESContext

Definition at line 35 of file mpegts.c.

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

Definition at line 56 of file mpegts.c.

typedef void SetServiceCallback(void *opaque, int ret)

Definition at line 58 of file mpegts.c.


Enumeration Type Documentation

Enumerator:
MPEGTS_PES 
MPEGTS_SECTION 

Definition at line 42 of file mpegts.c.

Enumerator:
MPEGTS_HEADER 
MPEGTS_PESHEADER_FILL 
MPEGTS_PAYLOAD 
MPEGTS_SKIP 

Definition at line 121 of file mpegts.c.


Function Documentation

static void add_pat_entry ( MpegTSContext ts,
unsigned int  programid 
) [static]

Definition at line 165 of file mpegts.c.

Referenced by pat_cb().

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

Definition at line 959 of file mpegts.c.

Referenced by handle_packet(), and pmt_cb().

static void add_pid_to_pmt ( MpegTSContext ts,
unsigned int  programid,
unsigned int  pid 
) [static]

Definition at line 178 of file mpegts.c.

Referenced by pat_cb(), and pmt_cb().

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

Definition at line 339 of file mpegts.c.

Referenced by get_packet_size(), and mpegts_probe().

void av_program_add_stream_index ( AVFormatContext ac,
int  progid,
unsigned int  idx 
)

Definition at line 2540 of file utils.c.

Referenced by pmt_cb().

void av_set_program_name ( AVProgram program,
char *  provider_name,
char *  name 
)

Definition at line 2196 of file utils.c.

Referenced by sdt_cb().

static void clear_program ( MpegTSContext ts,
unsigned int  programid 
) [static]

Definition at line 150 of file mpegts.c.

Referenced by pmt_cb().

static void clear_programs ( MpegTSContext ts  )  [static]

Definition at line 159 of file mpegts.c.

Referenced by pat_cb().

static int discard_pid ( MpegTSContext ts,
unsigned int  pid 
) [static]

discard_pid() decides if the pid is to be discarded according to caller's programs selection

Parameters:
ts : - TS context
pid : - pid
Returns:
1 if the pid is only comprised in programs that have .discard=AVDISCARD_ALL 0 otherwise

Definition at line 204 of file mpegts.c.

Referenced by handle_packet().

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

Definition at line 403 of file mpegts.c.

Referenced by parse_section_header(), pat_cb(), pmt_cb(), and sdt_cb().

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

Definition at line 390 of file mpegts.c.

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

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

Definition at line 364 of file mpegts.c.

Referenced by mpegts_read_header().

static int64_t get_pts ( const uint8_t p  )  [static]

Definition at line 758 of file mpegts.c.

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

Definition at line 418 of file mpegts.c.

Referenced by sdt_cb().

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

Definition at line 982 of file mpegts.c.

Referenced by handle_packets(), and mpegts_parse_packet().

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

Definition at line 1099 of file mpegts.c.

Referenced by mpegts_read_header(), and mpegts_read_packet().

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

Definition at line 325 of file mpegts.c.

Referenced by mpegts_read_close(), pat_cb(), and pmt_cb().

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

Definition at line 1347 of file mpegts.c.

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

Definition at line 303 of file mpegts.c.

Referenced by add_pes_stream().

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

Definition at line 271 of file mpegts.c.

Referenced by mpegts_scan_sdt(), mpegts_set_service(), and pat_cb().

void mpegts_parse_close ( MpegTSContext ts  ) 

Definition at line 1453 of file mpegts.c.

Referenced by rtp_parse_close().

MpegTSContext* mpegts_parse_open ( AVFormatContext s  ) 

Definition at line 1412 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 1428 of file mpegts.c.

Referenced by rtp_parse_packet().

static int mpegts_probe ( AVProbeData p  )  [static]

Definition at line 1122 of file mpegts.c.

static void mpegts_push_data ( MpegTSFilter filter,
const uint8_t buf,
int  buf_size,
int  is_start 
) [static]

Definition at line 767 of file mpegts.c.

Referenced by add_pes_stream().

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

Definition at line 1284 of file mpegts.c.

static int mpegts_read_close ( AVFormatContext s  )  [static]

Definition at line 1337 of file mpegts.c.

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

Definition at line 1180 of file mpegts.c.

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

Definition at line 1328 of file mpegts.c.

static int mpegts_resync ( ByteIOContext pb  )  [static]

Definition at line 1055 of file mpegts.c.

Referenced by read_packet().

static void mpegts_scan_sdt ( MpegTSContext ts  )  [static]

Definition at line 752 of file mpegts.c.

Referenced by mpegts_read_header().

static void mpegts_set_service ( MpegTSContext ts  )  [static]

Definition at line 671 of file mpegts.c.

Referenced by mpegts_read_header().

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

Definition at line 889 of file mpegts.c.

Referenced by mpegts_push_data(), and pmt_cb().

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

Definition at line 1153 of file mpegts.c.

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

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

Definition at line 440 of file mpegts.c.

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

static void pat_cb ( MpegTSFilter filter,
const uint8_t section,
int  section_len 
) [static]

Definition at line 625 of file mpegts.c.

Referenced by mpegts_set_service().

static void pmt_cb ( MpegTSFilter filter,
const uint8_t section,
int  section_len 
) [static]

Definition at line 470 of file mpegts.c.

Referenced by pat_cb().

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

Definition at line 1073 of file mpegts.c.

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

Definition at line 1386 of file mpegts.c.

static void sdt_cb ( MpegTSFilter filter,
const uint8_t section,
int  section_len 
) [static]

Definition at line 677 of file mpegts.c.

Referenced by mpegts_scan_sdt().

static void 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.

Definition at line 233 of file mpegts.c.

Referenced by handle_packet().


Variable Documentation

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 1462 of file mpegts.c.

Initial value:

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

Definition at line 1475 of file mpegts.c.


Generated on Wed Feb 9 19:10:13 2011 for ffmpeg by  doxygen 1.5.6