diff options
Diffstat (limited to 'src/input/input_dvb.c')
-rw-r--r-- | src/input/input_dvb.c | 126 |
1 files changed, 57 insertions, 69 deletions
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 795b843c5..1151d9a81 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -66,14 +66,17 @@ * OSD - this will allow for filtering/searching of epg data - useful for automatic recording :) */ -/* pthread.h must be included first so rest of the headers are imported - thread safely (on some systems). */ -#include <pthread.h> - #ifdef HAVE_CONFIG_H #include "config.h" #endif +/* pthread.h must be included first so rest of the headers are imported + thread safely (on some systems). + However, including it before config.h causes problems with asprintf not + being declared (glibc 2.3.6) +*/ +#include <pthread.h> + #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -97,9 +100,11 @@ #endif #include <ctype.h> -/* These will eventually be #include <linux/dvb/...> */ -#include "dvb/dmx.h" -#include "dvb/frontend.h" +/* XDG */ +#include <basedir.h> + +#include <linux/dvb/dmx.h> +#include <linux/dvb/frontend.h> #define LOG_MODULE "input_dvb" #define LOG_VERBOSE @@ -325,12 +330,12 @@ typedef struct { osd_object_t *background; xine_event_queue_t *event_queue; - /* CRC table for PAT rebuilding */ - unsigned long crc32_table[256]; /* scratch buffer for forward seeking */ char seek_buf[BUFSIZE]; + /* Is the GUI enabled at all? */ + int dvb_gui_enabled; /* simple vcr-like functionality */ int record_fd; int record_paused; @@ -427,7 +432,7 @@ static const Param transmissionmode_list [] = { }; -time_t dvb_mjdtime (char *buf); +static time_t dvb_mjdtime (uint8_t *buf); static void load_epg_data(dvb_input_plugin_t *this); static void show_eit(dvb_input_plugin_t *this); @@ -443,28 +448,6 @@ static void print_info(const char* estring) { } #endif -static void ts_build_crc32_table(dvb_input_plugin_t *this) { - uint32_t i, j, k; - - for( i = 0 ; i < 256 ; i++ ) { - k = 0; - for (j = (i << 24) | 0x800000 ; j != 0x80000000 ; j <<= 1) { - k = (k << 1) ^ (((k ^ j) & 0x80000000) ? 0x04c11db7 : 0); - } - this->crc32_table[i] = k; - } -} - -static uint32_t ts_compute_crc32(dvb_input_plugin_t *this, uint8_t *data, - uint32_t length, uint32_t crc32) { - uint32_t i; - - for(i = 0; i < length; i++) { - crc32 = (crc32 << 8) ^ this->crc32_table[(crc32 >> 24) ^ data[i]]; - } - return crc32; -} - static unsigned int getbits(unsigned char *buffer, unsigned int bitpos, unsigned int bitcount) { @@ -508,7 +491,7 @@ static int find_descriptor(uint8_t tag, const unsigned char *buf, int descriptor /* Extract UTC time and date encoded in modified julian date format and return it as a time_t. */ -time_t dvb_mjdtime (char *buf) +static time_t dvb_mjdtime (uint8_t *buf) { int i; unsigned int year, month, day, hour, min, sec; @@ -887,8 +870,8 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch int num_alloc = 0; int i; struct stat st; - - snprintf(filename, BUFSIZE, "%s/.xine/channels.conf", xine_get_homedir()); + + snprintf(filename, BUFSIZE, "%s/"PACKAGE"/channels.conf", xdgConfigHome(xine->basedir_handle)); f = fopen(filename, "r"); if (!f) { @@ -1220,8 +1203,8 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se static void dvb_parse_si(dvb_input_plugin_t *this) { - char *tmpbuffer; - char *bufptr; + uint8_t *tmpbuffer; + uint8_t *bufptr; int service_id; int result; int section_len; @@ -1329,8 +1312,8 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { /* Helper function for finding the channel index in the channels struct given the service_id. If channel is not found, -1 is returned. */ -static int channel_index(dvb_input_plugin_t* this, unsigned int service_id) { - unsigned int n; +static int channel_index(dvb_input_plugin_t* this, int service_id) { + int n; for (n=0; n < this->num_channels; n++) if (this->channels[n].service_id == service_id) return n; @@ -1420,8 +1403,8 @@ static void load_epg_data(dvb_input_plugin_t *this) int section_len = 0; unsigned int service_id=-1; int n; - char *eit = NULL; - char *foo = NULL; + uint8_t *eit = NULL; + uint8_t *foo = NULL; char *seen_channels = NULL; int text_len; struct pollfd fd; @@ -2473,7 +2456,7 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin originalPkt[11]=(this->channels[this->channel].pmtpid >> 8) & 0xff; originalPkt[12]=this->channels[this->channel].pmtpid & 0xff; - crc= ts_compute_crc32 (this, originalPkt+1, 12, 0xffffffff); + crc= _x_compute_crc32 (originalPkt+1, 12, 0xffffffff); originalPkt[13]=(crc>>24) & 0xff; originalPkt[14]=(crc>>16) & 0xff; @@ -2491,15 +2474,18 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin } static off_t dvb_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { dvb_input_plugin_t *this = (dvb_input_plugin_t *) this_gen; + uint8_t *buf = buf_gen; + off_t n=0, total=0; int have_mutex=0; struct pollfd pfd; if (!this->tuned_in) return 0; - dvb_event_handler (this); + if (this->dvb_gui_enabled) + dvb_event_handler (this); #ifdef LOG_READS xprintf(this->class->xine,XINE_VERBOSITY_DEBUG, "input_dvb: reading %" PRIdMAX " bytes...\n", (intmax_t)len); @@ -2764,6 +2750,11 @@ static int dvb_plugin_open(input_plugin_t * this_gen) xine_cfg_entry_t zoomdvb; xine_cfg_entry_t adapter; xine_cfg_entry_t lastchannel; + xine_cfg_entry_t gui_enabled; + + xine_config_lookup_entry(this->stream->xine, "media.dvb.gui_enabled", &gui_enabled); + this->dvb_gui_enabled = gui_enabled.num_value; + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: DVB GUI %s\n"), this->dvb_gui_enabled ? "enabled" : "disabled"); xine_config_lookup_entry(this->stream->xine, "media.dvb.adapter", &adapter); @@ -2823,7 +2814,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) * by numbers... */ int chanlen = strlen(channame); - int offset = 0; + size_t offset = 0; xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: exact match for %s not found: trying partial matches\n"), channame); @@ -2840,7 +2831,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) idx++; } offset++; - xprintf(this->class->xine,XINE_VERBOSITY_LOG,"%d,%d,%d\n", offset, idx, num_channels); + xprintf(this->class->xine,XINE_VERBOSITY_LOG,"%zd,%d,%d\n", offset, idx, num_channels); } while ((offset < 6) && (idx == num_channels)); if (idx < num_channels) { @@ -2990,15 +2981,16 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->event_queue = xine_event_new_queue(this->stream); #ifdef EPG_UPDATE_IN_BACKGROUND - /* Start the EPG updater thread. */ - this->epg_updater_stop = 0; - if (pthread_create(&this->epg_updater_thread, NULL, - epg_data_updater, this) != 0) { - xprintf( - this->class->xine, XINE_VERBOSITY_LOG, - _("input_dvb: cannot create EPG updater thread\n")); - return 0; - + if (this->dvb_gui_enabled) { + /* Start the EPG updater thread. */ + this->epg_updater_stop = 0; + if (pthread_create(&this->epg_updater_thread, NULL, + epg_data_updater, this) != 0) { + xprintf( + this->class->xine, XINE_VERBOSITY_LOG, + _("input_dvb: cannot create EPG updater thread\n")); + return 0; + } } #endif /* @@ -3079,8 +3071,6 @@ static int dvb_plugin_open(input_plugin_t * this_gen) snprintf(str, 256, "%s", this->channels[this->channel].name); _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, str); - /* compute CRC table for rebuilding pat */ - ts_build_crc32_table(this); /* Clear all pids, the pmt will tell us which to use */ for (x = 0; x < MAX_FILTERS; x++){ @@ -3151,15 +3141,6 @@ static input_plugin_t *dvb_class_get_instance (input_class_t *class_gen, * dvb input plugin class stuff */ -static const char *dvb_class_get_description (input_class_t *this_gen) { - return _("DVB (Digital TV) input plugin"); -} - -static const char *dvb_class_get_identifier (input_class_t *this_gen) { - return "dvb"; -} - - static void dvb_class_dispose(input_class_t * this_gen) { dvb_input_class_t *class = (dvb_input_class_t *) this_gen; @@ -3262,8 +3243,8 @@ static void *init_class (xine_t *xine, void *data) { this->xine = xine; this->input_class.get_instance = dvb_class_get_instance; - this->input_class.get_identifier = dvb_class_get_identifier; - this->input_class.get_description = dvb_class_get_description; + this->input_class.identifier = "dvb"; + this->input_class.description = N_("DVB (Digital TV) input plugin"); this->input_class.get_dir = NULL; this->input_class.get_autoplay_list = dvb_class_get_autoplay_list; this->input_class.dispose = dvb_class_dispose; @@ -3300,6 +3281,13 @@ static void *init_class (xine_t *xine, void *data) { "Greater than 0 means wait that many seconds to get a lock. Minimum is 5 seconds."), 0, NULL, (void *) this); + /* set to 0 to turn off the GUI built into this input plugin */ + config->register_bool(config, "media.dvb.gui_enabled", + 1, + _("Enable the DVB GUI"), + _("Enable the DVB GUI, mouse controlled recording and channel switching."), + 21, NULL, NULL); + config->register_num(config, "media.dvb.adapter", 0, _("Number of dvb card to use."), @@ -3319,6 +3307,6 @@ static void *init_class (xine_t *xine, void *data) { const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "DVB", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "DVB", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |