1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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;
}
|