2 * dvb-mpegtools for the Siemens Fujitsu DVB PCI card
4 * Copyright (C) 2000, 2001 Marcus Metzler
5 * for convergence integrated media GmbH
6 * Copyright (C) 2002 Marcus Metzler
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26 * The author can be reached at mocm@metzlerbros.de,
30 #ifndef _TS_TRANSFORM_H_
31 #define _TS_TRANSFORM_H_
34 #include <netinet/in.h>
39 #define PROG_STREAM_MAP 0xBC
40 #ifndef PRIVATE_STREAM1
41 #define PRIVATE_STREAM1 0xBD
43 #define PADDING_STREAM 0xBE
44 #ifndef PRIVATE_STREAM2
45 #define PRIVATE_STREAM2 0xBF
47 #define AUDIO_STREAM_S 0xC0
48 #define AUDIO_STREAM_E 0xDF
49 #define VIDEO_STREAM_S 0xE0
50 #define VIDEO_STREAM_E 0xEF
51 #define ECM_STREAM 0xF0
52 #define EMM_STREAM 0xF1
53 #define DSM_CC_STREAM 0xF2
54 #define ISO13522_STREAM 0xF3
55 #define PROG_STREAM_DIR 0xFF
57 #define BUFFYSIZE 10*MAX_PLENGTH
59 #define MAX_FRAME 8192
60 #define MAX_PACK_L 4096
61 #define PS_HEADER_L1 14
62 #define PS_HEADER_L2 (PS_HEADER_L1+18)
63 #define MAX_H_SIZE (PES_H_MIN + PS_HEADER_L1 + 5)
68 #define PTS_DTS_FLAGS 0xC0
69 #define ESCR_FLAG 0x20
70 #define ES_RATE_FLAG 0x10
71 #define DSM_TRICK_FLAG 0x08
72 #define ADD_CPY_FLAG 0x04
73 #define PES_CRC_FLAG 0x02
74 #define PES_EXT_FLAG 0x01
81 #define TRANS_ERROR 0x80
82 #define PAY_START 0x40
83 #define TRANS_PRIO 0x20
84 #define PID_MASK_HI 0x1F
86 #define TRANS_SCRMBL1 0x80
87 #define TRANS_SCRMBL2 0x40
88 #define ADAPT_FIELD 0x20
90 #define COUNT_MASK 0x0F
93 #define DISCON_IND 0x80
94 #define RAND_ACC_IND 0x40
95 #define ES_PRI_IND 0x20
97 #define OPCR_FLAG 0x08
98 #define SPLICE_FLAG 0x04
99 #define TRANS_PRIV 0x02
100 #define ADAP_EXT_FLAG 0x01
102 // adaptation extension flags
103 #define LTW_FLAG 0x80
104 #define PIECE_RATE 0x40
105 #define SEAM_SPLICE 0x20
108 #define MAX_PLENGTH 0xFFFF
109 #define MMAX_PLENGTH (8*MAX_PLENGTH)
113 #endif /* __cplusplus */
115 #define P2P_LENGTH 2048
117 enum{NOPES, AUDIO, VIDEO, AC3};
119 typedef struct p2pstruct {
121 uint8_t buf[MMAX_PLENGTH];
139 uint16_t bigend_repack;
140 void (*func)(uint8_t *buf, int count, void *p);
156 uint64_t trans_pts_dts(uint8_t *pts);
157 int write_ts_header(uint16_t pid, uint8_t *counter, int pes_start,
158 uint8_t *buf, uint8_t length);
159 uint16_t get_pid(uint8_t *pid);
160 void init_p2p(p2p *p, void (*func)(uint8_t *buf, int count, void *p),
162 void get_pes (uint8_t *buf, int count, p2p *p, void (*func)(p2p *p));
163 void get_pes (uint8_t *buf, int count, p2p *p, void (*func)(p2p *p));
164 void pes_repack(p2p *p);
165 void setup_pes2ts( p2p *p, uint32_t pida, uint32_t pidv,
166 void (*ts_write)(uint8_t *buf, int count, void *p));
167 void kpes_to_ts( p2p *p,uint8_t *buf ,int count );
168 void setup_ts2pes( p2p *pa, p2p *pv, uint32_t pida, uint32_t pidv,
169 void (*pes_write)(uint8_t *buf, int count, void *p));
170 void kts_to_pes( p2p *p, uint8_t *buf);
171 void pes_repack(p2p *p);
172 void extract_from_pes(int fdin, int fdout, uint8_t id, int es);
173 int64_t pes_dmx(int fdin, int fdouta, int fdoutv, int es);
174 void pes_to_ts2( int fdin, int fdout, uint16_t pida, uint16_t pidv);
175 void ts_to_pes( int fdin, uint16_t pida, uint16_t pidv, int pad);
176 int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
177 int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr);
178 int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
179 void filter_audio_from_pes(int fdin, int fdout, uint8_t id,
185 typedef struct ipack_s {
209 void (*func)(uint8_t *buf, int size, void *priv);
219 void instant_repack (uint8_t *buf, int count, ipack *p);
220 void init_ipack(ipack *p, int size,
221 void (*func)(uint8_t *buf, int size, void *priv),
223 void free_ipack(ipack * p);
224 void send_ipack(ipack *p);
225 void reset_ipack(ipack *p);
226 void ps_pes(ipack *p);
227 // use with ipack structure, repack size and callback func
229 int64_t ts_demux(int fd_in, int fdv_out,int fda_out,uint16_t pida,
230 uint16_t pidv, int es);
232 void ts2es(int fdin, uint16_t pidv);
233 void ts2es_opt(int fdin, uint16_t pidv, ipack *p, int verb);
234 void insert_pat_pmt( int fdin, int fdout);
235 void change_aspect(int fdin, int fdout, int aspect);
237 // SV: all made non-static:
238 void pes_in_ts(p2p *p);
240 // SV: moved from .c file:
245 #endif /* __cplusplus */
247 #endif /* _TS_TRANSFORM_H_*/