diff options
Diffstat (limited to 'src/input/input_dvd.c')
-rw-r--r-- | src/input/input_dvd.c | 148 |
1 files changed, 63 insertions, 85 deletions
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index de47de0d5..02017956e 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -16,10 +16,7 @@ * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * $Id: input_dvd.c,v 1.216 2007/02/20 01:04:07 dgp85 Exp $ - * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ /* This file was origninally part of the xine-dvdnav project @@ -88,9 +85,9 @@ #endif /* Xine includes */ -#include "xineutils.h" -#include "buffer.h" -#include "xine_internal.h" +#include <xine/xineutils.h> +#include <xine/buffer.h> +#include <xine/xine_internal.h> #include "media_helper.h" /* Print debug messages? */ @@ -158,7 +155,7 @@ # define lseek64 lseek #endif -static const char *dvdnav_menu_table[] = { +static const char *const dvdnav_menu_table[] = { NULL, NULL, "Title", @@ -228,7 +225,7 @@ typedef struct { int32_t region; int32_t play_single_chapter; - char *filelist[MAX_DIR_ENTRIES]; + const char *filelist[MAX_DIR_ENTRIES]; } dvd_input_class_t; @@ -335,12 +332,11 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction this->mouse_in = !this->mouse_in; if(direction != this->mouse_in) { - xine_event_t event; - xine_spu_button_t spu_event; - - spu_event.direction = direction; - spu_event.button = this->mouse_buttonN; - + xine_spu_button_t spu_event = { + .direction = direction, + .button = this->mouse_buttonN + }; + xine_event_t event; event.type = XINE_EVENT_SPU_BUTTON; event.stream = this->stream; event.data = &spu_event; @@ -356,8 +352,6 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction static int update_title_display(dvd_input_plugin_t *this) { char ui_title[MAX_STR_LEN + 1]; - xine_event_t uevent; - xine_ui_data_t data; int tt=-1, pr=-1; size_t ui_str_length=0; int num_tt = 0; @@ -434,13 +428,19 @@ static int update_title_display(dvd_input_plugin_t *this) { #ifdef INPUT_DEBUG printf("input_dvd: Changing title to read '%s'\n", ui_title); #endif - uevent.type = XINE_EVENT_UI_SET_TITLE; - uevent.stream = this->stream; - uevent.data = &data; - uevent.data_length = sizeof(data);; - memcpy(data.str, ui_title, strlen(ui_title) + 1); - data.str_len = strlen(ui_title) + 1; - xine_event_send(this->stream, &uevent); + { + xine_ui_data_t data; + xine_event_t uevent; + uevent.type = XINE_EVENT_UI_SET_TITLE; + uevent.stream = this->stream; + uevent.data = &data; + uevent.data_length = sizeof(data); + + memcpy(data.str, ui_title, strlen(ui_title) + 1); + data.str_len = strlen(ui_title) + 1; + + xine_event_send(this->stream, &uevent); + } return 1; } @@ -733,13 +733,14 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, { dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t*) (block); - xine_event_t event; /* Tell xine to update the UI */ - event.type = XINE_EVENT_UI_CHANNELS_CHANGED; - event.stream = this->stream; - event.data = NULL; - event.data_length = 0; + xine_event_t event = { + .type = XINE_EVENT_UI_CHANNELS_CHANGED, + .stream = this->stream, + .data = NULL, + .data_length = 0 + }; xine_event_send(this->stream, &event); if( !update_title_display(this) ) { @@ -853,8 +854,9 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, return buf; } -static off_t dvd_plugin_read (input_plugin_t *this_gen, char *ch_buf, off_t len) { +static off_t dvd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { /* dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; */ + char *ch_buf = (char *)buf_gen; /* FIXME: Tricking the demux_mpeg_block plugin */ ch_buf[0] = 0; @@ -1372,10 +1374,7 @@ check_solaris_vold_device(dvd_input_class_t *this) (volume_action = getenv("VOLUME_ACTION")) != NULL && strcmp(volume_action, "insert") == 0) { - device = malloc(strlen(volume_device) + strlen(volume_name) + 2); - if (device == NULL) - return; - sprintf(device, "%s/%s", volume_device, volume_name); + asprintf(&device, "%s/%s", volume_device, volume_name); if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) { free(device); return; @@ -1477,20 +1476,21 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; dvd_input_class_t *class = (dvd_input_class_t*)this_gen->input_class; - char *locator; + char *locator, *locator_orig; char *title_part; - xine_event_t event; xine_cfg_entry_t region_entry, lang_entry, cfg_entry; trace_print("Called\n"); /* we already checked the "dvd:/" MRL before */ - locator = this->mrl + (sizeof("dvd:") - 1); + locator_orig = locator = strdup (this->mrl + (sizeof("dvd:") - 1)); /* FIXME: call a generic xine-lib MRL parser here to pre-parse * the MRL for ?title=<title>&part=<part> stuff and to expand * escaped characters properly */ - + + _x_mrl_unescape (locator); + this->mode = dvd_parse_mrl(this, &locator, &title_part); if (this->mode == MODE_FAIL) { @@ -1499,9 +1499,10 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { _x_message(this->stream, XINE_MSG_READ_ERROR, /* FIXME: see FIXME in dvd_parse_try_open() */ (strlen(locator) && !(locator[0] == '/' && locator[1] == '\0')) ? locator : class->dvd_device, NULL); + free (locator_orig); return 0; } - + dvdnav_get_title_string(this->dvdnav, &this->dvd_name); if(this->dvd_name) _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, this->dvd_name); @@ -1549,6 +1550,7 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { "input_dvd: Title %i is out of range (1 to %i).\n", tt, titles); dvdnav_close(this->dvdnav); this->dvdnav = NULL; + free (locator_orig); return 0; } @@ -1562,6 +1564,7 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { "input_dvd: Part %i is out of range (1 to %i).\n", pr, parts); dvdnav_close(this->dvdnav); this->dvdnav = NULL; + free (locator_orig); return 0; } } @@ -1585,15 +1588,19 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { free(class->eject_device); class->eject_device = strdup(this->current_dvd_device); - /* Tell Xine to update the UI */ - event.type = XINE_EVENT_UI_CHANNELS_CHANGED; - event.stream = this->stream; - event.data = NULL; - event.data_length = 0; - xine_event_send(this->stream, &event); + { /* Tell Xine to update the UI */ + const xine_event_t event = { + .type = XINE_EVENT_UI_CHANNELS_CHANGED, + .stream = this->stream, + .data = NULL, + .data_length = 0 + }; + xine_event_send(this->stream, &event); + } update_title_display(this); - + + free (locator_orig); return 1; } @@ -1614,12 +1621,12 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, const char *data) { dvd_input_plugin_t *this; dvd_input_class_t *class = (dvd_input_class_t*)class_gen; - static char *handled_mrl = "dvd:/"; + static const char handled_mrl[] = "dvd:/"; trace_print("Called\n"); /* Check we can handle this MRL */ - if (strncasecmp (data, handled_mrl, strlen(handled_mrl) ) != 0) + if (strncasecmp (data, handled_mrl, sizeof(handled_mrl)-1 ) != 0) return NULL; this = (dvd_input_plugin_t *) xine_xmalloc (sizeof (dvd_input_plugin_t)); @@ -1629,7 +1636,7 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st this->mem_stack = 0; this->mem_stack_max = 1024; - this->mem = xine_xmalloc(sizeof(unsigned char *) * this->mem_stack_max); + this->mem = xine_xcalloc(this->mem_stack_max, sizeof(unsigned char *)); if (!this->mem) { free(this); return NULL; @@ -1676,18 +1683,6 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st return &this->input_plugin; } -static const char *dvd_class_get_description (input_class_t *this_gen) { - trace_print("Called\n"); - - return "DVD Navigator"; -} - -static const char *dvd_class_get_identifier (input_class_t *this_gen) { - trace_print("Called\n"); - - return "DVD"; -} - /* FIXME: adapt to new api. */ #if 0 static xine_mrl_t **dvd_class_get_dir (input_class_t *this_gen, @@ -1745,9 +1740,9 @@ static void *init_class (xine_t *xine, void *data) { dvd_input_class_t *this; config_values_t *config = xine->config; void *dvdcss; - static const char *skip_modes[] = {"skip program", "skip part", "skip title", NULL}; - static const char *seek_modes[] = {"seek in program chain", "seek in program", NULL}; - static const char *play_single_chapter_modes[] = {"entire dvd", "one chapter", NULL}; + static const char *const skip_modes[] = {"skip program", "skip part", "skip title", NULL}; + static const char *const seek_modes[] = {"seek in program chain", "seek in program", NULL}; + static const char *const play_single_chapter_modes[] = {"entire dvd", "one chapter", NULL}; trace_print("Called\n"); #ifdef INPUT_DEBUG @@ -1760,8 +1755,8 @@ static void *init_class (xine_t *xine, void *data) { return NULL; this->input_class.get_instance = dvd_class_get_instance; - this->input_class.get_identifier = dvd_class_get_identifier; - this->input_class.get_description = dvd_class_get_description; + this->input_class.identifier = "DVD"; + this->input_class.description = N_("DVD Navigator"); /* this->input_class.get_dir = dvd_class_get_dir; */ @@ -1791,8 +1786,7 @@ static void *init_class (xine_t *xine, void *data) { { /* we have found libdvdcss, enable the specific config options */ char *raw_device; - static const char *decrypt_modes[] = { "key", "disc", "title", NULL }; - char *css_cache_default, *css_cache; + static const char *const decrypt_modes[] = { "key", "disc", "title", NULL }; int mode; raw_device = config->register_filename(config, "media.dvd.raw_device", @@ -1817,22 +1811,6 @@ static void *init_class (xine_t *xine, void *data) { "playing scrambled DVDs."), 20, NULL, NULL); xine_setenv("DVDCSS_METHOD", decrypt_modes[mode], 0); - css_cache_default = (char *)malloc(strlen(xine_get_homedir()) + 10); - sprintf(css_cache_default, "%s/.dvdcss/", xine_get_homedir()); - css_cache = config->register_filename(config, "media.dvd.css_cache_path", css_cache_default, XINE_CONFIG_STRING_IS_DIRECTORY_NAME, - _("path to the title key cache"), - _("Since cracking the copy protection of scrambled DVDs can " - "be quite time consuming, libdvdcss will cache the cracked " - "keys in this directory.\nThis setting is security critical, " - "because files with uncontrollable names will be created in " - "this directory. Be sure to use a dedicated directory not " - "used for anything but DVD key caching."), - XINE_CONFIG_SECURITY, NULL, NULL); - if (strlen(css_cache) > 0) - xine_setenv("DVDCSS_CACHE", css_cache, 0); - free(css_cache_default); - - if(xine->verbosity > XINE_VERBOSITY_NONE) xine_setenv("DVDCSS_VERBOSE", "2", 0); else @@ -1913,6 +1891,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, "DVD", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "DVD", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |