Mercurial > mplayer.hg
annotate libvo/vo_mpegpes.c @ 17997:7bb7f54b4cfa
increasing sync tag to 1.15 after update by Diego
author | gabrov |
---|---|
date | Thu, 30 Mar 2006 14:50:16 +0000 |
parents | fd51fd1ff231 |
children | 3b839a8d297a |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
83 static int |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
84 config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, 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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
101 static int preinit(const char *arg){ |
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
|
102 #ifdef HAVE_DVB |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
103 int card = 0; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
104 char vo_file[30], ao_file[30], *tmp; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
105 |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
106 if(arg != NULL){ |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
107 if((tmp = strstr(arg, "card=")) != NULL) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
108 card = atoi(&tmp[5]); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
109 if((card < 1) || (card > 4)) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
110 mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
111 return -1; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
112 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
113 card--; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
114 arg = NULL; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
115 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
116 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
117 |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
118 if(!arg){ |
1876 | 119 //|O_NONBLOCK |
8594 | 120 #ifndef HAVE_DVB_HEAD |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
121 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/ost/video+audio\n"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
122 sprintf(vo_file, "/dev/ost/video"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
123 sprintf(ao_file, "/dev/ost/audio"); |
8594 | 124 #else |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
125 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/dvb/adapter%d/video0+audio0\n", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
126 sprintf(vo_file, "/dev/dvb/adapter%d/video0", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
127 sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
128 #endif |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
129 if((vo_mpegpes_fd = open(vo_file,O_RDWR)) < 0){ |
8594 | 130 perror("DVB VIDEO DEVICE: "); |
131 return -1; | |
132 } | |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
133 if((vo_mpegpes_fd2 = open(ao_file,O_RDWR|O_NONBLOCK)) < 0){ |
8594 | 134 perror("DVB AUDIO DEVICE: "); |
135 return -1; | |
136 } | |
1876 | 137 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){ |
138 perror("DVB VIDEO SET BLANK: "); | |
139 return -1; | |
140 } | |
141 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){ | |
142 perror("DVB VIDEO SELECT SOURCE: "); | |
143 return -1; | |
144 } | |
145 #if 1 | |
146 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)){ | |
147 perror("DVB AUDIO SELECT SOURCE: "); | |
148 return -1; | |
149 } | |
150 if ( (ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0)){ | |
151 perror("DVB AUDIO PLAY: "); | |
152 return -1; | |
153 } | |
154 #else | |
155 if ( (ioctl(vo_mpegpes_fd2,AUDIO_STOP,0) < 0)){ | |
156 perror("DVB AUDIO STOP: "); | |
157 return -1; | |
158 } | |
159 #endif | |
160 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){ | |
161 perror("DVB VIDEO PLAY: "); | |
162 return -1; | |
163 } | |
7860 | 164 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, true) < 0)){ |
1876 | 165 perror("DVB AUDIO SET AV SYNC: "); |
166 return -1; | |
167 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
168 // 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
|
169 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, true) < 0)){ |
1876 | 170 perror("DVB AUDIO SET MUTE: "); |
171 return -1; | |
172 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
173 return 0; |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
174 } |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
175 #endif |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
176 arg = (arg ? arg : "grab.mpg"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
177 mp_msg(MSGT_VO,MSGL_INFO, "Saving PES stream to %s\n", arg); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
178 vo_mpegpes_fd=open(arg,O_WRONLY|O_CREAT,0666); |
1872 | 179 if(vo_mpegpes_fd<0){ |
180 perror("vo_mpegpes"); | |
181 return -1; | |
182 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
183 vo_mpegpes_fd2=vo_mpegpes_fd; |
1871 | 184 return 0; |
185 } | |
186 | |
187 | |
188 static void draw_osd(void) | |
189 { | |
190 } | |
191 | |
1876 | 192 |
1872 | 193 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
|
194 #ifdef HAVE_DVB |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
195 #define NFD 2 |
1876 | 196 struct pollfd pfd[NFD]; |
197 | |
198 // printf("write %d bytes \n",len); | |
199 | |
200 pfd[0].fd = vo_mpegpes_fd; | |
201 pfd[0].events = POLLOUT; | |
202 | |
203 pfd[1].fd = vo_mpegpes_fd2; | |
204 pfd[1].events = POLLOUT; | |
205 | |
1872 | 206 while(len>0){ |
1876 | 207 if (poll(pfd,NFD,1)){ |
208 if (pfd[0].revents & POLLOUT){ | |
209 int ret=write(vo_mpegpes_fd,data,len); | |
210 // printf("ret=%d \n",ret); | |
211 if(ret<=0){ | |
212 perror("write"); | |
213 usleep(0); | |
214 } else { | |
215 len-=ret; data+=ret; | |
216 } | |
217 } else usleep(1000); | |
218 } | |
1872 | 219 } |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
220 |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
221 #else |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
222 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
|
223 #endif |
1872 | 224 } |
1871 | 225 |
1876 | 226 static unsigned char pes_header[PES_MAX_SIZE]; |
227 | |
2706 | 228 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ |
4306 | 229 int ptslen=timestamp?5:1; |
1876 | 230 |
4306 | 231 // startcode: |
1876 | 232 pes_header[0]=pes_header[1]=0; |
233 pes_header[2]=id>>8; pes_header[3]=id&255; | |
234 | |
4306 | 235 while(len>0){ |
236 int payload_size=len; // data + PTS | |
237 if(6+ptslen+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-(6+ptslen); | |
1876 | 238 |
239 // construct PES header: (code from ffmpeg's libav) | |
240 // packetsize: | |
4306 | 241 pes_header[4]=(ptslen+payload_size)>>8; |
242 pes_header[5]=(ptslen+payload_size)&255; | |
243 | |
244 if(ptslen==5){ | |
245 int x; | |
1876 | 246 // presentation time stamp: |
247 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1; | |
248 pes_header[6]=x; | |
249 x=((((timestamp >> 15) & 0x7fff) << 1) | 1); | |
250 pes_header[7]=x>>8; pes_header[8]=x&255; | |
251 x=((((timestamp) & 0x7fff) << 1) | 1); | |
252 pes_header[9]=x>>8; pes_header[10]=x&255; | |
4306 | 253 } else { |
254 // stuffing and header bits: | |
255 pes_header[6]=0x0f; | |
256 } | |
257 | |
258 memcpy(&pes_header[6+ptslen],data,payload_size); | |
259 my_write(pes_header,6+ptslen+payload_size); | |
1876 | 260 |
261 len-=payload_size; data+=payload_size; | |
4306 | 262 ptslen=1; // store PTS only once, at first packet! |
1876 | 263 } |
264 | |
265 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | |
266 | |
267 } | |
268 | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
269 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
|
270 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
271 int ptslen=timestamp?5:0; |
2706 | 272 |
4306 | 273 // startcode: |
2706 | 274 pes_header[0]=pes_header[1]=0; |
275 pes_header[2]=1; pes_header[3]=0xBD; | |
276 | |
277 while(len>=4){ | |
278 int payload_size; | |
279 | |
280 payload_size=PES_MAX_SIZE-6-20; // max possible data len | |
281 if(payload_size>len) payload_size=len; | |
282 payload_size&=(~3); // align! | |
283 | |
284 //if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6; | |
285 | |
286 // packetsize: | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
287 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
|
288 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
|
289 |
2706 | 290 // stuffing: |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
291 // TTCCxxxx CC=css TT=type: 1=STD 0=mpeg1 2=vob |
2706 | 292 pes_header[6]=0x81; |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
293 |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
294 // 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
|
295 pes_header[7]=ptslen ? 0x80 : 0; |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
296 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
297 // hdrlen: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
298 pes_header[8]=ptslen; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
299 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
300 if(ptslen){ |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
301 int x; |
2706 | 302 // presentation time stamp: |
303 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1; | |
304 pes_header[9]=x; | |
305 x=((((timestamp >> 15) & 0x7fff) << 1) | 1); | |
306 pes_header[10]=x>>8; pes_header[11]=x&255; | |
307 x=((((timestamp) & 0x7fff) << 1) | 1); | |
308 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
|
309 } |
2706 | 310 |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
311 // ============ LPCM header: (7 bytes) ================= |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
312 // Info by mocm@convergence.de |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
313 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
314 // ID: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
315 pes_header[ptslen+9]=id; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
316 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
317 // number of frames: |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
318 pes_header[ptslen+10]=0x07; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
319 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
320 // 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
|
321 pes_header[ptslen+11]=0x00; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
322 pes_header[ptslen+12]=0x04; |
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 // audio emphasis on-off 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
325 // audio mute on-off 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
326 // reserved 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
327 // audio frame number 5 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
328 pes_header[ptslen+13]=0x0C; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
329 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
330 // quantization word length 2 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
331 // 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
|
332 // reserved 1 bit |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
333 // 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
|
334 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
|
335 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
336 // dynamic range control (0x80 if off) |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
337 pes_header[ptslen+15]=0x80; |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
338 |
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
339 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
|
340 my_write(pes_header,6+3+ptslen+7+payload_size); |
2706 | 341 |
342 len-=payload_size; data+=payload_size; | |
4306 | 343 ptslen=0; // store PTS only once, at first packet! |
2706 | 344 } |
345 | |
346 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | |
347 | |
348 } | |
349 | |
350 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
351 static int draw_frame(uint8_t * src[]) |
1871 | 352 { |
1872 | 353 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
|
354 send_pes_packet(p->data,p->size,p->id,(p->timestamp>0)?p->timestamp:vo_pts); // video data |
1871 | 355 return 0; |
356 } | |
357 | |
1935 | 358 static void flip_page (void) |
359 { | |
360 } | |
361 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
362 static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0) |
1935 | 363 { |
364 return 0; | |
365 } | |
366 | |
367 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
368 static int |
1871 | 369 query_format(uint32_t format) |
370 { | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
371 if(format==IMGFMT_MPEGPES) return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER; |
1871 | 372 return 0; |
373 } | |
374 | |
375 static void | |
376 uninit(void) | |
377 { | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
378 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
|
379 vo_mpegpes_fd2=-1; |
1876 | 380 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;} |
1871 | 381 } |
382 | |
383 | |
384 static void check_events(void) | |
385 { | |
386 } | |
387 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
388 static int control(uint32_t request, void *data, ...) |
4352 | 389 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
390 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
391 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
392 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
393 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
394 return VO_NOTIMPL; |
4352 | 395 } |