}
boost::filesystem::path
-DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared_ptr<const CertificateChain> signer) const
+DCP::write_pkl (string file, Standard standard, string pkl_uuid, XMLMetadata metadata, shared_ptr<const CertificateChain> signer) const
{
boost::filesystem::path p = _directory;
- p /= String::compose ("pkl_%1.xml", pkl_uuid);
+ p /= file;
xmlpp::Document doc;
xmlpp::Element* pkl;
DCP::write_xml (
Standard standard,
XMLMetadata metadata,
- shared_ptr<const CertificateChain> signer
+ shared_ptr<const CertificateChain> signer,
+ FilenameFormat filename_format
)
{
BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
- string const filename = "cpl_" + i->id() + ".xml";
- i->write_xml (_directory / filename, standard, signer);
+ NameFormat::Map values;
+ values["type"] = "cpl";
+ values["id"] = i->id();
+ i->write_xml (_directory / (filename_format.get(values) + ".xml"), standard, signer);
}
string const pkl_uuid = make_uuid ();
- boost::filesystem::path const pkl_path = write_pkl (standard, pkl_uuid, metadata, signer);
+ NameFormat::Map values;
+ values["type"] = "pkl";
+ values["id"] = pkl_uuid;
+ boost::filesystem::path const pkl_path = write_pkl (filename_format.get(values) + ".xml", standard, pkl_uuid, metadata, signer);
write_volindex (standard);
write_assetmap (standard, pkl_uuid, boost::filesystem::file_size (pkl_path), metadata);
#include "types.h"
#include "certificate.h"
#include "metadata.h"
+#include "filename_format.h"
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include <string>
void write_xml (
Standard standard,
XMLMetadata metadata = XMLMetadata (),
- boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> ()
+ boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> (),
+ FilenameFormat filename_format = FilenameFormat("%t_%i")
);
void resolve_refs (std::list<boost::shared_ptr<Asset> > assets);
* @param pkl_uuid UUID to use.
*/
boost::filesystem::path write_pkl (
+ std::string file,
Standard standard,
std::string pkl_uuid,
XMLMetadata metadata,
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp 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.
+
+ libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+#include "filename_format.h"
+
+using std::string;
+using namespace dcp;
+
+FilenameFormat::FilenameFormat (string specification)
+ : NameFormat (specification)
+{
+ add ("type", 't', "asset type (j2c/pcm/sub/pkl/cpl)");
+ add ("id", 'i', "unique ID");
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp 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.
+
+ libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+#ifndef LIBDCP_FILENAME_FORMAT
+#define LIBDCP_FILENAME_FORMAT
+
+#include "name_format.h"
+
+namespace dcp {
+
+class FilenameFormat : public NameFormat
+{
+public:
+ FilenameFormat () {}
+ FilenameFormat (std::string specification);
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp 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.
+
+ libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+#include "name_format.h"
+#include <boost/optional.hpp>
+#include <boost/foreach.hpp>
+
+using std::string;
+using std::map;
+using boost::optional;
+using namespace dcp;
+
+static char
+filter (char c)
+{
+ if (c == '/' || c == ':') {
+ c = '-';
+ } else if (c == ' ') {
+ c = '_';
+ }
+
+ return c;
+}
+
+static string
+filter (string c)
+{
+ string o;
+
+ for (size_t i = 0; i < c.length(); ++i) {
+ o += filter (c[i]);
+ }
+
+ return o;
+}
+
+void
+NameFormat::add (string name, char placeholder, string title)
+{
+ _components.push_back (Component (name, placeholder, title));
+}
+
+optional<NameFormat::Component>
+NameFormat::component_by_placeholder (char p) const
+{
+ BOOST_FOREACH (Component const & i, _components) {
+ if (i.placeholder == p) {
+ return i;
+ }
+ }
+
+ return optional<Component> ();
+}
+
+string
+NameFormat::get (Map values) const
+{
+ string result;
+ for (size_t i = 0; i < _specification.length(); ++i) {
+ bool done = false;
+ if (_specification[i] == '%' && (i < _specification.length() - 1)) {
+ optional<Component> c = component_by_placeholder (_specification[i + 1]);
+ if (c) {
+ result += filter (values[c->name]);
+ ++i;
+ done = true;
+ }
+ }
+
+ if (!done) {
+ result += filter (_specification[i]);
+ }
+ }
+
+ return result;
+}
+
+bool
+dcp::operator== (NameFormat const & a, NameFormat const & b)
+{
+ return a.specification() == b.specification();
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp 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.
+
+ libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+#ifndef LIBDCP_NAME_FORMAT
+#define LIBDCP_NAME_FORMAT
+
+#include <boost/optional.hpp>
+#include <map>
+#include <list>
+
+namespace dcp {
+
+class NameFormat
+{
+public:
+ struct Component
+ {
+ Component (std::string name_, char placeholder_, std::string title_)
+ : name (name_)
+ , placeholder (placeholder_)
+ , title (title_)
+ {}
+
+ std::string name;
+ char placeholder;
+ std::string title;
+ };
+
+ std::list<Component> components () const {
+ return _components;
+ }
+
+ std::string specification () const {
+ return _specification;
+ }
+
+ void set_specification (std::string specification) {
+ _specification = specification;
+ }
+
+ typedef std::map<std::string, std::string> Map;
+
+ std::string get (Map) const;
+
+protected:
+ NameFormat () {}
+
+ NameFormat (std::string specification)
+ : _specification (specification)
+ {}
+
+ void add (std::string name, char placeholder, std::string title);
+
+private:
+ boost::optional<NameFormat::Component> component_by_placeholder (char p) const;
+
+ std::list<Component> _components;
+ std::string _specification;
+};
+
+extern bool operator== (NameFormat const & a, NameFormat const & b);
+
+}
+
+#endif
encrypted_kdm.cc
exceptions.cc
file.cc
+ filename_format.cc
font_asset.cc
font_node.cc
gamma_transfer_function.cc
mono_picture_asset_writer.cc
mono_picture_frame.cc
mxf.cc
+ name_format.cc
object.cc
openjpeg_image.cc
picture_asset.cc
decrypted_kdm_key.h
encrypted_kdm.h
exceptions.h
+ filename_format.h
font_asset.h
gamma_transfer_function.h
interop_load_font_node.h
mono_picture_frame.h
modified_gamma_transfer_function.h
mxf.h
+ name_format.h
object.h
openjpeg_image.h
picture_asset.h