mpegtsenc.c File Reference
#include "libavutil/bswap.h"
#include "libavutil/crc.h"
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavcodec/internal.h"
#include "avformat.h"
#include "internal.h"
#include "mpegts.h"
Include dependency graph for mpegtsenc.c:

Go to the source code of this file.

Data Structures

struct  MpegTSSection
 
struct  MpegTSService
 
struct  MpegTSWrite
 
struct  MpegTSWriteStream
 

Macros

#define PCR_TIME_BASE   27000000
 
#define MPEGTS_FLAG_REEMIT_PAT_PMT   0x01
 
#define MPEGTS_FLAG_AAC_LATM   0x02
 
#define DEFAULT_PES_HEADER_FREQ   16
 
#define DEFAULT_PES_PAYLOAD_SIZE   ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
 
#define DEFAULT_PROVIDER_NAME   "FFmpeg"
 
#define DEFAULT_SERVICE_NAME   "Service01"
 
#define SDT_RETRANS_TIME   500
 
#define PAT_RETRANS_TIME   100
 
#define PCR_RETRANS_TIME   20
 

Typedefs

typedef struct MpegTSSection MpegTSSection
 
typedef struct MpegTSService MpegTSService
 
typedef struct MpegTSWrite MpegTSWrite
 
typedef struct MpegTSWriteStream MpegTSWriteStream
 

Functions

static void mpegts_write_section (MpegTSSection *s, uint8_t *buf, int len)
 
static void put16 (uint8_t **q_ptr, int val)
 
static int mpegts_write_section1 (MpegTSSection *s, int tid, int id, int version, int sec_num, int last_sec_num, uint8_t *buf, int len)
 
static void mpegts_write_pat (AVFormatContext *s)
 
static void mpegts_write_pmt (AVFormatContext *s, MpegTSService *service)
 
static void putstr8 (uint8_t **q_ptr, const char *str)
 
static void mpegts_write_sdt (AVFormatContext *s)
 
static MpegTSServicempegts_add_service (MpegTSWrite *ts, int sid, const char *provider_name, const char *name)
 
static int64_t get_pcr (const MpegTSWrite *ts, AVIOContext *pb)
 
static void mpegts_prefix_m2ts_header (AVFormatContext *s)
 
static void section_write_packet (MpegTSSection *s, const uint8_t *packet)
 
static int mpegts_write_header (AVFormatContext *s)
 
static void retransmit_si_info (AVFormatContext *s, int force_pat)
 
static int write_pcr_bits (uint8_t *buf, int64_t pcr)
 
static void mpegts_insert_null_packet (AVFormatContext *s)
 
static void mpegts_insert_pcr_only (AVFormatContext *s, AVStream *st)
 
static void write_pts (uint8_t *q, int fourbits, int64_t pts)
 
static void set_af_flag (uint8_t *pkt, int flag)
 
static void extend_af (uint8_t *pkt, int size)
 
static uint8_tget_ts_payload_start (uint8_t *pkt)
 
static void mpegts_write_pes (AVFormatContext *s, AVStream *st, const uint8_t *payload, int payload_size, int64_t pts, int64_t dts, int key)
 
static int mpegts_write_packet_internal (AVFormatContext *s, AVPacket *pkt)
 
static void mpegts_write_flush (AVFormatContext *s)
 
