aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--stream/dvb_tune.c839
-rw-r--r--stream/dvbin.h106
-rw-r--r--stream/stream_dvb.c1588
3 files changed, 1261 insertions, 1272 deletions
diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c
index 873ac91ec5..5d625bdf12 100644
--- a/stream/dvb_tune.c
+++ b/stream/dvb_tune.c
@@ -40,335 +40,315 @@
#include "dvb_tune.h"
#include "common/msg.h"
-
-
int dvb_get_tuner_type(int fe_fd, struct mp_log *log)
{
- struct dvb_frontend_info fe_info;
-
- int res;
-
- res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
- if(res < 0)
- {
+ struct dvb_frontend_info fe_info;
+ int res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
+ if (res < 0) {
mp_err(log, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
return 0;
- }
+ }
- switch(fe_info.type)
- {
- case FE_OFDM:
- mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-T\n");
- return TUNER_TER;
+ switch (fe_info.type) {
+ case FE_OFDM:
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-T\n");
+ return TUNER_TER;
- case FE_QPSK:
- mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-S\n");
- return TUNER_SAT;
+ case FE_QPSK:
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-S\n");
+ return TUNER_SAT;
- case FE_QAM:
- mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-C\n");
- return TUNER_CBL;
+ case FE_QAM:
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-C\n");
+ return TUNER_CBL;
#ifdef DVB_ATSC
- case FE_ATSC:
- mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
- return TUNER_ATSC;
+ case FE_ATSC:
+ mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
+ return TUNER_ATSC;
#endif
- default:
- mp_err(log, "UNKNOWN TUNER TYPE\n");
- return 0;
- }
+ default:
+ mp_err(log, "UNKNOWN TUNER TYPE\n");
+ return 0;
+ }
}
int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt)
{
- int i;
- char frontend_dev[32], dvr_dev[32], demux_dev[32];
-
- sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n);
- sprintf(dvr_dev, "/dev/dvb/adapter%d/dvr0", n);
- sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", n);
- priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
- if(priv->fe_fd < 0)
- {
- MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno);
- return 0;
- }
- priv->demux_fds_cnt = 0;
- MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
- for(i = 0; i < demux_cnt; i++)
- {
- priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
- if(priv->demux_fds[i] < 0)
- {
- MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
- return 0;
- }
- else
- {
- MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt);
- priv->demux_fds_cnt++;
- }
+ int i;
+ char frontend_dev[32], dvr_dev[32], demux_dev[32];
+
+ sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n);
+ sprintf(dvr_dev, "/dev/dvb/adapter%d/dvr0", n);
+ sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", n);
+ priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+ if (priv->fe_fd < 0) {
+ MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n",
+ frontend_dev, errno);
+ return 0;
+ }
+ priv->demux_fds_cnt = 0;
+ MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
+ for (i = 0; i < demux_cnt; i++) {
+ priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+ if (priv->demux_fds[i] < 0) {
+ MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
+ return 0;
+ } else {
+ MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev,
+ priv->demux_fds[i], priv->demux_fds_cnt);
+ priv->demux_fds_cnt++;
}
+ }
- priv->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK | O_CLOEXEC);
- if(priv->dvr_fd < 0)
- {
- MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
- return 0;
- }
+ priv->dvr_fd = open(dvr_dev, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
+ if (priv->dvr_fd < 0) {
+ MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
+ return 0;
+ }
- return 1;
+ return 1;
}
int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
{
- int i;
- char demux_dev[32];
-
- sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card);
- MP_VERBOSE(priv, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
- if(priv->demux_fds_cnt >= cnt)
- {
- for(i = priv->demux_fds_cnt-1; i >= cnt; i--)
- {
- MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
- close(priv->demux_fds[i]);
- }
- priv->demux_fds_cnt = cnt;
+ int i;
+ char demux_dev[32];
+
+ sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card);
+ MP_VERBOSE(priv, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
+ if (priv->demux_fds_cnt >= cnt) {
+ for (i = priv->demux_fds_cnt - 1; i >= cnt; i--) {
+ MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
+ close(priv->demux_fds[i]);
}
- else if(priv->demux_fds_cnt < cnt)
- {
- for(i = priv->demux_fds_cnt; i < cnt; i++)
- {
- priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
- MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
- if(priv->demux_fds[i] < 0)
- {
- MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
- return 0;
- }
- else
- priv->demux_fds_cnt++;
- }
+ priv->demux_fds_cnt = cnt;
+ } else if (priv->demux_fds_cnt < cnt) {
+ for (i = priv->demux_fds_cnt; i < cnt; i++) {
+ priv->demux_fds[i] = open(demux_dev,
+ O_RDWR | O_NONBLOCK | O_CLOEXEC);
+ MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
+ if (priv->demux_fds[i] < 0) {
+ MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
+ return 0;
+ } else
+ priv->demux_fds_cnt++;
}
+ }
- return 1;
+ return 1;
}
-int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype)
+int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid,
+ dmx_pes_type_t pestype)
{
- int i;
- struct dmx_pes_filter_params pesFilterParams;
-
- pesFilterParams.pid = pid;
- pesFilterParams.input = DMX_IN_FRONTEND;
- pesFilterParams.output = DMX_OUT_TS_TAP;
- pesFilterParams.pes_type = pestype;
- pesFilterParams.flags = DMX_IMMEDIATE_START;
-
- {
- int buffersize = 64 * 1024;
- if (ioctl(fd, DMX_SET_BUFFER_SIZE, buffersize) < 0)
- MP_ERR(priv, "ERROR IN DMX_SET_BUFFER_SIZE %i for fd %d: ERRNO: %d\n", pid, fd, errno);
- }
-
- errno = 0;
- if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0)
- {
- MP_ERR(priv, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d\n", pid, fd, errno);
- return 0;
- }
+ int i;
+ struct dmx_pes_filter_params pesFilterParams;
+
+ pesFilterParams.pid = pid;
+ pesFilterParams.input = DMX_IN_FRONTEND;
+ pesFilterParams.output = DMX_OUT_TS_TAP;
+ pesFilterParams.pes_type = pestype;
+ pesFilterParams.flags = DMX_IMMEDIATE_START;
+
+ {
+ int buffersize = 64 * 1024;
+ if (ioctl(fd, DMX_SET_BUFFER_SIZE, buffersize) < 0)
+ MP_ERR(priv, "ERROR IN DMX_SET_BUFFER_SIZE %i for fd %d: ERRNO: %d\n",
+ pid, fd, errno);
+ }
- MP_VERBOSE(priv, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
- return 1;
+ errno = 0;
+ if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) {
+ MP_ERR(priv, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d\n",
+ pid, fd, errno);
+ return 0;
+ }
+
+ MP_VERBOSE(priv, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n",
+ pid, fd, i, errno);
+ return 1;
}
-int dvb_get_pmt_pid(dvb_priv_t *priv, int card, int service_id) {
- /* We need special filters on the demux,
- so open one locally, and close also here. */
- char demux_dev[32];
- sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", card);
-
- struct dmx_sct_filter_params fparams;
-
- memset(&fparams, 0, sizeof(fparams));
- fparams.pid = 0;
- fparams.filter.filter[0] = 0x00;
- fparams.filter.mask[0] = 0xff;
- fparams.timeout = 0;
- fparams.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC;
-
- int pat_fd;
- if ((pat_fd = open(demux_dev, O_RDWR)) < 0) {
- MP_ERR(priv, "Opening PAT DEMUX failed, error: %d", errno);
- return -1;
- }
-
- if (ioctl(pat_fd, DMX_SET_FILTER, &fparams) == -1) {
- MP_ERR(priv, "ioctl DMX_SET_FILTER failed, error: %d", errno);
- close(pat_fd);
- return -1;
- }
-
- int bytes_read;
- int section_length;
- unsigned char buft[4096];
- unsigned char *bufptr = buft;
-
- int pmt_pid = -1;
-
- bool pat_read = false;
- while (!pat_read) {
- if (((bytes_read = read(pat_fd, bufptr, sizeof(buft))) < 0) && errno == EOVERFLOW)
- bytes_read = read(pat_fd, bufptr, sizeof(buft));
- if (bytes_read < 0) {
- MP_ERR(priv, "PAT: read_sections: read error: %d", errno);
- close(pat_fd);
- return -1;
+int dvb_get_pmt_pid(dvb_priv_t *priv, int card, int service_id)
+{
+ /* We need special filters on the demux,
+ so open one locally, and close also here. */
+ char demux_dev[32];
+ sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", card);
+
+ struct dmx_sct_filter_params fparams;
+
+ memset(&fparams, 0, sizeof(fparams));
+ fparams.pid = 0;
+ fparams.filter.filter[0] = 0x00;
+ fparams.filter.mask[0] = 0xff;
+ fparams.timeout = 0;
+ fparams.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC;
+
+ int pat_fd;
+ if ((pat_fd = open(demux_dev, O_RDWR)) < 0) {
+ MP_ERR(priv, "Opening PAT DEMUX failed, error: %d", errno);
+ return -1;
}
-
- section_length = ((bufptr[1] & 0x0f) << 8) | bufptr[2];
- if (bytes_read != section_length + 3) {
- continue;
+
+ if (ioctl(pat_fd, DMX_SET_FILTER, &fparams) == -1) {
+ MP_ERR(priv, "ioctl DMX_SET_FILTER failed, error: %d", errno);
+ close(pat_fd);
+ return -1;
}
-
- bufptr += 8;
- section_length -= 8;
-
- /* assumes one section contains the whole pat */
- pat_read = true;
- while (section_length > 0) {
- int this_service_id = (bufptr[0] << 8) | bufptr[1];
- if (this_service_id == service_id) {
- pmt_pid = ((bufptr[2] & 0x1f) << 8) | bufptr[3];
- section_length = 0;
- }
- bufptr += 4;
- section_length -= 4;
+
+ int bytes_read;
+ int section_length;
+ unsigned char buft[4096];
+ unsigned char *bufptr = buft;
+
+ int pmt_pid = -1;
+
+ bool pat_read = false;
+ while (!pat_read) {
+ if (((bytes_read =
+ read(pat_fd, bufptr,
+ sizeof(buft))) < 0) && errno == EOVERFLOW)
+ bytes_read = read(pat_fd, bufptr, sizeof(buft));
+ if (bytes_read < 0) {
+ MP_ERR(priv, "PAT: read_sections: read error: %d", errno);
+ close(pat_fd);
+ return -1;
+ }
+
+ section_length = ((bufptr[1] & 0x0f) << 8) | bufptr[2];
+ if (bytes_read != section_length + 3)
+ continue;
+
+ bufptr += 8;
+ section_length -= 8;
+
+ /* assumes one section contains the whole pat */
+ pat_read = true;
+ while (section_length > 0) {
+ int this_service_id = (bufptr[0] << 8) | bufptr[1];
+ if (this_service_id == service_id) {
+ pmt_pid = ((bufptr[2] & 0x1f) << 8) | bufptr[3];
+ section_length = 0;
+ }
+ bufptr += 4;
+ section_length -= 4;
+ }
}
- }
- close(pat_fd);
-
- return pmt_pid;
+ close(pat_fd);
+
+ return pmt_pid;
}
int dvb_demux_stop(int fd)
{
- int i;
- i = ioctl(fd, DMX_STOP);
-
- return i == 0;
+ return ioctl(fd, DMX_STOP) == 0;
}
-
int dvb_demux_start(int fd)
{
- int i;
- i = ioctl(fd, DMX_START);
-
- return i == 0;
+ return ioctl(fd, DMX_START) == 0;
}
-
static void print_status(dvb_priv_t *priv, fe_status_t festatus)
{
- MP_VERBOSE(priv, "FE_STATUS:");
- if (festatus & FE_HAS_SIGNAL) MP_VERBOSE(priv, " FE_HAS_SIGNAL");
- if (festatus & FE_TIMEDOUT) MP_VERBOSE(priv, " FE_TIMEDOUT");
- if (festatus & FE_HAS_LOCK) MP_VERBOSE(priv, " FE_HAS_LOCK");
- if (festatus & FE_HAS_CARRIER) MP_VERBOSE(priv, " FE_HAS_CARRIER");
- if (festatus & FE_HAS_VITERBI) MP_VERBOSE(priv, " FE_HAS_VITERBI");
- if (festatus & FE_HAS_SYNC) MP_VERBOSE(priv, " FE_HAS_SYNC");
- MP_VERBOSE(priv, "\n");
+ MP_VERBOSE(priv, "FE_STATUS:");
+ if (festatus & FE_HAS_SIGNAL)
+ MP_VERBOSE(priv, " FE_HAS_SIGNAL");
+ if (festatus & FE_TIMEDOUT)
+ MP_VERBOSE(priv, " FE_TIMEDOUT");
+ if (festatus & FE_HAS_LOCK)
+ MP_VERBOSE(priv, " FE_HAS_LOCK");
+ if (festatus & FE_HAS_CARRIER)
+ MP_VERBOSE(priv, " FE_HAS_CARRIER");
+ if (festatus & FE_HAS_VITERBI)
+ MP_VERBOSE(priv, " FE_HAS_VITERBI");
+ if (festatus & FE_HAS_SYNC)
+ MP_VERBOSE(priv, " FE_HAS_SYNC");
+ MP_VERBOSE(priv, "\n");
}
-
static int check_status(dvb_priv_t *priv, int fd_frontend, int tmout)
{
- int32_t strength;
- fe_status_t festatus;
- struct pollfd pfd[1];
- int ok=0, locks=0;
- time_t tm1, tm2;
-
- pfd[0].fd = fd_frontend;
- pfd[0].events = POLLPRI;
-
- MP_VERBOSE(priv, "Getting frontend status\n");
- tm1 = tm2 = time((time_t*) NULL);
- while(!ok)
- {
- festatus = 0;
- if(poll(pfd,1,tmout*1000) > 0)
- {
- if (pfd[0].revents & POLLPRI)
- {
- if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0)
- if(festatus & FE_HAS_LOCK)
- locks++;
- }
+ int32_t strength;
+ fe_status_t festatus;
+ struct pollfd pfd[1];
+ int ok = 0, locks = 0;
+ time_t tm1, tm2;
+
+ pfd[0].fd = fd_frontend;
+ pfd[0].events = POLLPRI;
+
+ MP_VERBOSE(priv, "Getting frontend status\n");
+ tm1 = tm2 = time((time_t *) NULL);
+ while (!ok) {
+ festatus = 0;
+ if (poll(pfd, 1, tmout * 1000) > 0) {
+ if (pfd[0].revents & POLLPRI) {
+ if (ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0) {
+ if (festatus & FE_HAS_LOCK)
+ locks++;
}
- usleep(10000);
- tm2 = time((time_t*) NULL);
- if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout))
- ok = 1;
+ }
}
+ usleep(10000);
+ tm2 = time((time_t *) NULL);
+ if ((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout))
+ ok = 1;
+ }
- if(festatus & FE_HAS_LOCK)
- {
- strength=0;
- if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0)
- MP_VERBOSE(priv, "Bit error rate: %d\n",strength);
+ if (festatus & FE_HAS_LOCK) {
+ strength = 0;
+ if (ioctl(fd_frontend, FE_READ_BER, &strength) >= 0)
+ MP_VERBOSE(priv, "Bit error rate: %d\n", strength);
- strength=0;
- if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0)
- MP_VERBOSE(priv, "Signal strength: %d\n",strength);
+ strength = 0;
+ if (ioctl(fd_frontend, FE_READ_SIGNAL_STRENGTH, &strength) >= 0)
+ MP_VERBOSE(priv, "Signal strength: %d\n", strength);
- strength=0;
- if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0)
- MP_VERBOSE(priv, "SNR: %d\n",strength);
+ strength = 0;
+ if (ioctl(fd_frontend, FE_READ_SNR, &strength) >= 0)
+ MP_VERBOSE(priv, "SNR: %d\n", strength);
- strength=0;
- if(ioctl(fd_frontend,FE_READ_UNCORRECTED_BLOCKS,&strength) >= 0)
- MP_VERBOSE(priv, "UNC: %d\n",strength);
+ strength = 0;
+ if (ioctl(fd_frontend, FE_READ_UNCORRECTED_BLOCKS, &strength) >= 0)
+ MP_VERBOSE(priv, "UNC: %d\n", strength);
- print_status(priv, festatus);
- }
- else
- {
- MP_ERR(priv, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout);
- return -1;
- }
- return 0;
+ print_status(priv, festatus);
+ } else {
+ MP_ERR(priv, "Not able to lock to the signal on the given frequency, "
+ "timeout: %d\n", tmout);
+ return -1;
+ }
+ return 0;
}
-
struct diseqc_cmd {
- struct dvb_diseqc_master_cmd cmd;
- uint32_t wait;
+ struct dvb_diseqc_master_cmd cmd;
+ uint32_t wait;
};
static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
- fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
+ fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
{
- if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
- return -1;
- if(ioctl(fd, FE_SET_VOLTAGE, v) == -1)
- return -1;
- usleep(15 * 1000);
- if(ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) == -1)
- return -1;
- usleep(cmd->wait * 1000);
- usleep(15 * 1000);
- if(ioctl(fd, FE_DISEQC_SEND_BURST, b) == -1)
- return -1;
- usleep(15 * 1000);
- if(ioctl(fd, FE_SET_TONE, t) == -1)
- return -1;
+ if (ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
+ return -1;
+ if (ioctl(fd, FE_SET_VOLTAGE, v) == -1)
+ return -1;
+ usleep(15 * 1000);
+ if (ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) == -1)
+ return -1;
+ usleep(cmd->wait * 1000);
+ usleep(15 * 1000);
+ if (ioctl(fd, FE_DISEQC_SEND_BURST, b) == -1)
+ return -1;
+ usleep(15 * 1000);
+ if (ioctl(fd, FE_SET_TONE, t) == -1)
+ return -1;
return 0;
}
@@ -378,202 +358,203 @@ static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
*/
static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo)
{
- struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
+ struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
- /* param: high nibble: reset bits, low nibble set bits,
- * bits are: option, position, polarizaion, band
- */
- cmd.cmd.msg[3] =
- 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2));
+ /* param: high nibble: reset bits, low nibble set bits,
+ * bits are: option, position, polarizaion, band
+ */
+ cmd.cmd.msg[3] = 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2));
- return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
- &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
- (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
+ return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
+ &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
+ (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
}
-static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
- bool is_dvb_s2, int stream_id, fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation,
- fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
- fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
+static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec,
+ unsigned int freq, unsigned int srate, char pol, int tone,
+ bool is_dvb_s2, int stream_id,
+ fe_spectral_inversion_t specInv, unsigned int diseqc,
+ fe_modulation_t modulation,
+ fe_code_rate_t HP_CodeRate,
+ fe_transmit_mode_t TransmissionMode,
+ fe_guard_interval_t guardInterval,
+ fe_bandwidth_t bandwidth,
+ fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier,
+ int timeout)
{
- int hi_lo = 0, dfd;
- struct dvb_frontend_parameters feparams;
- struct dvb_frontend_info fe_info;
-
- MP_VERBOSE(priv, "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, diseqc %u\n",
- fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc);
+ int hi_lo = 0, dfd;
+ struct dvb_frontend_parameters feparams;
+ struct dvb_frontend_info fe_info;
+ MP_VERBOSE(priv, "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, "
+ "pol %c, tone %i, diseqc %u\n", fd_frontend, fd_sec,
+ (long unsigned int)freq, (long unsigned int)srate, pol,
+ tone, diseqc);
- memset(&feparams, 0, sizeof(feparams));
- if ( ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)
- {
+ memset(&feparams, 0, sizeof(feparams));
+ if (ioctl(fd_frontend, FE_GET_INFO, &fe_info) < 0) {
MP_FATAL(priv, "FE_GET_INFO FAILED\n");
return -1;
- }
+ }
- MP_VERBOSE(priv, "Using DVB card \"%s\"\n", fe_info.name);
+ MP_VERBOSE(priv, "Using DVB card \"%s\"\n", fe_info.name);
- {
- /* discard stale QPSK events */
- struct dvb_frontend_event ev;
- while (true) {
+ {
+ /* discard stale QPSK events */
+ struct dvb_frontend_event ev;
+ while (true) {
if (ioctl(fd_frontend, FE_GET_EVENT, &ev) == -1)
- break;
- }
- }
+ break;
+ }
+ }
- switch(fe_info.type)
- {
+ switch (fe_info.type) {
case FE_OFDM:
- if (freq < 1000000) freq*=1000UL;
- feparams.frequency=freq;
- feparams.inversion=specInv;
- feparams.u.ofdm.bandwidth=bandwidth;
- feparams.u.ofdm.code_rate_HP=HP_CodeRate;
- feparams.u.ofdm.code_rate_LP=LP_CodeRate;
- feparams.u.ofdm.constellation=modulation;
- feparams.u.ofdm.transmission_mode=TransmissionMode;
- feparams.u.ofdm.guard_interval=guardInterval;
- feparams.u.ofdm.hierarchy_information=hier;
- MP_VERBOSE(priv, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
- if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
- {
- MP_ERR(priv, "ERROR tuning channel\n");
- return -1;
- }
- break;
+ if (freq < 1000000)
+ freq *= 1000UL;
+ feparams.frequency = freq;
+ feparams.inversion = specInv;
+ feparams.u.ofdm.bandwidth = bandwidth;
+ feparams.u.ofdm.code_rate_HP = HP_CodeRate;
+ feparams.u.ofdm.code_rate_LP = LP_CodeRate;
+ feparams.u.ofdm.constellation = modulation;
+ feparams.u.ofdm.transmission_mode = TransmissionMode;
+ feparams.u.ofdm.guard_interval = guardInterval;
+ feparams.u.ofdm.hierarchy_information = hier;
+ MP_VERBOSE(priv, "tuning DVB-T to %d Hz, bandwidth: %d\n",
+ freq, bandwidth);
+ if (ioctl(fd_frontend, FE_SET_FRONTEND, &feparams) < 0) {
+ MP_ERR(priv, "ERROR tuning channel\n");
+ return -1;
+ }
+ break;
case FE_QPSK:
- // DVB-S
- if (freq > 2200000)
- {
- // this must be an absolute frequency
- if (freq < SLOF)
- {
- freq = feparams.frequency=(freq-LOF1);
- hi_lo = 0;
+ // DVB-S
+ if (freq > 2200000) {
+ // this must be an absolute frequency
+ if (freq < SLOF) {
+ freq = feparams.frequency = (freq - LOF1);
+ hi_lo = 0;
+ } else {
+ freq = feparams.frequency = (freq - LOF2);
+ hi_lo = 1;
+ }
+ } else {
+ // this is an L-Band frequency
+ feparams.frequency = freq;
}
- else
- {
- freq = feparams.frequency=(freq-LOF2);
- hi_lo = 1;
+
+ feparams.inversion = specInv;
+ feparams.u.qpsk.symbol_rate = srate;
+ feparams.u.qpsk.fec_inner = HP_CodeRate;
+ dfd = fd_frontend;
+
+ MP_VERBOSE(priv, "tuning DVB-S%sto Freq: %u, Pol: %c Srate: %d, "
+ "22kHz: %s, LNB: %d\n", is_dvb_s2 ? "2 " : " ", freq,
+ pol, srate, hi_lo ? "on" : "off", diseqc);
+
+ if (do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0) {
+ MP_VERBOSE(priv, "DISEQC setting succeeded\n");
+ } else {
+ MP_ERR(priv, "DISEQC setting failed\n");
+ return -1;
}
- }
- else
- {
- // this is an L-Band frequency
- feparams.frequency=freq;
- }
-
- feparams.inversion=specInv;
- feparams.u.qpsk.symbol_rate=srate;
- feparams.u.qpsk.fec_inner=HP_CodeRate;
- dfd = fd_frontend;
-
- MP_VERBOSE(priv, "tuning DVB-S%sto Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB: %d\n",
- is_dvb_s2 ? "2 ": " ", freq,pol,srate,hi_lo ? "on" : "off", diseqc);
-
- if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
- MP_VERBOSE(priv, "DISEQC setting succeeded\n");
- else
- {
- MP_ERR(priv, "DISEQC setting failed\n");
- return -1;
- }
- usleep(100000);
-
+ usleep(100000);
+
#ifdef DVB_USE_S2API
- /* S2API is the DVB API new since 2.6.28.
- * It is needed to tune to new delivery systems, e.g. DVB-S2.
- * It takes a struct with a list of pairs of command + parameter.
- */
-
- fe_delivery_system_t delsys = SYS_DVBS;
- if (is_dvb_s2) {
- delsys = SYS_DVBS2;
- }
- fe_rolloff_t rolloff = ROLLOFF_AUTO;
-
- struct dtv_property p[] = {
- { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys },
- { .cmd = DTV_FREQUENCY, .u.data = freq },
- { .cmd = DTV_MODULATION, .u.data = modulation },
- { .cmd = DTV_SYMBOL_RATE, .u.data = srate },
- { .cmd = DTV_INNER_FEC, .u.data = HP_CodeRate },
- { .cmd = DTV_INVERSION, .u.data = specInv },
- { .cmd = DTV_ROLLOFF, .u.data = rolloff },
- { .cmd = DTV_PILOT, .u.data = PILOT_AUTO },
- { .cmd = DTV_STREAM_ID, .u.data = stream_id },
- { .cmd = DTV_TUNE },
- };
- struct dtv_properties cmdseq = {
- .num = sizeof(p)/sizeof(p[0]),
- .props = p
- };
- MP_VERBOSE(priv, "Tuning via S2API, channel is DVB-S%s.\n", is_dvb_s2 ? "2": "");
- if ((ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq)) == -1)
- {
- MP_ERR(priv, "ERROR tuning channel\n");
- return -1;
- }
+ /* S2API is the DVB API new since 2.6.28.
+ * It is needed to tune to new delivery systems, e.g. DVB-S2.
+ * It takes a struct with a list of pairs of command + parameter.
+ */
+
+ fe_delivery_system_t delsys = SYS_DVBS;
+ if (is_dvb_s2)
+ delsys = SYS_DVBS2;
+ fe_rolloff_t rolloff = ROLLOFF_AUTO;
+
+ struct dtv_property p[] = {
+ { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys },
+ { .cmd = DTV_FREQUENCY, .u.data = freq },
+ { .cmd = DTV_MODULATION, .u.data = modulation },
+ { .cmd = DTV_SYMBOL_RATE, .u.data = srate },
+ { .cmd = DTV_INNER_FEC, .u.data = HP_CodeRate },
+ { .cmd = DTV_INVERSION, .u.data = specInv },
+ { .cmd = DTV_ROLLOFF, .u.data = rolloff },
+ { .cmd = DTV_PILOT, .u.data = PILOT_AUTO },
+ { .cmd = DTV_STREAM_ID, .u.data = stream_id },
+ { .cmd = DTV_TUNE },
+ };
+ struct dtv_properties cmdseq = {
+ .num = sizeof(p) / sizeof(p[0]),
+ .props = p
+ };
+ MP_VERBOSE(priv, "Tuning via S2API, channel is DVB-S%s.\n",
+ is_dvb_s2 ? "2" : "");
+ if ((ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq)) == -1) {
+ MP_ERR(priv, "ERROR tuning channel\n");
+ return -1;
+ }
#else
- MP_VERBOSE(priv, "Tuning via DVB-API version 3.\n");
- if (is_dvb_s2) {
- MP_ERR(priv, "ERROR: Can not tune to S2 channel, S2-API not available, will tune to DVB-S!\n")
- }
- if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
- {
- MP_ERR(priv, "ERROR tuning channel\n");
- return -1;
- }
+ MP_VERBOSE(priv, "Tuning via DVB-API version 3.\n");
+ if (is_dvb_s2) {
+ MP_ERR(priv, "ERROR: Can not tune to S2 channel, S2-API not "
+ "available, will tune to DVB-S!\n")
+ }
+ if (ioctl(fd_frontend, FE_SET_FRONTEND, &feparams) < 0) {
+ MP_ERR(priv, "ERROR tuning channel\n");
+ return -1;
+ }
#endif
- break;
+ break;
case FE_QAM:
- feparams.frequency=freq;
- feparams.inversion=specInv;
- feparams.u.qam.symbol_rate = srate;
- feparams.u.qam.fec_inner = HP_CodeRate;
- feparams.u.qam.modulation = modulation;
- MP_VERBOSE(priv, "tuning DVB-C to %d, srate=%d\n",freq,srate);
- if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
- {
- MP_ERR(priv, "ERROR tuning channel\n");
- return -1;
- }
- break;
+ feparams.frequency = freq;
+ feparams.inversion = specInv;
+ feparams.u.qam.symbol_rate = srate;
+ feparams.u.qam.fec_inner = HP_CodeRate;
+ feparams.u.qam.modulation = modulation;
+ MP_VERBOSE(priv, "tuning DVB-C to %d, srate=%d\n", freq, srate);
+ if (ioctl(fd_frontend, FE_SET_FRONTEND, &feparams) < 0) {
+ MP_ERR(priv, "ERROR tuning channel\n");
+ return -1;
+ }
+ break;
#ifdef DVB_ATSC
case FE_ATSC:
- feparams.frequency=freq;
- feparams.u.vsb.modulation = modulation;
- MP_VERBOSE(priv, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
- if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
- {
- MP_ERR(priv, "ERROR tuning channel\n");
- return -1;
- }
- break;
+ feparams.frequency = freq;
+ feparams.u.vsb.modulation = modulation;
+ MP_VERBOSE(priv, "tuning ATSC to %d, modulation=%d\n", freq, modulation);
+ if (ioctl(fd_frontend, FE_SET_FRONTEND, &feparams) < 0) {
+ MP_ERR(priv, "ERROR tuning channel\n");
+ return -1;
+ }
+ break;
#endif
default:
- MP_VERBOSE(priv, "Unknown FE type. Aborting\n");
- return 0;
- }
+ MP_VERBOSE(priv, "Unknown FE type. Aborting\n");
+ return 0;
+ }
- return check_status(priv, fd_frontend, timeout);
+ return check_status(priv, fd_frontend, timeout);
}
-
-int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
- bool is_dvb_s2, int stream_id, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
- fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate,
- fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
+int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc,
+ int tone,
+ bool is_dvb_s2, int stream_id, fe_spectral_inversion_t specInv,
+ fe_modulation_t modulation, fe_guard_interval_t guardInterval,
+ fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth,
+ fe_code_rate_t HP_CodeRate,
+ fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier,
+ int timeout)
{
- int ris;
-
- MP_INFO(priv, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
+ MP_INFO(priv, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
- ris = tune_it(priv, priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, is_dvb_s2, stream_id, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout);
+ int ris = tune_it(priv, priv->fe_fd, priv->sec_fd, freq, srate, pol, tone,
+ is_dvb_s2, stream_id, specInv, diseqc, modulation,
+ HP_CodeRate, TransmissionMode, guardInterval,
+ bandWidth, LP_CodeRate, hier, timeout);
- if(ris != 0)
- MP_INFO(priv, "dvb_tune, TUNING FAILED\n");
+ if (ris != 0)
+ MP_INFO(priv, "dvb_tune, TUNING FAILED\n");
- return ris == 0;
+ return ris == 0;
}
diff --git a/stream/dvbin.h b/stream/dvbin.h
index c475984450..5dfb20c548 100644
--- a/stream/dvbin.h
+++ b/stream/dvbin.h
@@ -11,9 +11,9 @@
#include "config.h"
#include "stream.h"
-#define SLOF (11700*1000UL)
-#define LOF1 (9750*1000UL)
-#define LOF2 (10600*1000UL)
+#define SLOF (11700 * 1000UL)
+#define LOF1 (9750 * 1000UL)
+#define LOF2 (10600 * 1000UL)
#include <inttypes.h>
#include <linux/dvb/dmx.h>
@@ -26,14 +26,14 @@
/* kernel headers >=2.6.28 have version 5.
*
* Version 5 is also called S2API, it adds support for tuning to S2 channels
- * and is extensible for future delivery systems. Old API is deprecated.
- * StreamID-implementation only supported since API >=5.2.
+ * and is extensible for future delivery systems. Old API is deprecated.
+ * StreamID-implementation only supported since API >=5.2.
*/
#if (DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR >= 2)
#define DVB_USE_S2API 1
-// This had a different name until API 5.8.
+// This had a different name until API 5.8.
#ifndef DTV_STREAM_ID
#define DTV_STREAM_ID DTV_ISDBS_TS_ID
#endif
@@ -50,7 +50,6 @@
#endif
-
#define DVB_CHANNEL_LOWER -1
#define DVB_CHANNEL_HIGHER 1
@@ -59,67 +58,66 @@
#endif
typedef struct {
- char *name;
- int freq, srate, diseqc, tone;
- char pol;
- int tpid, dpid1, dpid2, progid, ca, pids[DMX_FILTER_SIZE], pids_cnt;
- bool is_dvb_s2;
- int stream_id;
- int service_id;
- fe_spectral_inversion_t inv;
- fe_modulation_t mod;
- fe_transmit_mode_t trans;
- fe_bandwidth_t bw;
- fe_guard_interval_t gi;
- fe_code_rate_t cr, cr_lp;
- fe_hierarchy_t hier;
+ char *name;
+ int freq, srate, diseqc, tone;
+ char pol;
+ int tpid, dpid1, dpid2, progid, ca, pids[DMX_FILTER_SIZE], pids_cnt;
+ bool is_dvb_s2;
+ int stream_id;
+ int service_id;
+ fe_spectral_inversion_t inv;
+ fe_modulation_t mod;
+ fe_transmit_mode_t trans;
+ fe_bandwidth_t bw;
+ fe_guard_interval_t gi;
+ fe_code_rate_t cr, cr_lp;
+ fe_hierarchy_t hier;
} dvb_channel_t;
typedef struct {
- uint16_t NUM_CHANNELS;
- uint16_t current;
- dvb_channel_t *channels;
+ uint16_t NUM_CHANNELS;
+ uint16_t current;
+ dvb_channel_t *channels;
} dvb_channels_list;
typedef struct {
- int type;
- dvb_channels_list *list;
- char *name;
- int devno;
+ int type;
+ dvb_channels_list *list;
+ char *name;
+ int devno;
} dvb_card_config_t;
typedef struct {
- int count;
- dvb_card_config_t *cards;
- void *priv;
+ int count;
+ dvb_card_config_t *cards;
+ void *priv;
} dvb_config_t;
typedef struct dvb_params {
- struct mp_log *log;
- int fd;
- int card;
- int fe_fd;
- int sec_fd;
- int demux_fd[3], demux_fds[DMX_FILTER_SIZE], demux_fds_cnt;
- int dvr_fd;
-
- dvb_config_t *config;
- dvb_channels_list *list;
- int tuner_type;
- int is_on;
- int retry;
- int timeout;
- int last_freq;
-
- char *cfg_prog;
- int cfg_card;
- int cfg_timeout;
- char *cfg_file;
-
- int cfg_full_transponder;
+ struct mp_log *log;
+ int fd;
+ int card;
+ int fe_fd;
+ int sec_fd;
+ int demux_fd[3], demux_fds[DMX_FILTER_SIZE], demux_fds_cnt;
+ int dvr_fd;
+
+ dvb_config_t *config;
+ dvb_channels_list *list;
+ int tuner_type;
+ int is_on;
+ int retry;
+ int timeout;
+ int last_freq;
+
+ char *cfg_prog;
+ int cfg_card;
+ int cfg_timeout;
+ char *cfg_file;
+
+ int cfg_full_transponder;
} dvb_priv_t;
-
#define TUNER_SAT 1
#define TUNER_TER 2
#define TUNER_CBL 3
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 065604f7ab..66c762a75e 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -1,32 +1,32 @@
/*
-dvbstream
-(C) Dave Chapman <dave@dchapman.com> 2001, 2002.
+ dvbstream
+ (C) Dave Chapman <dave@dchapman.com> 2001, 2002.
-Original authors: Nico, probably Arpi
+ Original authors: Nico, probably Arpi
-Some code based on dvbstream, 0.4.3-pre3 (CVS checkout),
-http://sourceforge.net/projects/dvbtools/
+ Some code based on dvbstream, 0.4.3-pre3 (CVS checkout),
+ http://sourceforge.net/projects/dvbtools/
-Modified for use with MPlayer, for details see the changelog at
-http://svn.mplayerhq.hu/mplayer/trunk/
-$Id$
+ Modified for use with MPlayer, for details see the changelog at
+ http://svn.mplayerhq.hu/mplayer/trunk/
+ $Id$
-Copyright notice:
+ Copyright notice:
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -55,14 +55,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "dvbin.h"
#include "dvb_tune.h"
-
#define MAX_CHANNELS 8
#define CHANNEL_LINE_LEN 256
#define min(a, b) ((a) <= (b) ? (a) : (b))
-
-//TODO: CAMBIARE list_ptr e da globale a per_priv
-
#define OPT_BASE_STRUCT struct dvb_params
/// URL definition
@@ -76,7 +72,7 @@ const struct m_sub_options stream_dvb_conf = {
.opts = (const m_option_t[]) {
OPT_STRING("prog", cfg_prog, 0),
OPT_INTRANGE("card", cfg_card, 0, 1, 4),
- OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30),
+ OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30),
OPT_STRING("file", cfg_file, 0),
OPT_FLAG("full-transponder", cfg_full_transponder, 0),
{0}
@@ -89,665 +85,684 @@ const struct m_sub_options stream_dvb_conf = {
},
};
-static void parse_vdr_par_string(const char* vdr_par_str, dvb_channel_t* ptr) {
- //FIXME: There is more information in this parameter string, especially related
- // to non-DVB-S reception.
- if (vdr_par_str[0]) {
- const char* vdr_par = &vdr_par_str[0];
- while (vdr_par && *vdr_par) {
- switch (mp_toupper(*vdr_par)) {
- case 'H':
- ptr->pol = 'H';
- vdr_par++;
- break;
- case 'V':
- ptr->pol = 'V';
- vdr_par++;
- break;
- case 'S':
- vdr_par++;
- if (*vdr_par == '1') {
- ptr->is_dvb_s2 = true;
- } else {
- ptr->is_dvb_s2 = false;
- }
- vdr_par++;
- break;
- case 'P':
- vdr_par++;
- char *endptr = NULL;
- errno = 0;
- int n = strtol(vdr_par, &endptr, 10);
- if (!errno && endptr != vdr_par) {
- ptr->stream_id = n;
- vdr_par = endptr;
- }
- break;
- case 'I':
- vdr_par++;
- if (*vdr_par == '1') {
- ptr->inv = INVERSION_ON;
- } else {
- ptr->inv = INVERSION_OFF;
+static void parse_vdr_par_string(const char *vdr_par_str, dvb_channel_t *ptr)
+{
+ //FIXME: There is more information in this parameter string, especially related
+ // to non-DVB-S reception.
+ if (vdr_par_str[0]) {
+ const char *vdr_par = &vdr_par_str[0];
+ while (vdr_par && *vdr_par) {
+ switch (mp_toupper(*vdr_par)) {
+ case 'H':
+ ptr->pol = 'H';
+ vdr_par++;
+ break;
+ case 'V':
+ ptr->pol = 'V';
+ vdr_par++;
+ break;
+ case 'S':
+ vdr_par++;
+ if (*vdr_par == '1') {
+ ptr->is_dvb_s2 = true;
+ } else {
+ ptr->is_dvb_s2 = false;
+ }
+ vdr_par++;
+ break;
+ case 'P':
+ vdr_par++;
+ char *endptr = NULL;
+ errno = 0;
+ int n = strtol(vdr_par, &endptr, 10);
+ if (!errno && endptr != vdr_par) {
+ ptr->stream_id = n;
+ vdr_par = endptr;
+ }
+ break;
+ case 'I':
+ vdr_par++;
+ if (*vdr_par == '1') {
+ ptr->inv = INVERSION_ON;
+ } else {
+ ptr->inv = INVERSION_OFF;
+ }
+ vdr_par++;
+ break;
+ default:
+ vdr_par++;
+ }
}
- vdr_par++;
- break;
- default:
- vdr_par++;
- }
}
- }
}
-static char* dvb_strtok_r(char* s, const char* sep, char** p) {
- if (!s && !(s = *p)) {
- return NULL;
- }
-
- /* Skip leading separators. */
- s += strspn(s, sep);
-
- /* s points at first non-separator, or end of string. */
- if (!*s) {
- return (*p = 0);
- }
-
- /* Move *p to next separator. */
- *p = s + strcspn(s, sep);
- if (**p) {
- *(*p)++ = 0;
- } else {
- *p = 0;
- }
- return s;
+static char *dvb_strtok_r(char *s, const char *sep, char **p)
+{
+ if (!s && !(s = *p))
+ return NULL;
+
+ /* Skip leading separators. */
+ s += strspn(s, sep);
+
+ /* s points at first non-separator, or end of string. */
+ if (!*s)
+ return *p = 0;
+
+ /* Move *p to next separator. */
+ *p = s + strcspn(s, sep);
+ if (**p) {
+ *(*p)++ = 0;
+ } else {
+ *p = 0;
+ }
+ return s;
}
-static bool parse_pid_string(struct mp_log *log, char* pid_string, dvb_channel_t* ptr) {
- if (pid_string[0]) {
- int pcnt = 0;
- /** These tokens also catch vdr-style PID lists.
- * They can contain 123=deu@3,124=eng+jap@4;125
- * 3 and 4 are codes for codec type, =langLeft+langRight is allowed,
- * and ; may separate a dolby channel.
- * With the numChars-test and the full token-list, all is handled gracefully.
- */
- const char* tokens = "+,;";
- char* pidPart;
- char* savePtr;
- pidPart = dvb_strtok_r(pid_string, tokens, &savePtr);
- while (pidPart != NULL) {
- if (ptr->pids_cnt >= DMX_FILTER_SIZE-1) {
- mp_verbose(log, "Maximum number of PIDs for one channel reached, ignoring further ones!\n");
- return (pcnt > 0);
- }
- int numChars = 0;
- int pid = 0;
- pcnt += sscanf(pidPart, "%d%n", &pid, &numChars);
- if (numChars > 0) {
- ptr->pids[ptr->pids_cnt] = pid;
- ptr->pids_cnt++;
- }
- pidPart = dvb_strtok_r(NULL, tokens, &savePtr);
- }
- if (pcnt > 0) {
- return true;
+static bool parse_pid_string(struct mp_log *log, char *pid_string,
+ dvb_channel_t *ptr)
+{
+ if (pid_string[0]) {
+ int pcnt = 0;
+ /* These tokens also catch vdr-style PID lists.
+ * They can contain 123=deu@3,124=eng+jap@4;125
+ * 3 and 4 are codes for codec type, =langLeft+langRight is allowed,
+ * and ; may separate a dolby channel.
+ * With the numChars-test and the full token-list, all is handled
+ * gracefully.
+ */
+ const char *tokens = "+,;";
+ char *pidPart;
+ char *savePtr;
+ pidPart = dvb_strtok_r(pid_string, tokens, &savePtr);
+ while (pidPart != NULL) {
+ if (ptr->pids_cnt >= DMX_FILTER_SIZE - 1) {
+ mp_verbose(log, "Maximum number of PIDs for one channel "
+ "reached, ignoring further ones!\n");
+ return pcnt > 0;
+ }
+ int numChars = 0;
+ int pid = 0;
+ pcnt += sscanf(pidPart, "%d%n", &pid, &numChars);
+ if (numChars > 0) {
+ ptr->pids[ptr->pids_cnt] = pid;
+ ptr->pids_cnt++;
+ }
+ pidPart = dvb_strtok_r(NULL, tokens, &savePtr);
+ }
+ if (pcnt > 0)
+ return true;
}
- }
- return false;
+ return false;
}
-static dvb_channels_list *dvb_get_channels(struct mp_log *log, int cfg_full_transponder, char *filename, int type)
+static dvb_channels_list *dvb_get_channels(struct mp_log *log,
+ int cfg_full_transponder,
+ char *filename,
+ int type)
{
- dvb_channels_list *list;
- FILE *f;
- char line[CHANNEL_LINE_LEN], *colon;
-
- if (!filename)
- return NULL;
-
- int fields, cnt, k;
- int has8192, has0;
- dvb_channel_t *ptr, *tmp, chn;
- char tmp_lcr[256], tmp_hier[256], inv[256], bw[256], cr[256], mod[256], transm[256], gi[256], vpid_str[256], apid_str[256], tpid_str[256],
- vdr_par_str[256], vdr_loc_str[256];
- const char *cbl_conf = "%d:%255[^:]:%d:%255[^:]:%255[^:]:%255[^:]:%255[^:]\n";
- const char *sat_conf = "%d:%c:%d:%d:%255[^:]:%255[^:]\n";
- const char *ter_conf = "%d:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]\n";
- const char *atsc_conf = "%d:%255[^:]:%255[^:]:%255[^:]\n";
-
- const char *vdr_conf = "%d:%255[^:]:%255[^:]:%d:%255[^:]:%255[^:]:%255[^:]:%*255[^:]:%d:%*d:%*d:%*d\n%n";
-
- mp_verbose(log, "CONFIG_READ FILE: %s, type: %d\n", filename, type);
- if((f=fopen(filename, "r"))==NULL)
- {
- mp_fatal(log, "CAN'T READ CONFIG FILE %s\n", filename);
- return NULL;
- }
+ dvb_channels_list *list;
+ FILE *f;
+ char line[CHANNEL_LINE_LEN], *colon;
+
+ if (!filename)
+ return NULL;
+
+ int fields, cnt, k;
+ int has8192, has0;
+ dvb_channel_t *ptr, *tmp, chn;
+ char tmp_lcr[256], tmp_hier[256], inv[256], bw[256], cr[256], mod[256],
+ transm[256], gi[256], vpid_str[256], apid_str[256], tpid_str[256],
+ vdr_par_str[256], vdr_loc_str[256];
+ const char *cbl_conf =
+ "%d:%255[^:]:%d:%255[^:]:%255[^:]:%255[^:]:%255[^:]\n";
+ const char *sat_conf = "%d:%c:%d:%d:%255[^:]:%255[^:]\n";
+ const char *ter_conf =
+ "%d:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]\n";
+ const char *atsc_conf = "%d:%255[^:]:%255[^:]:%255[^:]\n";
+
+ const char *vdr_conf =
+ "%d:%255[^:]:%255[^:]:%d:%255[^:]:%255[^:]:%255[^:]:%*255[^:]:%d:%*d:%*d:%*d\n%n";
+
+ mp_verbose(log, "CONFIG_READ FILE: %s, type: %d\n", filename, type);
+ if ((f = fopen(filename, "r")) == NULL) {
+ mp_fatal(log, "CAN'T READ CONFIG FILE %s\n", filename);
+ return NULL;
+ }
- list = malloc(sizeof(dvb_channels_list));
- if(list == NULL)
- {
- fclose(f);
- mp_verbose(log, "DVB_GET_CHANNELS: couldn't malloc enough memory\n");
- return NULL;
- }
+ list = malloc(sizeof(dvb_channels_list));
+ if (list == NULL) {
+ fclose(f);
+ mp_verbose(log, "DVB_GET_CHANNELS: couldn't malloc enough memory\n");
+ return NULL;
+ }
- ptr = &chn;
- list->NUM_CHANNELS = 0;
- list->channels = NULL;
- while(! feof(f))
- {
- if( fgets(line, CHANNEL_LINE_LEN, f) == NULL )
- continue;
-
- if((line[0] == '#') || (strlen(line) == 0))
- continue;
-
- colon = strchr(line, ':');
- if (colon) {
- k = colon - line;
- if(!k)
- continue;
- // In some modern VDR-style configs, channel name also has bouquet after ;.
- // Parse that off, we ignore it.
- char* bouquet_sep = strchr(line, ';');
- int channel_name_length = k;
- if (bouquet_sep && bouquet_sep < colon) {
- channel_name_length = bouquet_sep - line;
- }
- ptr->name = malloc(channel_name_length+1);
- if(! ptr->name)
- continue;
- av_strlcpy(ptr->name, line, channel_name_length+1);
- } else {
- continue;
- }
- k++;
- vpid_str[0] = apid_str[0] = tpid_str[0] = 0;
- vdr_loc_str[0] = vdr_par_str[0] = 0;
- ptr->pids_cnt = 0;
- ptr->freq = 0;
- ptr->is_dvb_s2 = false;
- ptr->service_id = -1;
- ptr->stream_id = NO_STREAM_ID_FILTER;
+ ptr = &chn;
+ list->NUM_CHANNELS = 0;
+ list->channels = NULL;
+ while (!feof(f)) {
+ if (fgets(line, CHANNEL_LINE_LEN, f) == NULL)
+ continue;
+
+ if ((line[0] == '#') || (strlen(line) == 0))
+ continue;
+
+ colon = strchr(line, ':');
+ if (colon) {
+ k = colon - line;
+ if (!k)
+ continue;
+ // In some modern VDR-style configs, channel name also has bouquet after ;.
+ // Parse that off, we ignore it.
+ char *bouquet_sep = strchr(line, ';');
+ int channel_name_length = k;
+ if (bouquet_sep && bouquet_sep < colon)
+ channel_name_length = bouquet_sep - line;
+ ptr->name = malloc(channel_name_length + 1);
+ if (!ptr->name)
+ continue;
+ av_strlcpy(ptr->name, line, channel_name_length + 1);
+ } else {
+ continue;
+ }
+ k++;
+ vpid_str[0] = apid_str[0] = tpid_str[0] = 0;
+ vdr_loc_str[0] = vdr_par_str[0] = 0;
+ ptr->pids_cnt = 0;
+ ptr->freq = 0;
+ ptr->is_dvb_s2 = false;
+ ptr->service_id = -1;
+ ptr->stream_id = NO_STREAM_ID_FILTER;
+ ptr->inv = INVERSION_AUTO;
+
+ // Check if VDR-type channels.conf-line - then full line is consumed by the scan.
+ int num_chars = 0;
+ fields = sscanf(&line[k], vdr_conf,
+ &ptr->freq, vdr_par_str, vdr_loc_str, &ptr->srate,
+ vpid_str, apid_str, tpid_str, &ptr->service_id,
+ &num_chars);
+
+ if (num_chars == strlen(&line[k])) {
+ // It's a VDR-style config line.
+ parse_vdr_par_string(vdr_par_str, ptr);
+ // We still need the special SAT-handling here.
+ if (type != TUNER_TER && type != TUNER_CBL && type != TUNER_ATSC) {
+ ptr->freq *= 1000UL;
+ ptr->srate *= 1000UL;
+ ptr->tone = -1;
ptr->inv = INVERSION_AUTO;
-
- // Check if VDR-type channels.conf-line - then full line is consumed by the scan.
- int num_chars = 0;
- fields = sscanf(&line[k], vdr_conf,
- &ptr->freq, vdr_par_str, vdr_loc_str, &ptr->srate, vpid_str, apid_str, tpid_str, &ptr->service_id, &num_chars);
-
- if (num_chars == strlen(&line[k])) {
- // It's a VDR-style config line.
- parse_vdr_par_string(vdr_par_str, ptr);
- // We still need the special SAT-handling here.
- if (type != TUNER_TER && type != TUNER_CBL && type != TUNER_ATSC) {
- ptr->freq *= 1000UL;
- ptr->srate *= 1000UL;
- ptr->tone = -1;
- ptr->inv = INVERSION_AUTO;
- ptr->cr = FEC_AUTO;
-
- if (vdr_loc_str[0]) {
- // In older vdr config format, this field contained the DISEQc information.
- // If it is numeric, assume that's it.
- int diseqc_info = 0;
- int valid_digits = 0;
- if (sscanf(vdr_loc_str, "%d%n", &diseqc_info, &valid_digits) == 1) {
+ ptr->cr = FEC_AUTO;
+
+ if (vdr_loc_str[0]) {
+ // In older vdr config format, this field contained the DISEQc information.
+ // If it is numeric, assume that's it.
+ int diseqc_info = 0;
+ int valid_digits = 0;
+ if (sscanf(vdr_loc_str, "%d%n", &diseqc_info,
+ &valid_digits) == 1)
+ {
if (valid_digits == strlen(vdr_loc_str)) {
- ptr->diseqc = diseqc_info;
- if((ptr->diseqc > 4) || (ptr->diseqc < 0))
- continue;
- if(ptr->diseqc > 0)
- ptr->diseqc--;
+ ptr->diseqc = diseqc_info;
+ if ((ptr->diseqc > 4) || (ptr->diseqc < 0))
+ continue;
+ if (ptr->diseqc > 0)
+ ptr->diseqc--;
}
- }
}
-
- mp_verbose(log, "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d, S2: %s, StreamID: %d, SID: %d",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc,
- ptr->is_dvb_s2 ? "yes" : "no", ptr->stream_id, ptr->service_id);
- } else {
- mp_verbose(log, "VDR, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate);
- }
- } else if (type == TUNER_TER) {
- fields = sscanf(&line[k], ter_conf,
- &ptr->freq, inv, bw, cr, tmp_lcr, mod,
- transm, gi, tmp_hier, vpid_str, apid_str);
- mp_verbose(log, "TER, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
- } else if (type == TUNER_CBL) {
- fields = sscanf(&line[k], cbl_conf,
- &ptr->freq, inv, &ptr->srate,
- cr, mod, vpid_str, apid_str);
- mp_verbose(log, "CBL, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate);
}
+
+ mp_verbose(log, "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, "
+ "FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d, S2: %s, "
+ "StreamID: %d, SID: %d", list->NUM_CHANNELS,
+ fields, ptr->name, ptr->freq, ptr->srate, ptr->pol,
+ ptr->diseqc, ptr->is_dvb_s2 ? "yes" : "no",
+ ptr->stream_id, ptr->service_id);
+ } else {
+ mp_verbose(log, "VDR, NUM: %d, NUM_FIELDS: %d, NAME: %s, "
+ "FREQ: %d, SRATE: %d", list->NUM_CHANNELS, fields,
+ ptr->name, ptr->freq, ptr->srate);
+ }
+ } else if (type == TUNER_TER) {
+ fields = sscanf(&line[k], ter_conf,
+ &ptr->freq, inv, bw, cr, tmp_lcr, mod,
+ transm, gi, tmp_hier, vpid_str, apid_str);
+ mp_verbose(log, "TER, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d",
+ list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
+ } else if (type == TUNER_CBL) {
+ fields = sscanf(&line[k], cbl_conf,
+ &ptr->freq, inv, &ptr->srate,
+ cr, mod, vpid_str, apid_str);
+ mp_verbose(log, "CBL, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, "
+ "SRATE: %d", list->NUM_CHANNELS, fields, ptr->name,
+ ptr->freq, ptr->srate);
+ }
#ifdef DVB_ATSC
- else if (type == TUNER_ATSC)
- {
- fields = sscanf(&line[k], atsc_conf,
- &ptr->freq, mod, vpid_str, apid_str);
- mp_verbose(log, "ATSC, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d\n",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
- }
+ else if (type == TUNER_ATSC) {
+ fields = sscanf(&line[k], atsc_conf,
+ &ptr->freq, mod, vpid_str, apid_str);
+ mp_verbose(log, "ATSC, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d\n",
+ list->NUM_CHANNELS, fields, ptr->name, ptr->freq);
+ }
#endif
- else //SATELLITE
- {
- fields = sscanf(&line[k], sat_conf,
- &ptr->freq, &ptr->pol, &ptr->diseqc, &ptr->srate, vpid_str, apid_str);
- ptr->pol = mp_toupper(ptr->pol);
- ptr->freq *= 1000UL;
- ptr->srate *= 1000UL;
- ptr->tone = -1;
- ptr->inv = INVERSION_AUTO;
- ptr->cr = FEC_AUTO;
- if((ptr->diseqc > 4) || (ptr->diseqc < 0))
- continue;
- if(ptr->diseqc > 0)
- ptr->diseqc--;
- mp_verbose(log, "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d",
- list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc);
- }
-
- if (parse_pid_string(log, vpid_str, ptr)) {
- fields++;
- }
- if (parse_pid_string(log, apid_str, ptr)) {
- fields++;
- }
- /* If we do not know the service_id, PMT can not be extracted.
- Teletext decoding will fail without PMT. */
- if (ptr->service_id != -1) {
- if (parse_pid_string(log, tpid_str, ptr)) {
- fields++;
- }
- }
-
-
- if((fields < 2) || (ptr->pids_cnt <= 0) || (ptr->freq == 0) || (strlen(ptr->name) == 0))
- continue;
-
- /* Add some PIDs which are mandatory in DVB,
- * and contain human-readable helpful data. */
-
- /* This is the STD, the service description table.
- * It contains service names and such, ffmpeg decodes it. */
- ptr->pids[ptr->pids_cnt] = 0x0011;
- ptr->pids_cnt++;
+ else { //SATELLITE
+ fields = sscanf(&line[k], sat_conf,
+ &ptr->freq, &ptr->pol, &ptr->diseqc, &ptr->srate,
+ vpid_str,
+ apid_str);
+ ptr->pol = mp_toupper(ptr->pol);
+ ptr->freq *= 1000UL;
+ ptr->srate *= 1000UL;
+ ptr->tone = -1;
+ ptr->inv = INVERSION_AUTO;
+ ptr->cr = FEC_AUTO;
+ if ((ptr->diseqc > 4) || (ptr->diseqc < 0))
+ continue;
+ if (ptr->diseqc > 0)
+ ptr->diseqc--;
+ mp_verbose(log, "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, "
+ "SRATE: %d, POL: %c, DISEQC: %d",
+ list->NUM_CHANNELS, fields, ptr->name, ptr->freq,
+ ptr->srate, ptr->pol, ptr->diseqc);
+ }
- /* This is the EIT, which contains EPG data.
- * ffmpeg can not decode it (yet), but e.g. VLC
- * shows what was recorded. */
- ptr->pids[ptr->pids_cnt] = 0x0012;
- ptr->pids_cnt++;
+ if (parse_pid_string(log, vpid_str, ptr))
+ fields++;
+ if (parse_pid_string(log, apid_str, ptr))
+ fields++;
+ /* If we do not know the service_id, PMT can not be extracted.
+ Teletext decoding will fail without PMT. */
+ if (ptr->service_id != -1) {
+ if (parse_pid_string(log, tpid_str, ptr))
+ fields++;
+ }
- if (ptr->service_id != -1) {
- /* We have the PMT-PID in addition.
- This will be found later, when we tune to the channel.
- Push back here to create the additional demux. */
- ptr->pids[ptr->pids_cnt] = -1; // Placeholder.
- ptr->pids_cnt++;
- }
-
- has8192 = has0 = 0;
- for(cnt = 0; cnt < ptr->pids_cnt; cnt++)
- {
- if(ptr->pids[cnt] == 8192)
- has8192 = 1;
- if(ptr->pids[cnt] == 0)
- has0 = 1;
- }
-
- /* 8192 is the pseudo-PID for full TP dump,
- enforce that if requested. */
- if (!has8192 && cfg_full_transponder) {
- has8192 = 1;
- }
- if (has8192) {
- ptr->pids[0] = 8192;
- ptr->pids_cnt = 1;
- } else if (!has0) {
- ptr->pids[ptr->pids_cnt] = 0; //PID 0 is the PAT
- ptr->pids_cnt++;
- }
- mp_verbose(log, " PIDS: ");
- for(cnt = 0; cnt < ptr->pids_cnt; cnt++)
- mp_verbose(log, " %d ", ptr->pids[cnt]);
- mp_verbose(log, "\n");
-
- if((type == TUNER_TER) || (type == TUNER_CBL))
- {
- if(! strcmp(inv, "INVERSION_ON"))
- ptr->inv = INVERSION_ON;
- else if(! strcmp(inv, "INVERSION_OFF"))
- ptr->inv = INVERSION_OFF;
- else
- ptr->inv = INVERSION_AUTO;
-
-
- if(! strcmp(cr, "FEC_1_2"))
- ptr->cr =FEC_1_2;
- else if(! strcmp(cr, "FEC_2_3"))
- ptr->cr =FEC_2_3;
- else if(! strcmp(cr, "FEC_3_4"))
- ptr->cr =FEC_3_4;
- else if(! strcmp(cr, "FEC_4_5"))
- ptr->cr =FEC_4_5;
- else if(! strcmp(cr, "FEC_6_7"))
- ptr->cr =FEC_6_7;
- else if(! strcmp(cr, "FEC_8_9"))
- ptr->cr =FEC_8_9;
- else if(! strcmp(cr, "FEC_5_6"))
- ptr->cr =FEC_5_6;
- else if(! strcmp(cr, "FEC_7_8"))
- ptr->cr =FEC_7_8;
- else if(! strcmp(cr, "FEC_NONE"))
- ptr->cr =FEC_NONE;
- else ptr->cr =FEC_AUTO;
- }
+ if ((fields < 2) || (ptr->pids_cnt <= 0) || (ptr->freq == 0) ||
+ (strlen(ptr->name) == 0))
+ continue;
+
+ /* Add some PIDs which are mandatory in DVB,
+ * and contain human-readable helpful data. */
+
+ /* This is the STD, the service description table.
+ * It contains service names and such, ffmpeg decodes it. */
+ ptr->pids[ptr->pids_cnt] = 0x0011;
+ ptr->pids_cnt++;
+ /* This is the EIT, which contains EPG data.
+ * ffmpeg can not decode it (yet), but e.g. VLC
+ * shows what was recorded. */
+ ptr->pids[ptr->pids_cnt] = 0x0012;
+ ptr->pids_cnt++;
+
+ if (ptr->service_id != -1) {
+ /* We have the PMT-PID in addition.
+ This will be found later, when we tune to the channel.
+ Push back here to create the additional demux. */
+ ptr->pids[ptr->pids_cnt] = -1; // Placeholder.
+ ptr->pids_cnt++;
+ }
+
+ has8192 = has0 = 0;
+ for (cnt = 0; cnt < ptr->pids_cnt; cnt++) {
+ if (ptr->pids[cnt] == 8192)
+ has8192 = 1;
+ if (ptr->pids[cnt] == 0)
+ has0 = 1;
+ }
- if((type == TUNER_TER) || (type == TUNER_CBL) || (type == TUNER_ATSC))
- {
- if(! strcmp(mod, "QAM_128"))
- ptr->mod = QAM_128;
- else if(! strcmp(mod, "QAM_256"))
- ptr->mod = QAM_256;
- else if(! strcmp(mod, "QAM_64"))
- ptr->mod = QAM_64;
- else if(! strcmp(mod, "QAM_32"))
- ptr->mod = QAM_32;
- else if(! strcmp(mod, "QAM_16"))
- ptr->mod = QAM_16;
+ /* 8192 is the pseudo-PID for full TP dump,
+ enforce that if requested. */
+ if (!has8192 && cfg_full_transponder)
+ has8192 = 1;
+ if (has8192) {
+ ptr->pids[0] = 8192;
+ ptr->pids_cnt = 1;
+ } else if (!has0) {
+ ptr->pids[ptr->pids_cnt] = 0; //PID 0 is the PAT
+ ptr->pids_cnt++;
+ }
+
+ mp_verbose(log, " PIDS: ");
+ for (cnt = 0; cnt < ptr->pids_cnt; cnt++)
+ mp_verbose(log, " %d ", ptr->pids[cnt]);
+ mp_verbose(log, "\n");
+
+ if ((type == TUNER_TER) || (type == TUNER_CBL)) {
+ if (!strcmp(inv, "INVERSION_ON")) {
+ ptr->inv = INVERSION_ON;
+ } else if (!strcmp(inv, "INVERSION_OFF")) {
+ ptr->inv = INVERSION_OFF;
+ } else {
+ ptr->inv = INVERSION_AUTO;
+ }
+
+
+ if (!strcmp(cr, "FEC_1_2")) {
+ ptr->cr = FEC_1_2;
+ } else if (!strcmp(cr, "FEC_2_3")) {
+ ptr->cr = FEC_2_3;
+ } else if (!strcmp(cr, "FEC_3_4")) {
+ ptr->cr = FEC_3_4;
+ } else if (!strcmp(cr, "FEC_4_5")) {
+ ptr->cr = FEC_4_5;
+ } else if (!strcmp(cr, "FEC_6_7")) {
+ ptr->cr = FEC_6_7;
+ } else if (!strcmp(cr, "FEC_8_9")) {
+ ptr->cr = FEC_8_9;
+ } else if (!strcmp(cr, "FEC_5_6")) {
+ ptr->cr = FEC_5_6;
+ } else if (!strcmp(cr, "FEC_7_8")) {
+ ptr->cr = FEC_7_8;
+ } else if (!strcmp(cr, "FEC_NONE")) {
+ ptr->cr = FEC_NONE;
+ } else {
+ ptr->cr = FEC_AUTO;
+ }
+ }
+
+
+ if (type == TUNER_TER || type == TUNER_CBL || type == TUNER_ATSC) {
+ if (!strcmp(mod, "QAM_128")) {
+ ptr->mod = QAM_128;
+ } else if (!strcmp(mod, "QAM_256")) {
+ ptr->mod = QAM_256;
+ } else if (!strcmp(mod, "QAM_64")) {
+ ptr->mod = QAM_64;
+ } else if (!strcmp(mod, "QAM_32")) {
+ ptr->mod = QAM_32;
+ } else if (!strcmp(mod, "QAM_16")) {
+ ptr->mod = QAM_16;
#ifdef DVB_ATSC
- else if(! strcmp(mod, "VSB_8") || ! strcmp(mod, "8VSB"))
- ptr->mod = VSB_8;
- else if(! strcmp(mod, "VSB_16") || !strcmp(mod, "16VSB"))
- ptr->mod = VSB_16;
- else if(! strcmp(mod, "QAM_AUTO"))
- ptr->mod = QAM_AUTO;
+ } else if (!strcmp(mod, "VSB_8") || !strcmp(mod, "8VSB")) {
+ ptr->mod = VSB_8;
+ } else if (!strcmp(mod, "VSB_16") || !strcmp(mod, "16VSB")) {
+ ptr->mod = VSB_16;
+ } else if (!strcmp(mod, "QAM_AUTO")) {
+ ptr->mod = QAM_AUTO;
+ }
#endif
- }
+ }
- if(type == TUNER_TER)
- {
- if(! strcmp(bw, "BANDWIDTH_6_MHZ"))
- ptr->bw = BANDWIDTH_6_MHZ;
- else if(! strcmp(bw, "BANDWIDTH_7_MHZ"))
- ptr->bw = BANDWIDTH_7_MHZ;
- else if(! strcmp(bw, "BANDWIDTH_8_MHZ"))
- ptr->bw = BANDWIDTH_8_MHZ;
-
-
- if(! strcmp(transm, "TRANSMISSION_MODE_2K"))
- ptr->trans = TRANSMISSION_MODE_2K;
- else if(! strcmp(transm, "TRANSMISSION_MODE_8K"))
- ptr->trans = TRANSMISSION_MODE_8K;
- else if(! strcmp(transm, "TRANSMISSION_MODE_AUTO"))
- ptr->trans = TRANSMISSION_MODE_AUTO;
-
- if(! strcmp(gi, "GUARD_INTERVAL_1_32"))
- ptr->gi = GUARD_INTERVAL_1_32;
- else if(! strcmp(gi, "GUARD_INTERVAL_1_16"))
- ptr->gi = GUARD_INTERVAL_1_16;
- else if(! strcmp(gi, "GUARD_INTERVAL_1_8"))
- ptr->gi = GUARD_INTERVAL_1_8;
- else if(! strcmp(gi, "GUARD_INTERVAL_1_4"))
- ptr->gi = GUARD_INTERVAL_1_4;
- else ptr->gi = GUARD_INTERVAL_AUTO;
-
- if(! strcmp(tmp_lcr, "FEC_1_2"))
- ptr->cr_lp =FEC_1_2;
- else if(! strcmp(tmp_lcr, "FEC_2_3"))
- ptr->cr_lp =FEC_2_3;
- else if(! strcmp(tmp_lcr, "FEC_3_4"))
- ptr->cr_lp =FEC_3_4;
- else if(! strcmp(tmp_lcr, "FEC_4_5"))
- ptr->cr_lp =FEC_4_5;
- else if(! strcmp(tmp_lcr, "FEC_6_7"))
- ptr->cr_lp =FEC_6_7;
- else if(! strcmp(tmp_lcr, "FEC_8_9"))
- ptr->cr_lp =FEC_8_9;
- else if(! strcmp(tmp_lcr, "FEC_5_6"))
- ptr->cr_lp =FEC_5_6;
- else if(! strcmp(tmp_lcr, "FEC_7_8"))
- ptr->cr_lp =FEC_7_8;
- else if(! strcmp(tmp_lcr, "FEC_NONE"))
- ptr->cr_lp =FEC_NONE;
- else ptr->cr_lp =FEC_AUTO;
-
-
- if(! strcmp(tmp_hier, "HIERARCHY_1"))
- ptr->hier = HIERARCHY_1;
- else if(! strcmp(tmp_hier, "HIERARCHY_2"))
- ptr->hier = HIERARCHY_2;
- else if(! strcmp(tmp_hier, "HIERARCHY_4"))
- ptr->hier = HIERARCHY_4;
- else if(! strcmp(tmp_hier, "HIERARCHY_AUTO"))
- ptr->hier = HIERARCHY_AUTO;
- else ptr->hier = HIERARCHY_NONE;
- }
+ if (type == TUNER_TER) {
+ if (!strcmp(bw, "BANDWIDTH_6_MHZ")) {
+ ptr->bw = BANDWIDTH_6_MHZ;
+ } else if (!strcmp(bw, "BANDWIDTH_7_MHZ")) {
+ ptr->bw = BANDWIDTH_7_MHZ;
+ } else if (!strcmp(bw, "BANDWIDTH_8_MHZ")) {
+ ptr->bw = BANDWIDTH_8_MHZ;
+ }
- tmp = realloc(list->channels, sizeof(dvb_channel_t) * (list->NUM_CHANNELS + 1));
- if(tmp == NULL)
- break;
-
- list->channels = tmp;
- memcpy(&(list->channels[list->NUM_CHANNELS]), ptr, sizeof(dvb_channel_t));
- list->NUM_CHANNELS++;
- if(sizeof(dvb_channel_t) * list->NUM_CHANNELS >= 1024*1024)
- {
- mp_verbose(log, "dvbin.c, > 1MB allocated for channels struct, dropping the rest of the file\r\n");
- break;
- }
+
+ if (!strcmp(transm, "TRANSMISSION_MODE_2K")) {
+ ptr->trans = TRANSMISSION_MODE_2K;
+ } else if (!strcmp(transm, "TRANSMISSION_MODE_8K")) {
+ ptr->trans = TRANSMISSION_MODE_8K;
+ } else if (!strcmp(transm, "TRANSMISSION_MODE_AUTO")) {
+ ptr->trans = TRANSMISSION_MODE_AUTO;
+ }
+
+ if (!strcmp(gi, "GUARD_INTERVAL_1_32")) {
+ ptr->gi = GUARD_INTERVAL_1_32;
+ } else if (!strcmp(gi, "GUARD_INTERVAL_1_16")) {
+ ptr->gi = GUARD_INTERVAL_1_16;
+ } else if (!strcmp(gi, "GUARD_INTERVAL_1_8")) {
+ ptr->gi = GUARD_INTERVAL_1_8;
+ } else if (!strcmp(gi, "GUARD_INTERVAL_1_4")) {
+ ptr->gi = GUARD_INTERVAL_1_4;
+ } else {
+ ptr->gi = GUARD_INTERVAL_AUTO;
+ }
+
+ if (!strcmp(tmp_lcr, "FEC_1_2")) {
+ ptr->cr_lp = FEC_1_2;
+ } else if (!strcmp(tmp_lcr, "FEC_2_3")) {
+ ptr->cr_lp = FEC_2_3;
+ } else if (!strcmp(tmp_lcr, "FEC_3_4")) {
+ ptr->cr_lp = FEC_3_4;
+ } else if (!strcmp(tmp_lcr, "FEC_4_5")) {
+ ptr->cr_lp = FEC_4_5;
+ } else if (!strcmp(tmp_lcr, "FEC_6_7")) {
+ ptr->cr_lp = FEC_6_7;
+ } else if (!strcmp(tmp_lcr, "FEC_8_9")) {
+ ptr->cr_lp = FEC_8_9;
+ } else if (!strcmp(tmp_lcr, "FEC_5_6")) {
+ ptr->cr_lp = FEC_5_6;
+ } else if (!strcmp(tmp_lcr, "FEC_7_8")) {
+ ptr->cr_lp = FEC_7_8;
+ } else if (!strcmp(tmp_lcr, "FEC_NONE")) {
+ ptr->cr_lp = FEC_NONE;
+ } else {
+ ptr->cr_lp = FEC_AUTO;
+ }
+
+
+ if (!strcmp(tmp_hier, "HIERARCHY_1")) {
+ ptr->hier = HIERARCHY_1;
+ } else if (!strcmp(tmp_hier, "HIERARCHY_2")) {
+ ptr->hier = HIERARCHY_2;
+ } else if (!strcmp(tmp_hier, "HIERARCHY_4")) {
+ ptr->hier = HIERARCHY_4;
+ } else if (!strcmp(tmp_hier, "HIERARCHY_AUTO")) {
+ ptr->hier = HIERARCHY_AUTO;
+ } else {
+ ptr->hier = HIERARCHY_NONE;
+ }
}
- fclose(f);
- if(list->NUM_CHANNELS == 0)
- {
- free(list->channels);
- free(list);
- return NULL;
+ tmp = realloc(list->channels, sizeof(dvb_channel_t) *
+ (list->NUM_CHANNELS + 1));
+ if (tmp == NULL)
+ break;
+
+ list->channels = tmp;
+ memcpy(&(list->channels[list->NUM_CHANNELS]), ptr, sizeof(dvb_channel_t));
+ list->NUM_CHANNELS++;
+ if (sizeof(dvb_channel_t) * list->NUM_CHANNELS >= 1024 * 1024) {
+ mp_verbose(log, "dvbin.c, > 1MB allocated for channels struct, "
+ "dropping the rest of the file\n");
+ break;
}
+ }
+
+ fclose(f);
+ if (list->NUM_CHANNELS == 0) {
+ free(list->channels);
+ free(list);
+ return NULL;
+ }
- list->current = 0;
- return list;
+ list->current = 0;
+ return list;
}
void dvb_free_config(dvb_config_t *config)
{
- int i, j;
-
- for(i=0; i<config->count; i++)
- {
- free(config->cards[i].name);
- if(!config->cards[i].list)
- continue;
- if(config->cards[i].list->channels)
- {
- for(j=0; j<config->cards[i].list->NUM_CHANNELS; j++)
- free(config->cards[i].list->channels[j].name);
- free(config->cards[i].list->channels);
- }
- free(config->cards[i].list);
+ int i, j;
+
+ for (i = 0; i < config->count; i++) {
+ free(config->cards[i].name);
+ if (!config->cards[i].list)
+ continue;
+ if (config->cards[i].list->channels) {
+ for (j = 0; j < config->cards[i].list->NUM_CHANNELS; j++)
+ free(config->cards[i].list->channels[j].name);
+ free(config->cards[i].list->channels);
}
- free(config);
+ free(config->cards[i].list);
+ }
+ free(config);
}
static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
{
- struct pollfd pfds[1];
- int pos=0, tries, rk, fd;
- dvb_priv_t *priv = (dvb_priv_t *) stream->priv;
-
- MP_TRACE(stream, "dvb_streaming_read(%d)\n", size);
-
- tries = priv->retry + 1;
-
- fd = priv->fd;
- while(pos < size)
- {
- pfds[0].fd = fd;
- pfds[0].events = POLLIN | POLLPRI;
-
- rk = size - pos;
- if(poll(pfds, 1, 500) <= 0)
- {
- MP_ERR(stream, "dvb_streaming_read, attempt N. %d failed with errno %d when reading %d bytes\n", tries, errno, size-pos);
- errno = 0;
- if(--tries > 0)
- continue;
- else
- break;
- }
- if((rk = read(fd, &buffer[pos], rk)) > 0)
- {
- pos += rk;
- MP_TRACE(stream, "ret (%d) bytes\n", pos);
- }
+ struct pollfd pfds[1];
+ int pos = 0, tries, rk, fd;
+ dvb_priv_t *priv = (dvb_priv_t *) stream->priv;
+
+ MP_TRACE(stream, "dvb_streaming_read(%d)\n", size);
+
+ tries = priv->retry + 1;
+
+ fd = priv->fd;
+ while (pos < size) {
+ pfds[0].fd = fd;
+ pfds[0].events = POLLIN | POLLPRI;
+
+ rk = size - pos;
+ if (poll(pfds, 1, 500) <= 0) {
+ MP_ERR(stream, "dvb_streaming_read, attempt N. %d failed with "
+ "errno %d when reading %d bytes\n", tries, errno, size - pos);
+ errno = 0;
+ if (--tries > 0)
+ continue;
+ break;
}
+ if ((rk = read(fd, &buffer[pos], rk)) > 0) {
+ pos += rk;
+ MP_TRACE(stream, "ret (%d) bytes\n", pos);
+ }
+ }
+ if (!pos)
+ MP_ERR(stream, "dvb_streaming_read, return %d bytes\n", pos);
- if(! pos)
- MP_ERR(stream, "dvb_streaming_read, return %d bytes\n", pos);
-
- return pos;
+ return pos;
}
static void dvbin_close(stream_t *stream);
int dvb_set_channel(stream_t *stream, int card, int n)
{
- dvb_channels_list *new_list;
- dvb_channel_t *channel;
- dvb_priv_t *priv = stream->priv;
- char buf[4096];
- dvb_config_t *conf = (dvb_config_t *) priv->config;
- int devno;
- int i;
-
- if((card < 0) || (card > conf->count))
- {
- MP_ERR(stream, "dvb_set_channel: INVALID CARD NUMBER: %d vs %d, abort\n", card, conf->count);
- return 0;
- }
+ dvb_channels_list *new_list;
+ dvb_channel_t *channel;
+ dvb_priv_t *priv = stream->priv;
+ char buf[4096];
+ dvb_config_t *conf = (dvb_config_t *) priv->config;
+ int devno;
+ int i;
+
+ if ((card < 0) || (card > conf->count)) {
+ MP_ERR(stream, "dvb_set_channel: INVALID CARD NUMBER: %d vs %d, abort\n",
+ card, conf->count);
+ return 0;
+ }
- devno = conf->cards[card].devno;
- new_list = conf->cards[card].list;
- if((n > new_list->NUM_CHANNELS) || (n < 0))
- {
- MP_ERR(stream, "dvb_set_channel: INVALID CHANNEL NUMBER: %d, for card %d, abort\n", n, card);
+ devno = conf->cards[card].devno;
+ new_list = conf->cards[card].list;
+ if ((n > new_list->NUM_CHANNELS) || (n < 0)) {
+ MP_ERR(stream, "dvb_set_channel: INVALID CHANNEL NUMBER: %d, for "
+ "card %d, abort\n", n, card);
+ return 0;
+ }
+ channel = &(new_list->channels[n]);
+
+ if (priv->is_on) { //the fds are already open and we have to stop the demuxers
+ for (i = 0; i < priv->demux_fds_cnt; i++)
+ dvb_demux_stop(priv->demux_fds[i]);
+
+ priv->retry = 0;
+ //empty both the stream's and driver's buffer
+ while (dvb_streaming_read(stream, buf, 4096) > 0) {}
+ if (priv->card != card) {
+ dvbin_close(stream);
+ if (!dvb_open_devices(priv, devno, channel->pids_cnt)) {
+ MP_ERR(stream, "DVB_SET_CHANNEL, COULDN'T OPEN DEVICES OF "
+ "CARD: %d, EXIT\n", card);
+ return 0;
+ }
+ } else {
+ // close all demux_fds with pos > pids required for the new channel
+ // or open other demux_fds if we have too few
+ if (!dvb_fix_demuxes(priv, channel->pids_cnt))
return 0;
}
- channel = &(new_list->channels[n]);
-
- if(priv->is_on) //the fds are already open and we have to stop the demuxers
- {
- for(i = 0; i < priv->demux_fds_cnt; i++)
- dvb_demux_stop(priv->demux_fds[i]);
-
- priv->retry = 0;
- while(dvb_streaming_read(stream, buf, 4096) > 0); //empty both the stream's and driver's buffer
- if(priv->card != card)
- {
- dvbin_close(stream);
- if(! dvb_open_devices(priv, devno, channel->pids_cnt))
- {
- MP_ERR(stream, "DVB_SET_CHANNEL, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
- return 0;
- }
- }
- else //close all demux_fds with pos > pids required for the new channel or open other demux_fds if we have too few
- {
- if(! dvb_fix_demuxes(priv, channel->pids_cnt))
- return 0;
- }
- }
- else
- {
- if(! dvb_open_devices(priv, devno, channel->pids_cnt))
- {
- MP_ERR(stream, "DVB_SET_CHANNEL2, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card);
- return 0;
- }
+ } else {
+ if (!dvb_open_devices(priv, devno, channel->pids_cnt)) {
+ MP_ERR(stream, "DVB_SET_CHANNEL2, COULDN'T OPEN DEVICES OF "
+ "CARD: %d, EXIT\n", card);
+ return 0;
}
+ }
+
+ priv->card = card;
+ priv->list = new_list;
+ priv->retry = 5;
+ new_list->current = n;
+ priv->fd = priv->dvr_fd;
+ MP_VERBOSE(stream, "DVB_SET_CHANNEL: new channel name=%s, card: %d, "
+ "channel %d\n", channel->name, card, n);
+
+ stream_drop_buffers(stream);
+
+ if (channel->freq != priv->last_freq) {
+ if (!dvb_tune(priv, channel->freq, channel->pol, channel->srate,
+ channel->diseqc, channel->tone,
+ channel->is_dvb_s2, channel->stream_id, channel->inv,
+ channel->mod, channel->gi,
+ channel->trans, channel->bw, channel->cr, channel->cr_lp,
+ channel->hier, priv->cfg_timeout))
+ return 0;
+ }
+
+ priv->last_freq = channel->freq;
+ priv->is_on = 1;
- priv->card = card;
- priv->list = new_list;
- priv->retry = 5;
- new_list->current = n;
- priv->fd = priv->dvr_fd;
- MP_VERBOSE(stream, "DVB_SET_CHANNEL: new channel name=%s, card: %d, channel %d\n", channel->name, card, n);
-
- stream_drop_buffers(stream);
-
- if(channel->freq != priv->last_freq)
- if (! dvb_tune(priv, channel->freq, channel->pol, channel->srate, channel->diseqc, channel->tone,
- channel->is_dvb_s2, channel->stream_id, channel->inv, channel->mod, channel->gi,
- channel->trans, channel->bw, channel->cr, channel->cr_lp, channel->hier, priv->cfg_timeout))
- return 0;
-
- priv->last_freq = channel->freq;
- priv->is_on = 1;
-
- if (channel->service_id != -1) {
- /* We need the PMT-PID in addition.
- If it has not yet beem resolved, do it now. */
- for (i = 0; i < channel->pids_cnt; i++) {
+ if (channel->service_id != -1) {
+ /* We need the PMT-PID in addition.
+ If it has not yet beem resolved, do it now. */
+ for (i = 0; i < channel->pids_cnt; i++) {
if (channel->pids[i] == -1) {
- MP_VERBOSE(stream, "DVB_SET_CHANNEL: PMT-PID for service %d not resolved yet, parsing PAT...\n", channel->service_id);
- int pmt_pid = dvb_get_pmt_pid(priv, card, channel->service_id);
- MP_VERBOSE(stream, "DVB_SET_CHANNEL: Found PMT-PID: %d\n", pmt_pid);
- channel->pids[i] = pmt_pid;
+ MP_VERBOSE(stream, "DVB_SET_CHANNEL: PMT-PID for service %d "
+ "not resolved yet, parsing PAT...\n",
+ channel->service_id);
+ int pmt_pid = dvb_get_pmt_pid(priv, card, channel->service_id);
+ MP_VERBOSE(stream, "DVB_SET_CHANNEL: Found PMT-PID: %d\n",
+ pmt_pid);
+ channel->pids[i] = pmt_pid;
}
- }
}
+ }
- // sets demux filters and restart the stream
- for(i = 0; i < channel->pids_cnt; i++)
- {
- if (channel->pids[i] == -1) {
+ // sets demux filters and restart the stream
+ for (i = 0; i < channel->pids_cnt; i++) {
+ if (channel->pids[i] == -1) {
// In case PMT was not resolved, skip it here.
- MP_ERR(stream, "DVB_SET_CHANNEL: PMT-PID not found, teletext-decoding may fail.\n");
- } else {
- if (!dvb_set_ts_filt(priv,priv->demux_fds[i], channel->pids[i], DMX_PES_OTHER))
- return 0;
- }
+ MP_ERR(stream, "DVB_SET_CHANNEL: PMT-PID not found, "
+ "teletext-decoding may fail.\n");
+ } else {
+ if (!dvb_set_ts_filt(priv, priv->demux_fds[i], channel->pids[i],
+ DMX_PES_OTHER))
+ return 0;
}
+ }
- return 1;
+ return 1;
}
-
-
int dvb_step_channel(stream_t *stream, int dir)
{
- int new_current;
- dvb_channels_list *list;
- dvb_priv_t *priv = stream->priv;
+ int new_current;
+ dvb_channels_list *list;
+ dvb_priv_t *priv = stream->priv;
- MP_VERBOSE(stream, "DVB_STEP_CHANNEL dir %d\n", dir);
+ MP_VERBOSE(stream, "DVB_STEP_CHANNEL dir %d\n", dir);
- if(priv == NULL)
- {
- MP_ERR(stream, "dvb_step_channel: NULL priv_ptr, quit\n");
- return 0;
- }
+ if (priv == NULL) {
+ MP_ERR(stream, "dvb_step_channel: NULL priv_ptr, quit\n");
+ return 0;
+ }
- list = priv->list;
- if(list == NULL)
- {
- MP_ERR(stream, "dvb_step_channel: NULL list_ptr, quit\n");
- return 0;
- }
+ list = priv->list;
+ if (list == NULL) {
+ MP_ERR(stream, "dvb_step_channel: NULL list_ptr, quit\n");
+ return 0;
+ }
- new_current = (list->NUM_CHANNELS + list->current + (dir >= 0 ? 1 : -1)) % list->NUM_CHANNELS;
+ new_current = (list->NUM_CHANNELS + list->current +
+ (dir >= 0 ? 1 : -1)) % list->NUM_CHANNELS;
- return dvb_set_channel(stream, priv->card, new_current);
+ return dvb_set_channel(stream, priv->card, new_current);
}
static int dvbin_stream_control(struct stream *s, int cmd, void *arg)
@@ -768,68 +783,63 @@ static int dvbin_stream_control(struct stream *s, int cmd, void *arg)
static void dvbin_close(stream_t *stream)
{
- int i;
- dvb_priv_t *priv = (dvb_priv_t *) stream->priv;
-
- for(i = priv->demux_fds_cnt-1; i >= 0; i--)
- {
- priv->demux_fds_cnt--;
- MP_VERBOSE(stream, "DVBIN_CLOSE, close(%d), fd=%d, COUNT=%d\n", i, priv->demux_fds[i], priv->demux_fds_cnt);
- close(priv->demux_fds[i]);
- }
- close(priv->dvr_fd);
+ int i;
+ dvb_priv_t *priv = (dvb_priv_t *) stream->priv;
+
+ for (i = priv->demux_fds_cnt - 1; i >= 0; i--) {
+ priv->demux_fds_cnt--;
+ MP_VERBOSE(stream, "DVBIN_CLOSE, close(%d), fd=%d, COUNT=%d\n", i,
+ priv->demux_fds[i], priv->demux_fds_cnt);
+ close(priv->demux_fds[i]);
+ }
+ close(priv->dvr_fd);
- close(priv->fe_fd);
- priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1;
+ close(priv->fe_fd);
+ priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1;
- priv->is_on = 0;
- dvb_free_config(priv->config);
+ priv->is_on = 0;
+ dvb_free_config(priv->config);
}
-
static int dvb_streaming_start(stream_t *stream, int tuner_type, char *progname)
{
- int i;
- dvb_channel_t *channel = NULL;
- dvb_priv_t *priv = stream->priv;
- dvb_priv_t *opts = priv;
+ int i;
+ dvb_channel_t *channel = NULL;
+ dvb_priv_t *priv = stream->priv;
+ dvb_priv_t *opts = priv;
- MP_VERBOSE(stream, "\r\ndvb_streaming_start(PROG: %s, CARD: %d)\r\n",
- opts->cfg_prog, opts->cfg_card);
+ MP_VERBOSE(stream, "\r\ndvb_streaming_start(PROG: %s, CARD: %d)\n",
+ opts->cfg_prog, opts->cfg_card);
- priv->is_on = 0;
+ priv->is_on = 0;
- i = 0;
- while((channel == NULL) && i < priv->list->NUM_CHANNELS)
- {
- if(! strcmp(priv->list->channels[i].name, progname))
- channel = &(priv->list->channels[i]);
+ i = 0;
+ while ((channel == NULL) && i < priv->list->NUM_CHANNELS) {
+ if (!strcmp(priv->list->channels[i].name, progname))
+ channel = &(priv->list->channels[i]);
- i++;
- }
+ i++;
+ }
- if(channel != NULL)
- {
- priv->list->current = i-1;
- MP_VERBOSE(stream, "PROGRAM NUMBER %d: name=%s, freq=%u\n", i-1, channel->name, channel->freq);
- }
- else
- {
- MP_ERR(stream, "\n\nDVBIN: no such channel \"%s\"\n\n", progname);
- return 0;
- }
+ if (channel != NULL) {
+ priv->list->current = i - 1;
+ MP_VERBOSE(stream, "PROGRAM NUMBER %d: name=%s, freq=%u\n", i - 1,
+ channel->name, channel->freq);
+ } else {
+ MP_ERR(stream, "\n\nDVBIN: no such channel \"%s\"\n\n", progname);
+ return 0;
+ }
- if(!dvb_set_channel(stream, priv->card, priv->list->current))
- {
- MP_ERR(stream, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current);
- dvbin_close(stream);
- return 0;
- }
+ if (!dvb_set_channel(stream, priv->card, priv->list->current)) {
+ MP_ERR(stream, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current);
+ dvbin_close(stream);
+ return 0;
+ }
- MP_VERBOSE(stream, "SUCCESSFUL EXIT from dvb_streaming_start\n");
+ MP_VERBOSE(stream, "SUCCESSFUL EXIT from dvb_streaming_start\n");
- return 1;
+ return 1;
}
@@ -837,181 +847,181 @@ static int dvb_streaming_start(stream_t *stream, int tuner_type, char *progname)
static int dvb_open(stream_t *stream)
{
- // I don't force the file format bacause, although it's almost always TS,
- // there are some providers that stream an IP multicast with M$ Mpeg4 inside
- dvb_priv_t *priv = stream->priv;
- priv->log = stream->log;
- dvb_priv_t *p = priv;
- char *progname;
- int tuner_type = 0, i;
-
- priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1;
- priv->config = dvb_get_config(stream);
- if(priv->config == NULL)
- {
- MP_ERR(stream, "DVB CONFIGURATION IS EMPTY, exit\n");
- return STREAM_ERROR;
- }
-
- priv->card = -1;
- for(i=0; i<priv->config->count; i++)
- {
- if(priv->config->cards[i].devno+1 == p->cfg_card)
- {
- priv->card = i;
- break;
- }
- }
+ // I don't force the file format bacause, although it's almost always TS,
+ // there are some providers that stream an IP multicast with M$ Mpeg4 inside
+ dvb_priv_t *priv = stream->priv;
+ priv->log = stream->log;
+ dvb_priv_t *p = priv;
+ char *progname;
+ int tuner_type = 0, i;
+
+ priv->fe_fd = priv->sec_fd = priv->dvr_fd = -1;
+ priv->config = dvb_get_config(stream);
+ if (priv->config == NULL) {
+ MP_ERR(stream, "DVB CONFIGURATION IS EMPTY, exit\n");
+ return STREAM_ERROR;
+ }
- if(priv->card == -1)
- {
- MP_ERR(stream, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->cfg_card);
- return STREAM_ERROR;
+ priv->card = -1;
+ for (i = 0; i < priv->config->count; i++) {
+ if (priv->config->cards[i].devno + 1 == p->cfg_card) {
+ priv->card = i;
+ break;
}
- priv->timeout = p->cfg_timeout;
+ }
- tuner_type = priv->config->cards[priv->card].type;
+ if (priv->card == -1) {
+ MP_ERR(stream, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n",
+ p->cfg_card);
+ return STREAM_ERROR;
+ }
+ priv->timeout = p->cfg_timeout;
- if(tuner_type == 0)
- {
- MP_VERBOSE(stream, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n");
- return STREAM_ERROR;
- }
+ tuner_type = priv->config->cards[priv->card].type;
+ if (tuner_type == 0) {
+ MP_VERBOSE(stream,
+ "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n");
+ return STREAM_ERROR;
+ }
- priv->tuner_type = tuner_type;
+ priv->tuner_type = tuner_type;
- MP_VERBOSE(stream, "OPEN_DVB: prog=%s, card=%d, type=%d\n",
- p->cfg_prog, priv->card+1, priv->tuner_type);
+ MP_VERBOSE(stream, "OPEN_DVB: prog=%s, card=%d, type=%d\n",
+ p->cfg_prog, priv->card + 1, priv->tuner_type);
- priv->list = priv->config->cards[priv->card].list;
+ priv->list = priv->config->cards[priv->card].list;
- if((! strcmp(p->cfg_prog, "")) && (priv->list != NULL))
- progname = priv->list->channels[0].name;
- else
- progname = p->cfg_prog;
+ if ((!strcmp(p->cfg_prog, "")) && (priv->list != NULL)) {
+ progname = priv->list->channels[0].name;
+ } else {
+ progname = p->cfg_prog;
+ }
- if(! dvb_streaming_start(stream, tuner_type, progname))
- {
- return STREAM_ERROR;
- }
+ if (!dvb_streaming_start(stream, tuner_type, progname))
+ return STREAM_ERROR;
- stream->type = STREAMTYPE_DVB;
- stream->fill_buffer = dvb_streaming_read;
- stream->close = dvbin_close;
- stream->control = dvbin_stream_control;
- stream->streaming = true;
+ stream->type = STREAMTYPE_DVB;
+ stream->fill_buffer = dvb_streaming_read;
+ stream->close = dvbin_close;
+ stream->control = dvbin_stream_control;
+ stream->streaming = true;
- stream->demuxer = "lavf";
- stream->lavf_type = "mpegts";
+ stream->demuxer = "lavf";
+ stream->lavf_type = "mpegts";
- return STREAM_OK;
+ return STREAM_OK;
}
#define MAX_CARDS 4
dvb_config_t *dvb_get_config(stream_t *stream)
{
- struct mp_log *log = stream->log;
- struct mpv_global *global = stream->global;
- dvb_priv_t *priv = stream->priv;
- int i, fd, type, size;
- char filename[30], *name;
- dvb_channels_list *list;
- dvb_card_config_t *cards = NULL, *tmp;
- dvb_config_t *conf = NULL;
-
-
- conf = malloc(sizeof(dvb_config_t));
- if(conf == NULL)
- return NULL;
-
- conf->priv = NULL;
- conf->count = 0;
- conf->cards = NULL;
- for(i=0; i<MAX_CARDS; i++)
- {
- snprintf(filename, sizeof(filename), "/dev/dvb/adapter%d/frontend0", i);
- fd = open(filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
- if(fd < 0)
- {
- mp_verbose(log, "DVB_CONFIG, can't open device %s, skipping\n", filename);
- continue;
- }
+ struct mp_log *log = stream->log;
+ struct mpv_global *global = stream->global;
+ dvb_priv_t *priv = stream->priv;
+ int i, fd, type, size;
+ char filename[30], *name;
+ dvb_channels_list *list;
+ dvb_card_config_t *cards = NULL, *tmp;
+ dvb_config_t *conf = NULL;
+
+ conf = malloc(sizeof(dvb_config_t));
+ if (conf == NULL)
+ return NULL;
+
+ conf->priv = NULL;
+ conf->count = 0;
+ conf->cards = NULL;
+ for (i = 0; i < MAX_CARDS; i++) {
+ snprintf(filename, sizeof(filename), "/dev/dvb/adapter%d/frontend0", i);
+ fd = open(filename, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
+ if (fd < 0) {
+ mp_verbose(log, "DVB_CONFIG, can't open device %s, skipping\n",
+ filename);
+ continue;
+ }
- type = dvb_get_tuner_type(fd, log);
- close(fd);
- if(type != TUNER_SAT && type != TUNER_TER && type != TUNER_CBL && type != TUNER_ATSC)
- {
- mp_verbose(log, "DVB_CONFIG, can't detect tuner type of card %d, skipping\n", i);
- continue;
- }
+ type = dvb_get_tuner_type(fd, log);
+ close(fd);
+ if (type != TUNER_SAT && type != TUNER_TER && type != TUNER_CBL &&
+ type != TUNER_ATSC) {
+ mp_verbose(log, "DVB_CONFIG, can't detect tuner type of "
+ "card %d, skipping\n", i);
+ continue;
+ }
void *talloc_ctx = talloc_new(NULL);
char *conf_file = NULL;
- if (priv->cfg_file && priv->cfg_file[0]) {
+ if (priv->cfg_file && priv->cfg_file[0])
conf_file = priv->cfg_file;
- } else {
- switch(type) {
+ else {
+ switch (type) {
case TUNER_TER:
- conf_file = mp_find_config_file(talloc_ctx, global, "channels.conf.ter");
+ conf_file = mp_find_config_file(talloc_ctx, global,
+ "channels.conf.ter");
break;
case TUNER_CBL:
- conf_file = mp_find_config_file(talloc_ctx, global, "channels.conf.cbl");
+ conf_file = mp_find_config_file(talloc_ctx, global,
+ "channels.conf.cbl");
break;
case TUNER_SAT:
- conf_file = mp_find_config_file(talloc_ctx, global, "channels.conf.sat");
+ conf_file = mp_find_config_file(talloc_ctx, global,
+ "channels.conf.sat");
break;
case TUNER_ATSC:
- conf_file = mp_find_config_file(talloc_ctx, global, "channels.conf.atsc");
+ conf_file = mp_find_config_file(talloc_ctx, global,
+ "channels.conf.atsc");
break;
}
if (conf_file) {
mp_verbose(log, "Ignoring other channels.conf files.\n");
} else {
- conf_file = mp_find_config_file(talloc_ctx, global, "channels.conf");
+ conf_file = mp_find_config_file(talloc_ctx, global,
+ "channels.conf");
}
}
- list = dvb_get_channels(log, priv->cfg_full_transponder, conf_file, type);
+ list = dvb_get_channels(log, priv->cfg_full_transponder, conf_file,
+ type);
talloc_free(talloc_ctx);
- if(list == NULL)
- continue;
-
- size = sizeof(dvb_card_config_t) * (conf->count + 1);
- tmp = realloc(conf->cards, size);
-
- if(tmp == NULL)
- {
- fprintf(stderr, "DVB_CONFIG, can't realloc %d bytes, skipping\n", size);
- continue;
- }
- cards = tmp;
+ if (list == NULL)
+ continue;
- name = malloc(20);
- if(name==NULL)
- {
- fprintf(stderr, "DVB_CONFIG, can't realloc 20 bytes, skipping\n");
- continue;
- }
+ size = sizeof(dvb_card_config_t) * (conf->count + 1);
+ tmp = realloc(conf->cards, size);
- conf->cards = cards;
- conf->cards[conf->count].devno = i;
- conf->cards[conf->count].list = list;
- conf->cards[conf->count].type = type;
- snprintf(name, 20, "DVB-%c card n. %d", type==TUNER_TER ? 'T' : (type==TUNER_CBL ? 'C' : 'S'), conf->count+1);
- conf->cards[conf->count].name = name;
- conf->count++;
+ if (tmp == NULL) {
+ fprintf(stderr, "DVB_CONFIG, can't realloc %d bytes, skipping\n",
+ size);
+ continue;
}
+ cards = tmp;
- if(conf->count == 0)
- {
- free(conf);
- conf = NULL;
+ name = malloc(20);
+ if (name == NULL) {
+ fprintf(stderr, "DVB_CONFIG, can't realloc 20 bytes, skipping\n");
+ continue;
}
- return conf;
+ conf->cards = cards;
+ conf->cards[conf->count].devno = i;
+ conf->cards[conf->count].list = list;
+ conf->cards[conf->count].type = type;
+ snprintf(name, 20, "DVB-%c card n. %d",
+ type == TUNER_TER ? 'T' : (type == TUNER_CBL ? 'C' : 'S'),
+ conf->count + 1);
+ conf->cards[conf->count].name = name;
+ conf->count++;
+ }
+
+ if (conf->count == 0) {
+ free(conf);
+ conf = NULL;
+ }
+
+ return conf;
}
static void *get_defaults(stream_t *st)
@@ -1022,11 +1032,11 @@ static void *get_defaults(stream_t *st)
const stream_info_t stream_info_dvb = {
.name = "dvbin",
.open = dvb_open,
- .protocols = (const char*const[]){ "dvb", NULL },
+ .protocols = (const char *const[]){ "dvb", NULL },
.priv_size = sizeof(dvb_priv_t),
.get_defaults = get_defaults,
.options = stream_params,
- .url_options = (const char*const[]){
+ .url_options = (const char *const[]){
"hostname=prog",
"username=card",
NULL