Mercurial > mplayer.hg
annotate libvo/vo_mpegpes.c @ 8653:5af3d90a8f6b
NetWM fs. switching cleanup
patch by Filip Kalinski <filon@pld.org.pl>
author | arpi |
---|---|
date | Mon, 30 Dec 2002 00:47:43 +0000 |
parents | 00326905484b |
children | 0694a2fba3dd |
rev | line source |
---|---|
5059 | 1 // Don't change for DVB card, it must be 2048 |
1876 | 2 #define PES_MAX_SIZE 2048 |
5059 | 3 |
1876 | 4 /* |
5 * Based on: | |
6 * | |
7 * test_av.c - Test program for new API | |
8 * | |
9 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de> | |
10 * & Marcus Metzler <marcus@convergence.de> | |
11 * for convergence integrated media GmbH | |
12 * | |
13 * libav - MPEG-PS multiplexer, part of ffmpeg | |
14 * Copyright Gerard Lantau (see http://ffmpeg.sf.net) | |
15 * | |
16 */ | |
1871 | 17 |
6239 | 18 #include "config.h" |
1871 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
22 #include <errno.h> |
1876 | 23 #include <sys/types.h> |
24 #include <sys/stat.h> | |
25 #include <fcntl.h> | |
6239 | 26 #include <unistd.h> |
1876 | 27 |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
28 #include "mp_msg.h" |
8594 | 29 #ifdef HAVE_DVB_HEAD |
30 #define HAVE_DVB 1 | |
31 #endif | |
1876 | 32 #ifdef HAVE_DVB |
8594 | 33 #ifndef HAVE_DVB_HEAD |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
34 #include <sys/poll.h> |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
35 |
1876 | 36 #include <sys/ioctl.h> |
37 #include <stdio.h> | |
38 #include <time.h> | |
39 | |
40 #include <ost/dmx.h> | |
41 #include <ost/frontend.h> | |
42 #include <ost/sec.h> | |
43 #include <ost/video.h> | |
44 #include <ost/audio.h> | |
45 | |
8594 | 46 #else |
47 #define true 1 | |
48 #define false 0 | |
49 #include <sys/poll.h> | |
50 | |
51 #include <sys/ioctl.h> | |
52 #include <stdio.h> | |
53 #include <time.h> | |
54 | |
55 #include <linux/dvb/dmx.h> | |
56 #include <linux/dvb/frontend.h> | |
57 #include <linux/dvb/video.h> | |
58 #include <linux/dvb/audio.h> | |
59 #endif | |
1876 | 60 #endif |
61 | |
1871 | 62 #include "config.h" |
63 #include "video_out.h" | |
64 #include "video_out_internal.h" | |
65 | |
1872 | 66 int vo_mpegpes_fd=-1; |
1876 | 67 int vo_mpegpes_fd2=-1; |
1872 | 68 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
69 static vo_info_t info = |
1871 | 70 { |
1876 | 71 #ifdef HAVE_DVB |
72 "Mpeg-PES to DVB card", | |
73 #else | |
1871 | 74 "Mpeg-PES file", |
1876 | 75 #endif |
76 "mpegpes", | |
1871 | 77 "A'rpi", |
78 "" | |
79 }; | |
80 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
81 LIBVO_EXTERN (mpegpes) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
82 |
1871 | 83 static uint32_t |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6273
diff
changeset
|
84 config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format) |
1871 | 85 { |
1876 | 86 #ifdef HAVE_DVB |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
87 switch(s_height){ |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
88 case 288: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
89 case 576: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
90 case 240: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
91 case 480: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
92 break; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
93 default: |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
94 mp_msg(MSGT_VO,MSGL_ERR,"DVB: height=%d not supported (try 240/480 (ntsc) or 288/576 (pal)\n",s_height); |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
95 return -1; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
96 } |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
97 #endif |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
98 return 0; |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
99 } |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
100 |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
101 static uint32_t preinit(const char *arg){ |
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
102 #ifdef HAVE_DVB |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
103 if(!arg){ |
1876 | 104 //|O_NONBLOCK |
8594 | 105 #ifndef HAVE_DVB_HEAD |
1876 | 106 if((vo_mpegpes_fd = open("/dev/ost/video",O_RDWR)) < 0){ |
107 perror("DVB VIDEO DEVICE: "); | |
108 return -1; | |
109 } | |
110 if((vo_mpegpes_fd2 = open("/dev/ost/audio",O_RDWR|O_NONBLOCK)) < 0){ | |
111 perror("DVB AUDIO DEVICE: "); | |
112 return -1; | |
113 } | |
8594 | 114 #else |
115 if((vo_mpegpes_fd = open("/dev/dvb/adapter0/video0",O_RDWR)) < 0){ | |
116 perror("DVB VIDEO DEVICE: "); | |
117 return -1; | |
118 } | |
119 if((vo_mpegpes_fd2 = open("/dev/dvb/adapter0/audio0",O_RDWR|O_NONBLOCK)) < 0){ | |
120 perror("DVB AUDIO DEVICE: "); | |
121 return -1; | |
122 } | |
123 #endif | |
1876 | 124 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){ |
125 perror("DVB VIDEO SET BLANK: "); | |
126 return -1; | |
127 } | |
128 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){ | |
129 perror("DVB VIDEO SELECT SOURCE: "); | |
130 return -1; | |
131 } | |
132 #if 1 | |
133 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)){ | |
134 perror("DVB AUDIO SELECT SOURCE: "); | |
135 return -1; | |
136 } | |
137 if ( (ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0)){ | |
138 perror("DVB AUDIO PLAY: "); | |
139 return -1; | |
140 } | |
141 #else | |
142 if ( (ioctl(vo_mpegpes_fd2,AUDIO_STOP,0) < 0)){ | |
143 perror("DVB AUDIO STOP: "); | |
144 return -1; | |
145 } | |
146 #endif | |
147 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){ | |
148 perror("DVB VIDEO PLAY: "); | |
149 return -1; | |
150 } | |
7860 | 151 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, true) < 0)){ |
1876 | 152 perror("DVB AUDIO SET AV SYNC: "); |
153 return -1; | |
154 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
155 // if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, false) < 0)){ |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
156 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, true) < 0)){ |
1876 | 157 perror("DVB AUDIO SET MUTE: "); |
158 return -1; | |
159 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
160 return 0; |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
161 } |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
162 #endif |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
163 vo_mpegpes_fd=open(arg ? arg : "grab.mpg",O_WRONLY|O_CREAT,0666); |
1872 | 164 if(vo_mpegpes_fd<0){ |
165 perror("vo_mpegpes"); | |
166 return -1; | |
167 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
168 vo_mpegpes_fd2=vo_mpegpes_fd; |
1871 | 169 return 0; |
170 } | |
171 | |
172 | |
173 static void draw_osd(void) | |
174 { | |
175 } | |
176 | |
1876 | 177 |
1872 | 178 static void my_write(unsigned char* data,int len){ |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
179 #ifdef HAVE_DVB |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
180 #define NFD 2 |
1876 | 181 struct pollfd pfd[NFD]; |
182 | |
183 // printf("write %d bytes \n",len); | |
184 | |
185 pfd[0].fd = vo_mpegpes_fd; | |
186 pfd[0].events = POLLOUT; | |
187 | |
188 pfd[1].fd = vo_mpegpes_fd2; | |
189 pfd[1].events = POLLOUT; | |
190 | |
1872 | 191 while(len>0){ |
1876 | 192 if (poll(pfd,NFD,1)){ |
193 if (pfd[0].revents & POLLOUT){ | |
194 int ret=write(vo_mpegpes_fd,data,len); | |
195 // printf("ret=%d \n",ret); | |
196 if(ret<=0){ | |
197 perror("write"); | |
198 usleep(0); | |
199 } else { | |
200 len-=ret; data+=ret; | |
201 } | |
202 } else usleep(1000); | |
203 } | |
1872 | 204 } |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
205 |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
206 #else |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
207 write(vo_mpegpes_fd,data,len); // write to file |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
208 #endif |
1872 | 209 } |
1871 | 210 |
1876 | 211 static unsigned char pes_header[PES_MAX_SIZE]; |
212 | |
2706 | 213 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ |
4306 | 214 int ptslen=timestamp?5:1; |
1876 | 215 |
4306 | 216 // startcode: |
1876 | 217 pes_header[0]=pes_header[1]=0; |
218 pes_header[2]=id>>8; pes_header[3]=id&255; | |
219 | |
4306 | 220 while(len>0){ |
221 int payload_size=len; // data + PTS | |
222 if(6+ptslen+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-(6+ptslen); | |
1876 | 223 |
224 // construct PES header: (code from ffmpeg's libav) | |
225 // packetsize: | |
4306 | 226 pes_header[4]=(ptslen+payload_size)>>8; |
227 pes_header[5]=(ptslen+payload_size)&255; | |
228 | |
229 if(ptslen==5){ | |
230 int x; | |
1876 | 231 // presentation time stamp: |
232 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1; | |
233 pes_header[6]=x; | |
234 x=((((timestamp >> 15) & 0x7fff) << 1) | 1); | |
235 pes_header[7]=x>>8; pes_header[8]=x&255; | |
236 x=((((timestamp) & 0x7fff) << 1) | 1); | |
237 pes_header[9]=x>>8; pes_header[10]=x&255; | |
4306 | 238 } else { |
239 // stuffing and header bits: | |
240 pes_header[6]=0x0f; | |
241 } | |
242 | |
243 memcpy(&pes_header[6+ptslen],data,payload_size); | |
244 my_write(pes_header,6+ptslen+payload_size); | |
1876 | 245 |
246 len-=payload_size; data+=payload_size; | |
4306 | 247 ptslen=1; // store PTS only once, at first packet! |
1876 | 248 } |
249 | |
250 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | |
251 | |
252 } | |
253 | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
254 void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){ |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
255 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
256 int ptslen=timestamp?5:0; |
2706 | 257 |
4306 | 258 // startcode: |
2706 | 259 pes_header[0]=pes_header[1]=0; |
260 pes_header[2]=1; pes_header[3]=0xBD; | |
261 | |
262 while(len>=4){ | |
263 int payload_size; | |
264 | |
265 payload_size=PES_MAX_SIZE-6-20; // max possible data len | |
266 if(payload_size>len) payload_size=len; | |
267 payload_size&=(~3); // align! | |
268 | |
269 //if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6; | |
270 | |
271 // packetsize: | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
272 pes_header[4]=(payload_size+3+ptslen+7)>>8; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
273 pes_header[5]=(payload_size+3+ptslen+7)&255; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
274 |
2706 | 275 // stuffing: |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
276 // TTCCxxxx CC=css TT=type: 1=STD 0=mpeg1 2=vob |
2706 | 277 pes_header[6]=0x81; |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
278 |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
279 // FFxxxxxx FF=pts flags=2 vs 0 |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
280 pes_header[7]=ptslen ? 0x80 : 0; |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
281 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
282 // hdrlen: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
283 pes_header[8]=ptslen; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
284 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
285 if(ptslen){ |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
286 int x; |
2706 | 287 // presentation time stamp: |
288 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1; | |
289 pes_header[9]=x; | |
290 x=((((timestamp >> 15) & 0x7fff) << 1) | 1); | |
291 pes_header[10]=x>>8; pes_header[11]=x&255; | |
292 x=((((timestamp) & 0x7fff) << 1) | 1); | |
293 pes_header[12]=x>>8; pes_header[13]=x&255; | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
294 } |
2706 | 295 |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
296 // ============ LPCM header: (7 bytes) ================= |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
297 // Info by mocm@convergence.de |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
298 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
299 // ID: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
300 pes_header[ptslen+9]=id; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
301 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
302 // number of frames: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
303 pes_header[ptslen+10]=0x07; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
304 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
305 // first acces unit pointer, i.e. start of audio frame: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
306 pes_header[ptslen+11]=0x00; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
307 pes_header[ptslen+12]=0x04; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
308 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
309 // audio emphasis on-off 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
310 // audio mute on-off 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
311 // reserved 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
312 // audio frame number 5 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
313 pes_header[ptslen+13]=0x0C; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
314 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
315 // quantization word length 2 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
316 // audio sampling frequency (48khz = 0, 96khz = 1) 2 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
317 // reserved 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
318 // number of audio channels - 1 (e.g. stereo = 1) 3 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
319 pes_header[ptslen+14]=1|(freq_id<<4); |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
320 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
321 // dynamic range control (0x80 if off) |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
322 pes_header[ptslen+15]=0x80; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
323 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
324 memcpy(&pes_header[6+3+ptslen+7],data,payload_size); |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
325 my_write(pes_header,6+3+ptslen+7+payload_size); |
2706 | 326 |
327 len-=payload_size; data+=payload_size; | |
4306 | 328 ptslen=0; // store PTS only once, at first packet! |
2706 | 329 } |
330 | |
331 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | |
332 | |
333 } | |
334 | |
335 | |
1871 | 336 static uint32_t draw_frame(uint8_t * src[]) |
337 { | |
1872 | 338 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
5877
93de400ad48e
libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents:
5844
diff
changeset
|
339 send_pes_packet(p->data,p->size,p->id,(p->timestamp>0)?p->timestamp:vo_pts); // video data |
1871 | 340 return 0; |
341 } | |
342 | |
1935 | 343 static void flip_page (void) |
344 { | |
345 } | |
346 | |
347 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0) | |
348 { | |
349 return 0; | |
350 } | |
351 | |
352 | |
1871 | 353 static uint32_t |
354 query_format(uint32_t format) | |
355 { | |
5566 | 356 if(format==IMGFMT_MPEGPES) return 3|VFCAP_TIMER; |
1871 | 357 return 0; |
358 } | |
359 | |
360 static void | |
361 uninit(void) | |
362 { | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
363 if(vo_mpegpes_fd2>=0 && vo_mpegpes_fd2!=vo_mpegpes_fd) close(vo_mpegpes_fd2); |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
364 vo_mpegpes_fd2=-1; |
1876 | 365 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;} |
1871 | 366 } |
367 | |
368 | |
369 static void check_events(void) | |
370 { | |
371 } | |
372 | |
4596 | 373 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 374 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
375 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
376 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
377 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
378 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
379 return VO_NOTIMPL; |
4352 | 380 } |