summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-10-09 20:50:20 +0100
committerCarl Hetherington <cth@carlh.net>2018-10-09 20:50:20 +0100
commit71589ebfea5a7adc49f013d405b3158ea612222a (patch)
tree205ecd463c7405ee052a0dfd553426d92cef27c5 /src
parent23f2dc3bfb94930b938281c7f1e5663b761fa508 (diff)
Add SPL class.
Diffstat (limited to 'src')
-rw-r--r--src/lib/spl.cc41
-rw-r--r--src/lib/spl.h37
-rw-r--r--src/lib/spl_entry.h2
-rw-r--r--src/lib/wscript1
-rw-r--r--src/tools/dcpomatic_player.cc14
-rw-r--r--src/wx/controls.cc5
-rw-r--r--src/wx/controls.h6
7 files changed, 95 insertions, 11 deletions
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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "spl.h"
+#include "spl_entry.h"
+#include <dcp/cpl.h>
+#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
+
+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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_SPL_H
+#define DCPOMATIC_SPL_H
+
+#include <boost/filesystem.hpp>
+
+class SPLEntry;
+
+class SPL
+{
+public:
+ void as_xml (boost::filesystem::path file) const;
+
+ std::string name;
+ std::list<SPLEntry> 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<SPLEntry> spl;
+ SPL spl;
BOOST_FOREACH (shared_ptr<dcp::CPL> 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<dcp::EncryptedKDM>();
}
- void set_spl (list<SPLEntry> spl)
+ void set_spl (SPL spl)
{
if (_viewer->playing ()) {
_viewer->stop ();
@@ -374,7 +376,7 @@ public:
_film.reset (new Film (optional<boost::filesystem::path>()));
- 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<DCPContent> first;
- BOOST_FOREACH (SPLEntry i, spl) {
+ BOOST_FOREACH (SPLEntry i, spl.playlist) {
shared_ptr<DCPContent> 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 <dcp/dcp.h>
#include <dcp/cpl.h>
#include <dcp/reel.h>
@@ -192,7 +193,7 @@ Controls::add_clicked ()
{
optional<CPL> 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 <wx/wx.h>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
@@ -54,7 +54,7 @@ public:
void show_extended_player_controls (bool s);
void log (wxString s);
- boost::signals2::signal<void (std::list<SPLEntry>)> SPLChanged;
+ boost::signals2::signal<void (SPL)> SPLChanged;
private:
void update_position_label ();
@@ -125,7 +125,7 @@ private:
wxToggleButton* _play_button;
#endif
boost::optional<std::string> _active_job;
- std::list<SPLEntry> _spl;
+ SPL _spl;
ClosedCaptionsDialog* _closed_captions_dialog;