X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fasset.cc;h=3d2a0e03e21054b02805279ea6fd9ff4d303050a;hb=1c4257eacfe62f30f3e08edfe049a954cd7b43a3;hp=4b02774c3f68e6945647c253fc8d09d85262727b;hpb=aaa33afbc17d60f9e836b4a2ad2e7ec2c294b837;p=libdcp.git diff --git a/src/asset.cc b/src/asset.cc index 4b02774c..3d2a0e03 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -34,15 +34,14 @@ using namespace std; using namespace boost; using namespace libdcp; -Asset::Asset (string directory, string mxf_name, sigc::signal1* progress, int fps, int length) +Asset::Asset (string directory, string file_name) : _directory (directory) - , _mxf_name (mxf_name) - , _progress (progress) - , _fps (fps) - , _length (length) + , _file_name (file_name) , _uuid (make_uuid ()) { - + if (_file_name.empty ()) { + _file_name = _uuid + ".xml"; + } } void @@ -50,9 +49,9 @@ Asset::write_to_pkl (ostream& s) const { s << " \n" << " urn:uuid:" << _uuid << "\n" - << " " << _mxf_name << "\n" - << " " << _digest << "\n" - << " " << filesystem::file_size(mxf_path()) << "\n" + << " " << _file_name << "\n" + << " " << digest() << "\n" + << " " << filesystem::file_size(path()) << "\n" << " application/mxf\n" << " \n"; } @@ -64,91 +63,30 @@ Asset::write_to_assetmap (ostream& s) const << " urn:uuid:" << _uuid << "\n" << " \n" << " \n" - << " " << _mxf_name << "\n" + << " " << _file_name << "\n" << " 1\n" << " 0\n" - << " " << filesystem::file_size(mxf_path()) << "\n" + << " " << filesystem::file_size(path()) << "\n" << " \n" << " \n" << " \n"; } -void -Asset::fill_writer_info (ASDCP::WriterInfo* writer_info) const -{ - writer_info->ProductVersion = Metadata::instance()->product_version; - writer_info->CompanyName = Metadata::instance()->company_name; - writer_info->ProductName = Metadata::instance()->product_name.c_str(); - - writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE; - unsigned int c; - Kumu::hex2bin (_uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c); - assert (c == Kumu::UUID_Length); -} - filesystem::path -Asset::mxf_path () const +Asset::path () const { filesystem::path p; p /= _directory; - p /= _mxf_name; + p /= _file_name; return p; } -list -Asset::equals (shared_ptr other, EqualityFlags flags) const +string +Asset::digest () const { - list notes; - - if (flags & LIBDCP_METADATA) { - if (_mxf_name != other->_mxf_name) { - notes.push_back ("MXF names differ"); - } - if (_fps != other->_fps) { - notes.push_back ("MXF frames per second differ"); - } - if (_length != other->_length) { - notes.push_back ("MXF lengths differ"); - } - if (_digest != other->_digest) { - notes.push_back ("MXF digests differ"); - } - } - - if (flags & MXF_BITWISE) { - if (filesystem::file_size (mxf_path()) != filesystem::file_size (other->mxf_path())) { - notes.push_back (mxf_path().string() + " and " + other->mxf_path().string() + " sizes differ"); - return notes; - } - - ifstream a (mxf_path().c_str(), ios::binary); - ifstream b (other->mxf_path().c_str(), ios::binary); - - int buffer_size = 65536; - char abuffer[buffer_size]; - char bbuffer[buffer_size]; - - int n = filesystem::file_size (mxf_path ()); - - while (n) { - int const t = min (n, buffer_size); - a.read (abuffer, t); - b.read (bbuffer, t); - - for (int i = 0; i < t; ++i) { - if (abuffer[i] != bbuffer[i]) { - notes.push_back (mxf_path().string() + " and " + other->mxf_path().string() + " content differs"); - return notes; - } - } - - n -= t; - } - } - - if (flags & MXF_INSPECT) { - + if (_digest.empty ()) { + _digest = make_digest (path().string()); } - return notes; + return _digest; }