diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-02-28 00:37:34 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-02-29 23:53:47 +0100 |
| commit | 54af50c3b8e9082f9751e809d63540c51197a4a1 (patch) | |
| tree | 9025a623ce5453ff73c3ce76924567e941de6cdd /src/lib | |
| parent | d3f97ca7ca2877689f4ed59482e935431d43f027 (diff) | |
Various playlist editor developments and fixes.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/spl.cc | 15 | ||||
| -rw-r--r-- | src/lib/spl.h | 51 | ||||
| -rw-r--r-- | src/lib/spl_entry.cc | 20 | ||||
| -rw-r--r-- | src/lib/spl_entry.h | 17 |
4 files changed, 27 insertions, 76 deletions
diff --git a/src/lib/spl.cc b/src/lib/spl.cc index 02ed966a4..ccf809f8b 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -18,7 +18,7 @@ */ -#include "swaroop_spl.h" +#include "spl.h" #include "content_store.h" #include <libcxml/cxml.h> #include <dcp/raw_convert.h> @@ -34,38 +34,31 @@ using dcp::raw_convert; void SPL::read (boost::filesystem::path path, ContentStore* store) { - _path = path; - _spl.clear (); _missing = false; cxml::Document doc ("SPL"); doc.read_file (path); _id = doc.string_child("Id"); + _name = doc.string_child("Name"); BOOST_FOREACH (cxml::ConstNodePtr i, doc.node_children("Entry")) { shared_ptr<Content> c = store->get(i->string_child("Digest")); if (c) { - add (SPLEntry(c, i)); + add (SPLEntry(c)); } else { _missing = true; } } - - _allowed_shows = doc.optional_number_child<int>("AllowedShows"); } void SPL::write (boost::filesystem::path path) const { - _path = path; - xmlpp::Document doc; xmlpp::Element* root = doc.create_root_node ("SPL"); root->add_child("Id")->add_child_text (_id); + root->add_child("Name")->add_child_text (_name); BOOST_FOREACH (SPLEntry i, _spl) { i.as_xml (root->add_child("Entry")); } - if (_allowed_shows) { - root->add_child("AllowedShows")->add_child_text(raw_convert<string>(*_allowed_shows)); - } doc.write_to_file_formatted (path.string()); } diff --git a/src/lib/spl.h b/src/lib/spl.h index 308f5286d..8dd8eed92 100644 --- a/src/lib/spl.h +++ b/src/lib/spl.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -21,8 +21,9 @@ #ifndef DCPOMATIC_SPL_H #define DCPOMATIC_SPL_H -#include "swaroop_spl_entry.h" +#include "spl_entry.h" #include <dcp/util.h> +#include <boost/signals2.hpp> class ContentStore; @@ -34,6 +35,13 @@ public: , _missing (false) {} + SPL (std::string name) + : _id (dcp::make_uuid()) + , _name (name) + , _missing (false) + {} + + void add (SPLEntry e) { _spl.push_back (e); } @@ -61,52 +69,27 @@ public: return _id; } - boost::optional<boost::filesystem::path> path () const { - return _path; + std::string name () const { + return _name; } - std::string name () const { - if (!_path) { - return ""; - } - return _path->filename().string(); + void set_name (std::string name) { + _name = name; + NameChanged (); } bool missing () const { return _missing; } - boost::optional<int> allowed_shows () const { - return _allowed_shows; - } - - bool have_allowed_shows () const { - return !_allowed_shows || *_allowed_shows > 0; - } - - void set_allowed_shows (int s) { - _allowed_shows = s; - } - - void unset_allowed_shows () { - _allowed_shows = boost::optional<int>(); - } - - void decrement_allowed_shows () { - if (_allowed_shows) { - (*_allowed_shows)--; - } - - } + boost::signals2::signal<void ()> NameChanged; private: std::string _id; - mutable boost::optional<boost::filesystem::path> _path; + std::string _name; std::vector<SPLEntry> _spl; /** true if any content was missing when read() was last called on this SPL */ bool _missing; - /** number of times left that the player will allow this playlist to be played (unset means infinite shows) */ - boost::optional<int> _allowed_shows; }; #endif diff --git a/src/lib/spl_entry.cc b/src/lib/spl_entry.cc index ed5a469ac..5b011a046 100644 --- a/src/lib/spl_entry.cc +++ b/src/lib/spl_entry.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,7 +18,7 @@ */ -#include "swaroop_spl_entry.h" +#include "spl_entry.h" #include "dcp_content.h" #include "dcpomatic_assert.h" #include <libxml++/libxml++.h> @@ -27,17 +27,6 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; SPLEntry::SPLEntry (shared_ptr<Content> content) - : skippable (false) - , disable_timeline (false) - , stop_after_play (false) -{ - construct (content); -} - -SPLEntry::SPLEntry (shared_ptr<Content> content, cxml::ConstNodePtr node) - : skippable (node->bool_child("Skippable")) - , disable_timeline (node->bool_child("DisableTimeline")) - , stop_after_play (node->bool_child("StopAfterPlay")) { construct (content); } @@ -53,11 +42,9 @@ SPLEntry::construct (shared_ptr<Content> c) DCPOMATIC_ASSERT (dcp->cpl()); id = *dcp->cpl(); kind = dcp->content_kind().get_value_or(dcp::FEATURE); - type = DCP; encrypted = dcp->encrypted (); } else { name = content->path(0).filename().string(); - type = ECINEMA; kind = dcp::FEATURE; } } @@ -66,7 +53,4 @@ void SPLEntry::as_xml (xmlpp::Element* e) { e->add_child("Digest")->add_child_text(digest); - e->add_child("Skippable")->add_child_text(skippable ? "1" : "0"); - e->add_child("DisableTimeline")->add_child_text(disable_timeline ? "1" : "0"); - e->add_child("StopAfterPlay")->add_child_text(stop_after_play ? "1" : "0"); } diff --git a/src/lib/spl_entry.h b/src/lib/spl_entry.h index 75e0b5223..740082eaf 100644 --- a/src/lib/spl_entry.h +++ b/src/lib/spl_entry.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,8 @@ */ -#ifndef DCPOMATIC_SWAROOP_SPL_ENTRY_H -#define DCPOMATIC_SWAROOP_SPL_ENTRY_H +#ifndef DCPOMATIC_SPL_ENTRY_H +#define DCPOMATIC_SPL_ENTRY_H #include <libcxml/cxml.h> #include <dcp/types.h> @@ -35,7 +35,6 @@ class SPLEntry { public: SPLEntry (boost::shared_ptr<Content> content); - SPLEntry (boost::shared_ptr<Content> content, cxml::ConstNodePtr node); void as_xml (xmlpp::Element* e); @@ -43,18 +42,10 @@ public: std::string name; /** Digest of this content */ std::string digest; - /** CPL ID or something else for MP4 (?) */ + /** CPL ID */ std::string id; dcp::ContentKind kind; - enum Type { - DCP, - ECINEMA - }; - Type type; bool encrypted; - bool skippable; - bool disable_timeline; - bool stop_after_play; private: void construct (boost::shared_ptr<Content> content); |
