return file (p.string ());
}
-/** Make an educated guess as to whether we have a complete DCP
- * or not.
- * @return true if we do.
- */
-
-bool
-Film::have_dcp () const
+/** @return List of subdirectories (not full paths) containing DCPs that can be successfully libdcp::DCP::read() */
+list<boost::filesystem::path>
+Film::dcps () const
{
- try {
- libdcp::DCP dcp (dir (dcp_name()));
- dcp.read ();
- } catch (...) {
- return false;
- }
+ list<boost::filesystem::path> out;
+
+ boost::filesystem::path const dir = directory ();
+ for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i) {
+ if (
+ boost::filesystem::is_directory (*i) &&
+ i->path().leaf() != "j2c" && i->path().leaf() != "video" && i->path().leaf() != "info" && i->path().leaf() != "analysis"
+ ) {
+
+ try {
+ libdcp::DCP dcp (*i);
+ dcp.read ();
+ out.push_back (i->path().leaf ());
+ } catch (...) {
- return true;
+ }
+ }
+ }
+
+ return out;
}
shared_ptr<Player>
libdcp::KDM
Film::make_kdm (
shared_ptr<libdcp::Certificate> target,
+ boost::filesystem::path dcp_dir,
boost::posix_time::ptime from,
boost::posix_time::ptime until
) const
{
shared_ptr<const Signer> signer = make_signer ();
- /* Find the DCP to make the KDM for */
- boost::filesystem::path const dir = this->directory ();
- list<boost::filesystem::path> dcps;
- for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i) {
- if (
- boost::filesystem::is_directory (*i) &&
- i->path().leaf() != "j2c" && i->path().leaf() != "video" && i->path().leaf() != "info" && i->path().leaf() != "analysis"
- ) {
-
- dcps.push_back (i->path());
- }
- }
-
- if (dcps.empty()) {
- throw KDMError (_("Could not find DCP to make KDM for"));
- } else if (dcps.size() > 1) {
- throw KDMError (_("More than one possible DCP to make KDM for"));
- }
-
- libdcp::DCP dcp (dcps.front ());
+ libdcp::DCP dcp (dir (dcp_dir.string ()));
try {
dcp.read ();
list<libdcp::KDM>
Film::make_kdms (
list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime until
) const
list<libdcp::KDM> kdms;
for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
- kdms.push_back (make_kdm ((*i)->certificate, from, until));
+ kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until));
}
return kdms;
libdcp::Size full_frame () const;
- bool have_dcp () const;
+ std::list<boost::filesystem::path> dcps () const;
boost::shared_ptr<Player> make_player () const;
boost::shared_ptr<Playlist> playlist () const;
libdcp::KDM
make_kdm (
boost::shared_ptr<libdcp::Certificate> target,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime until
) const;
std::list<libdcp::KDM> make_kdms (
std::list<boost::shared_ptr<Screen> >,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime until
) const;
}
static list<ScreenKDM>
-make_screen_kdms (shared_ptr<Film> film, list<shared_ptr<Screen> > screens, boost::posix_time::ptime from, boost::posix_time::ptime to)
+make_screen_kdms (
+ shared_ptr<Film> film,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to
+ )
{
- list<libdcp::KDM> kdms = film->make_kdms (screens, from, to);
+ list<libdcp::KDM> kdms = film->make_kdms (screens, dcp, from, to);
list<ScreenKDM> screen_kdms;
}
static list<CinemaKDMs>
-make_cinema_kdms (shared_ptr<Film> film, list<shared_ptr<Screen> > screens, boost::posix_time::ptime from, boost::posix_time::ptime to)
+make_cinema_kdms (
+ shared_ptr<Film> film,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to
+ )
{
- list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, from, to);
+ list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, dcp, from, to);
list<CinemaKDMs> cinema_kdms;
while (!screen_kdms.empty ()) {
void
write_kdm_files (
- shared_ptr<Film> film, list<shared_ptr<Screen> > screens, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory
+ shared_ptr<Film> film,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to,
+ boost::filesystem::path directory
)
{
- list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, from, to);
+ list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, dcp, from, to);
/* Write KDMs to the specified directory */
for (list<ScreenKDM>::iterator i = screen_kdms.begin(); i != screen_kdms.end(); ++i) {
void
write_kdm_zip_files (
- shared_ptr<Film> film, list<shared_ptr<Screen> > screens, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory
+ shared_ptr<Film> film,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to,
+ boost::filesystem::path directory
)
{
- list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, from, to);
+ list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to);
for (list<CinemaKDMs>::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) {
boost::filesystem::path path = directory;
}
void
-email_kdms (shared_ptr<Film> film, list<shared_ptr<Screen> > screens, boost::posix_time::ptime from, boost::posix_time::ptime to)
+email_kdms (
+ shared_ptr<Film> film,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to
+ )
{
- list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, from, to);
+ list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to);
for (list<CinemaKDMs>::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) {
extern void write_kdm_files (
boost::shared_ptr<Film> film,
std::list<boost::shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime to,
boost::filesystem::path directory
extern void write_kdm_zip_files (
boost::shared_ptr<Film> film,
std::list<boost::shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime to,
boost::filesystem::path directory
extern void email_kdms (
boost::shared_ptr<Film> film,
std::list<boost::shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
boost::posix_time::ptime from,
boost::posix_time::ptime to
);
#define ALWAYS 0x0
#define NEEDS_FILM 0x1
#define NOT_DURING_DCP_CREATION 0x2
+#define NEEDS_DCP 0x4
map<wxMenuItem*, int> menu_items;
++i;
}
bool const dcp_creation = (i != jobs.end ());
+ bool const have_dcp = !film->dcps().empty ();
for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
if ((j->second & NOT_DURING_DCP_CREATION) && dcp_creation) {
enabled = false;
}
+
+ if ((j->second & NEEDS_DCP) && !have_dcp) {
+ enabled = false;
+ }
j->first->Enable (enabled);
}
jobs_menu = new wxMenu;
add_item (jobs_menu, _("&Make DCP"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
- add_item (jobs_menu, _("Make &KDMs..."), ID_jobs_make_kdms, NEEDS_FILM);
- add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION);
- add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
+ add_item (jobs_menu, _("Make &KDMs..."), ID_jobs_make_kdms, NEEDS_FILM | NEEDS_DCP);
+ add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_DCP);
+ add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_DCP);
wxMenu* help = new wxMenu;
#ifdef __WXOSX__
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT);
- Bind (wxEVT_MENU_OPEN, boost::bind (&Frame::menu_opened, this, _1));
Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
/* Use a panel as the only child of the Frame so that we avoid
private:
- void menu_opened (wxMenuEvent& ev)
- {
- if (ev.GetMenu() != jobs_menu) {
- return;
- }
-
- bool const have_dcp = false;//film && film->have_dcp();
- jobs_menu->Enable (ID_jobs_send_dcp_to_tms, have_dcp);
- jobs_menu->Enable (ID_jobs_show_dcp, have_dcp);
- }
-
void set_film ()
{
film_viewer->set_film (film);
return;
}
- KDMDialog* d = new KDMDialog (this);
+ KDMDialog* d = new KDMDialog (this, film);
if (d->ShowModal () != wxID_OK) {
d->Destroy ();
return;
try {
if (d->write_to ()) {
- write_kdm_files (film, d->screens (), d->from (), d->until (), d->directory ());
+ write_kdm_files (film, d->screens (), d->dcp (), d->from (), d->until (), d->directory ());
} else {
- email_kdms (film, d->screens (), d->from (), d->until ());
+ email_kdms (film, d->screens (), d->dcp (), d->from (), d->until ());
}
} catch (KDMError& e) {
error_dialog (this, e.what ());
cout << "Making KDMs valid from " << valid_from.get() << " to " << valid_to.get() << "\n";
}
+ /* XXX: allow specification of this */
+ list<boost::filesystem::path> dcps = film->dcps ();
+ if (dcps.empty ()) {
+ error ("no DCPs found in film");
+ } else if (dcps.size() > 1) {
+ error ("more than one DCP found in film");
+ }
+
+ boost::filesystem::path dcp = dcps.front ();
+
if (cinema_name.empty ()) {
if (output.empty ()) {
}
shared_ptr<libdcp::Certificate> certificate (new libdcp::Certificate (boost::filesystem::path (certificate_file)));
- libdcp::KDM kdm = film->make_kdm (certificate, valid_from.get(), valid_to.get());
+ libdcp::KDM kdm = film->make_kdm (certificate, dcp, valid_from.get(), valid_to.get());
kdm.as_xml (output);
if (verbose) {
cout << "Generated KDM " << output << " for certificate.\n";
try {
if (zip) {
- write_kdm_zip_files (film, (*i)->screens(), valid_from.get(), valid_to.get(), output);
+ write_kdm_zip_files (film, (*i)->screens(), dcp, valid_from.get(), valid_to.get(), output);
if (verbose) {
cout << "Wrote ZIP files to " << output << "\n";
}
} else {
- write_kdm_files (film, (*i)->screens(), valid_from.get(), valid_to.get(), output);
+ write_kdm_files (film, (*i)->screens(), dcp, valid_from.get(), valid_to.get(), output);
if (verbose) {
cout << "Wrote KDM files to " << output << "\n";
}
#include <wx/datectrl.h>
#include <wx/timectrl.h>
#include <wx/stdpaths.h>
+#include <wx/listctrl.h>
#include "lib/cinema.h"
#include "lib/config.h"
+#include "lib/film.h"
#include "kdm_dialog.h"
#include "cinema_dialog.h"
#include "screen_dialog.h"
using std::map;
using std::list;
using std::pair;
+using std::cout;
using std::make_pair;
using boost::shared_ptr;
-KDMDialog::KDMDialog (wxWindow* parent)
+KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
: wxDialog (parent, wxID_ANY, _("Make KDMs"))
{
wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
_until_time = new wxTimePickerCtrl (this, wxID_ANY);
table->Add (_until_time, 1, wxEXPAND);
+ vertical->Add (table, 0, wxEXPAND | wxALL, 6);
+
+ _dcps = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
+ wxListItem ip;
+ ip.SetId (0);
+ ip.SetText (_("DCP"));
+ ip.SetWidth (400);
+ _dcps->InsertColumn (0, ip);
+ vertical->Add (_dcps, 0, wxEXPAND | wxALL, 6);
+
+ list<boost::filesystem::path> dcps = film->dcps ();
+ for (list<boost::filesystem::path>::const_iterator i = dcps.begin(); i != dcps.end(); ++i) {
+ wxListItem item;
+ int const n = _dcps->GetItemCount ();
+ item.SetId (n);
+ _dcps->InsertItem (item);
+ _dcps->SetItem (n, 0, std_to_wx (i->string ()));
+
+ if (dcps.size() == 1 || i->string() == film->dcp_name ()) {
+ _dcps->SetItemState (n, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+ }
+
+ table = new wxFlexGridSizer (3, 2, 6);
+
_write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
table->Add (_write_to, 1, wxEXPAND);
_edit_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KDMDialog::edit_screen_clicked, this));
_remove_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KDMDialog::remove_screen_clicked, this));
+ _dcps->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&KDMDialog::setup_sensitivity, this));
+ _dcps->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&KDMDialog::setup_sensitivity, this));
+
_write_to->Bind (wxEVT_COMMAND_RADIOBUTTON_SELECTED, boost::bind (&KDMDialog::setup_sensitivity, this));
_email->Bind (wxEVT_COMMAND_RADIOBUTTON_SELECTED, boost::bind (&KDMDialog::setup_sensitivity, this));
{
bool const sc = selected_cinemas().size() == 1;
bool const ss = selected_screens().size() == 1;
+ bool const sd = _dcps->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1;
_edit_cinema->Enable (sc);
_remove_cinema->Enable (sc);
_remove_screen->Enable (ss);
wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK));
- ok->Enable (sc || ss);
+ ok->Enable ((sc || ss) && sd);
_folder->Enable (_write_to->GetValue ());
}
return posix_time (_until_date, _until_time);
}
-string
+boost::filesystem::path
+KDMDialog::dcp () const
+{
+ int const item = _dcps->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ assert (item >= 0);
+ return wx_to_std (_dcps->GetItemText (item));
+}
+
+boost::filesystem::path
KDMDialog::directory () const
{
return wx_to_std (_folder->GetPath ());
class KDMDialog : public wxDialog
{
public:
- KDMDialog (wxWindow *);
+ KDMDialog (wxWindow *, boost::shared_ptr<const Film>);
std::list<boost::shared_ptr<Screen> > screens () const;
boost::posix_time::ptime from () const;
boost::posix_time::ptime until () const;
- std::string directory () const;
+ boost::filesystem::path dcp () const;
+ boost::filesystem::path directory () const;
bool write_to () const;
private:
wxDatePickerCtrl* _until_date;
wxTimePickerCtrl* _from_time;
wxTimePickerCtrl* _until_time;
+ wxListCtrl* _dcps;
wxRadioButton* _write_to;
#ifdef DCPOMATIC_USE_OWN_DIR_PICKER
DirPickerCtrl* _folder;
boost::filesystem::path p = test_film_dir ("ffmpeg_dcp_test");
shared_ptr<Film> f (new Film (p.string ()));
f->read_metadata ();
- BOOST_CHECK (f->have_dcp());
+ BOOST_CHECK (!f->dcps().empty());
p /= f->dcp_name();
p /= f->video_mxf_filename();
boost::filesystem::remove (p);
- BOOST_CHECK (!f->have_dcp ());
+ BOOST_CHECK (f->dcps().empty());
}