Write hashes of encoded frames.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Jan 2013 23:11:18 +0000 (23:11 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Jan 2013 23:11:18 +0000 (23:11 +0000)
src/lib/dcp_video_frame.cc
src/lib/dcp_video_frame.h
src/lib/writer.cc

index 89db5761a1bb56f04a85e0ade660ef3a57ecd9ff..c3f0fed03dcff3932faf25eb5a854089cf23afbf 100644 (file)
@@ -401,8 +401,8 @@ EncodedData::~EncodedData ()
 }
 
 /** Write this data to a J2K file.
- *  @param opt Options.
- *  @param frame DCP Frame index.
+ *  @param Film Film.
+ *  @param frame DCP frame index.
  */
 void
 EncodedData::write (shared_ptr<const Film> film, int frame) const
@@ -422,12 +422,14 @@ EncodedData::write (shared_ptr<const Film> film, int frame) const
 
        /* Rename the file from foo.j2c.tmp to foo.j2c now that it is complete */
        boost::filesystem::rename (tmp_j2k, real_j2k);
+}
 
-       /* Write a file containing the hash */
+void
+EncodedData::write_hash (shared_ptr<const Film> film, int frame) const
+{
        string const hash = film->hash_out_path (frame, false);
        ofstream h (hash.c_str());
        h << md5_digest (_data, _size) << "\n";
-       h.close ();
 }
 
 /** Send this data to a socket.
index 2ad2b0d444e9c5bd8631c7c9513cdef7930c9941..1d434505abef04a1c7efee3d8e946ca2d07b7a26 100644 (file)
@@ -49,6 +49,7 @@ public:
 
        void send (boost::shared_ptr<Socket> socket);
        void write (boost::shared_ptr<const Film>, int) const;
+       void write_hash (boost::shared_ptr<const Film>, int) const;
 
        /** @return data */
        uint8_t* data () const {
index 2cefd32fb106160d5c5f2850392e43a0bec7c29d..b94ff3c24072132ec764f6d2d9d5174b550cf8e8 100644 (file)
@@ -124,9 +124,11 @@ Writer::thread ()
                        _film->log()->log (String::compose ("Writer writes %1 to MXF", encoded.second));
                        if (encoded.first) {
                                _picture_asset_writer->write (encoded.first->data(), encoded.first->size());
+                               encoded.first->write_hash (_film, encoded.second);
                                _last_written = encoded.first;
                        } else {
                                _picture_asset_writer->write (_last_written->data(), _last_written->size());
+                               _last_written->write_hash (_film, encoded.second);
                        }
                        lock.lock ();