dvbd / transform.h @ bfdb7446
History | View | Annotate | Download (5.98 KB)
1 |
/*
|
---|---|
2 |
* mpegtools for the Siemens Fujitsu DVB PCI card
|
3 |
*
|
4 |
* Copyright (C) 2000, 2001 Marcus Metzler
|
5 |
* for convergence integrated media GmbH
|
6 |
*
|
7 |
* This program is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU General Public License
|
9 |
* as published by the Free Software Foundation; either version 2
|
10 |
* of the License, or (at your option) any later version.
|
11 |
*
|
12 |
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
22 |
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
|
23 |
*
|
24 |
|
25 |
* The author can be reached at marcus@convergence.de,
|
26 |
|
27 |
* the project's page is at http://linuxtv.org/dvb/
|
28 |
*/
|
29 |
|
30 |
#ifndef _TS_TRANSFORM_H_
|
31 |
#define _TS_TRANSFORM_H_
|
32 |
|
33 |
#include <stdint.h> |
34 |
#include <netinet/in.h> |
35 |
#include <stdio.h> |
36 |
#include <unistd.h> |
37 |
#include "remux.h" |
38 |
|
39 |
#define PROG_STREAM_MAP 0xBC |
40 |
#ifndef PRIVATE_STREAM1
|
41 |
#define PRIVATE_STREAM1 0xBD |
42 |
#endif
|
43 |
#define PADDING_STREAM 0xBE |
44 |
#ifndef PRIVATE_STREAM2
|
45 |
#define PRIVATE_STREAM2 0xBF |
46 |
#endif
|
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 |
56 |
|
57 |
#define BUFFYSIZE 10*MAX_PLENGTH |
58 |
#define MAX_PTS 8192 |
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) |
64 |
#define PES_MIN 7 |
65 |
#define PES_H_MIN 9 |
66 |
|
67 |
//flags2
|
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 |
75 |
|
76 |
//pts_dts flags
|
77 |
#define PTS_ONLY 0x80 |
78 |
#define PTS_DTS 0xC0 |
79 |
|
80 |
#define TS_SIZE 188 |
81 |
#define TRANS_ERROR 0x80 |
82 |
#define PAY_START 0x40 |
83 |
#define TRANS_PRIO 0x20 |
84 |
#define PID_MASK_HI 0x1F |
85 |
//flags
|
86 |
#define TRANS_SCRMBL1 0x80 |
87 |
#define TRANS_SCRMBL2 0x40 |
88 |
#define ADAPT_FIELD 0x20 |
89 |
#define PAYLOAD 0x10 |
90 |
#define COUNT_MASK 0x0F |
91 |
|
92 |
// adaptation flags
|
93 |
#define DISCON_IND 0x80 |
94 |
#define RAND_ACC_IND 0x40 |
95 |
#define ES_PRI_IND 0x20 |
96 |
#define PCR_FLAG 0x10 |
97 |
#define OPCR_FLAG 0x08 |
98 |
#define SPLICE_FLAG 0x04 |
99 |
#define TRANS_PRIV 0x02 |
100 |
#define ADAP_EXT_FLAG 0x01 |
101 |
|
102 |
// adaptation extension flags
|
103 |
#define LTW_FLAG 0x80 |
104 |
#define PIECE_RATE 0x40 |
105 |
#define SEAM_SPLICE 0x20 |
106 |
|
107 |
|
108 |
#define MAX_PLENGTH 0xFFFF |
109 |
#define MMAX_PLENGTH (8*MAX_PLENGTH) |
110 |
|
111 |
#ifdef __cplusplus
|
112 |
extern "C" { |
113 |
#endif /* __cplusplus */ |
114 |
|
115 |
#define P2P_LENGTH 2048 |
116 |
|
117 |
enum{NOPES, AUDIO, VIDEO};
|
118 |
|
119 |
typedef struct p2pstruct { |
120 |
int found;
|
121 |
uint8_t buf[MMAX_PLENGTH]; |
122 |
uint8_t cid; |
123 |
uint32_t plength; |
124 |
uint8_t plen[2];
|
125 |
uint8_t flag1; |
126 |
uint8_t flag2; |
127 |
uint8_t hlength; |
128 |
uint8_t pts[5];
|
129 |
int mpeg;
|
130 |
uint8_t check; |
131 |
int fd1;
|
132 |
int fd2;
|
133 |
int es;
|
134 |
int filter;
|
135 |
int which;
|
136 |
int done;
|
137 |
int repack;
|
138 |
uint16_t bigend_repack; |
139 |
void (*func)(uint8_t *buf, int count, struct p2pstruct *p); |
140 |
int startv;
|
141 |
int starta;
|
142 |
int64_t apts; |
143 |
int64_t vpts; |
144 |
uint16_t pid; |
145 |
uint16_t pida; |
146 |
uint16_t pidv; |
147 |
uint8_t acounter; |
148 |
uint8_t vcounter; |
149 |
uint8_t count0; |
150 |
uint8_t count1; |
151 |
void *data;
|
152 |
} p2p; |
153 |
|
154 |
|
155 |
uint32_t trans_pts_dts(uint8_t *pts); |
156 |
int write_ts_header(uint16_t pid, uint8_t *counter, int pes_start, |
157 |
uint8_t *buf, uint8_t length); |
158 |
uint16_t get_pid(uint8_t *pid); |
159 |
void init_p2p(p2p *p, void (*func)(uint8_t *buf, int count, p2p *p), |
160 |
int repack);
|
161 |
void get_pes (uint8_t *buf, int count, p2p *p, void (*func)(p2p *p)); |
162 |
void get_pes (uint8_t *buf, int count, p2p *p, void (*func)(p2p *p)); |
163 |
void pes_repack(p2p *p);
|
164 |
void setup_pes2ts( p2p *p, uint32_t pida, uint32_t pidv,
|
165 |
void (*ts_write)(uint8_t *buf, int count, p2p *p)); |
166 |
void kpes_to_ts( p2p *p,uint8_t *buf ,int count ); |
167 |
void setup_ts2pes( p2p *pa, p2p *pv, uint32_t pida, uint32_t pidv,
|
168 |
void (*pes_write)(uint8_t *buf, int count, p2p *p)); |
169 |
void kts_to_pes( p2p *p, uint8_t *buf);
|
170 |
void pes_repack(p2p *p);
|
171 |
void extract_from_pes(int fdin, int fdout, uint8_t id, int es); |
172 |
int64_t pes_dmx(int fdin, int fdouta, int fdoutv, int es); |
173 |
void pes_to_ts2( int fdin, int fdout, uint16_t pida, uint16_t pidv); |
174 |
void ts_to_pes( int fdin, uint16_t pida, uint16_t pidv, int pad); |
175 |
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr); |
176 |
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr); |
177 |
int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr); |
178 |
|
179 |
|
180 |
//instant repack
|
181 |
|
182 |
typedef struct ipack_s { |
183 |
int size;
|
184 |
int size_orig;
|
185 |
int found;
|
186 |
int ps;
|
187 |
int has_ai;
|
188 |
int has_vi;
|
189 |
AudioInfo ai; |
190 |
VideoInfo vi; |
191 |
uint8_t *buf; |
192 |
uint8_t cid; |
193 |
uint32_t plength; |
194 |
uint8_t plen[2];
|
195 |
uint8_t flag1; |
196 |
uint8_t flag2; |
197 |
uint8_t hlength; |
198 |
uint8_t pts[5];
|
199 |
uint8_t last_pts[5];
|
200 |
int mpeg;
|
201 |
uint8_t check; |
202 |
int which;
|
203 |
int done;
|
204 |
void *data;
|
205 |
void (*func)(uint8_t *buf, int size, void *priv); |
206 |
int count;
|
207 |
int start;
|
208 |
int fd;
|
209 |
} ipack; |
210 |
|
211 |
void instant_repack (uint8_t *buf, int count, ipack *p); |
212 |
void init_ipack(ipack *p, int size, |
213 |
void (*func)(uint8_t *buf, int size, void *priv), |
214 |
int pad);
|
215 |
void free_ipack(ipack * p);
|
216 |
void send_ipack(ipack *p);
|
217 |
void reset_ipack(ipack *p);
|
218 |
void ps_pes(ipack *p);
|
219 |
// use with ipack structure, repack size and callback func
|
220 |
|
221 |
int64_t ts_demux(int fd_in, int fdv_out,int fda_out,uint16_t pida, |
222 |
uint16_t pidv, int es);
|
223 |
|
224 |
void ts2es(int fdin, uint16_t pidv); |
225 |
void insert_pat_pmt( int fdin, int fdout); |
226 |
void change_aspect(int fdin, int fdout, int aspect); |
227 |
|
228 |
#ifdef __cplusplus
|
229 |
} |
230 |
#endif /* __cplusplus */ |
231 |
|
232 |
#endif /* _TS_TRANSFORM_H_*/ |
233 |
|
234 |
|
235 |
|