Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DVB-SI and DVB-Text
Hi!
On Thu, 17 Aug 2000 Robert.Schneider@lotus.com wrote:
> I would like to implement showing the running and next program in VDR.
>[...]
> Could someone point me in the right direction on how to tell the driver to
> forward those packages to me?
Here is my implementation for your request (it was written in 10 mins, so
be indulgent). The code sets up a bitfilter for actual TS EIT
present/following, and dumps to the stdout any data received (so a lot of
stuff missing, e.g. CRC check, section format check, etc...) If you want
to "decode" the EIT table, I recommend you to get EN 300 468 at ETSI. To
compile the source, make sure you use -I to extend include search path
with your DVB/driver source (where dvb_v4l.h is).. before you start it
tune in a channel.
Bye,
David
---- sample source begins here --------
/* make sure to compile the source with -I/where/you/have/the/DVB/driver
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include "dvb_v4l.h"
#include "dvb_comcode.h"
void main()
{
unsigned char bitfilter_dev[]="/dev/vbi";
struct bitfilter BitFilter;
struct pollfd pfd;
int fsi,cnt,seclen;
int filter_handle=0;
unsigned char filterruns;
unsigned char buf[65536]; /* data buffer */
/* open DVB bitfilter device - /dev/vbi (or /dev/video is good too) */
if((fsi=open(bitfilter_dev, O_RDWR))<0)
{
fprintf(stderr,"Failed to open DVB bitfilter device: '%s'\n",
bitfilter_dev);
fprintf(stderr,"Error is"); perror(" ");
return;
}
/* setup bitfilter for actual TS, EIT present/following, for continouous
* mode
*/
/* fill bitfilter struct */
BitFilter.pid=0x0012; /* EIT_PID */
for(cnt=0;cnt<16;cnt++) BitFilter.data[cnt]=0; /* erase filter data */
BitFilter.data[0]=0x4EFF; /* set filter first byte - table_id 0x4E */
BitFilter.mode=SECTION_CONTINUOS;
BitFilter.handle=filter_handle;
BitFilter.flags=FILTER_MEM;
/* setup bitfilter */
if(ioctl(fsi, VIDIOCSBITFILTER, &BitFilter)<0)
{
fprintf(stderr,"ioctl VIDIOCSBITFILTER failed\n");
fprintf(stderr,"Error is"); perror(" ");
close(fsi); return;
}
filterruns=1;
while(filterruns)
{
/* wait data become ready from the bitfilter */
pfd.fd=fsi;
pfd.events=POLLIN;
if(poll(&pfd,1,5000000)!=0) /* timeout is 5 secs */
{
/* read section */
read(fsi, buf, 8);
seclen=(buf[6]<<8)|buf[7];
read(fsi, buf, seclen);
/* EIT table is in buf... here you have to process the table */
/* for now just dump it to the stdout */
seclen=((buf[1]&0x0f)<<8)|buf[2];
for(cnt=0;cnt<seclen;cnt++)
/* print chars only between 32-127 */
printf("%c",buf[cnt]<32?'.':buf[cnt]>=127?'.':buf[cnt]);
printf("\n");
fflush(stdout);
}
else filterruns=0;
}
/* shutdown filter */
if(ioctl(fsi, VIDIOCSSHUTDOWNFILTER, &filter_handle)<0)
{
fprintf(stderr,"ioctl VIDIOCSSHUTDOWNFILTER failed!\n");
fprintf(stderr,"Error is"); perror(" ");
}
close(fsi);
};
---- sample source ends here --------
Home |
Main Index |
Thread Index