-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.c
281 lines (245 loc) · 10.1 KB
/
config.c
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
* See the files COPYING and README for copyright information and how to reach
* the author.
*
* $Id: config.c,v 1.17 2006/09/16 18:33:36 lordjaxom Exp $
*/
#include "config.h"
#include "filter.h"
#include "setup.h"
#include <vdr/config.h>
#include <vdr/i18n.h>
namespace vdr_burn
{
using namespace std;
using proctools::logger;
using proctools::format;
// --- dvdauthor_xml -----------------------------------------------------
dvdauthor_xml::dvdauthor_xml(const job& Job):
m_job(Job)
{
}
#if 0
const char* dvdauthor_xml::get_video_format(component_type::type type_)
{
switch (type_) {
case component_type::hz25_4_3 ... component_type::hz25_21_9: return "pal";
case component_type::hz30_4_3 ... component_type::hz30_21_9: return "ntsc";
default: return 0;
}
}
#endif
string dvdauthor_xml::get_video_aspect(track_info::aspectratio type)
{
switch (type) {
case track_info::aspectratio_4_3: return "aspect=\"4:3\"";
case track_info::aspectratio_16_9:
case track_info::aspectratio_21_9: return "aspect=\"16:9\"";
default: return "";
}
}
string dvdauthor_xml::get_audio_language(int language)
{
return "lang=\"" + track_info::get_language_codes()[ language ] + "\"";
}
void dvdauthor_xml::write_main_menu()
{
m_file << " <menus>" << endl;
int pages = ScanPageCount(m_job.get_paths().data);
for (int p = 0; p < pages; ++p) {
if (p == 0) {
m_file << " <pgc entry=\"title\">" << endl // pause="inf"??
<< " <pre>" << endl;
for (int q = 2; q <= pages; q++)
m_file << " if (g0 eq " << q << ") { jump menu " << q <<";}" << endl;
m_file << " button=g1;g3=0;" << endl
<< " </pre>" << endl;
}
else
{
m_file << " <pgc>" << endl
<< " <pre>button=g1;g3=0;</pre>" << endl;
}
m_file << " <vob file=\"" << m_job.get_paths().data << "/menu-bg-"
<< p << ".mpg\" pause=\"inf\"/>" << endl; // TODO observe pause=inf
for (uint i = p * m_job.get_skin().get_main_menu_titles().size();
i < std::min(static_cast<recording_list::size_type>((p + 1)
* m_job.get_skin().get_main_menu_titles().size()), m_job.get_recordings().size());
++i)
m_file << " <button>g1=button;jump titleset " << (i + 1)
<< " menu;</button>" << endl;
if (p > 0)
m_file << " <button>g0=" << p << ";g1=" << (m_job.get_skin().get_main_menu_titles().size()*1024)
<< ";jump menu " << p << ";</button>" << endl;
if (p < pages - 1)
m_file << " <button>g0=" << (p + 2) << ";g1=1024;jump menu " << (p + 2)
<< ";</button>" << endl;
m_file << " </pgc>" << endl;
}
m_file << " </menus>" << endl;
}
void dvdauthor_xml::write_title_menu(recording_list::const_iterator rec)
{
int pages = ScanPageCount(rec->get_paths().data);
m_file << " <menus>" << endl;
for (int i = 0; i < pages; ++i) {
m_file << " <pgc" << (i == 0 ? " entry=\"root\"" : "") << ">" << endl;
if (rec->get_eventDescription() == "" && m_job.get_skip_titlemenu())
m_file << " <pre>jump title 1 chapter 1;</pre>" << endl;
else {
if ( i == 0) {
m_file << " <pre>button=1024;</pre>" << endl;
}
else
{
m_file << " <pre>if (g3 eq 1){button=3072;}" << endl
<< " if (g3 eq 2){button=1024;}" << endl
<< " if (g3 eq 3){button=2048;}" << endl
<< " </pre>" << endl;
}
m_file << " <vob file=\"" << rec->get_menu_mpeg(i) << "\" pause=\"inf\"/>"
<< endl;
if (i > 0)
m_file << " <button>g3=2;jump menu " << i << ";</button>"
<< endl;
m_file << " <button>jump title 1 chapter 1;</button>" << endl;
if (i < pages - 1)
m_file << " <button>g3=" << (i == pages - 2 ? 3 : 1) << ";jump menu "
<< (i + 2) << ";</button>" << endl;
// show the back button only unless SkipMainmenu or if we have more than one track on disk
if( !m_job.get_options().SkipMainmenu || m_job.get_recordings().size() > 1 )
m_file << " <button>jump vmgm menu;</button>" << endl;
}
m_file << " </pgc>" << endl;
}
m_file << " </menus>" << endl;
}
void dvdauthor_xml::write()
{
m_file.open(get_xml_path().c_str(), ios::out);
if (!m_file) {
logger::error(format("couldn't create {0}") % get_xml_path());
return;
}
m_file << "<?xml version=\"1.0\" encoding=\"" << plugin::get_character_encoding() << "\"?>" << endl;
m_file << "<dvdauthor dest=\"" << get_author_path() << "\">" << endl
<< " <vmgm>" << endl;
bool createMenu = (m_job.get_disk_type() == disktype_dvd_menu);
if (createMenu) {
// Go directly to the menu of the first title, if SkipMainMenu and this is the only item in the main menu
if( m_job.get_options().SkipMainmenu && m_job.get_recordings().size() == 1 ) {
// Jump to the title-menu of the only track
m_file << " <fpc>g0=1;g1=1024;jump titleset 1 menu;</fpc>" << endl;
m_file << " <menus>" << endl
<< " <pgc entry=\"title\">" << endl
<< " <pre>" << endl
<< " button=g1;g3=0;jump titleset 1 menu;" << endl;
m_file << " </pre>" << endl
<< " <vob file=\"" << m_job.get_paths().data << "/menu-bg-0.mpg\" pause=\"inf\"/>" << endl
<< " <button>g1=button;jump titleset 1 menu;</button>" << endl
<< " </pgc>" << endl
<< " </menus>" << endl;
}
else {
// Jump to the main-menu
m_file << " <fpc>g0=1;g1=1024;jump vmgm menu 1;</fpc>" << endl;
write_main_menu();
}
m_file << " </vmgm>" << endl;
for (recording_list::const_iterator rec = m_job.get_recordings().begin();
rec != m_job.get_recordings().end(); ++rec) {
m_file << " <titleset>" << endl;
write_title_menu(rec);
m_file << " <titles>" << endl;
const_track_filter videoTracks( rec->get_tracks(), track_info::streamtype_video, track_predicate::used );
if (videoTracks.begin() != videoTracks.end()) {
const track_info& track = *videoTracks.begin();
m_file << " <video " << get_video_aspect(track.video.aspect) << "/>" << endl;
}
const_track_filter audioTracks( rec->get_tracks(), track_info::streamtype_audio, track_predicate::used );
const_track_filter::iterator audioTrack = audioTracks.begin();
while (audioTrack != audioTracks.end()) {
const track_info& track = *audioTrack;
m_file << " <audio " << get_audio_language(track.language) << "/>"
<< " <!-- " << track.language << " - " << track.description << " -->" << endl;
audioTrack++;
}
const_track_filter subtitleTracks( rec->get_tracks(), track_info::streamtype_subtitle, track_predicate::used );
const_track_filter::iterator subtitleTrack = subtitleTracks.begin();
while (subtitleTrack != subtitleTracks.end()) {
const track_info& track = *subtitleTrack;
m_file << " <subpicture " << get_audio_language(track.language) << "/>"
<< " <!-- " << track.language << " - " << track.description << " -->" << endl;
subtitleTrack++;
}
m_file << " <pgc>" << endl
<< " <vob file=\"" << rec->get_movie_path() << "\" chapters=\""
<< rec->get_chapters(m_job.get_chapters_mode()) << "\"/>" << endl;
m_file << " <post>call vmgm menu;</post>" << endl;
m_file << " </pgc>" << endl
<< " </titles>" << endl
<< " </titleset>" << endl;
}
}
else
{ // DVD without menus
m_file << " <fpc>g3=1;jump vmgm menu 1;</fpc>" << endl
<< " <menus>" << endl
<< " <pgc entry=\"title\">" << endl
<< " <pre>" << endl;
int titleset = 1;
for (recording_list::const_iterator rec = m_job.get_recordings().begin();
rec != m_job.get_recordings().end(); ++rec) {
m_file << " if (g3 eq " << titleset << ") {jump title " << titleset
<< ";}" << endl;
titleset++;
}
m_file << " </pre>" << endl
<< " <!-- dummy vob required: vob file= -->" << endl
<< " </pgc>" << endl
<< " </menus>" << endl
<< " </vmgm>" << endl;
int t = 1;
for (recording_list::const_iterator rec = m_job.get_recordings().begin();
rec != m_job.get_recordings().end(); ++rec) {
m_file << " <titleset>" << endl;
m_file << " <titles>" << endl;
const_track_filter videoTracks( rec->get_tracks(), track_info::streamtype_video, track_predicate::used );
if (videoTracks.begin() != videoTracks.end()) {
const track_info& track = *videoTracks.begin();
m_file << "<video " << get_video_aspect(track.video.aspect) << "/>" << endl;
}
const_track_filter audioTracks( rec->get_tracks(), track_info::streamtype_audio, track_predicate::used );
const_track_filter::iterator audioTrack = audioTracks.begin();
while (audioTrack != audioTracks.end()) {
const track_info& track = *audioTrack;
m_file << " <audio " << get_audio_language(track.language) << "/>"
<< " <!-- " << track.language << " - " << track.description << " -->" << endl;
audioTrack++;
}
const_track_filter subtitleTracks( rec->get_tracks(), track_info::streamtype_subtitle, track_predicate::used );
const_track_filter::iterator subtitleTrack = subtitleTracks.begin();
while (subtitleTrack != subtitleTracks.end()) {
const track_info& track = *subtitleTrack;
m_file << " <subpicture " << get_audio_language(track.language) << "/>"
<< " <!-- " << track.language << " - " << track.description << " -->" << endl;
subtitleTrack++;
}
m_file << " <pgc>" << endl
<< " <vob file=\"" << rec->get_movie_path()
<< "\" chapters=\""
<< rec->get_chapters(m_job.get_chapters_mode()) << "\" pause=\"2\" />" << endl;
if (t+1 < titleset) {
m_file << " <post>g3=" << ++t <<";call vmgm menu 1;</post>" << endl;
}
else {
m_file << " <post>exit;</post>" << endl;
}
m_file << " </pgc>" << endl
<< " </titles>" << endl
<< " </titleset>" << endl;
}
}
m_file << "</dvdauthor>\n";
}
}