4 * test_av.c - Test program for new API
6 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
7 * & Marcus Metzler <marcus@convergence.de>
8 * for convergence integrated media GmbH
10 * libav - MPEG-PS multiplexer, part of ffmpeg
11 * Copyright Gerard Lantau (see http://ffmpeg.sf.net)
20 #include <sys/types.h>
33 #include <sys/ioctl.h>
38 #include <ost/frontend.h>
40 #include <ost/video.h>
41 #include <ost/audio.h>
48 #include <sys/ioctl.h>
52 #include <linux/dvb/dmx.h>
53 #include <linux/dvb/frontend.h>
54 #include <linux/dvb/video.h>
55 #include <linux/dvb/audio.h>
60 #include "video_out.h"
61 #include "video_out_internal.h"
62 #include "libmpdemux/mpeg_packetizer.h"
65 extern int vo_mpegpes_fd2
;
67 static const vo_info_t info
=
70 "Mpeg-PES to DVB card",
79 const LIBVO_EXTERN (mpegpes
)
82 config(uint32_t s_width
, uint32_t s_height
, uint32_t width
, uint32_t height
, uint32_t flags
, char *title
, uint32_t format
)
92 mp_msg(MSGT_VO
,MSGL_ERR
,"DVB: height=%d not supported (try 240/480 (ntsc) or 288/576 (pal)\n",s_height
);
99 static int preinit(const char *arg
){
102 char vo_file
[30], ao_file
[30], *tmp
;
105 if((tmp
= strstr(arg
, "card=")) != NULL
) {
106 card
= atoi(&tmp
[5]);
107 if((card
< 1) || (card
> 4)) {
108 mp_msg(MSGT_VO
, MSGL_ERR
, "DVB card number must be between 1 and 4\n");
118 #ifndef HAVE_DVB_HEAD
119 mp_msg(MSGT_VO
,MSGL_INFO
, "Opening /dev/ost/video+audio\n");
120 sprintf(vo_file
, "/dev/ost/video");
121 sprintf(ao_file
, "/dev/ost/audio");
123 mp_msg(MSGT_VO
,MSGL_INFO
, "Opening /dev/dvb/adapter%d/video0+audio0\n", card
);
124 sprintf(vo_file
, "/dev/dvb/adapter%d/video0", card
);
125 sprintf(ao_file
, "/dev/dvb/adapter%d/audio0", card
);
127 if((vo_mpegpes_fd
= open(vo_file
,O_RDWR
)) < 0){
128 perror("DVB VIDEO DEVICE: ");
131 if ( (ioctl(vo_mpegpes_fd
,VIDEO_SET_BLANK
, false) < 0)){
132 perror("DVB VIDEO SET BLANK: ");
135 if ( (ioctl(vo_mpegpes_fd
,VIDEO_SELECT_SOURCE
, VIDEO_SOURCE_MEMORY
) < 0)){
136 perror("DVB VIDEO SELECT SOURCE: ");
139 if ( (ioctl(vo_mpegpes_fd
,VIDEO_PLAY
) < 0)){
140 perror("DVB VIDEO PLAY: ");
146 arg
= (arg
? arg
: "grab.mpg");
147 mp_msg(MSGT_VO
,MSGL_INFO
, "Saving PES stream to %s\n", arg
);
148 vo_mpegpes_fd
=open(arg
,O_WRONLY
|O_CREAT
,0666);
150 perror("vo_mpegpes");
157 static void draw_osd(void)
162 static int my_write(unsigned char* data
,int len
){
166 struct pollfd pfd
[NFD
];
168 // printf("write %d bytes \n",len);
170 pfd
[0].fd
= vo_mpegpes_fd
;
171 pfd
[0].events
= POLLOUT
;
173 pfd
[1].fd
= vo_mpegpes_fd2
;
174 pfd
[1].events
= POLLOUT
;
177 if (poll(pfd
,NFD
,1)){
178 if (pfd
[0].revents
& POLLOUT
){
179 int ret
=write(vo_mpegpes_fd
,data
,len
);
180 // printf("ret=%d \n",ret);
192 write(vo_mpegpes_fd
,data
,len
); // write to file
197 void send_pes_packet(unsigned char* data
,int len
,int id
,int timestamp
){
198 send_mpeg_pes_packet (data
, len
, id
, timestamp
, 1, my_write
);
201 void send_lpcm_packet(unsigned char* data
,int len
,int id
,unsigned int timestamp
,int freq_id
){
202 send_mpeg_lpcm_packet(data
, len
, id
, timestamp
, freq_id
, my_write
);
206 static int draw_frame(uint8_t * src
[])
208 vo_mpegpes_t
*p
=(vo_mpegpes_t
*)src
[0];
209 send_pes_packet(p
->data
,p
->size
,p
->id
,(p
->timestamp
>0)?p
->timestamp
:vo_pts
); // video data
213 static void flip_page (void)
217 static int draw_slice(uint8_t *srcimg
[], int stride
[], int w
,int h
,int x0
,int y0
)
224 query_format(uint32_t format
)
226 if(format
==IMGFMT_MPEGPES
) return VFCAP_CSP_SUPPORTED
|VFCAP_CSP_SUPPORTED_BY_HW
|VFCAP_TIMER
;
233 if(vo_mpegpes_fd2
>=0 && vo_mpegpes_fd2
!=vo_mpegpes_fd
) close(vo_mpegpes_fd2
);
235 if(vo_mpegpes_fd
>=0){ close(vo_mpegpes_fd
);vo_mpegpes_fd
=-1;}
239 static void check_events(void)
243 static int control(uint32_t request
, void *data
, ...)
246 case VOCTRL_QUERY_FORMAT
:
247 return query_format(*((uint32_t*)data
));