// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
// See the file "COPYING" for licence details.

#ifndef INC_GENERATE_DVD_HPP
#define INC_GENERATE_DVD_HPP

#include <string>
#include <vector>

#include <boost/shared_ptr.hpp>

#include "temp_file.hpp"
#include "vob_list.hpp"

// Description of menus and titles to go on a DVD.

struct dvd_contents
{
    enum pgc_type { unknown_pgc,  menu_pgc, title_pgc };

    // Reference to some PGC (program chain).
    struct pgc_ref
    {
	explicit pgc_ref(pgc_type type = unknown_pgc,
			 int index = -1,
			 int sub_index = 0)
		: type(type), index(index), sub_index(sub_index)
	    {}
	bool operator==(const pgc_ref & other) const
	    {
		return type == other.type && index == other.index;
	    }
	bool operator!=(const pgc_ref & other) const
	    {
		return !(*this == other);
	    }
	    
	pgc_type type;      // Menu or title reference?
	unsigned index;     // Menu or title index (within resp. vector)
	unsigned sub_index; // Button or chapter number (1-based; 0 if
	                    // unspecified; not compared!)
    };

    // Menu definition.
    struct menu
    {
	menu();

	// Temporary file in which the menu VOB should be generated.
	// This is created as an empty file and then closed.
	boost::shared_ptr<temp_file> vob_temp;

	// References to the menus and titles that the menu buttons
	// are meant to link to, in the same order as the buttons.
	std::vector<pgc_ref> entries;
    };

    std::vector<menu> menus;
    std::vector<vob_list> titles;
};

// Use dvdauthor to generate a DVD filesystem with the given contents.
void generate_dvd(const dvd_contents & contents,
		  const std::string & output_dir);

#endif // !INC_GENERATE_DVD_HPP
