static int set_demux(int dmxfd, int pid, int pes_type, int dvr) { struct dmx_pes_filter_params pesfilter; if (pid <= 0 || pid >= 0x1fff) /* ignore this pid to allow radio services */ return TRUE; if (dvr) { int buffersize = 64 * 1024; if (ioctl(dmxfd, DMX_SET_BUFFER_SIZE, buffersize) == -1) 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; //audio ? DMX_PES_AUDIO : DMX_PES_VIDEO; pesfilter.flags = DMX_IMMEDIATE_START; if (ioctl(dmxfd, DMX_SET_PES_FILTER, &pesfilter) == -1) { fprintf(stderr, "DMX_SET_PES_FILTER failed " "(PID = 0x%04x): %d %m\n", pid, errno); return FALSE; } return TRUE; }