summaryrefslogtreecommitdiff
path: root/xine/BluRay/input_bluray.c
diff options
context:
space:
mode:
Diffstat (limited to 'xine/BluRay/input_bluray.c')
-rw-r--r--xine/BluRay/input_bluray.c83
1 files changed, 54 insertions, 29 deletions
diff --git a/xine/BluRay/input_bluray.c b/xine/BluRay/input_bluray.c
index e45cf4f1..69e104f1 100644
--- a/xine/BluRay/input_bluray.c
+++ b/xine/BluRay/input_bluray.c
@@ -553,48 +553,73 @@ static void bluray_plugin_dispose (input_plugin_t *this_gen)
free (this);
}
-static int bluray_plugin_open (input_plugin_t *this_gen)
+static int parse_mrl(const char *mrl_in, char **path, int *title, int *chapter)
{
- bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen;
- int title = -1, chapter = 0;
-
- lprintf("bluray_plugin_open\n");
+ if (strncasecmp (mrl_in, "bluray:", 7))
+ return -1;
- /* validate mrl */
+ char *mrl = strdup(mrl_in);
- if (strncasecmp (this->mrl, "bluray:", 7))
- return -1;
+ /* title[.chapter] given ? parse and drop it */
+ if (mrl[strlen(mrl)-1] != '/') {
+ char *end = strrchr(mrl, '/');
+ if (end && end[1]) {
+ if (sscanf(end, "/%d.%d", title, chapter) < 1)
+ *title = -1;
+ else
+ *end = 0;
+ }
+ }
+ lprintf(" -> title %d, chapter %d, mrl \'%s\'\n", *title, *chapter, mrl);
- if (!strcasecmp (this->mrl, "bluray:") ||
- !strcasecmp (this->mrl, "bluray:/") ||
- !strcasecmp (this->mrl, "bluray://") ||
- !strcasecmp (this->mrl, "bluray:///")) {
+ if (!strcasecmp (mrl, "bluray:") ||
+ !strcasecmp (mrl, "bluray:/") ||
+ !strcasecmp (mrl, "bluray://") ||
+ !strcasecmp (mrl, "bluray:///")) {
- this->disc_root = strdup(this->class->mountpoint);
+ /* default device */
+ *path = NULL;
+
+ } else if (!strncasecmp (mrl, "bluray:/", 8)) {
- } else if (!strncasecmp (this->mrl, "bluray:/", 8)) {
+ /* strip extra slashes */
+ char *start = mrl + 7;
+ while (start[0] == '/' && start[1] == '/')
+ start++;
- if (!strncasecmp (this->mrl, "bluray:///", 10))
- this->disc_root = strdup(this->mrl + 9);
- else if (!strncasecmp (this->mrl, "bluray://", 9))
- this->disc_root = strdup(this->mrl + 8);
- else
- this->disc_root = strdup(this->mrl + 7);
+ *path = strdup(start);
- _x_mrl_unescape(this->disc_root);
+ _x_mrl_unescape(*path);
- if (this->disc_root[strlen(this->disc_root)-1] != '/') {
- char *end = strrchr(this->disc_root, '/');
- if (end && end[1])
- if (sscanf(end, "/%d.%d", &title, &chapter) < 1)
- title = -1;
- *end = 0;
- }
+ lprintf("non-defaut mount point \'%s\'\n", *path);
} else {
- return -1;
+ lprintf("invalid mrl \'%s\'\n", mrl);
+ free(mrl);
+ return 0;
}
+ free(mrl);
+
+ return 1;
+}
+
+static int bluray_plugin_open (input_plugin_t *this_gen)
+{
+ bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen;
+ int title = -1;
+ int chapter = 0;
+
+ lprintf("bluray_plugin_open\n");
+
+ /* validate and parse mrl */
+
+ if (!parse_mrl(this->mrl, &this->disc_root, &title, &chapter))
+ return -1;
+
+ if (!this->disc_root)
+ this->disc_root = strdup(this->class->mountpoint);
+
/* open libbluray */
/* replace ~/ in keyfile path */