]> git.decadent.org.uk Git - videolink.git/blob - generate_dvd.hpp
Remove inclusion of <boost/shared_ptr.hpp> and build-dependency on Boost
[videolink.git] / generate_dvd.hpp
1 // Copyright 2005-6 Ben Hutchings <ben@decadent.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 <glibmm/refptr.h>
11
12 #include "geometry.hpp"
13 #include "temp_file.hpp"
14 #include "video.hpp"
15 #include "vob_list.hpp"
16
17 namespace Gdk
18 {
19     class Pixbuf;
20 }
21
22 // Description of menus and titles to go on a DVD.
23
24 class dvd_generator
25 {
26 public:
27     enum pgc_type { unknown_pgc,  menu_pgc, title_pgc };
28
29     // Reference to some PGC (program chain).
30     struct pgc_ref
31     {
32         explicit pgc_ref(pgc_type type = unknown_pgc,
33                          int index = -1,
34                          int sub_index = 0)
35                 : type(type), index(index), sub_index(sub_index)
36             {}
37         bool operator==(const pgc_ref & other) const
38             {
39                 return type == other.type && index == other.index;
40             }
41         bool operator!=(const pgc_ref & other) const
42             {
43                 return !(*this == other);
44             }
45             
46         pgc_type type;      // Menu or title reference?
47         unsigned index;     // Menu or title index (within resp. vector)
48         unsigned sub_index; // Button or chapter number (1-based; 0 if
49                             // unspecified; not compared!)
50     };
51
52     // We can try using either of these encoders to convert PNG to MPEG.
53     enum mpeg_encoder
54     {
55         mpeg_encoder_ffmpeg,         // ffmpeg
56         mpeg_encoder_mjpegtools      // mjpegtools from version 1.8
57     };
58
59     dvd_generator(const video::frame_params & frame_params,
60                   mpeg_encoder encoder);
61
62     // Create a new empty menu; return a reference to it.
63     // The client must call generate_menu_vob() for each menu before
64     // calling generate().
65     pgc_ref add_menu();
66     // Add a menu entry (link) to an existing menu.
67     void add_menu_entry(unsigned index,
68                         const rectangle & area,
69                         const pgc_ref & target);
70     // Generate the menu VOB from a background image and button
71     // highlight image.
72     void generate_menu_vob(unsigned index,
73                            Glib::RefPtr<Gdk::Pixbuf> background,
74                            Glib::RefPtr<Gdk::Pixbuf> highlights) const;
75
76     // Create a new title using the given vob_list; return a reference
77     // to it.  The argument will be pilfered (i.e. emptied).
78     pgc_ref add_title(vob_list & list);
79
80     // Use dvdauthor to generate a DVD filesystem.
81     void generate(const std::string & output_dir) const;
82
83 private:
84     struct menu_entry
85     {
86         rectangle area;
87         pgc_ref target;
88     };
89
90     // Menu definition.
91     struct menu
92     {
93         // References to the menus and titles that the menu buttons
94         // are meant to link to, in the same order as the buttons.
95         std::vector<menu_entry> entries;
96     };
97
98     temp_dir temp_dir_;
99     video::frame_params frame_params_;
100     mpeg_encoder encoder_;
101     std::vector<menu> menus_;
102     std::vector<vob_list> titles_;
103 };
104
105 #endif // !INC_GENERATE_DVD_HPP