]> git.decadent.org.uk Git - videolink.git/blobdiff - generate_dvd.cpp
Brought documentation up to date.
[videolink.git] / generate_dvd.cpp
index 6144ef5ba0b78e06a2d5568154f03ca1eeaa0e7d..9f15d2f96a903e3d8dd73d74cadeb2788bcef142 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2005-6 Ben Hutchings <ben@decadentplace.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #include <fstream>
@@ -8,6 +8,7 @@
 
 #include "dvd.hpp"
 #include "generate_dvd.hpp"
+#include "xml_utils.hpp"
 
 dvd_contents::menu::menu()
        : vob_temp(new temp_file("webdvd-vob-"))
@@ -54,7 +55,7 @@ void generate_dvd(const dvd_contents & contents,
            // This is the first (title) menu, displayed when the
            // disc is first played.
            file <<
-               "      <pgc entry='title'>\n"
+               "      <pgc entry='title' pause='inf'>\n"
                "        <pre>\n"
                // Initialise the current location if it is not set
                // (all general registers are initially 0).
@@ -64,7 +65,7 @@ void generate_dvd(const dvd_contents & contents,
        else
        {
            file <<
-               "      <pgc>\n"
+               "      <pgc pause='inf'>\n"
                "        <pre>\n";
        }
 
@@ -159,15 +160,23 @@ void generate_dvd(const dvd_contents & contents,
                     << 1 + menu_num + (1 + button_num) * button_mult
                     << "; jump title "
                     << 1 + target.index;
-               if (target.sub_index)
-                   file << " chapter " << target.sub_index;
+               // FIXME: Here we should check target.sub_index and
+               // jump to a specific chapter if it is non-zero.
+               // However, we can't jump directly to chapters from
+               // the VMGM.
                file << ";";
            }
 
            file <<  " </button>\n";
        }
 
-       file << "      </pgc>\n";
+       file <<
+           // Some DVD players don't seem to obey pause='inf' so make
+           // them loop.
+           "        <post>\n"
+           "          jump cell 1;\n"
+           "        </post>\n"
+           "      </pgc>\n";
     }
 
     file <<
@@ -193,8 +202,22 @@ void generate_dvd(const dvd_contents & contents,
            "    <titles>\n"
            "      <pgc>\n"
            // Record calling location.
-           "        <pre> g12 = g1; </pre>\n"
-            << contents.titles[title_num].vob_list <<
+           "        <pre> g12 = g1; </pre>\n";
+
+       for (vob_list::const_iterator it = contents.titles[title_num].begin(),
+                end = contents.titles[title_num].end();
+            it != end;
+            ++it)
+       {
+           file << "        <vob file='" << xml_escape(it->file) << "'";
+           if (!it->chapters.empty())
+               file << " chapters='" << xml_escape(it->chapters) << "'";
+           if (!it->pause.empty())
+               file << " pause='" << xml_escape(it->pause) << "'";
+           file << "/>\n";
+       }
+
+       file <<
            // If the menu location has not been changed during
            // the title, set the location to be the following
            // button in the menu.  In any case, return to some