]> git.decadent.org.uk Git - videolink.git/blob - generate_dvd.hpp
8ce8f7b89e97f1ef1285e640d00de990b3c5c5b4
[videolink.git] / generate_dvd.hpp
1 // Copyright 2005-6 Ben Hutchings <ben@decadentplace.org.uk>.
2 // See the file "COPYING" for licence details.
3
4 #ifndef INC_GENERATE_DVD_HPP
5 #define INC_GENERATE_DVD_HPP
6
7 #include <string>
8 #include <vector>
9
10 #include <boost/shared_ptr.hpp>
11
12 #include "temp_file.hpp"
13
14 // Description of menus and titles to go on a DVD.
15
16 struct dvd_contents
17 {
18     enum pgc_type { unknown_pgc,  menu_pgc, title_pgc };
19
20     // Reference to some PGC (program chain).
21     struct pgc_ref
22     {
23         explicit pgc_ref(pgc_type type = unknown_pgc,
24                          int index = -1,
25                          int sub_index = 0)
26                 : type(type), index(index), sub_index(sub_index)
27             {}
28         bool operator==(const pgc_ref & other) const
29             {
30                 return type == other.type && index == other.index;
31             }
32         bool operator!=(const pgc_ref & other) const
33             {
34                 return !(*this == other);
35             }
36             
37         pgc_type type;      // Menu or title reference?
38         unsigned index;     // Menu or title index (within resp. vector)
39         unsigned sub_index; // Button or chapter number (1-based; 0 if
40                             // unspecified; not compared!)
41     };
42
43     // Menu definition.
44     struct menu
45     {
46         menu();
47
48         // Temporary file in which the menu VOB should be generated.
49         // This is created as an empty file and then closed.
50         boost::shared_ptr<temp_file> vob_temp;
51
52         // References to the menus and titles that the menu buttons
53         // are meant to link to, in the same order as the buttons.
54         std::vector<pgc_ref> entries;
55     };
56
57     // Title definition.  This is currently just an XML fragment
58     // consisting of one of more <vob> elements.  It is included
59     // directly within the corresponding <pgc> element in the file
60     // passed to dvdauthor.
61     struct title
62     {
63         explicit title(const std::string & vob_list)
64                 : vob_list(vob_list)
65             {}
66
67         std::string vob_list;
68     };
69
70     std::vector<menu> menus;
71     std::vector<title> titles;
72 };
73
74 // Use dvdauthor to generate a DVD filesystem with the given contents.
75 void generate_dvd(const dvd_contents & contents,
76                   const std::string & output_dir);
77
78 #endif // !INC_GENERATE_DVD_HPP