libavformat/mpegts.c File Reference

#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
#include "seek.h"
#include "isom.h"

Go to the source code of this file.

Data Structures

struct  MpegTSPESFilter
struct  MpegTSSectionFilter
struct  MpegTSFilter
struct  Program
struct  MpegTSContext
struct  PESContext
struct  SectionHeader
struct  StreamType

Defines

#define MAX_SCAN_PACKETS   32000
#define MAX_RESYNC_SIZE   65536
#define MAX_PES_PAYLOAD   200*1024
#define MAX_PIDS_PER_PROGRAM   64
#define PES_START_SIZE   6
#define PES_HEADER_SIZE   9
#define MAX_PES_HEADER_SIZE   (9 + 255)
#define CHECK_COUNT   10
#define MAX_PACKET_READAHEAD   ((128 * 1024) / 188)

Typedefs

typedef struct MpegTSFilter MpegTSFilter
typedef int PESCallback (MpegTSFilter *f, const uint8_t *buf, int len, int is_start, int64_t pos)
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, MPEGTS_PESHEADER_FILL, MPEGTS_PAYLOAD,
  MPEGTS_SKIP
}

Functions

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)
 Assemble PES packets out of TS packets, and then call 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 mpegts_find_stream_type (AVStream *st, uint32_t stream_type, const StreamType *types)
