Mercurial > mplayer.hg
annotate libvo/vo_mpegpes.c @ 27845:dedacb09ed45
Change OpenGL support to work on unmodified MinGW64
author | reimar |
---|---|
date | Sun, 02 Nov 2008 16:37:45 +0000 |
parents | bb738b9ea7c4 |
children | 7681eab10aea |
rev | line source |
---|---|
1876 | 1 /* |
2 * Based on: | |
3 * | |
4 * test_av.c - Test program for new API | |
5 * | |
6 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de> | |
7 * & Marcus Metzler <marcus@convergence.de> | |
8 * for convergence integrated media GmbH | |
9 * | |
10 * libav - MPEG-PS multiplexer, part of ffmpeg | |
11 * Copyright Gerard Lantau (see http://ffmpeg.sf.net) | |
12 * | |
13 */ | |
1871 | 14 |
6239 | 15 #include "config.h" |
1871 | 16 #include <stdio.h> |
17 #include <stdlib.h> | |
18 #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
|
19 #include <errno.h> |
1876 | 20 #include <sys/types.h> |
21 #include <sys/stat.h> | |
22 #include <fcntl.h> | |
6239 | 23 #include <unistd.h> |
1876 | 24 |
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
|
25 #include "mp_msg.h" |
27369
8598536ca4f5
Set HAVE_DVB in configure when HAVE_DVB_HEAD is defined
diego
parents:
27368
diff
changeset
|
26 |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
27 #ifdef CONFIG_DVB |
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
28 #ifndef CONFIG_DVB_HEAD |
27431
bb738b9ea7c4
Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents:
27430
diff
changeset
|
29 #include <poll.h> |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
30 |
1876 | 31 #include <sys/ioctl.h> |
32 #include <stdio.h> | |
33 #include <time.h> | |
34 | |
35 #include <ost/dmx.h> | |
36 #include <ost/frontend.h> | |
37 #include <ost/sec.h> | |
38 #include <ost/video.h> | |
39 #include <ost/audio.h> | |
40 | |
8594 | 41 #else |
42 #define true 1 | |
43 #define false 0 | |
27431
bb738b9ea7c4
Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents:
27430
diff
changeset
|
44 #include <poll.h> |
8594 | 45 |
46 #include <sys/ioctl.h> | |
47 #include <stdio.h> | |
48 #include <time.h> | |
49 | |
50 #include <linux/dvb/dmx.h> | |
51 #include <linux/dvb/frontend.h> | |
52 #include <linux/dvb/video.h> | |
53 #include <linux/dvb/audio.h> | |
54 #endif | |
1876 | 55 #endif |
56 | |
1871 | 57 #include "config.h" |
58 #include "video_out.h" | |
59 #include "video_out_internal.h" | |
19148
3b839a8d297a
simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents:
16171
diff
changeset
|
60 #include "libmpdemux/mpeg_packetizer.h" |
1871 | 61 |
1872 | 62 int vo_mpegpes_fd=-1; |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
19163
diff
changeset
|
63 extern int vo_mpegpes_fd2; |
1872 | 64 |
25216 | 65 static const vo_info_t info = |
1871 | 66 { |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
67 #ifdef CONFIG_DVB |
27368 | 68 "MPEG-PES to DVB card", |
1876 | 69 #else |
27368 | 70 "MPEG-PES file", |
1876 | 71 #endif |
72 "mpegpes", | |
1871 | 73 "A'rpi", |
74 "" | |
75 }; | |
76 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
77 const LIBVO_EXTERN (mpegpes) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7860
diff
changeset
|
78 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
79 static int |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
80 config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, char *title, uint32_t format) |
1871 | 81 { |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
82 #ifdef CONFIG_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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 } |
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 #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
|
94 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
|
95 } |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
97 static int preinit(const char *arg){ |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
98 #ifdef CONFIG_DVB |
25558
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
99 int card = -1; |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
100 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
|
101 |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
102 if(arg != NULL){ |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
103 if((tmp = strstr(arg, "card=")) != NULL) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
104 card = atoi(&tmp[5]); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
105 if((card < 1) || (card > 4)) { |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
106 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
|
107 return -1; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
108 } |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
109 card--; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
110 arg = NULL; |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
111 } |
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 |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
114 if(!arg){ |
1876 | 115 //|O_NONBLOCK |
25558
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
116 //search the first usable card |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
117 if(card==-1) { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
118 int n; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
119 for(n=0; n<4; n++) { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
120 sprintf(vo_file, "/dev/dvb/adapter%d/video0", n); |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
121 if(access(vo_file, F_OK | W_OK)==0) { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
122 card = n; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
123 break; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
124 } |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
125 } |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
126 } |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
127 if(card==-1) { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
128 mp_msg(MSGT_VO,MSGL_INFO, "Couldn't find a usable dvb video device, exiting\n"); |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
129 return -1; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
25220
diff
changeset
|
130 } |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
131 #ifndef CONFIG_DVB_HEAD |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
132 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
|
133 sprintf(vo_file, "/dev/ost/video"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
134 sprintf(ao_file, "/dev/ost/audio"); |
8594 | 135 #else |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 #endif |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
140 if((vo_mpegpes_fd = open(vo_file,O_RDWR)) < 0){ |
8594 | 141 perror("DVB VIDEO DEVICE: "); |
142 return -1; | |
143 } | |
1876 | 144 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){ |
145 perror("DVB VIDEO SET BLANK: "); | |
146 return -1; | |
147 } | |
148 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){ | |
149 perror("DVB VIDEO SELECT SOURCE: "); | |
150 return -1; | |
151 } | |
152 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){ | |
153 perror("DVB VIDEO PLAY: "); | |
154 return -1; | |
155 } | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
156 return 0; |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
157 } |
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
158 #endif |
13048
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
159 arg = (arg ? arg : "grab.mpg"); |
2f150c190f7a
user can select dvb card number to use (V3 api only)
nicodvb
parents:
8917
diff
changeset
|
160 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
|
161 vo_mpegpes_fd=open(arg,O_WRONLY|O_CREAT,0666); |
1872 | 162 if(vo_mpegpes_fd<0){ |
163 perror("vo_mpegpes"); | |
164 return -1; | |
165 } | |
1871 | 166 return 0; |
167 } | |
168 | |
169 | |
170 static void draw_osd(void) | |
171 { | |
172 } | |
173 | |
1876 | 174 |
19150 | 175 static int my_write(unsigned char* data,int len){ |
19153 | 176 int orig_len = len; |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
177 #ifdef CONFIG_DVB |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
178 #define NFD 2 |
1876 | 179 struct pollfd pfd[NFD]; |
180 | |
181 // printf("write %d bytes \n",len); | |
182 | |
183 pfd[0].fd = vo_mpegpes_fd; | |
184 pfd[0].events = POLLOUT; | |
185 | |
186 pfd[1].fd = vo_mpegpes_fd2; | |
187 pfd[1].events = POLLOUT; | |
188 | |
1872 | 189 while(len>0){ |
1876 | 190 if (poll(pfd,NFD,1)){ |
191 if (pfd[0].revents & POLLOUT){ | |
192 int ret=write(vo_mpegpes_fd,data,len); | |
193 // printf("ret=%d \n",ret); | |
194 if(ret<=0){ | |
195 perror("write"); | |
196 usleep(0); | |
197 } else { | |
198 len-=ret; data+=ret; | |
199 } | |
200 } else usleep(1000); | |
201 } | |
1872 | 202 } |
2066
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
203 |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
204 #else |
2b14cad013b7
using poll() only for DVB card - not required for file write
arpi
parents:
1986
diff
changeset
|
205 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
|
206 #endif |
19150 | 207 return orig_len; |
1872 | 208 } |
1871 | 209 |
2706 | 210 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ |
19148
3b839a8d297a
simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents:
16171
diff
changeset
|
211 send_mpeg_pes_packet (data, len, id, timestamp, 1, my_write); |
1876 | 212 } |
213 | |
4299
8e157167cee5
LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents:
2727
diff
changeset
|
214 void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){ |
19161
049c74156629
reuse send_mpeg_lpcm_packet() instead of the old packetizer
nicodvb
parents:
19153
diff
changeset
|
215 send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write); |
2706 | 216 } |
217 | |
218 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
219 static int draw_frame(uint8_t * src[]) |
1871 | 220 { |
1872 | 221 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
|
222 send_pes_packet(p->data,p->size,p->id,(p->timestamp>0)?p->timestamp:vo_pts); // video data |
1871 | 223 return 0; |
224 } | |
225 | |
1935 | 226 static void flip_page (void) |
227 { | |
228 } | |
229 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
230 static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0) |
1935 | 231 { |
232 return 0; | |
233 } | |
234 | |
235 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
236 static int |
1871 | 237 query_format(uint32_t format) |
238 { | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13048
diff
changeset
|
239 if(format==IMGFMT_MPEGPES) return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER; |
1871 | 240 return 0; |
241 } | |
242 | |
243 static void | |
244 uninit(void) | |
245 { | |
7672
e6b46875e1b9
- fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents:
7124
diff
changeset
|
246 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
|
247 vo_mpegpes_fd2=-1; |
1876 | 248 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;} |
1871 | 249 } |
250 | |
251 | |
252 static void check_events(void) | |
253 { | |
254 } | |
255 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
256 static int control(uint32_t request, void *data, ...) |
4352 | 257 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
258 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
259 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
260 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
261 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
262 return VO_NOTIMPL; |
4352 | 263 } |