static int mpegts_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int mpegts_write_end (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass mpegts_muxer_class
 
AVOutputFormat ff_mpegts_muxer
 

Macro Definition Documentation

#define DEFAULT_PES_HEADER_FREQ   16

Definition at line 91 of file mpegtsenc.c.

#define DEFAULT_PES_PAYLOAD_SIZE   ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)

Definition at line 92 of file mpegtsenc.c.

#define DEFAULT_PROVIDER_NAME   "FFmpeg"

Definition at line 220 of file mpegtsenc.c.

Referenced by mpegts_write_header().

#define DEFAULT_SERVICE_NAME   "Service01"

Definition at line 221 of file mpegtsenc.c.

Referenced by mpegts_write_header().

#define MPEGTS_FLAG_AAC_LATM   0x02

Definition at line 85 of file mpegtsenc.c.

Referenced by mpegts_write_header(), and mpegts_write_pmt().

#define MPEGTS_FLAG_REEMIT_PAT_PMT   0x01

Definition at line 84 of file mpegtsenc.c.

Referenced by mpegts_write_packet_internal().

#define PAT_RETRANS_TIME   100

Definition at line 225 of file mpegtsenc.c.

Referenced by mpegts_write_header().

#define PCR_RETRANS_TIME   20

Definition at line 226 of file mpegtsenc.c.

Referenced by mpegts_write_header().

#define PCR_TIME_BASE   27000000

Definition at line 34 of file mpegtsenc.c.

Referenced by get_pcr(), and mpegts_write_header().

#define SDT_RETRANS_TIME   500

Definition at line 224 of file mpegtsenc.c.

Referenced by mpegts_write_header().

Typedef Documentation

typedef struct MpegTSSection MpegTSSection
typedef struct MpegTSService MpegTSService
typedef struct MpegTSWrite MpegTSWrite

Function Documentation

static void extend_af ( uint8_t pkt,
int  size 
)
static

Definition at line 820 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static int64_t get_pcr ( const MpegTSWrite ts,
AVIOContext pb 
)
static
static uint8_t* get_ts_payload_start ( uint8_t pkt)
static

Definition at line 828 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static MpegTSService* mpegts_add_service ( MpegTSWrite ts,
int  sid,
const char *  provider_name,
const char *  name 
)
static

Definition at line 465 of file mpegtsenc.c.

Referenced by mpegts_write_header().

static void mpegts_insert_null_packet ( AVFormatContext s)
static

Definition at line 748 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static void mpegts_insert_pcr_only ( AVFormatContext s,
AVStream st 
)
static

Definition at line 764 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static void mpegts_prefix_m2ts_header ( AVFormatContext s)
static
static int mpegts_write_end ( AVFormatContext s)
static

Definition at line 1230 of file mpegtsenc.c.

static void mpegts_write_flush ( AVFormatContext s)
static

Definition at line 1202 of file mpegtsenc.c.

Referenced by mpegts_write_end(), and mpegts_write_packet().

static int mpegts_write_header ( AVFormatContext s)
static

Definition at line 509 of file mpegtsenc.c.

static int mpegts_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1220 of file mpegtsenc.c.

static int mpegts_write_packet_internal ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1057 of file mpegtsenc.c.

Referenced by mpegts_write_packet().

static void mpegts_write_pat ( AVFormatContext s)
static

Definition at line 242 of file mpegtsenc.c.

Referenced by retransmit_si_info().

static void mpegts_write_pes ( AVFormatContext s,
AVStream st,
const uint8_t payload,
int  payload_size,
int64_t  pts,
int64_t  dts,
int  key 
)
static

Definition at line 841 of file mpegtsenc.c.

Referenced by mpegts_write_flush(), and mpegts_write_packet_internal().

static void mpegts_write_pmt ( AVFormatContext s,
MpegTSService service 
)
static

Definition at line 259 of file mpegtsenc.c.

Referenced by retransmit_si_info().

static void mpegts_write_sdt ( AVFormatContext s)
static

Definition at line 427 of file mpegtsenc.c.

Referenced by retransmit_si_info().

static void mpegts_write_section ( MpegTSSection s,
uint8_t buf,
int  len 
)
static

Definition at line 135 of file mpegtsenc.c.

Referenced by mpegts_write_section1().

static int mpegts_write_section1 ( MpegTSSection s,
int  tid,
int  id,
int  version,
int  sec_num,
int  last_sec_num,
uint8_t buf,
int  len 
)
static

Definition at line 190 of file mpegtsenc.c.

Referenced by mpegts_write_pat(), mpegts_write_pmt(), and mpegts_write_sdt().

static void put16 ( uint8_t **  q_ptr,
int  val 
)
inlinestatic
static void putstr8 ( uint8_t **  q_ptr,
const char *  str 
)
static

Definition at line 411 of file mpegtsenc.c.

Referenced by mpegts_write_sdt().

static void retransmit_si_info ( AVFormatContext s,
int  force_pat 
)
static

Definition at line 715 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static void section_write_packet ( MpegTSSection s,
const uint8_t packet 
)
static

Definition at line 502 of file mpegtsenc.c.

Referenced by mpegts_write_header().

static void set_af_flag ( uint8_t pkt,
int  flag 
)
static

Definition at line 804 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

static int write_pcr_bits ( uint8_t buf,
int64_t  pcr 
)
static

Definition at line 733 of file mpegtsenc.c.

Referenced by mpegts_insert_pcr_only(), and mpegts_write_pes().

static void write_pts ( uint8_t q,
int  fourbits,
int64_t  pts 
)
static

Definition at line 789 of file mpegtsenc.c.

Referenced by mpegts_write_pes().

Variable Documentation

AVOutputFormat ff_mpegts_muxer
Initial value:
= {
.name = "mpegts",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"),
.mime_type = "video/x-mpegts",
.extensions = "ts,m2t,m2ts,mts",
.priv_data_size = sizeof(MpegTSWrite),
.audio_codec = AV_CODEC_ID_MP2,
.video_codec = AV_CODEC_ID_MPEG2VIDEO,
.priv_class = &mpegts_muxer_class,
}
static int write_packet(AVFormatContext *s, AVPacket *pkt)
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:361
static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mpegtsenc.c:1220
static int write_trailer(AVFormatContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int mpegts_write_header(AVFormatContext *s)
Definition: mpegtsenc.c:509
preferred ID for MPEG-1/2 video decoding
static int mpegts_write_end(AVFormatContext *s)
Definition: mpegtsenc.c:1230
static int flags
Definition: cpu.c:23
struct MpegTSWrite MpegTSWrite
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:470
static const AVClass mpegts_muxer_class
Definition: mpegtsenc.c:127

Definition at line 1259 of file mpegtsenc.c.

const AVClass mpegts_muxer_class
static
Initial value:
= {
.class_name = "MPEGTS muxer",
.item_name = av_default_item_name,
.option = options,
}
av_default_item_name
static const AVOption options[]
Definition: mpegtsenc.c:94
LIBAVUTIL_VERSION_INT
Definition: eval.c:55

Definition at line 127 of file mpegtsenc.c.

const AVOption options[]
static

Definition at line 94 of file mpegtsenc.c.