diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/cookies.c | 74 | ||||
-rw-r--r-- | stream/cookies.h | 5 | ||||
-rw-r--r-- | stream/dvb_tune.c | 335 | ||||
-rw-r--r-- | stream/dvbin.h | 62 | ||||
-rw-r--r-- | stream/stream.c | 20 | ||||
-rw-r--r-- | stream/stream.h | 5 | ||||
-rw-r--r-- | stream/stream_avdevice.c | 2 | ||||
-rw-r--r-- | stream/stream_bluray.c | 25 | ||||
-rw-r--r-- | stream/stream_cb.c | 2 | ||||
-rw-r--r-- | stream/stream_cdda.c | 83 | ||||
-rw-r--r-- | stream/stream_concat.c | 2 | ||||
-rw-r--r-- | stream/stream_dvb.c | 770 | ||||
-rw-r--r-- | stream/stream_dvdnav.c | 2 | ||||
-rw-r--r-- | stream/stream_file.c | 18 | ||||
-rw-r--r-- | stream/stream_lavf.c | 45 | ||||
-rw-r--r-- | stream/stream_libarchive.c | 2 | ||||
-rw-r--r-- | stream/stream_memory.c | 2 | ||||
-rw-r--r-- | stream/stream_mf.c | 3 | ||||
-rw-r--r-- | stream/stream_null.c | 2 | ||||
-rw-r--r-- | stream/stream_slice.c | 7 |
20 files changed, 558 insertions, 908 deletions
diff --git a/stream/cookies.c b/stream/cookies.c index d1c6e6d488..fe61c0e512 100644 --- a/stream/cookies.c +++ b/stream/cookies.c @@ -29,8 +29,7 @@ #include <dirent.h> #include <inttypes.h> -#include "osdep/io.h" - +#include "stream/stream.h" #include "options/options.h" #include "cookies.h" #include "common/msg.h" @@ -77,65 +76,21 @@ static int parse_line(char **ptr, char *cols[7]) return 1; } -/* Loads a file into RAM */ -static char *load_file(struct mp_log *log, const char *filename, int64_t * length) -{ - int fd; - char *buffer = NULL; - - mp_verbose(log, "Loading cookie file: %s\n", filename); - - fd = open(filename, O_RDONLY | O_CLOEXEC); - if (fd < 0) { - mp_verbose(log, "Could not open"); - goto err_out; - } - - *length = lseek(fd, 0, SEEK_END); - - if (*length < 0) { - mp_verbose(log, "Could not find EOF"); - goto err_out; - } - - if (*length > SIZE_MAX - 1) { - mp_verbose(log, "File too big, could not malloc."); - goto err_out; - } - - lseek(fd, 0, SEEK_SET); - - if (!(buffer = malloc(*length + 1))) { - mp_verbose(log, "Could not malloc."); - goto err_out; - } - - if (read(fd, buffer, *length) != *length) { - mp_verbose(log, "Read is behaving funny."); - goto err_out; - } - close(fd); - buffer[*length] = 0; - - return buffer; - -err_out: - if (fd != -1) close(fd); - free(buffer); - return NULL; -} - /* Loads a cookies.txt file into a linked list. */ static struct cookie_list_type *load_cookies_from(void *ctx, + struct mpv_global *global, struct mp_log *log, const char *filename) { - char *ptr, *file; - int64_t length; - - ptr = file = load_file(log, filename, &length); - if (!ptr) + mp_verbose(log, "Loading cookie file: %s\n", filename); + bstr data = stream_read_file(filename, ctx, global, 1000000); + if (!data.start) { + mp_verbose(log, "Error reading\n"); return NULL; + } + + bstr_xappend(ctx, &data, (struct bstr){"", 1}); // null-terminate + char *ptr = data.start; struct cookie_list_type *list = NULL; while (*ptr) { @@ -152,19 +107,22 @@ static struct cookie_list_type *load_cookies_from(void *ctx, list = new; } } - free(file); + return list; } // Return a cookies string as expected by lavf (libavformat/http.c). The format // is like a Set-Cookie header (http://curl.haxx.se/rfc/cookie_spec.html), // separated by newlines. -char *cookies_lavf(void *talloc_ctx, struct mp_log *log, char *file) +char *cookies_lavf(void *talloc_ctx, + struct mpv_global *global, + struct mp_log *log, + const char *file) { void *tmp = talloc_new(NULL); struct cookie_list_type *list = NULL; if (file && file[0]) - list = load_cookies_from(tmp, log, file); + list = load_cookies_from(tmp, global, log, file); char *res = talloc_strdup(talloc_ctx, ""); diff --git a/stream/cookies.h b/stream/cookies.h index 6acd0c3ba3..491b87df78 100644 --- a/stream/cookies.h +++ b/stream/cookies.h @@ -23,6 +23,9 @@ #ifndef MPLAYER_COOKIES_H #define MPLAYER_COOKIES_H -char *cookies_lavf(void *talloc_ctx, struct mp_log *log, char *file); +char *cookies_lavf(void *talloc_ctx, + struct mpv_global *global, + struct mp_log *log, + const char *file); #endif /* MPLAYER_COOKIES_H */ diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c index d9b350f876..d18f70f7a9 100644 --- a/stream/dvb_tune.c +++ b/stream/dvb_tune.c @@ -30,13 +30,12 @@ #include <poll.h> #include <unistd.h> #include <fcntl.h> -#include <time.h> #include <errno.h> #include <linux/dvb/dmx.h> #include <linux/dvb/frontend.h> -#include "config.h" #include "osdep/io.h" +#include "osdep/timer.h" #include "dvbin.h" #include "dvb_tune.h" #include "common/msg.h" @@ -77,95 +76,22 @@ unsigned int dvb_get_tuner_delsys_mask(int fe_fd, struct mp_log *log) unsigned int ret_mask = 0, delsys; struct dtv_property prop[1]; struct dtv_properties cmdseq = {.num = 1, .props = prop}; - struct dvb_frontend_info fe_info; -#ifdef DVB_USE_S2API - /* S2API is the DVB API new since 2.6.28. - It allows to query frontends with multiple delivery systems. */ - mp_verbose(log, "Querying tuner frontend type via DVBv5 API for frontend FD %d\n", - fe_fd); prop[0].cmd = DTV_ENUM_DELSYS; if (ioctl(fe_fd, FE_GET_PROPERTY, &cmdseq) < 0) { - mp_err(log, "DVBv5: FE_GET_PROPERTY(DTV_ENUM_DELSYS) error: %d, FD: %d\n\n", errno, fe_fd); - goto old_api; + mp_err(log, "DVBv5: FE_GET_PROPERTY(DTV_ENUM_DELSYS) error: %d\n", errno); + return ret_mask; } - unsigned int i, delsys_count = prop[0].u.buffer.len; - mp_verbose(log, "DVBv5: Number of supported delivery systems: %d\n", delsys_count); + unsigned int delsys_count = prop[0].u.buffer.len; if (delsys_count == 0) { - mp_err(log, "DVBv5: Frontend FD %d returned no delivery systems!\n", fe_fd); - goto old_api; + mp_err(log, "DVBv5: Frontend returned no delivery systems!\n"); + return ret_mask; } - for (i = 0; i < delsys_count; i++) { + mp_verbose(log, "DVBv5: Number of supported delivery systems: %d\n", delsys_count); + for (unsigned int i = 0; i < delsys_count; i++) { delsys = (unsigned int)prop[0].u.buffer.data[i]; DELSYS_SET(ret_mask, delsys); - mp_verbose(log, "DVBv5: Tuner frontend type seems to be %s\n", get_dvb_delsys(delsys)); - } - - return ret_mask; - -old_api: -#endif - mp_verbose(log, "Querying tuner frontend type via pre-DVBv5 API for frontend FD %d\n", - fe_fd); - - memset(&fe_info, 0x00, sizeof(struct dvb_frontend_info)); - if (ioctl(fe_fd, FE_GET_INFO, &fe_info) < 0) { - mp_err(log, "DVBv3: FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); - return ret_mask; - } - /* Try to get kernel DVB API version. */ - prop[0].cmd = DTV_API_VERSION; - if (ioctl(fe_fd, FE_GET_PROPERTY, &cmdseq) < 0) { - prop[0].u.data = 0x0300; /* Fail, assume 3.0 */ - } - - mp_verbose(log, "DVBv3: Queried tuner frontend type of device named '%s', FD: %d\n", - fe_info.name, fe_fd); - switch (fe_info.type) { - case FE_OFDM: - DELSYS_SET(ret_mask, SYS_DVBT); - if (prop[0].u.data < 0x0500) - break; - if (FE_CAN_2G_MODULATION & fe_info.caps) { - DELSYS_SET(ret_mask, SYS_DVBT2); - } - break; - case FE_QPSK: - DELSYS_SET(ret_mask, SYS_DVBS); - if (prop[0].u.data < 0x0500) - break; - if (FE_CAN_2G_MODULATION & fe_info.caps) { - DELSYS_SET(ret_mask, SYS_DVBS2); - } -#if 0 /* Not used now. */ - if (FE_CAN_TURBO_FEC & fe_info.caps) { - DELSYS_SET(ret_mask, SYS_TURBO); - } -#endif - break; - case FE_QAM: - DELSYS_SET(ret_mask, SYS_DVBC_ANNEX_A); - DELSYS_SET(ret_mask, SYS_DVBC_ANNEX_C); - break; -#ifdef DVB_ATSC - case FE_ATSC: - if ((FE_CAN_8VSB | FE_CAN_16VSB) & fe_info.caps) { - DELSYS_SET(ret_mask, SYS_ATSC); - } - if ((FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO) & fe_info.caps) { - DELSYS_SET(ret_mask, SYS_DVBC_ANNEX_B); - } - break; -#endif - default: - mp_err(log, "DVBv3: Unknown tuner frontend type: %d\n", fe_info.type); - return ret_mask; - } - - for (delsys = 0; delsys < SYS_DVB__COUNT__; delsys ++) { - if (!DELSYS_IS_SET(ret_mask, delsys)) - continue; /* Skip unsupported. */ - mp_verbose(log, "DVBv3: Tuner frontend type seems to be %s\n", get_dvb_delsys(delsys)); + mp_verbose(log, " %s\n", get_dvb_delsys(delsys)); } return ret_mask; @@ -174,70 +100,63 @@ old_api: int dvb_open_devices(dvb_priv_t *priv, unsigned int adapter, unsigned int frontend, unsigned int demux_cnt) { - unsigned int i; - char frontend_dev[PATH_MAX], dvr_dev[PATH_MAX], demux_dev[PATH_MAX]; - dvb_state_t* state = priv->state; + dvb_state_t *state = priv->state; + char frontend_dev[100], dvr_dev[100], demux_dev[100]; snprintf(frontend_dev, sizeof(frontend_dev), "/dev/dvb/adapter%u/frontend%u", adapter, frontend); snprintf(dvr_dev, sizeof(dvr_dev), "/dev/dvb/adapter%u/dvr0", adapter); snprintf(demux_dev, sizeof(demux_dev), "/dev/dvb/adapter%u/demux0", adapter); - MP_VERBOSE(priv, "DVB_OPEN_DEVICES: frontend: %s\n", frontend_dev); + + MP_VERBOSE(priv, "Opening frontend device %s\n", frontend_dev); state->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); if (state->fe_fd < 0) { - MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", - frontend_dev, errno); + MP_ERR(priv, "Error opening frontend device: %d\n", errno); return 0; } + state->demux_fds_cnt = 0; - MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt); - for (i = 0; i < demux_cnt; i++) { + MP_VERBOSE(priv, "Opening %d demuxers\n", demux_cnt); + for (unsigned int i = 0; i < demux_cnt; i++) { state->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); if (state->demux_fds[i] < 0) { - MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno); + MP_ERR(priv, "Error opening demux0: %d\n", errno); return 0; - } else { - MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, - state->demux_fds[i], state->demux_fds_cnt); - state->demux_fds_cnt++; } + state->demux_fds_cnt++; } state->dvr_fd = open(dvr_dev, O_RDONLY | O_NONBLOCK | O_CLOEXEC); if (state->dvr_fd < 0) { - MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno); + MP_ERR(priv, "Error opening dvr device %s: %d\n", dvr_dev, errno); return 0; } return 1; } - int dvb_fix_demuxes(dvb_priv_t *priv, unsigned int cnt) { - int i; - char demux_dev[PATH_MAX]; - - dvb_state_t* state = priv->state; + dvb_state_t *state = priv->state; + char demux_dev[100]; snprintf(demux_dev, sizeof(demux_dev), "/dev/dvb/adapter%d/demux0", state->adapters[state->cur_adapter].devno); - MP_VERBOSE(priv, "FIX %d -> %d\n", state->demux_fds_cnt, cnt); + + MP_VERBOSE(priv, "Changing demuxer count %d -> %d\n", state->demux_fds_cnt, cnt); if (state->demux_fds_cnt >= cnt) { - for (i = state->demux_fds_cnt - 1; i >= (int)cnt; i--) { - MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, state->demux_fds[i]); + for (int i = state->demux_fds_cnt - 1; i >= (int)cnt; i--) { close(state->demux_fds[i]); } state->demux_fds_cnt = cnt; } else { - for (i = state->demux_fds_cnt; i < cnt; i++) { + for (int i = state->demux_fds_cnt; i < cnt; i++) { state->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); - MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, state->demux_fds[i]); if (state->demux_fds[i] < 0) { - MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno); + MP_ERR(priv, "Error opening demux0: %d\n", errno); return 0; - } else - state->demux_fds_cnt++; + } + state->demux_fds_cnt++; } } @@ -259,19 +178,17 @@ int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, { int buffersize = 256 * 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_ERR(priv, "Error in DMX_SET_BUFFER_SIZE %i: errno=%d\n", + pid, 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); + MP_ERR(priv, "Error in DMX_SET_PES_FILTER %i: errno=%d\n", + pid, 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; } @@ -279,12 +196,10 @@ int dvb_get_pmt_pid(dvb_priv_t *priv, int devno, int service_id) { /* We need special filters on the demux, so open one locally, and close also here. */ - char demux_dev[PATH_MAX]; + char demux_dev[100]; snprintf(demux_dev, sizeof(demux_dev), "/dev/dvb/adapter%d/demux0", devno); - struct dmx_sct_filter_params fparams; - - memset(&fparams, 0x00, sizeof(fparams)); + struct dmx_sct_filter_params fparams = {0}; fparams.pid = 0; fparams.filter.filter[0] = 0x00; fparams.filter.mask[0] = 0xff; @@ -293,18 +208,17 @@ int dvb_get_pmt_pid(dvb_priv_t *priv, int devno, int service_id) int pat_fd; if ((pat_fd = open(demux_dev, O_RDWR)) < 0) { - MP_ERR(priv, "Opening PAT DEMUX failed, error: %d", errno); + MP_ERR(priv, "Opening PAT demux failed: %d", errno); return -1; } if (ioctl(pat_fd, DMX_SET_FILTER, &fparams) < 0) { - MP_ERR(priv, "ioctl DMX_SET_FILTER failed, error: %d", errno); + MP_ERR(priv, "ioctl DMX_SET_FILTER failed: %d", errno); close(pat_fd); return -1; } int bytes_read; - int section_length; unsigned char buft[4096]; unsigned char *bufptr = buft; @@ -312,17 +226,16 @@ int dvb_get_pmt_pid(dvb_priv_t *priv, int devno, int service_id) 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 && errno == EOVERFLOW) bytes_read = read(pat_fd, bufptr, sizeof(buft)); if (bytes_read < 0) { - MP_ERR(priv, "PAT: read_sections: read error: %d", errno); + MP_ERR(priv, "PAT: read error: %d", errno); close(pat_fd); return -1; } - section_length = ((bufptr[1] & 0x0f) << 8) | bufptr[2]; + int section_length = ((bufptr[1] & 0x0f) << 8) | bufptr[2]; if (bytes_read != section_length + 3) continue; @@ -366,17 +279,16 @@ static void print_status(dvb_priv_t *priv, fe_status_t festatus) 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; + bool ok = false; + int locks = 0; + struct pollfd pfd[1]; pfd[0].fd = fd_frontend; pfd[0].events = POLLPRI; MP_VERBOSE(priv, "Getting frontend status\n"); - tm1 = tm2 = time((time_t *) NULL); + int tm1 = (int)mp_time_sec(); while (!ok) { festatus = 0; if (poll(pfd, 1, tmout * 1000) > 0) { @@ -388,34 +300,35 @@ static int check_status(dvb_priv_t *priv, int fd_frontend, int tmout) } } usleep(10000); - tm2 = time((time_t *) NULL); + int tm2 = (int)mp_time_sec(); if ((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout)) - ok = 1; + ok = true; } - 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_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); - - print_status(priv, festatus); - } else { + if (!(festatus & FE_HAS_LOCK)) { MP_ERR(priv, "Not able to lock to the signal on the given frequency, " "timeout: %d\n", tmout); return -1; } + + int32_t 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_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); + + print_status(priv, festatus); + return 0; } @@ -463,25 +376,21 @@ static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo) ((sat_no / 4) % 2) ? SEC_MINI_B : SEC_MINI_A); } -#ifdef DVB_USE_S2API static int dvbv5_tune(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, struct dtv_properties* cmdseq) { - MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", - get_dvb_delsys(delsys)); MP_VERBOSE(priv, "Dumping raw tuning commands and values:\n"); for (int i = 0; i < cmdseq->num; ++i) { - MP_VERBOSE(priv, "%02d: 0x%x(%d) => 0x%x(%d)\n", + MP_VERBOSE(priv, " %02d: 0x%x(%d) => 0x%x(%d)\n", i, cmdseq->props[i].cmd, cmdseq->props[i].cmd, cmdseq->props[i].u.data, cmdseq->props[i].u.data); } if (ioctl(fd_frontend, FE_SET_PROPERTY, cmdseq) < 0) { - MP_ERR(priv, "ERROR tuning channel\n"); + MP_ERR(priv, "Error tuning channel\n"); return -1; } return 0; } -#endif static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, unsigned int freq, unsigned int srate, char pol, @@ -495,12 +404,9 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) { - int hi_lo = 0, bandwidth_hz = 0; - dvb_state_t* state = priv->state; - struct dvb_frontend_parameters feparams; + dvb_state_t *state = priv->state; - - MP_VERBOSE(priv, "TUNE_IT, fd_frontend %d, %s freq %lu, srate %lu, " + MP_VERBOSE(priv, "tune_it: fd_frontend %d, %s freq %lu, srate %lu, " "pol %c, diseqc %u\n", fd_frontend, get_dvb_delsys(delsys), (long unsigned int)freq, (long unsigned int)srate, @@ -519,15 +425,12 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, } } - /* Prepare params, be verbose. */ + /* Prepare params, be verbose. */ + int hi_lo = 0, bandwidth_hz = 0; switch (delsys) { case SYS_DVBT2: -#ifndef DVB_USE_S2API - MP_ERR(priv, "ERROR: Can not tune to T2 channel, S2-API not " - "available, will tune to DVB-T!\n"); -#endif - /* PASSTROUTH. */ case SYS_DVBT: + case SYS_ISDBT: if (freq < 1000000) freq *= 1000UL; switch (bandwidth) { @@ -562,11 +465,6 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, get_dvb_delsys(delsys), freq, bandwidth_hz); break; case SYS_DVBS2: -#ifndef DVB_USE_S2API - MP_ERR(priv, "ERROR: Can not tune to S2 channel, S2-API not " - "available, will tune to DVB-S!\n"); -#endif - /* PASSTROUTH. */ case SYS_DVBS: if (freq > 2200000) { // this must be an absolute frequency @@ -595,19 +493,16 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, MP_VERBOSE(priv, "tuning %s to %d, srate=%d\n", get_dvb_delsys(delsys), freq, srate); break; -#ifdef DVB_ATSC case SYS_ATSC: case SYS_DVBC_ANNEX_B: MP_VERBOSE(priv, "tuning %s to %d, modulation=%d\n", get_dvb_delsys(delsys), freq, modulation); break; -#endif default: - MP_VERBOSE(priv, "Unknown FE type. Aborting\n"); + MP_VERBOSE(priv, "Unknown FE type, aborting.\n"); return 0; } -#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. @@ -622,7 +517,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, .props = p_clear }; if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq_clear) < 0) { - MP_ERR(priv, "FE_SET_PROPERTY DTV_CLEAR failed\n"); + MP_ERR(priv, "DTV_CLEAR failed\n"); } /* Tune. */ @@ -646,12 +541,13 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, .props = p }; if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) { - goto old_api; + goto error_tune; } } break; case SYS_DVBT: case SYS_DVBT2: + case SYS_ISDBT: { struct dtv_property p[] = { { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, @@ -673,7 +569,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, .props = p }; if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) { - goto old_api; + goto error_tune; } } break; @@ -694,11 +590,10 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, .props = p }; if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) { - goto old_api; + goto error_tune; } } break; -#ifdef DVB_ATSC case SYS_ATSC: case SYS_DVBC_ANNEX_B: { @@ -714,73 +609,21 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, .props = p }; if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) { - goto old_api; + goto error_tune; } } break; -#endif } int tune_status = check_status(priv, fd_frontend, timeout); if (tune_status != 0) { - MP_ERR(priv, "ERROR locking to channel when tuning with S2API, clearing and falling back to DVBv3-tuning.\n"); - if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq_clear) < 0) { - MP_ERR(priv, "FE_SET_PROPERTY DTV_CLEAR failed\n"); - } - goto old_api; - } else { - return tune_status; - } - -old_api: -#endif - - MP_VERBOSE(priv, "Tuning via DVB-API version 3.\n"); - - if (stream_id != NO_STREAM_ID_FILTER && stream_id != 0) { - MP_ERR(priv, "DVB-API version 3 does not support stream_id (PLP).\n"); - return -1; - } - memset(&feparams, 0x00, sizeof(feparams)); - feparams.frequency = freq; - feparams.inversion = specInv; - - switch (delsys) { - case SYS_DVBT: - case SYS_DVBT2: - 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; - break; - case SYS_DVBS: - case SYS_DVBS2: - feparams.u.qpsk.symbol_rate = srate; - feparams.u.qpsk.fec_inner = HP_CodeRate; - break; - case SYS_DVBC_ANNEX_A: - case SYS_DVBC_ANNEX_C: - feparams.u.qam.symbol_rate = srate; - feparams.u.qam.fec_inner = HP_CodeRate; - feparams.u.qam.modulation = modulation; - break; -#ifdef DVB_ATSC - case SYS_ATSC: - case SYS_DVBC_ANNEX_B: - feparams.u.vsb.modulation = modulation; - break; -#endif - } - - if (ioctl(fd_frontend, FE_SET_FRONTEND, &feparams) < 0) { - MP_ERR(priv, "ERROR tuning channel\n"); - return -1; + MP_ERR(priv, "Error locking to channel\n"); } + return tune_status; - return check_status(priv, fd_frontend, timeout); +error_tune: + MP_ERR(priv, "Error tuning channel\n"); + return -1; } int dvb_tune(dvb_priv_t *priv, unsigned int delsys, @@ -792,10 +635,10 @@ int dvb_tune(dvb_priv_t *priv, unsigned int delsys, fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) { - MP_INFO(priv, "dvb_tune %s Freq: %lu\n", + MP_INFO(priv, "Tuning to %s frequency %lu Hz\n", get_dvb_delsys(delsys), (long unsigned int) freq); - dvb_state_t* state = priv->state; + dvb_state_t *state = priv->state; int ris = tune_it(priv, state->fe_fd, delsys, freq, srate, pol, stream_id, specInv, diseqc, modulation, @@ -803,7 +646,7 @@ int dvb_tune(dvb_priv_t *priv, unsigned int delsys, bandWidth, LP_CodeRate, hier, timeout); if (ris != 0) - MP_INFO(priv, "dvb_tune, TUNING FAILED\n"); + MP_INFO(priv, "Tuning failed\n"); return ris == 0; } diff --git a/stream/dvbin.h b/stream/dvbin.h index aca2cabdb4..3daf7470de 100644 --- a/stream/dvbin.h +++ b/stream/dvbin.h @@ -22,42 +22,13 @@ #include <inttypes.h> #include <linux/dvb/dmx.h> #include <linux/dvb/frontend.h> -#include <linux/dvb/video.h> -#include <linux/dvb/audio.h> #include <linux/dvb/version.h> #define MAX_ADAPTERS 16 #define MAX_FRONTENDS 8 -#undef DVB_ATSC -#if defined(DVB_API_VERSION_MINOR) - -/* 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. - * At least DTV_ENUM_DELSYS requires 5.5. - */ - -#if (DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR >= 5) -#define DVB_USE_S2API 1 - -// This had a different name until API 5.8. -#ifndef DTV_STREAM_ID -#define DTV_STREAM_ID DTV_ISDBS_TS_ID -#endif -#endif - -// This is only defined, for convenience, since API 5.8. -#ifndef NO_STREAM_ID_FILTER -#define NO_STREAM_ID_FILTER (~0U) -#endif - -#if (DVB_API_VERSION == 3 && DVB_API_VERSION_MINOR >= 1) || DVB_API_VERSION == 5 -#define DVB_ATSC 1 -#endif - +#if DVB_API_VERSION < 5 || DVB_API_VERSION_MINOR < 8 +#error DVB support requires a non-ancient kernel #endif #define DVB_CHANNEL_LOWER -1 @@ -108,7 +79,7 @@ typedef struct { int dvr_fd; int demux_fd[3], demux_fds[DMX_FILTER_SIZE], demux_fds_cnt; - int is_on; + bool is_on; int retry; unsigned int last_freq; bool switching_channel; @@ -120,7 +91,7 @@ typedef struct { int cfg_devno; int cfg_timeout; char *cfg_file; - int cfg_full_transponder; + bool cfg_full_transponder; int cfg_channel_switch_offset; } dvb_opts_t; @@ -132,22 +103,13 @@ typedef struct { char *prog; int devno; + int opts_check_time; dvb_opts_t *opts; struct m_config_cache *opts_cache; } dvb_priv_t; /* Keep in sync with enum fe_delivery_system. */ -#ifndef DVB_USE_S2API -# define SYS_DVBC_ANNEX_A 1 -# define SYS_DVBC_ANNEX_B 1 -# define SYS_DVBT 3 -# define SYS_DVBS 5 -# define SYS_DVBS2 6 -# define SYS_ATSC 11 -# define SYS_DVBT2 16 -# define SYS_DVBC_ANNEX_C 18 -#endif #define SYS_DVB__COUNT__ (SYS_DVBC_ANNEX_C + 1) @@ -160,7 +122,6 @@ typedef struct { (0 != ((__mask) & DELSYS_BIT((__bit)))) -#ifdef DVB_ATSC #define DELSYS_SUPP_MASK \ ( \ DELSYS_BIT(SYS_DVBC_ANNEX_A) | \ @@ -170,24 +131,13 @@ typedef struct { DELSYS_BIT(SYS_ATSC) | \ DELSYS_BIT(SYS_DVBC_ANNEX_B) | \ DELSYS_BIT(SYS_DVBT2) | \ + DELSYS_BIT(SYS_ISDBT) | \ DELSYS_BIT(SYS_DVBC_ANNEX_C) \ ) -#else -#define DELSYS_SUPP_MASK \ - ( \ - DELSYS_BIT(SYS_DVBC_ANNEX_A) | \ - DELSYS_BIT(SYS_DVBT) | \ - DELSYS_BIT(SYS_DVBS) | \ - DELSYS_BIT(SYS_DVBS2) | \ - DELSYS_BIT(SYS_DVBT2) | \ - DELSYS_BIT(SYS_DVBC_ANNEX_C) \ - ) -#endif void dvb_update_config(stream_t *); int dvb_parse_path(stream_t *); int dvb_set_channel(stream_t *, unsigned int, unsigned int); dvb_state_t *dvb_get_state(stream_t *); -void dvb_free_state(dvb_state_t *); #endif /* MPLAYER_DVBIN_H */ diff --git a/stream/stream.c b/stream/stream.c index 116dcef4a4..43a7f51a60 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -30,6 +30,7 @@ #include "common/common.h" #include "common/global.h" +#include "demux/demux.h" #include "misc/bstr.h" #include "misc/thread_tools.h" #include "common/msg.h" @@ -92,7 +93,6 @@ static const stream_info_t *const stream_list[] = { &stream_info_slice, &stream_info_fd, &stream_info_cb, - NULL }; // Because of guarantees documented on STREAM_BUFFER_SIZE. @@ -104,7 +104,7 @@ static const stream_info_t *const stream_list[] = { struct stream_opts { int64_t buffer_size; - i |