*/
#include <iostream>
+#include <fstream>
#include <boost/filesystem.hpp>
#include "AS_DCP.h"
#include "KM_util.h"
p /= _mxf_name;
return p;
}
+
+list<string>
+Asset::equals (Asset const & other, EqualityFlags flags) const
+{
+ list<string> notes;
+
+ switch (flags) {
+ case LIBDCP_METADATA:
+ break;
+ case 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;
+ }
+ }
+
+ return notes;
+}
#include <string>
#include <sigc++/sigc++.h>
+#include "types.h"
namespace ASDCP {
class WriterInfo;
*/
void write_to_assetmap (std::ostream& s) const;
+ std::list<std::string> equals (Asset const & other, EqualityFlags flags) const;
+
protected:
/** Fill in a ADSCP::WriteInfo struct.
* @param w struct to fill in.
}
list<string>
-DCP::equals (DCP const & other, EqualityType type) const
+DCP::equals (DCP const & other, EqualityFlags flags) const
{
list<string> notes;
- switch (type) {
- case LIBDCP_METADATA:
+ if (flags & LIBDCP_METADATA) {
if (_name != other._name) {
notes.push_back ("names differ");
}
if (_length != other._length) {
notes.push_back ("lengths differ");
}
+ }
+
+ if (flags & LIBDCP_METADATA || flags & MXF_BITWISE) {
if (_assets.size() != other._assets.size()) {
notes.push_back ("asset counts differ");
}
- break;
+ }
+
+ if (flags & MXF_BITWISE) {
+ list<shared_ptr<Asset> >::const_iterator a = _assets.begin ();
+ list<shared_ptr<Asset> >::const_iterator b = other._assets.begin ();
+
+ while (a != _assets.end ()) {
+ list<string> n = (*a)->equals (*b->get(), MXF_BITWISE);
+ notes.merge (n);
+ ++a;
+ ++b;
+ }
}
return notes;
return _length;
}
- std::list<std::string> equals (DCP const & other, EqualityType type) const;
+ std::list<std::string> equals (DCP const & other, EqualityFlags flags) const;
/** Emitted with a parameter between 0 and 1 to indicate progress
* for long jobs.
int denominator;
};
-enum EqualityType {
- LIBDCP_METADATA
+enum EqualityFlags {
+ LIBDCP_METADATA = 0x1,
+ MXF_BITWISE = 0x2
};
}
DCP a (argv[optind]);
DCP b (argv[optind + 1]);
- list<string> notes = a.equals (b, LIBDCP_METADATA);
+ list<string> notes = a.equals (b, EqualityFlags (LIBDCP_METADATA | MXF_BITWISE));
if (notes.empty ()) {
- cout << "DCPs identical by LIBDCP_METADATA\n";
+ cout << "DCPs identical\n";
exit (EXIT_SUCCESS);
}