2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/asset.cc
21 * @brief Parent class for assets of DCPs made up of MXF files.
26 #include <boost/filesystem.hpp>
29 #include "mxf_asset.h"
34 using namespace boost;
35 using namespace libdcp;
37 MXFAsset::MXFAsset (string directory, string file_name, sigc::signal1<void, float>* progress, int fps, int entry_point, int length)
38 : Asset (directory, file_name)
39 , _progress (progress)
41 , _entry_point (entry_point)
48 MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info) const
50 writer_info->ProductVersion = Metadata::instance()->product_version;
51 writer_info->CompanyName = Metadata::instance()->company_name;
52 writer_info->ProductName = Metadata::instance()->product_name.c_str();
54 writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
56 Kumu::hex2bin (_uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
57 assert (c == Kumu::UUID_Length);
61 MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const
63 shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other);
65 return list<string> ();
70 if (opt.flags & LIBDCP_METADATA) {
71 if (_file_name != other_mxf->_file_name) {
72 notes.push_back ("MXF names differ");
74 if (_fps != other_mxf->_fps) {
75 notes.push_back ("MXF frames per second differ");
77 if (_length != other_mxf->_length) {
78 notes.push_back ("MXF lengths differ");
82 if (opt.flags & MXF_BITWISE) {
84 if (digest() != other_mxf->digest()) {
85 notes.push_back ("MXF digests differ");
88 if (filesystem::file_size (path()) != filesystem::file_size (other_mxf->path())) {
89 notes.push_back (path().string() + " and " + other_mxf->path().string() + " sizes differ");
93 ifstream a (path().string().c_str(), ios::binary);
94 ifstream b (other_mxf->path().string().c_str(), ios::binary);
96 int buffer_size = 65536;
97 char abuffer[buffer_size];
98 char bbuffer[buffer_size];
100 int n = filesystem::file_size (path ());
103 int const t = min (n, buffer_size);
107 if (memcmp (abuffer, bbuffer, t) != 0) {
108 notes.push_back (path().string() + " and " + other_mxf->path().string() + " content differs");
120 MXFAsset::length () const