#ifndef _DVB_DEMUX_H
#define _DVB_DEMUX_H
+#include <linux/dvb/dmx.h>
+
#ifdef __cplusplus
extern "C" {
#endif
int dvb_dmx_open(int adapter, int demux, unsigned verbose);
void dvb_dmx_close(int dmx_fd);
-int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr);
+int dvb_set_pesfilter(int dmxfd, int pid, dmx_pes_type_t type, dmx_output_t output, int buffersize);
int get_pmt_pid(const char *dmxdev, int sid);
#include <fcntl.h>
#include <stdlib.h> /* free */
-#include <linux/dvb/dmx.h>
#include "dvb-demux.h"
int dvb_dmx_open(int adapter, int demux, unsigned verbose)
close( dmx_fd);
}
-int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr)
+int dvb_set_pesfilter(int dmxfd, int pid, dmx_pes_type_t type, dmx_output_t output, int buffersize)
{
struct dmx_pes_filter_params pesfilter;
/* ignore this pid to allow radio services */
if (pid < 0 ||
pid >= 0x1fff ||
- (pid == 0 && pes_type != DMX_PES_OTHER))
+ (pid == 0 && type != DMX_PES_OTHER))
return 0;
- if (dvr) {
- int buffersize = 64 * 1024;
+ if (buffersize) {
if (ioctl(dmxfd, DMX_SET_BUFFER_SIZE, buffersize) == -1)
- perror("DMX_SET_BUFFER_SIZE failed");
+ perror("DMX_SET_BUFFER_SIZE failed");
}
pesfilter.pid = pid;
pesfilter.input = DMX_IN_FRONTEND;
- pesfilter.output = dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER;
- pesfilter.pes_type = pes_type;
+ pesfilter.output = output;
+ pesfilter.pes_type = type;
pesfilter.flags = DMX_IMMEDIATE_START;
if (ioctl(dmxfd, DMX_SET_PES_FILTER, &pesfilter) == -1) {
perror("opening pat demux failed");
return -1;
}
- if (set_pesfilter(pat_fd, 0, DMX_PES_OTHER, args.dvr) < 0)
+ if (dvb_set_pesfilter(pat_fd, 0, DMX_PES_OTHER,
+ args.dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER,
+ args.dvr ? 64 * 1024 : 0) < 0)
return -1;
if ((pmt_fd = open(args.demux_dev, O_RDWR)) < 0) {
perror("opening pmt demux failed");
return -1;
}
- if (set_pesfilter(pmt_fd, pmtpid, DMX_PES_OTHER, args.dvr) < 0)
+ if (dvb_set_pesfilter(pmt_fd, pmtpid, DMX_PES_OTHER,
+ args.dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER,
+ args.dvr ? 64 * 1024 : 0) < 0)
return -1;
}
PERROR("failed opening '%s'", args.demux_dev);
return -1;
}
- if (set_pesfilter(video_fd, vpid, DMX_PES_VIDEO, args.dvr) < 0)
+ printf( " dvb_set_pesfilter %d\n", vpid );
+ if (dvb_set_pesfilter(video_fd, vpid, DMX_PES_VIDEO,
+ args.dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER,
+ args.dvr ? 64 * 1024 : 0) < 0)
return -1;
}
return -1;
}
- if (set_pesfilter(audio_fd, apid, DMX_PES_AUDIO, args.dvr) < 0)
+ if (dvb_set_pesfilter(audio_fd, apid, DMX_PES_AUDIO,
+ args.dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER,
+ args.dvr ? 64 * 1024 : 0) < 0)
return -1;
}