Add SPL class.
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Oct 2018 19:50:20 +0000 (20:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 Oct 2018 19:50:20 +0000 (20:50 +0100)
src/lib/spl.cc [new file with mode: 0644]
src/lib/spl.h [new file with mode: 0644]
src/lib/spl_entry.h
src/lib/wscript
src/tools/dcpomatic_player.cc
src/wx/controls.cc
src/wx/controls.h

diff --git a/src/lib/spl.cc b/src/lib/spl.cc
new file mode 100644 (file)
index 0000000..ba99e30
--- /dev/null
@@ -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 (file)
index 0000000..526016f
--- /dev/null
@@ -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
index 033cab6a0a2439b95e3f6cfd7f57c7cafbe87939..cc28d92bda2adf21236f54ef84acfb31e291a302 100644 (file)
@@ -18,6 +18,8 @@
 
 */
 
+#include "dcpomatic_time.h"
+
 namespace dcp {
        class CPL;
 }
index 5e5a868842e03682497a215beffefe5258d6ce70..768c27f9201a201ef74e609e4e54e32c8d7a6e0c 100644 (file)
@@ -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
index c20c3cbd88d5490aab84ab5b7cccb046804e8a42..0b84d1c349989cde59ca30f0f906ff0ee95c0cb0 100644 (file)
@@ -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;
index 0c9a27518635f70dde4b120ca111d8eb1e71deec..753014c4665bde18e188a1cf04cd7332a11d2640 100644 (file)
@@ -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);
index ba7c46fcc50a7ff724c6df6768cd09360b3bbcc0..fd8178435e253c7ffbb51f2f712019357e32a250 100644 (file)
@@ -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;