41 #include "compose.hpp"
48 LIBDCP_DISABLE_WARNINGS
49 #include <libxml++/libxml++.h>
50 LIBDCP_ENABLE_WARNINGS
51 #include <boost/algorithm/string.hpp>
55 using boost::function;
56 using std::shared_ptr;
57 using boost::optional;
58 using namespace boost::filesystem;
68 Asset::Asset (path file)
84 Asset::add_to_pkl (shared_ptr<PKL> pkl, path root)
const
88 auto path = relative_to_root (
90 canonical(
_file.get())
100 pkl->add_asset (_id, _id,
hash(), file_size(
_file.get()),
pkl_type(pkl->standard()));
105 Asset::write_to_assetmap (xmlpp::Node* node, path root)
const
108 write_file_to_assetmap (node, root,
_file.get(), _id);
113 Asset::write_file_to_assetmap (xmlpp::Node* node, path root, path file,
string id)
115 auto path = relative_to_root (
127 auto asset = node->add_child (
"Asset");
128 asset->add_child(
"Id")->add_child_text(
"urn:uuid:" +
id);
129 auto chunk_list = asset->add_child (
"ChunkList");
130 auto chunk = chunk_list->add_child (
"Chunk");
132 chunk->add_child(
"Path")->add_child_text(path.get().generic_string());
133 chunk->add_child(
"VolumeIndex")->add_child_text(
"1");
134 chunk->add_child(
"Offset")->add_child_text(
"0");
135 chunk->add_child(
"Length")->add_child_text(raw_convert<string>(file_size(
file)));
140 Asset::hash (
function<
void (
float)> progress)
const
153 Asset::equals (std::shared_ptr<const Asset> other,
EqualityOptions, NoteHandler note)
const
155 if (
_hash != other->_hash) {
156 note (NoteType::ERROR,
"Asset: hashes differ");
168 _hash = boost::optional<string>();
173 Asset::set_hash (
string hash)
virtual std::string pkl_type(Standard standard) const =0
boost::optional< boost::filesystem::path > file() const
boost::optional< boost::filesystem::path > _file
boost::optional< std::string > _hash
void set_file(boost::filesystem::path file) const
std::string hash(boost::function< void(float)> progress={}) const
Some part of a DCP that has a UUID.
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
std::string make_digest(boost::filesystem::path filename, boost::function< void(float)>)
Methods for conversion to/from string.
A class to describe what "equality" means for a particular test.
Utility methods and classes.