static int mpegts_set_stream_info (AVStream *st, PESContext *pes, uint32_t stream_type, uint32_t prog_reg_desc)
static int64_t get_pts (const uint8_t *p)
static void new_pes_packet (PESContext *pes, AVPacket *pkt)
static int mpegts_push_data (MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start, int64_t pos)
static PESContextadd_pes_stream (MpegTSContext *ts, int pid, int pcr_pid)
static int mp4_read_iods (AVFormatContext *s, const uint8_t *buf, unsigned size, int *es_id, uint8_t **dec_config_descr, int *dec_config_descr_size)
int ff_parse_mpeg2_descriptor (AVFormatContext *fc, AVStream *st, int stream_type, const uint8_t **pp, const uint8_t *desc_list_end, int mp4_dec_config_descr_len, int mp4_es_id, int pid, uint8_t *mp4_dec_config_descr)
 Parse an MPEG-2 descriptor.
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 sdt_cb (MpegTSFilter *filter, const uint8_t *section, int section_len)
static int handle_packet (MpegTSContext *ts, const uint8_t *packet)
static int mpegts_resync (AVFormatContext *s)
static int read_packet (AVFormatContext *s, 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)
MpegTSContextff_mpegts_parse_open (AVFormatContext *s)
int ff_mpegts_parse_packet (MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
void ff_mpegts_parse_close (MpegTSContext *ts)

Variables

AVInputFormat mpegts_demuxer
static const StreamType ISO_types []
static const StreamType HDMV_types []
static const StreamType MISC_types []
static const StreamType REGD_types []
static const StreamType DESC_types []
AVInputFormat mpegtsraw_demuxer


Define Documentation

#define CHECK_COUNT   10

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

Definition at line 1546 of file mpegts.c.

Referenced by mpegts_raw_read_packet().

#define MAX_PES_HEADER_SIZE   (9 + 255)

Definition at line 139 of file mpegts.c.

#define MAX_PES_PAYLOAD   200*1024

Definition at line 42 of file mpegts.c.

Referenced by mpegts_push_data().

#define MAX_PIDS_PER_PROGRAM   64

Definition at line 82 of file mpegts.c.

Referenced by add_pid_to_pmt().

#define MAX_RESYNC_SIZE   65536

Definition at line 40 of file mpegts.c.

Referenced by mpegts_resync().

#define MAX_SCAN_PACKETS   32000

Definition at line 36 of file mpegts.c.

#define PES_HEADER_SIZE   9

Definition at line 138 of file mpegts.c.

Referenced by mpegts_push_data().

#define PES_START_SIZE   6

Definition at line 137 of file mpegts.c.

Referenced by mpegts_push_data().


Typedef Documentation

typedef struct MpegTSFilter MpegTSFilter

Definition at line 49 of file mpegts.c.

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

Definition at line 51 of file mpegts.c.

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

Definition at line 58 of file mpegts.c.

typedef void SetServiceCallback(void *opaque, int ret)

Definition at line 60 of file mpegts.c.


Enumeration Type Documentation

Enumerator:
MPEGTS_PES 
MPEGTS_SECTION 

Definition at line 44 of file mpegts.c.

Enumerator:
MPEGTS_HEADER 
MPEGTS_PESHEADER 
MPEGTS_PESHEADER_FILL 
MPEGTS_PAYLOAD 
MPEGTS_SKIP 

Definition at line 128 of file mpegts.c.


Function Documentation

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

Definition at line 178 of file mpegts.c.

Referenced by pat_cb().

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

Definition at line 836 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 191 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 358 of file mpegts.c.

Referenced by get_packet_size(), and mpegts_probe().

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

Definition at line 163 of file mpegts.c.

Referenced by pmt_cb().

static void clear_programs ( MpegTSContext ts  )  [static]

Definition at line 172 of file mpegts.c.

Referenced by mpegts_read_close(), and 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 217 of file mpegts.c.

Referenced by handle_packet().

void ff_mpegts_parse_close ( MpegTSContext ts  ) 

Definition at line 1839 of file mpegts.c.

Referenced by rtp_parse_close().

MpegTSContext* ff_mpegts_parse_open ( AVFormatContext s  ) 

Definition at line 1798 of file mpegts.c.

Referenced by rtp_parse_open().

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

Definition at line 1814 of file mpegts.c.

Referenced by rtp_parse_one_packet(), and rtp_parse_packet_internal().

int ff_parse_mpeg2_descriptor ( AVFormatContext fc,
AVStream st,
int  stream_type,
const uint8_t **  pp,
const uint8_t *  desc_list_end,
int  mp4_dec_config_descr_len,
int  mp4_es_id,
int  pid,
uint8_t *  mp4_dec_config_descr 
)

Parse an MPEG-2 descriptor.

Parameters:
[in] fc Format context (used for logging only)
st Stream
stream_type STREAM_TYPE_xxx
pp Descriptor buffer pointer
desc_list_end End of buffer
mp4_dec_config_descr_len Length of 'mp4_dec_config_descr', or zero if not present
mp4_es_id 
pid 
mp4_dec_config_descr 
Returns:
<0 to stop processing

Definition at line 896 of file mpegts.c.

Referenced by parse_chunks(), and pmt_cb().

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

Definition at line 422 of file mpegts.c.

Referenced by ff_parse_mpeg2_descriptor(), 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 409 of file mpegts.c.

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

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

Definition at line 383 of file mpegts.c.

Referenced by mpegts_read_header().

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

Definition at line 604 of file mpegts.c.

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

Definition at line 437 of file mpegts.c.

Referenced by sdt_cb().

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

Definition at line 1231 of file mpegts.c.

Referenced by ff_mpegts_parse_packet(), and handle_packets().

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

Definition at line 1360 of file mpegts.c.

Referenced by mpegts_read_header(), and mpegts_read_packet().

static int mp4_read_iods ( AVFormatContext s,
const uint8_t *  buf,
unsigned  size,
int *  es_id,
uint8_t **  dec_config_descr,
int *  dec_config_descr_size 
) [static]

Definition at line 860 of file mpegts.c.

Referenced by pmt_cb().

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

Definition at line 337 of file mpegts.c.

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

static void mpegts_find_stream_type ( AVStream st,
uint32_t  stream_type,
const StreamType types 
) [static]

Definition at line 541 of file mpegts.c.

Referenced by ff_parse_mpeg2_descriptor(), and mpegts_set_stream_info().

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

Definition at line 1645 of file mpegts.c.

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

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

Referenced by mpegts_read_header(), and pat_cb().

static int mpegts_probe ( AVProbeData p  )  [static]

Definition at line 1384 of file mpegts.c.

static int mpegts_push_data ( MpegTSFilter filter,
const uint8_t *  buf,
int  buf_size,
int  is_start,
int64_t  pos 
) [static]

Definition at line 639 of file mpegts.c.

Referenced by add_pes_stream().

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

Definition at line 1548 of file mpegts.c.

static int mpegts_read_close ( AVFormatContext s  )  [static]

Definition at line 1632 of file mpegts.c.

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

Definition at line 1443 of file mpegts.c.

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

Definition at line 1592 of file mpegts.c.

static int mpegts_resync ( AVFormatContext s  )  [static]

Definition at line 1313 of file mpegts.c.

Referenced by read_packet().

static int mpegts_set_stream_info ( AVStream st,
PESContext pes,
uint32_t  stream_type,
uint32_t  prog_reg_desc 
) [static]

Definition at line 553 of file mpegts.c.

Referenced by mpegts_push_data(), and pmt_cb().

static void new_pes_packet ( PESContext pes,
AVPacket pkt 
) [static]

Definition at line 612 of file mpegts.c.

Referenced by mpegts_push_data(), and mpegts_read_packet().

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

Definition at line 1416 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 459 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 1109 of file mpegts.c.

Referenced by mpegts_read_header().

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

Definition at line 982 of file mpegts.c.

Referenced by pat_cb().

static int read_packet ( AVFormatContext s,
uint8_t *  buf,
int  raw_packet_size 
) [static]

Definition at line 1333 of file mpegts.c.

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

Definition at line 1770 of file mpegts.c.

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

Definition at line 1152 of file mpegts.c.

Referenced by mpegts_read_header().

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

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

Definition at line 246 of file mpegts.c.

Referenced by handle_packet().


Variable Documentation

const StreamType DESC_types[] [static]

Initial value:

Definition at line 532 of file mpegts.c.

const StreamType HDMV_types[] [static]

const StreamType ISO_types[] [static]

const StreamType MISC_types[] [static]

Initial value:

 {
    { 0x81, AVMEDIA_TYPE_AUDIO,   CODEC_ID_AC3 },
    { 0x8a, AVMEDIA_TYPE_AUDIO,   CODEC_ID_DTS },
    { 0 },
}

Definition at line 519 of file mpegts.c.

Initial value:

Definition at line 1848 of file mpegts.c.

Initial value:

Definition at line 1864 of file mpegts.c.

const StreamType REGD_types[] [static]

Initial value:

 {
    { MKTAG('d','r','a','c'), AVMEDIA_TYPE_VIDEO, CODEC_ID_DIRAC },
    { MKTAG('A','C','-','3'), AVMEDIA_TYPE_AUDIO,   CODEC_ID_AC3 },
    { 0 },
}

Definition at line 525 of file mpegts.c.


Generated on Wed Jan 19 23:49:50 2011 for FFmpeg by  doxygen 1.5.6