Remove film player, DVD ripping, alignment, screen configs; never finished and not...
[dcpomatic.git] / src / lib / film.h
index 3eff9e3dae37cbc26e084b62d18e5494ba6ae75f..64e7a3a7072bb890e662329d2aedf116cd421d22 100644 (file)
 #include <boost/thread/mutex.hpp>
 #include <boost/thread.hpp>
 #include <boost/signals2.hpp>
+#include <boost/enable_shared_from_this.hpp>
 extern "C" {
 #include <libavcodec/avcodec.h>
 }
 #include "dcp_content_type.h"
 #include "util.h"
 #include "stream.h"
-#include "trim_action.h"
 
 class Format;
 class Job;
@@ -64,7 +64,6 @@ public:
 
        void examine_content ();
        void send_dcp_to_tms ();
-       void copy_from_dvd ();
 
        void make_dcp (bool);
 
@@ -83,11 +82,9 @@ public:
        std::string content_path () const;
        ContentType content_type () const;
        
-       bool content_is_dvd () const;
-
        std::string thumb_file (int) const;
        std::string thumb_base (int) const;
-       int thumb_frame (int) const;
+       SourceFrame thumb_frame (int) const;
 
        int target_audio_sample_rate () const;
        
@@ -95,7 +92,7 @@ public:
        void read_metadata ();
 
        Size cropped_size (Size) const;
-       boost::optional<int> dcp_length () const;
+       boost::optional<SourceFrame> dcp_length () const;
        std::string dci_name () const;
        std::string dcp_name () const;
 
@@ -105,6 +102,8 @@ public:
 
        int audio_channels () const;
 
+       void set_dci_date_today ();
+
        enum Property {
                NONE,
                NAME,
@@ -115,8 +114,8 @@ public:
                CROP,
                FILTERS,
                SCALER,
-               DCP_FRAMES,
-               DCP_TRIM_ACTION,
+               DCP_TRIM_START,
+               DCP_TRIM_END,
                DCP_AB,
                AUDIO_STREAM,
                AUDIO_GAIN,
@@ -141,7 +140,7 @@ public:
        /* GET */
 
        std::string directory () const {
-               boost::mutex::scoped_lock lm (_state_mutex);
+               boost::mutex::scoped_lock lm (_directory_mutex);
                return _directory;
        }
 
@@ -185,16 +184,16 @@ public:
                return _scaler;
        }
 
-       boost::optional<int> dcp_frames () const {
+       SourceFrame dcp_trim_start () const {
                boost::mutex::scoped_lock lm (_state_mutex);
-               return _dcp_frames;
+               return _dcp_trim_start;
        }
 
-       TrimAction dcp_trim_action () const {
+       SourceFrame dcp_trim_end () const {
                boost::mutex::scoped_lock lm (_state_mutex);
-               return _dcp_trim_action;
+               return _dcp_trim_end;
        }
-
+       
        bool dcp_ab () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _dcp_ab;
@@ -287,7 +286,7 @@ public:
                return _package_type;
        }
 
-       std::vector<int> thumbs () const {
+       std::vector<SourceFrame> thumbs () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _thumbs;
        }
@@ -297,7 +296,7 @@ public:
                return _size;
        }
 
-       boost::optional<int> length () const {
+       boost::optional<SourceFrame> length () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _length;
        }
@@ -338,7 +337,7 @@ public:
        void set_directory (std::string);
        void set_name (std::string);
        void set_use_dci_name (bool);
-       virtual void set_content (std::string);
+       void set_content (std::string);
        void set_dcp_content_type (DCPContentType const *);
        void set_format (Format const *);
        void set_crop (Crop);
@@ -348,9 +347,8 @@ public:
        void set_bottom_crop (int);
        void set_filters (std::vector<Filter const *>);
        void set_scaler (Scaler const *);
-       void set_dcp_frames (int);
-       void unset_dcp_frames ();
-       void set_dcp_trim_action (TrimAction);
+       void set_dcp_trim_start (int);
+       void set_dcp_trim_end (int);
        void set_dcp_ab (bool);
        void set_audio_stream (int);
        void set_audio_gain (float);
@@ -367,9 +365,9 @@ public:
        void set_studio (std::string);
        void set_facility (std::string);
        void set_package_type (std::string);
-       void set_thumbs (std::vector<int>);
+       void set_thumbs (std::vector<SourceFrame>);
        void set_size (Size);
-       void set_length (int);
+       void set_length (SourceFrame);
        void unset_length ();
        void set_audio_sample_rate (int);
        void set_content_digest (std::string);
@@ -389,19 +387,21 @@ private:
        /** Any running ExamineContentJob, or 0 */
        boost::shared_ptr<ExamineContentJob> _examine_content_job;
 
-       std::string thumb_file_for_frame (int) const;
-       std::string thumb_file_for_frame_locked (int) const;
-       std::string thumb_base_for_frame (int) const;
-       std::string thumb_base_for_frame_locked (int) const;
+       /** The date that we should use in a DCI name */
+       boost::gregorian::date _dci_date;
+
+       std::string thumb_file_for_frame (SourceFrame) const;
+       std::string thumb_base_for_frame (SourceFrame) const;
        void signal_changed (Property);
-       std::string file_locked (std::string) const;
-       std::string dir_locked (std::string d) const;
        void examine_content_finished ();
-       
+
        /** Complete path to directory containing the film metadata;
         *  must not be relative.
         */
        std::string _directory;
+       /** Mutex for _directory */
+       mutable boost::mutex _directory_mutex;
+       
        /** Name for DVD-o-matic */
        std::string _name;
        /** True if a auto-generated DCI-compliant name should be used for our DCP */
@@ -420,10 +420,10 @@ private:
        std::vector<Filter const *> _filters;
        /** Scaler algorithm to use */
        Scaler const * _scaler;
-       /** Maximum number of frames to put in the DCP, if applicable */
-       boost::optional<int> _dcp_frames;
-       /** What to do with audio when trimming DCPs */
-       TrimAction _dcp_trim_action;
+       /** Frames to trim off the start of the source */
+       SourceFrame _dcp_trim_start;
+       /** Frames to trim off the end of the source */
+       SourceFrame _dcp_trim_end;
        /** true to create an A/B comparison DCP, where the left half of the image
            is the video without any filters or post-processing, and the right half
            has the specified filters and post-processing.
@@ -460,11 +460,11 @@ private:
        /* Data which are cached to speed things up */
 
        /** Vector of frame indices for each of our `thumbnails' */
-       std::vector<int> _thumbs;
+       std::vector<SourceFrame> _thumbs;
        /** Size, in pixels, of the source (ignoring cropping) */
        Size _size;
        /** Actual length of the source (in video frames) from examining it */
-       boost::optional<int> _length;
+       boost::optional<SourceFrame> _length;
        /** Sample rate of the source audio, in Hz */
        int _audio_sample_rate;
        /** MD5 digest of our content file */
@@ -480,6 +480,7 @@ private:
 
        mutable bool _dirty;
 
+       /** Mutex for all state except _directory */
        mutable boost::mutex _state_mutex;
 
        friend class paths_test;