diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-28 00:11:30 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-28 00:11:30 +0000 |
| commit | a246eb45b34ebc6bf277694b295f693706be8c6a (patch) | |
| tree | bb5d78210f036eaddd8ad66af1325bc3d6636fcb /src | |
| parent | 103c20d48c22f0c604e402de41bce7336ef9b386 (diff) | |
Add support for hashing mono picture MXF writes on the way out.
Diffstat (limited to 'src')
| -rw-r--r-- | src/picture_asset.cc | 27 | ||||
| -rw-r--r-- | src/picture_asset.h | 24 |
2 files changed, 45 insertions, 6 deletions
diff --git a/src/picture_asset.cc b/src/picture_asset.cc index cd6dd4dc..d242777c 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -41,6 +41,9 @@ using std::ostream; using std::list; using std::vector; using std::max; +using std::pair; +using std::make_pair; +using std::istream; using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::lexical_cast; @@ -216,7 +219,6 @@ MonoPictureAsset::construct (boost::function<string (int)> get_path) throw FileError ("could not open JPEG2000 file for reading", path); } - /* XXX: passing 0 to WriteFrame ok? */ if (ASDCP_FAILURE (mxf_writer.WriteFrame (frame_buffer, 0, 0))) { throw MiscError ("error in writing video MXF"); } @@ -240,7 +242,7 @@ MonoPictureAsset::path_from_list (int f, vector<string> const & files) const shared_ptr<const MonoPictureFrame> MonoPictureAsset::get_frame (int n) const { - return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (path().string(), n + _entry_point)); + return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (path().string(), n)); } @@ -390,7 +392,7 @@ StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int f shared_ptr<const StereoPictureFrame> StereoPictureAsset::get_frame (int n) const { - return shared_ptr<const StereoPictureFrame> (new StereoPictureFrame (path().string(), n + _entry_point)); + return shared_ptr<const StereoPictureFrame> (new StereoPictureFrame (path().string(), n)); } shared_ptr<MonoPictureAssetWriter> @@ -400,6 +402,17 @@ MonoPictureAsset::start_write () return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this)); } +FrameInfo::FrameInfo (istream& s) +{ + s >> offset >> length >> hash; +} + +void +FrameInfo::write (ostream& s) +{ + s << offset << " " << length << " " << hash; +} + struct MonoPictureAssetWriter::ASDCPState { ASDCPState() @@ -426,7 +439,7 @@ MonoPictureAssetWriter::MonoPictureAssetWriter (MonoPictureAsset* a) } -void +FrameInfo MonoPictureAssetWriter::write (uint8_t* data, int size) { assert (!_finalized); @@ -448,11 +461,15 @@ MonoPictureAssetWriter::write (uint8_t* data, int size) } } - if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0))) { + uint64_t const before_offset = _state->mxf_writer.Tell (); + + string hash; + if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0, &hash))) { throw MiscError ("error in writing video MXF"); } _frames_written++; + return FrameInfo (before_offset, _state->mxf_writer.Tell() - before_offset, hash); } void diff --git a/src/picture_asset.h b/src/picture_asset.h index 71900200..4e9e1dd7 100644 --- a/src/picture_asset.h +++ b/src/picture_asset.h @@ -17,6 +17,9 @@ */ +#ifndef LIBDCP_PICTURE_ASSET_H +#define LIBDCP_PICTURE_ASSET_H + /** @file src/picture_asset.h * @brief An asset made up of JPEG2000 files */ @@ -79,6 +82,23 @@ protected: class MonoPictureAsset; +struct FrameInfo +{ + FrameInfo (uint64_t o, uint64_t l, std::string h) + : offset (o) + , length (l) + , hash (h) + {} + + FrameInfo (std::istream& s); + + void write (std::ostream& s); + + uint64_t offset; + uint64_t length; + std::string hash; +}; + /** A helper class for writing to MonoPictureAssets progressively (i.e. writing frame-by-frame, * rather than giving libdcp all the frames in one go). * @@ -94,7 +114,7 @@ class MonoPictureAssetWriter public: ~MonoPictureAssetWriter (); - void write (uint8_t* data, int size); + FrameInfo write (uint8_t* data, int size); void finalize (); private: @@ -205,3 +225,5 @@ public: } + +#endif |
