[libbluray-devel] Cache "known" playlists when playing using on-disc menus
hpi1
git at videolan.org
Fri May 12 08:12:50 CEST 2017
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu May 11 14:22:23 2017 +0300| [2b816e6f20cea20c8c0d236efd08e12e9ec55541] | committer: hpi1
Cache "known" playlists when playing using on-disc menus
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=2b816e6f20cea20c8c0d236efd08e12e9ec55541
---
src/libbluray/bluray.c | 32 ++++++++++++++++++++++++++++++++
src/libbluray/disc/disc.h | 5 ++++-
src/util/strutl.c | 21 +++++++++++++++++++++
src/util/strutl.h | 3 +++
4 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index ecb19de1..7faf4e51 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -2295,6 +2295,33 @@ static void _close_playlist(BLURAY *bd)
_update_uo_mask(bd);
}
+static int _add_known_playlist(BD_DISC *p, const char *mpls_id)
+{
+ char *old_mpls_ids;
+ char *new_mpls_ids = NULL;
+ int result = -1;
+
+ old_mpls_ids = disc_property_get(p, DISC_PROPERTY_PLAYLISTS);
+ if (!old_mpls_ids) {
+ return disc_property_put(p, DISC_PROPERTY_PLAYLISTS, mpls_id);
+ }
+
+ /* no duplicates */
+ if (str_strcasestr(old_mpls_ids, mpls_id)) {
+ goto out;
+ }
+
+ new_mpls_ids = str_printf("%s,%s", old_mpls_ids, mpls_id);
+ if (new_mpls_ids) {
+ result = disc_property_put(p, DISC_PROPERTY_PLAYLISTS, new_mpls_ids);
+ }
+
+ out:
+ X_FREE(old_mpls_ids);
+ X_FREE(new_mpls_ids);
+ return result;
+}
+
static int _open_playlist(BLURAY *bd, const char *f_name, unsigned angle)
{
_close_playlist(bd);
@@ -2325,6 +2352,11 @@ static int _open_playlist(BLURAY *bd, const char *f_name, unsigned angle)
bd->st0.seek_flag = 1;
+ /* remember played playlists when using menus */
+ if (bd->title_type != title_undef) {
+ _add_known_playlist(bd->disc, bd->title->name);
+ }
+
return 1;
}
return 0;
diff --git a/src/libbluray/disc/disc.h b/src/libbluray/disc/disc.h
index 3738c6f6..612a5473 100644
--- a/src/libbluray/disc/disc.h
+++ b/src/libbluray/disc/disc.h
@@ -1,6 +1,6 @@
/*
* This file is part of libbluray
- * Copyright (C) 2014 Petri Hintukainen <phintuka at users.sourceforge.net>
+ * Copyright (C) 2014-2017 Petri Hintukainen <phintuka at users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -102,6 +102,9 @@ BD_PRIVATE struct bd_file_s *disc_open_stream(BD_DISC *disc, const char *file);
BD_PRIVATE int disc_property_put(BD_DISC *disc, const char *property, const char *value);
BD_PRIVATE char *disc_property_get(BD_DISC *disc, const char *property);
+/* "Known" playlists */
+#define DISC_PROPERTY_PLAYLISTS "Playlists"
+
/*
*
*/
diff --git a/src/util/strutl.c b/src/util/strutl.c
index 4712373e..9669fef7 100644
--- a/src/util/strutl.c
+++ b/src/util/strutl.c
@@ -1,6 +1,7 @@
/*
* This file is part of libbluray
* Copyright (C) 2009-2010 John Stebbins
+ * Copyright (C) 2011-2017 Petri Hintukainen <phintuka at users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -118,3 +119,23 @@ char *str_print_hex(char *out, const uint8_t *buf, int count)
return out;
}
+
+const char *str_strcasestr(const char *haystack, const char *needle)
+{
+ const char *result = NULL;
+
+ char *h = str_dup(haystack);
+ char *n = str_dup(needle);
+ if (h && n) {
+ str_tolower(h);
+ str_tolower(n);
+ result = strstr(h, n);
+ if (result) {
+ result = haystack + (result - h);
+ }
+ }
+
+ X_FREE(h);
+ X_FREE(n);
+ return result;
+}
diff --git a/src/util/strutl.h b/src/util/strutl.h
index b512655f..dbd5e1c3 100644
--- a/src/util/strutl.h
+++ b/src/util/strutl.h
@@ -1,6 +1,7 @@
/*
* This file is part of libbluray
* Copyright (C) 2009-2010 John Stebbins
+ * Copyright (C) 2011-2017 Petri Hintukainen <phintuka at users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -32,4 +33,6 @@ BD_PRIVATE void str_tolower(char *s);
BD_PRIVATE char * str_print_hex(char *out, const uint8_t *str, int count);
+BD_PRIVATE const char *str_strcasestr(const char *haystack, const char *needle);
+
#endif // STRUTL_H_
More information about the libbluray-devel
mailing list