From adeab682b76138d7a05bab3943af23cd57e2bc57 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 27 Feb 2020 23:50:10 +0100 Subject: Move swaroop playlist editor stuff into its own swaroop_ files. --- src/lib/spl.cc | 71 --------------------------- src/lib/spl.h | 112 ------------------------------------------- src/lib/spl_entry.cc | 72 ---------------------------- src/lib/spl_entry.h | 63 ------------------------ src/lib/swaroop_spl.cc | 71 +++++++++++++++++++++++++++ src/lib/swaroop_spl.h | 112 +++++++++++++++++++++++++++++++++++++++++++ src/lib/swaroop_spl_entry.cc | 72 ++++++++++++++++++++++++++++ src/lib/swaroop_spl_entry.h | 63 ++++++++++++++++++++++++ src/lib/wscript | 5 +- 9 files changed, 321 insertions(+), 320 deletions(-) delete mode 100644 src/lib/spl.cc delete mode 100644 src/lib/spl.h delete mode 100644 src/lib/spl_entry.cc delete mode 100644 src/lib/spl_entry.h create mode 100644 src/lib/swaroop_spl.cc create mode 100644 src/lib/swaroop_spl.h create mode 100644 src/lib/swaroop_spl_entry.cc create mode 100644 src/lib/swaroop_spl_entry.h (limited to 'src/lib') diff --git a/src/lib/spl.cc b/src/lib/spl.cc deleted file mode 100644 index e8e86f89c..000000000 --- a/src/lib/spl.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2018-2019 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 "content_store.h" -#include -#include -#include -#include -#include - -using std::cout; -using std::string; -using boost::shared_ptr; -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"); - BOOST_FOREACH (cxml::ConstNodePtr i, doc.node_children("Entry")) { - shared_ptr c = store->get(i->string_child("Digest")); - if (c) { - add (SPLEntry(c, i)); - } else { - _missing = true; - } - } - - _allowed_shows = doc.optional_number_child("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); - BOOST_FOREACH (SPLEntry i, _spl) { - i.as_xml (root->add_child("Entry")); - } - if (_allowed_shows) { - root->add_child("AllowedShows")->add_child_text(raw_convert(*_allowed_shows)); - } - doc.write_to_file_formatted (path.string()); -} diff --git a/src/lib/spl.h b/src/lib/spl.h deleted file mode 100644 index 18892993f..000000000 --- a/src/lib/spl.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - 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 "spl_entry.h" -#include - -class ContentStore; - -class SPL -{ -public: - SPL () - : _id (dcp::make_uuid()) - , _missing (false) - {} - - void add (SPLEntry e) { - _spl.push_back (e); - } - - void remove (std::size_t index) { - _spl.erase (_spl.begin() + index); - } - - std::vector const & get () const { - return _spl; - } - - SPLEntry & operator[] (std::size_t index) { - return _spl[index]; - } - - SPLEntry const & operator[] (std::size_t index) const { - return _spl[index]; - } - - void read (boost::filesystem::path path, ContentStore* store); - void write (boost::filesystem::path path) const; - - std::string id () const { - return _id; - } - - boost::optional path () const { - return _path; - } - - std::string name () const { - if (!_path) { - return ""; - } - return _path->filename().string(); - } - - bool missing () const { - return _missing; - } - - boost::optional 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(); - } - - void decrement_allowed_shows () { - if (_allowed_shows) { - (*_allowed_shows)--; - } - - } - -private: - std::string _id; - mutable boost::optional _path; - std::vector _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 _allowed_shows; -}; - -#endif diff --git a/src/lib/spl_entry.cc b/src/lib/spl_entry.cc deleted file mode 100644 index a2f36317e..000000000 --- a/src/lib/spl_entry.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - 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_entry.h" -#include "dcp_content.h" -#include "dcpomatic_assert.h" -#include - -using boost::shared_ptr; -using boost::dynamic_pointer_cast; - -SPLEntry::SPLEntry (shared_ptr content) - : skippable (false) - , disable_timeline (false) - , stop_after_play (false) -{ - construct (content); -} - -SPLEntry::SPLEntry (shared_ptr content, cxml::ConstNodePtr node) - : skippable (node->bool_child("Skippable")) - , disable_timeline (node->bool_child("DisableTimeline")) - , stop_after_play (node->bool_child("StopAfterPlay")) -{ - construct (content); -} - -void -SPLEntry::construct (shared_ptr c) -{ - content = c; - shared_ptr dcp = dynamic_pointer_cast (content); - digest = content->digest (); - if (dcp) { - name = dcp->name (); - 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; - } -} - -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 deleted file mode 100644 index d939ec66a..000000000 --- a/src/lib/spl_entry.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - 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_ENTRY_H -#define DCPOMATIC_SPL_ENTRY_H - -#include -#include -#include - -namespace xmlpp { - class Element; -} - -class Content; - -class SPLEntry -{ -public: - SPLEntry (boost::shared_ptr content); - SPLEntry (boost::shared_ptr content, cxml::ConstNodePtr node); - - void as_xml (xmlpp::Element* e); - - boost::shared_ptr content; - std::string name; - /** Digest of this content */ - std::string digest; - /** CPL ID or something else for MP4 (?) */ - 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); -}; - -#endif diff --git a/src/lib/swaroop_spl.cc b/src/lib/swaroop_spl.cc new file mode 100644 index 000000000..02ed966a4 --- /dev/null +++ b/src/lib/swaroop_spl.cc @@ -0,0 +1,71 @@ +/* + Copyright (C) 2018-2019 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 "swaroop_spl.h" +#include "content_store.h" +#include +#include +#include +#include +#include + +using std::cout; +using std::string; +using boost::shared_ptr; +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"); + BOOST_FOREACH (cxml::ConstNodePtr i, doc.node_children("Entry")) { + shared_ptr c = store->get(i->string_child("Digest")); + if (c) { + add (SPLEntry(c, i)); + } else { + _missing = true; + } + } + + _allowed_shows = doc.optional_number_child("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); + BOOST_FOREACH (SPLEntry i, _spl) { + i.as_xml (root->add_child("Entry")); + } + if (_allowed_shows) { + root->add_child("AllowedShows")->add_child_text(raw_convert(*_allowed_shows)); + } + doc.write_to_file_formatted (path.string()); +} diff --git a/src/lib/swaroop_spl.h b/src/lib/swaroop_spl.h new file mode 100644 index 000000000..308f5286d --- /dev/null +++ b/src/lib/swaroop_spl.h @@ -0,0 +1,112 @@ +/* + 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 "swaroop_spl_entry.h" +#include + +class ContentStore; + +class SPL +{ +public: + SPL () + : _id (dcp::make_uuid()) + , _missing (false) + {} + + void add (SPLEntry e) { + _spl.push_back (e); + } + + void remove (std::size_t index) { + _spl.erase (_spl.begin() + index); + } + + std::vector const & get () const { + return _spl; + } + + SPLEntry & operator[] (std::size_t index) { + return _spl[index]; + } + + SPLEntry const & operator[] (std::size_t index) const { + return _spl[index]; + } + + void read (boost::filesystem::path path, ContentStore* store); + void write (boost::filesystem::path path) const; + + std::string id () const { + return _id; + } + + boost::optional path () const { + return _path; + } + + std::string name () const { + if (!_path) { + return ""; + } + return _path->filename().string(); + } + + bool missing () const { + return _missing; + } + + boost::optional 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(); + } + + void decrement_allowed_shows () { + if (_allowed_shows) { + (*_allowed_shows)--; + } + + } + +private: + std::string _id; + mutable boost::optional _path; + std::vector _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 _allowed_shows; +}; + +#endif diff --git a/src/lib/swaroop_spl_entry.cc b/src/lib/swaroop_spl_entry.cc new file mode 100644 index 000000000..ed5a469ac --- /dev/null +++ b/src/lib/swaroop_spl_entry.cc @@ -0,0 +1,72 @@ +/* + 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 "swaroop_spl_entry.h" +#include "dcp_content.h" +#include "dcpomatic_assert.h" +#include + +using boost::shared_ptr; +using boost::dynamic_pointer_cast; + +SPLEntry::SPLEntry (shared_ptr content) + : skippable (false) + , disable_timeline (false) + , stop_after_play (false) +{ + construct (content); +} + +SPLEntry::SPLEntry (shared_ptr content, cxml::ConstNodePtr node) + : skippable (node->bool_child("Skippable")) + , disable_timeline (node->bool_child("DisableTimeline")) + , stop_after_play (node->bool_child("StopAfterPlay")) +{ + construct (content); +} + +void +SPLEntry::construct (shared_ptr c) +{ + content = c; + shared_ptr dcp = dynamic_pointer_cast (content); + digest = content->digest (); + if (dcp) { + name = dcp->name (); + 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; + } +} + +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/swaroop_spl_entry.h b/src/lib/swaroop_spl_entry.h new file mode 100644 index 000000000..75e0b5223 --- /dev/null +++ b/src/lib/swaroop_spl_entry.h @@ -0,0 +1,63 @@ +/* + 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_SWAROOP_SPL_ENTRY_H +#define DCPOMATIC_SWAROOP_SPL_ENTRY_H + +#include +#include +#include + +namespace xmlpp { + class Element; +} + +class Content; + +class SPLEntry +{ +public: + SPLEntry (boost::shared_ptr content); + SPLEntry (boost::shared_ptr content, cxml::ConstNodePtr node); + + void as_xml (xmlpp::Element* e); + + boost::shared_ptr content; + std::string name; + /** Digest of this content */ + std::string digest; + /** CPL ID or something else for MP4 (?) */ + 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); +}; + +#endif diff --git a/src/lib/wscript b/src/lib/wscript index 31071bf7a..6ef41e91e 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -150,8 +150,6 @@ sources = """ server.cc shuffler.cc state.cc - spl.cc - spl_entry.cc string_log_entry.cc string_text_file.cc string_text_file_content.cc @@ -201,6 +199,9 @@ def build(bld): obj.source = sources + ' version.cc' + if bld.env.VARIANT == 'swaroop-theater' or bld.env.VARIANT == 'swaroop-studio': + obj.source += ' swaroop_spl.cc swaroop_spl_entry.cc' + if bld.env.TARGET_WINDOWS: obj.uselib += ' WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE' if bld.env.STATIC_DCPOMATIC: -- cgit v1.2.3