summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2013-01-05 23:04:50 +0200
committerPetri Hintukainen <phintuka@users.sourceforge.net>2013-01-05 23:15:49 +0200
commit202a2beaac8949b1e192790242c9bc9c9b2230d0 (patch)
tree6e0c7bcca02029ec19b09347a02fdea857afdc39
parentd209d84645f5ef3618024faefa0f57f1f92b272f (diff)
downloadvdr-plugin-bluray-202a2beaac8949b1e192790242c9bc9c9b2230d0.tar.gz
vdr-plugin-bluray-202a2beaac8949b1e192790242c9bc9c9b2230d0.tar.bz2
Added title selection menu (can be accessed with kBack)
-rw-r--r--bdplayer.c52
-rw-r--r--bdplayer.h5
-rw-r--r--titlemenu.c93
-rw-r--r--titlemenu.h25
4 files changed, 175 insertions, 0 deletions
diff --git a/bdplayer.c b/bdplayer.c
index e6048a5..d58bf45 100644
--- a/bdplayer.c
+++ b/bdplayer.c
@@ -60,6 +60,8 @@ public:
void SkipSeconds(int seconds);
void Play();
void Pause();
+ bool SelectPlaylist(int pl);
+ BLURAY *BDHandle() { return bd; }
cMarks *Marks() { return &marks; }
cString PosStr();
@@ -317,6 +319,19 @@ void cBDPlayer::Empty(void)
DeviceClear();
}
+bool cBDPlayer::SelectPlaylist(int pl)
+{
+ bool end_of_title;
+
+ LOCK_THREAD;
+
+ Empty();
+
+ end_of_title = !bd_select_playlist(bd, pl);
+ isyslog("bd_select_playlist -> %s", end_of_title ? "FAIL" : "OK");
+ return !end_of_title;
+}
+
void cBDPlayer::Pause(void)
{
// from vdr-1.7.34
@@ -373,6 +388,8 @@ bool cBDPlayer::GetReplayMode(bool &Play, bool &Forward, int &Speed)
// --- cBDControl -------------------------------------------------------
+#include "titlemenu.h"
+
#define MODETIMEOUT 3 // seconds
int cBDControl::active = 0;
@@ -393,6 +410,7 @@ cBDControl::cBDControl(cBDPlayer *Player)
chapterSeekTime = 0;
disc_name = tr("BluRay");
+ menu = NULL;
cStatus::MsgReplaying(this, "BluRay", NULL, true);
}
@@ -477,6 +495,20 @@ void cBDControl::Play(void)
player->Play();
}
+BLURAY *cBDControl::BDHandle()
+{
+ if (player)
+ return player->BDHandle();
+ return NULL;
+}
+
+bool cBDControl::SelectPlaylist(int pl)
+{
+ if (player)
+ return player->SelectPlaylist(pl);
+ return false;
+}
+
void cBDControl::SkipSeconds(int seconds)
{
if (player)
@@ -705,6 +737,23 @@ eOSState cBDControl::ProcessKey(eKeys Key)
// from vdr-1.7.34
if (!Active())
return osEnd;
+
+ // Handle menus
+ if (menu) {
+ eOSState state = menu->ProcessKey(Key);
+ if (state == osBack) {
+ delete menu;
+ menu = NULL;
+ return osEnd;
+ }
+ if (state == osEnd) {
+ Hide();
+ delete menu;
+ menu = NULL;
+ }
+ return osContinue;
+ }
+
if (visible) {
if (timeoutShow && time(NULL) > timeoutShow) {
Hide();
@@ -759,6 +808,9 @@ eOSState cBDControl::ProcessKey(eKeys Key)
else
Show();
break;
+ case kBack: Hide();
+ menu = new cTitleMenu(this);
+ break;
default: return osUnknown;
}
}
diff --git a/bdplayer.h b/bdplayer.h
index d47fe5f..dfc0e31 100644
--- a/bdplayer.h
+++ b/bdplayer.h
@@ -12,12 +12,14 @@
#include <vdr/tools.h>
class cBDPlayer;
+struct bluray;
class cBDControl : public cControl {
private:
static int active;
cBDPlayer *player;
cString disc_name;
+ cOsdMenu *menu;
cBDControl();
cBDControl(cBDPlayer *Player);
@@ -58,6 +60,9 @@ public:
virtual cString GetHeader(void);
virtual eOSState ProcessKey(eKeys Key);
+
+ struct bluray *BDHandle();
+ bool SelectPlaylist(int pl);
};
#endif //_BDPLAYER_H
diff --git a/titlemenu.c b/titlemenu.c
new file mode 100644
index 0000000..dc35d25
--- /dev/null
+++ b/titlemenu.c
@@ -0,0 +1,93 @@
+/*
+ * titlemenu.c:
+ *
+ * See the README file for copyright information and how to reach the author.
+ *
+ */
+
+#include <libbluray/bluray.h>
+
+#include <vdr/tools.h>
+#include <vdr/osdbase.h>
+
+#include "bdplayer.h"
+
+#include "titlemenu.h"
+
+/*
+ * cTitleItem
+ */
+
+class cTitleItem : public cOsdItem
+{
+ private:
+ int playlist;
+ int length;
+
+ public:
+ cTitleItem(unsigned Index, unsigned Playlist, unsigned Seconds);
+
+ int GetPlaylist() { return playlist; }
+
+ virtual int Compare(const cListObject &ListObject) const {
+ const cTitleItem *o = (const cTitleItem *)&ListObject;
+ return o->length - length;
+ }
+};
+
+cTitleItem::cTitleItem(unsigned Index, unsigned Playlist, unsigned Seconds) :
+ cOsdItem(cString::sprintf("Title %d (%02d:%02d:%02d)",
+ Index,
+ Seconds / 3600, (Seconds / 60) % 60, Seconds % 60),
+ osUser1)
+{
+ playlist = Playlist;
+ length = Seconds;
+}
+
+/*
+ * cTitleMenu
+ */
+
+cTitleMenu::cTitleMenu(cBDControl *Ctrl) :
+ cOsdMenu("BluRay Titles")
+{
+ ctrl = Ctrl;
+
+ /* load title list */
+ BLURAY *bd = ctrl->BDHandle();
+ unsigned num_title_idx = bd_get_titles(bd, TITLES_RELEVANT, 0);
+ isyslog("%d titles", num_title_idx);
+
+ for (unsigned i = 0; i < num_title_idx; i++) {
+ BLURAY_TITLE_INFO *info = bd_get_title_info(bd, i, 0);
+ if (info) {
+
+ Add(new cTitleItem(i+1, info->playlist, info->duration / 90000));
+
+ bd_free_title_info(info);
+ }
+ }
+
+ Sort();
+ Display();
+}
+
+eOSState cTitleMenu::ProcessKey(eKeys Key)
+{
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ switch (state) {
+ case osUser1: {
+ cTitleItem *ti = (cTitleItem*)Get(Current());
+ if (ti) {
+ ctrl->SelectPlaylist(ti->GetPlaylist());
+ return osEnd;
+ }
+ break;
+ }
+ default: break;
+ }
+
+ return state;
+}
diff --git a/titlemenu.h b/titlemenu.h
new file mode 100644
index 0000000..506f957
--- /dev/null
+++ b/titlemenu.h
@@ -0,0 +1,25 @@
+/*
+ * titlemenu.h: BluRay title menu
+ *
+ * See the README file for copyright information and how to reach the author.
+ *
+ */
+
+#ifndef _TITLEMENU_H
+#define _TITLEMENU_H
+
+#include <vdr/menuitems.h>
+
+class cBDControl;
+
+class cTitleMenu : public cOsdMenu {
+ private:
+ cBDControl *ctrl;
+
+ public:
+ cTitleMenu(cBDControl *Ctrl);
+
+ virtual eOSState ProcessKey(eKeys Key);
+};
+
+#endif //_TITLEMENU_H