/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include "mono_picture_frame.h"
+#include "compose.hpp"
using std::string;
using std::vector;
+using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
-using boost::lexical_cast;
using namespace dcp;
-MonoPictureMXF::MonoPictureMXF (boost::filesystem::path directory, boost::filesystem::path mxf_name)
- : PictureMXF (directory, mxf_name)
-{
-
-}
-
-void
-MonoPictureMXF::read ()
+MonoPictureMXF::MonoPictureMXF (boost::filesystem::path file)
+ : PictureMXF (file)
{
ASDCP::JP2K::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
}
ASDCP::JP2K::PictureDescriptor desc;
boost::throw_exception (DCPReadError ("could not read video MXF information"));
}
- _size.width = desc.StoredWidth;
- _size.height = desc.StoredHeight;
- _edit_rate = desc.EditRate.Numerator;
- assert (desc.EditRate.Denominator == 1);
- _intrinsic_duration = desc.ContainerDuration;
+ read_picture_descriptor (desc);
+
+ ASDCP::WriterInfo info;
+ if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
+ boost::throw_exception (DCPReadError ("could not read video MXF information"));
+ }
+
+ read_writer_info (info);
}
-boost::filesystem::path
-MonoPictureMXF::path_from_list (int f, vector<boost::filesystem::path> const & files) const
+MonoPictureMXF::MonoPictureMXF (Fraction edit_rate)
+ : PictureMXF (edit_rate)
{
- return files[f];
+
}
shared_ptr<const MonoPictureFrame>
MonoPictureMXF::get_frame (int n) const
{
- return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (path(), n, _decryption_context));
+ return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (_file, n, _decryption_context));
}
bool
-MonoPictureMXF::equals (shared_ptr<const ContentAsset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+MonoPictureMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
+ if (!dynamic_pointer_cast<const MonoPictureMXF> (other)) {
+ return false;
+ }
+
if (!MXF::equals (other, opt, note)) {
return false;
}
ASDCP::JP2K::MXFReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader_A.OpenRead (_file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file.string(), r));
}
ASDCP::JP2K::MXFReader reader_B;
- r = reader_B.OpenRead (other->path().string().c_str());
+ r = reader_B.OpenRead (other->file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file().string(), r));
}
ASDCP::JP2K::PictureDescriptor desc_A;
}
shared_ptr<const MonoPictureMXF> other_picture = dynamic_pointer_cast<const MonoPictureMXF> (other);
- assert (other_picture);
+ DCP_ASSERT (other_picture);
for (int i = 0; i < _intrinsic_duration; ++i) {
if (i >= other_picture->intrinsic_duration()) {
return false;
}
- note (PROGRESS, "Comparing video frame " + lexical_cast<string> (i) + " of " + lexical_cast<string> (_intrinsic_duration));
+ note (DCP_PROGRESS, String::compose ("Comparing video frame %1 of %2", i, _intrinsic_duration));
shared_ptr<const MonoPictureFrame> frame_A = get_frame (i);
shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i);
}
shared_ptr<PictureMXFWriter>
-MonoPictureMXF::start_write (bool overwrite)
+MonoPictureMXF::start_write (boost::filesystem::path file, Standard standard, bool overwrite)
{
/* XXX: can't we use shared_ptr here? */
- return shared_ptr<MonoPictureMXFWriter> (new MonoPictureMXFWriter (this, overwrite));
+ return shared_ptr<MonoPictureMXFWriter> (new MonoPictureMXFWriter (this, file, standard, overwrite));
}
string
{
return "MainPicture";
}
-
-int
-MonoPictureMXF::edit_rate_factor () const
-{
- return 1;
-}