summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschnusch <schnusch@users.noreply.github.com>2016-10-11 23:33:28 +0200
committerwm4 <wm4@nowhere>2016-10-17 19:23:07 +0200
commit51dbb5607e19ea7f6a397f685fb5f58346b79f88 (patch)
tree213bd47d6f352bc0d9e44a636438531fd0bbb8c1
parent139f6b5de738a3a4746c9dc991e0bee17bda4b17 (diff)
downloadmpv-51dbb5607e19ea7f6a397f685fb5f58346b79f88.tar.bz2
mpv-51dbb5607e19ea7f6a397f685fb5f58346b79f88.tar.xz
stream_bluray: select title by playlist
Blu-ray titles can now be selected by playlist number like this: bd://mpls/[playlist]
-rw-r--r--stream/stream_bluray.c52
1 files changed, 34 insertions, 18 deletions
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 81e4c00ba9..69f920ed73 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -53,6 +53,7 @@
#define BLURAY_DEFAULT_ANGLE 0
#define BLURAY_DEFAULT_CHAPTER 0
+#define BLURAY_PLAYLIST_TITLE -3
#define BLURAY_DEFAULT_TITLE -2
#define BLURAY_MENU_TITLE -1
@@ -80,6 +81,7 @@ struct bluray_priv_s {
int current_playlist;
int cfg_title;
+ int cfg_playlist;
char *cfg_device;
bool use_nav;
@@ -92,6 +94,11 @@ static void destruct(struct bluray_priv_s *priv)
bd_close(priv->bd);
}
+inline static int play_playlist(struct bluray_priv_s *priv, int playlist)
+{
+ return bd_select_playlist(priv->bd, playlist);
+}
+
inline static int play_title(struct bluray_priv_s *priv, int title)
{
return bd_select_title(priv->bd, title);
@@ -341,19 +348,25 @@ static bool check_disc_info(stream_t *s)
static void select_initial_title(stream_t *s, int title_guess) {
struct bluray_priv_s *b = s->priv;
- int title = -1;
- if (b->cfg_title != BLURAY_DEFAULT_TITLE )
- title = b->cfg_title;
- else
- title = title_guess;
- if (title < 0)
- return;
-
- if (play_title(b, title))
- b->current_title = title;
- else {
- MP_WARN(s, "Couldn't start title '%d'.\n", title);
+ if (b->cfg_title == BLURAY_PLAYLIST_TITLE) {
+ if (!play_playlist(b, b->cfg_playlist))
+ MP_WARN(s, "Couldn't start playlist '%05d'.\n", b->cfg_playlist);
b->current_title = bd_get_current_title(b->bd);
+ } else {
+ int title = -1;
+ if (b->cfg_title != BLURAY_DEFAULT_TITLE )
+ title = b->cfg_title;
+ else
+ title = title_guess;
+ if (title < 0)
+ return;
+
+ if (play_title(b, title))
+ b->current_title = title;
+ else {
+ MP_WARN(s, "Couldn't start title '%d'.\n", title);
+ b->current_title = bd_get_current_title(b->bd);
+ }
}
}
@@ -456,7 +469,7 @@ static int bluray_stream_open(stream_t *s)
b->use_nav = s->info == &stream_info_bdnav;
- bstr title, bdevice;
+ bstr title, bdevice, rest = { .len = 0 };
bstr_split_tok(bstr0(s->path), "/", &title, &bdevice);
b->cfg_title = BLURAY_DEFAULT_TITLE;
@@ -465,13 +478,16 @@ static int bluray_stream_open(stream_t *s)
b->cfg_title = BLURAY_DEFAULT_TITLE;
} else if (bstr_equals0(title, "menu")) {
b->cfg_title = BLURAY_MENU_TITLE;
+ } else if (bstr_equals0(title, "mpls")) {
+ bstr_split_tok(bdevice, "/", &title, &bdevice);
+ b->cfg_playlist = bstrtoll(title, &rest, 10);
+ b->cfg_title = BLURAY_PLAYLIST_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;
- }
+ }
+ if (rest.len) {
+ MP_ERR(s, "number expected: '%.*s'\n", BSTR_P(rest));
+ return STREAM_ERROR;
}
b->cfg_device = bstrto0(b, bdevice);