diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream_bluray.c | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 2a9c864402..9ad56e5de0 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -41,8 +41,7 @@ #include "mpv_talloc.h" #include "common/common.h" #include "common/msg.h" -#include "options/m_option.h" -#include "options/options.h" +#include "options/m_config.h" #include "options/path.h" #include "stream.h" #include "osdep/timer.h" @@ -86,31 +85,6 @@ struct bluray_priv_s { bool use_nav; }; -static const struct bluray_priv_s bluray_stream_priv_dflts = { - .cfg_title = BLURAY_DEFAULT_TITLE, -}; - -static const struct bluray_priv_s bdnav_stream_priv_dflts = { - .cfg_title = BLURAY_DEFAULT_TITLE, - .use_nav = true, -}; - -#define OPT_BASE_STRUCT struct bluray_priv_s -static const m_option_t bluray_stream_opts_fields[] = { - OPT_CHOICE_OR_INT("title", cfg_title, 0, 0, 99999, - ({"longest", BLURAY_DEFAULT_TITLE})), - OPT_STRING("device", cfg_device, 0), - {0} -}; - -static const m_option_t bdnav_stream_opts_fields[] = { - OPT_CHOICE_OR_INT("title", cfg_title, 0, 0, 99999, - ({"menu", BLURAY_MENU_TITLE}, - {"first", BLURAY_DEFAULT_TITLE})), - OPT_STRING("device", cfg_device, 0), - {0} -}; - static void destruct(struct bluray_priv_s *priv) { if (priv->title_info) @@ -383,18 +357,20 @@ static void select_initial_title(stream_t *s, int title_guess) { } } -static int bluray_stream_open(stream_t *s) +static int bluray_stream_open_internal(stream_t *s) { struct bluray_priv_s *b = s->priv; - const char *device = NULL; + char *device = NULL; /* find the requested device */ - if (b->cfg_device && b->cfg_device[0]) + if (b->cfg_device && b->cfg_device[0]) { device = b->cfg_device; - else if (s->opts->bluray_device && s->opts->bluray_device[0]) - device = s->opts->bluray_device; + } else { + mp_read_option_raw(s->global, "bluray-device", &m_option_type_string, + &device); + } - if (!device) { + if (!device || !device[0]) { MP_ERR(s, "No Blu-ray device/location was specified ...\n"); return STREAM_UNSUPPORTED; } @@ -470,32 +446,48 @@ static int bluray_stream_open(stream_t *s) return STREAM_OK; } +const stream_info_t stream_info_bdnav; + +static int bluray_stream_open(stream_t *s) +{ + struct bluray_priv_s *b = talloc_zero(s, struct bluray_priv_s); + s->priv = b; + + b->use_nav = s->info == &stream_info_bdnav; + + bstr title, bdevice; + bstr_split_tok(bstr0(s->path), "/", &title, &bdevice); + + b->cfg_title = BLURAY_DEFAULT_TITLE; + + if (bstr_equals0(title, "longest") || bstr_equals0(title, "first")) { + b->cfg_title = BLURAY_DEFAULT_TITLE; + } else if (bstr_equals0(title, "menu")) { + b->cfg_title = BLURAY_MENU_TITLE; + } else if (title.len) { + bstr rest; + b->cfg_title = bstrtoll(title, &rest, 10); + if (rest.len) { + MP_ERR(s, "number expected: '%.*s'\n", BSTR_P(rest)); + return STREAM_ERROR; + } + } + + b->cfg_device = bstrto0(b, bdevice); + + return bluray_stream_open_internal(s); +} + const stream_info_t stream_info_bluray = { .name = "bd", .open = bluray_stream_open, .protocols = (const char*const[]){ "bd", "br", "bluray", NULL }, - .priv_defaults = &bluray_stream_priv_dflts, - .priv_size = sizeof(struct bluray_priv_s), - .options = bluray_stream_opts_fields, - .url_options = (const char*const[]){ - "hostname=title", - "filename=device", - NULL - }, }; const stream_info_t stream_info_bdnav = { .name = "bdnav", .open = bluray_stream_open, .protocols = (const char*const[]){ "bdnav", "brnav", "bluraynav", NULL }, - .priv_defaults = &bdnav_stream_priv_dflts, - .priv_size = sizeof(struct bluray_priv_s), - .options = bdnav_stream_opts_fields, - .url_options = (const char*const[]){ - "hostname=title", - "filename=device", - NULL - }, }; static bool check_bdmv(const char *path) @@ -542,7 +534,9 @@ static int bdmv_dir_stream_open(stream_t *stream) { struct bluray_priv_s *priv = talloc_ptrtype(stream, priv); stream->priv = priv; - *priv = bluray_stream_priv_dflts; + *priv = (struct bluray_priv_s){ + .cfg_title = BLURAY_DEFAULT_TITLE, + }; char *path = mp_file_get_path(priv, bstr0(stream->url)); if (!path) @@ -569,7 +563,7 @@ static int bdmv_dir_stream_open(stream_t *stream) goto unsupported; MP_INFO(stream, "BDMV detected. Redirecting to bluray://\n"); - return bluray_stream_open(stream); + return bluray_stream_open_internal(stream); unsupported: talloc_free(priv); |