From 71589ebfea5a7adc49f013d405b3158ea612222a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 9 Oct 2018 20:50:20 +0100 Subject: [PATCH] Add SPL class. --- src/lib/spl.cc | 41 +++++++++++++++++++++++++++++++++++ src/lib/spl.h | 37 +++++++++++++++++++++++++++++++ src/lib/spl_entry.h | 2 ++ src/lib/wscript | 1 + src/tools/dcpomatic_player.cc | 14 +++++++----- src/wx/controls.cc | 5 +++-- src/wx/controls.h | 6 ++--- 7 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 src/lib/spl.cc create mode 100644 src/lib/spl.h diff --git a/src/lib/spl.cc b/src/lib/spl.cc new file mode 100644 index 000000000..ba99e3028 --- /dev/null +++ b/src/lib/spl.cc @@ -0,0 +1,41 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "spl.h" +#include "spl_entry.h" +#include +#include +#include + +void +SPL::as_xml (boost::filesystem::path file) const +{ + xmlpp::Document doc; + xmlpp::Element* root = doc.create_root_node ("DCPPlaylist"); + root->set_attribute ("Name", name); + + BOOST_FOREACH (SPLEntry i, playlist) { + xmlpp::Element* d = root->add_child ("DCP"); + d->set_attribute ("CPL", i.cpl->id()); + d->add_child_text (i.directory.string()); + } + + doc.write_to_file_formatted(file.string()); +} diff --git a/src/lib/spl.h b/src/lib/spl.h new file mode 100644 index 000000000..526016f45 --- /dev/null +++ b/src/lib/spl.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#ifndef DCPOMATIC_SPL_H +#define DCPOMATIC_SPL_H + +#include + +class SPLEntry; + +class SPL +{ +public: + void as_xml (boost::filesystem::path file) const; + + std::string name; + std::list playlist; +}; + +#endif diff --git a/src/lib/spl_entry.h b/src/lib/spl_entry.h index 033cab6a0..cc28d92bd 100644 --- a/src/lib/spl_entry.h +++ b/src/lib/spl_entry.h @@ -18,6 +18,8 @@ */ +#include "dcpomatic_time.h" + namespace dcp { class CPL; } diff --git a/src/lib/wscript b/src/lib/wscript index 5e5a86884..768c27f92 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -138,6 +138,7 @@ sources = """ send_problem_report_job.cc server.cc shuffler.cc + spl.cc string_log_entry.cc string_text_file.cc string_text_file_content.cc diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index c20c3cbd8..0b84d1c34 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -36,6 +36,8 @@ #include "lib/compose.hpp" #include "lib/dcp_content.h" #include "lib/job_manager.h" +#include "lib/spl.h" +#include "lib/spl_entry.h" #include "lib/job.h" #include "lib/film.h" #include "lib/video_content.h" @@ -315,9 +317,9 @@ public: { dcp::DCP dcp (dir); dcp.read (); - list spl; + SPL spl; BOOST_FOREACH (shared_ptr j, dcp.cpls()) { - spl.push_back (SPLEntry(j, dir)); + spl.playlist.push_back (SPLEntry(j, dir)); } set_spl (spl); Config::instance()->add_to_player_history (dir); @@ -366,7 +368,7 @@ public: return optional(); } - void set_spl (list spl) + void set_spl (SPL spl) { if (_viewer->playing ()) { _viewer->stop (); @@ -374,7 +376,7 @@ public: _film.reset (new Film (optional())); - if (spl.empty ()) { + if (spl.playlist.empty ()) { _viewer->set_film (_film); _info->triggered_update (); return; @@ -387,7 +389,7 @@ public: DCPTime position = DCPTime::from_frames(1, _film->video_frame_rate()); shared_ptr first; - BOOST_FOREACH (SPLEntry i, spl) { + BOOST_FOREACH (SPLEntry i, spl.playlist) { shared_ptr dcp; try { dcp.reset (new DCPContent (_film, i.directory)); @@ -456,7 +458,7 @@ public: _cpl_menu->Remove (*i); } - if (spl.size() == 1) { + if (spl.playlist.size() == 1) { /* Offer a CPL menu */ DCPExaminer ex (first); int id = ID_view_cpl; diff --git a/src/wx/controls.cc b/src/wx/controls.cc index 0c9a27518..753014c46 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -26,6 +26,7 @@ #include "lib/job_manager.h" #include "lib/player_video.h" #include "lib/dcp_content.h" +#include "lib/spl_entry.h" #include #include #include @@ -192,7 +193,7 @@ Controls::add_clicked () { optional sel = selected_cpl (); DCPOMATIC_ASSERT (sel); - _spl.push_back (SPLEntry(sel->first, sel->second)); + _spl.playlist.push_back (SPLEntry(sel->first, sel->second)); add_cpl_to_list (sel->first, _spl_view); SPLChanged (_spl); setup_sensitivity (); @@ -416,7 +417,7 @@ Controls::setup_sensitivity () { /* examine content is the only job which stops the viewer working */ bool const active_job = _active_job && *_active_job != "examine_content"; - bool const c = ((_film && !_film->content().empty()) || !_spl.empty()) && !active_job; + bool const c = ((_film && !_film->content().empty()) || !_spl.playlist.empty()) && !active_job; _slider->Enable (c); _rewind_button->Enable (c); diff --git a/src/wx/controls.h b/src/wx/controls.h index ba7c46fcc..fd8178435 100644 --- a/src/wx/controls.h +++ b/src/wx/controls.h @@ -21,7 +21,7 @@ #include "lib/dcpomatic_time.h" #include "lib/types.h" #include "lib/film.h" -#include "lib/spl_entry.h" +#include "lib/spl.h" #include #include #include @@ -54,7 +54,7 @@ public: void show_extended_player_controls (bool s); void log (wxString s); - boost::signals2::signal)> SPLChanged; + boost::signals2::signal SPLChanged; private: void update_position_label (); @@ -125,7 +125,7 @@ private: wxToggleButton* _play_button; #endif boost::optional _active_job; - std::list _spl; + SPL _spl; ClosedCaptionsDialog* _closed_captions_dialog; -- 2.30.2