Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: example program
>
> Justin Cormack wrote:
> > Has anyone got a short demo bit of code that just reads the transport
> > stream? It would be really helpful. Or even just a sketch. It would be
> > useful in the docs.
>
> just copy'n'paste the code fragment in szap.c, set_demux() for vdr=1,
> this sets up the demux to stream a TS out of the dvr device, you can do
> something simple like
>
> $ cat /dev/dvb/adapter0/dvr > stream.ts
>
> to write this into a file. Note that as soon you close the demux file
> descriptor the stream will stop.
ok thanks, mostly there I think (still trying to sort out my oops of
yesterday. Basically I cant get dvbstream not to oops on any machine so I
thought I would go back to basics).
I cant get tzap to tune though, with config file set to
BBC-1:50583333:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601
(which I think is right for Crystal Palace) I get
./tzap BBC-1
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
tuning to 50583333 Hz
status 01 | signal 2d2d | snr 0000 | ber 0000ffff | unc 00000000 |
status 01 | signal 2d2d | snr 0000 | ber 0000ffff | unc 00000000 |
status 01 | signal 2d2d | snr 0000 | ber 0000ffff | unc 00000000 |
status 01 | signal 2d2d | snr 0000 | ber 0000ffff | unc 00000000 |
>
> > Also, none of the dvbtools compile on todays DVB cvs, as all the type names
> > seem to have changed.
>
> what do you mean by dvbtools? The tools in the DVB/apps/ directory? Or
> Dave Chapman's dvbstream?
yes dvbstream.
Does below look about right then, minus the missing tuning?
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
#define FRONTEND "/dev/dvb/adapter0/frontend0"
#define DEMUX "/dev/dvb/adapter0/demux0"
#define DVR "/dev/dvb/adapter0/dvr0"
int main(int argc, char ** argv) {
struct dvb_frontend_info info;
struct dvb_frontend_parameters frontend;
struct dmx_pes_filter_params pesfilter;
int fd, fdd, fdts;
uint16_t strength, snr;
fe_status_t status;
int buffersize = 64 * 1024;
char buffer[1024];
int pid = 0;
if ((fd = open (FRONTEND, O_RDWR)) < 0) {
perror ("frontend open failed");
return -1;
}
ioctl (fd, FE_GET_INFO, &info);
fprintf(stderr, "card found: %s\n", info.name);
if (info.type != FE_OFDM)
fprintf(stderr, "warning: this program understands DVB-T best\n");
/* add tuning here */
/* printf ("tuning to %i Hz\n", frontend->frequency);
if (ioctl(fd, FE_SET_FRONTEND, &frontend) < 0) {
PERROR("ioctl FE_SET_FRONTEND failed");
close(fd);
return -1;
}
*/
ioctl(fd, FE_READ_SIGNAL_STRENGTH, &strength);
ioctl(fd, FE_READ_SNR, &snr);
fprintf(stderr, "signal strength %d SNR %d\n", strength, snr);
ioctl(fd, FE_READ_STATUS, &status);
if (status & FE_HAS_LOCK)
fprintf(stderr, "FE_HAS_LOCK");
if ((fdd = open(DEMUX, O_RDWR)) < 0) {
perror ("demux open failed");
return -1;
}
if (ioctl(fdd, DMX_SET_BUFFER_SIZE, buffersize) == -1)
perror("DMX_SET_BUFFER_SIZE failed");
pesfilter.pid = pid; // ?
pesfilter.input = DMX_IN_FRONTEND;
pesfilter.output = DMX_OUT_TS_TAP;
pesfilter.pes_type = DMX_PES_VIDEO;
pesfilter.flags = DMX_IMMEDIATE_START;
if (ioctl(fdd, DMX_SET_PES_FILTER, &pesfilter) == -1) {
fprintf(stderr, "DMX_SET_PES_FILTER failed "
"(PID = 0x%04x): %d %m\n", pid, errno);
return -1;
}
if ((fdts = open(DVR, O_RDONLY)) < 0) {
perror ("dvr open failed");
return -1;
}
while (read(fdts, buffer, 1024) > 0)
write(STDOUT_FILENO, buffer, 1024);
return 0;
}
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index