X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fwriter.h;h=9e95c05314d16580fcfb8432fc8b0be56dbd537b;hb=a79d78d8bb6d51f6662f1f63b9f8fd19e1a0c5f1;hp=62714edf39f675e6354510434618e695a214576c;hpb=a183c1776cfd020a37d028ebb0f641352f49697b;p=dcpomatic.git diff --git a/src/lib/writer.h b/src/lib/writer.h index 62714edf3..9e95c0531 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -17,22 +17,31 @@ */ +/** @file src/lib/writer.h + * @brief Writer class. + */ + #include #include #include #include #include "exceptions.h" +#include "types.h" class Film; class EncodedData; class AudioBuffers; class Job; -namespace libdcp { - class MonoPictureAsset; - class MonoPictureAssetWriter; - class SoundAsset; - class SoundAssetWriter; +namespace dcp { + class MonoPictureMXF; + class MonoPictureMXFWriter; + class StereoPictureMXF; + class StereoPictureMXFWriter; + class PictureMXF; + class PictureMXFWriter; + class SoundMXF; + class SoundMXFWriter; } struct QueueItem @@ -56,32 +65,48 @@ public: int size; /** frame index */ int frame; + Eyes eyes; }; bool operator< (QueueItem const & a, QueueItem const & b); bool operator== (QueueItem const & a, QueueItem const & b); -class Writer : public ExceptionStore +/** @class Writer + * @brief Class to manage writing JPEG2000 and audio data to MXFs on disk. + * + * This class creates sound and picture MXFs, then takes EncodedData + * or AudioBuffers objects (containing image or sound data respectively) + * and writes them to the MXFs. + * + * ::write() for EncodedData can be called out of order, and the Writer + * will sort it out. write() for AudioBuffers must be called in order. + */ + +class Writer : public ExceptionStore, public boost::noncopyable { public: - Writer (boost::shared_ptr, boost::shared_ptr); + Writer (boost::shared_ptr, boost::weak_ptr); + ~Writer (); bool can_fake_write (int) const; - void write (boost::shared_ptr, int); - void fake_write (int); + void write (boost::shared_ptr, int, Eyes); + void fake_write (int, Eyes); void write (boost::shared_ptr); - void repeat (int f); + void repeat (int f, Eyes); void finish (); private: void thread (); + void terminate_thread (bool); void check_existing_picture_mxf (); + bool check_existing_picture_mxf_frame (FILE *, int, Eyes); + bool have_sequenced_image_at_queue_head (); /** our Film */ - boost::shared_ptr _film; - boost::shared_ptr _job; + boost::shared_ptr _film; + boost::weak_ptr _job; /** the first frame index that does not already exist in our MXF */ int _first_nonexistant_frame; @@ -95,12 +120,15 @@ private: int _queued_full_in_memory; /** mutex for thread state */ mutable boost::mutex _mutex; - /** condition to manage thread wakeups */ - boost::condition _condition; + /** condition to manage thread wakeups when we have nothing to do */ + boost::condition _empty_condition; + /** condition to manage thread wakeups when we have too much to do */ + boost::condition _full_condition; /** the data of the last written frame, or 0 if there isn't one */ - boost::shared_ptr _last_written; + boost::shared_ptr _last_written[EYES_COUNT]; /** the index of the last written frame */ int _last_written_frame; + Eyes _last_written_eyes; /** maximum number of frames to hold in memory, for when we are managing ordering */ @@ -117,8 +145,8 @@ private: */ int _pushed_to_disk; - boost::shared_ptr _picture_asset; - boost::shared_ptr _picture_asset_writer; - boost::shared_ptr _sound_asset; - boost::shared_ptr _sound_asset_writer; + boost::shared_ptr _picture_mxf; + boost::shared_ptr _picture_mxf_writer; + boost::shared_ptr _sound_mxf; + boost::shared_ptr _sound_mxf_writer; };