Various attempts to clean up DCP comparison code.
[libdcp.git] / src / picture_mxf.h
index 1966ee8e7c133f98909905dac1e36d1dbf2896c5..bf8fcf763f5a0824055e2ff32d89a7c3a16bd203 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 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
 #ifndef LIBDCP_PICTURE_MXF_H
 #define LIBDCP_PICTURE_MXF_H
 
-/** @file  src/picture_asset.h
- *  @brief An asset made up of JPEG2000 data
+/** @file  src/picture_mxf.h
+ *  @brief PictureMXF class.
  */
 
-#include <openjpeg.h>
 #include "mxf.h"
 #include "util.h"
 #include "metadata.h"
+#include <openjpeg.h>
 
 namespace ASDCP {
        namespace JP2K {
-               class PictureDescriptor;
+               struct PictureDescriptor;
        }
 }
 
@@ -42,32 +42,21 @@ class MonoPictureFrame;
 class StereoPictureFrame;
 class PictureMXFWriter;
 
-/** @brief An asset made up of JPEG2000 data */
+/** @class PictureMXF
+ *  @brief An asset made up of JPEG2000 data.
+ */
 class PictureMXF : public MXF
 {
 public:
-       /** Construct a PictureAsset.
-        *  
-        *  @param directory Directory where MXF file is.
-        *  @param mxf_name Name of MXF file.
-        */
-       PictureMXF (boost::filesystem::path directory, boost::filesystem::path mxf_name);
-
-       /** Start a progressive write to this asset.
-        *  The following parameters must be set up (if required) before calling this:
-        *      Interop mode (set_interop)
-        *      Edit rate    (set_edit_rate)
-        *      MXF Metadata (set_metadata)
-        *      
-        *  @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
-        *  MXF file does not exist.
-        */
-       virtual boost::shared_ptr<PictureMXFWriter> start_write (bool overwrite) = 0;
-
-       virtual void read () = 0;
-       virtual void create (std::vector<boost::filesystem::path> const &) {}
-       virtual void create (boost::function<boost::filesystem::path (int)>) {}
-       
+       PictureMXF (boost::filesystem::path file);
+       PictureMXF (Fraction edit_rate);
+
+       virtual boost::shared_ptr<PictureMXFWriter> start_write (
+               boost::filesystem::path file,
+               Standard standard,
+               bool overwrite
+               ) = 0;
+
        Size size () const {
                return _size;
        }
@@ -76,9 +65,23 @@ public:
                _size = s;
        }
 
-       void write_to_cpl (xmlpp::Element *) const;
+       Fraction frame_rate () const {
+               return _frame_rate;
+       }
 
-protected:     
+       void set_frame_rate (Fraction r) {
+               _frame_rate = r;
+       }
+
+       Fraction screen_aspect_ratio () const {
+               return _screen_aspect_ratio;
+       }
+
+       void set_screen_aspect_ratio (Fraction r) {
+               _screen_aspect_ratio = r;
+       }
+
+protected:
 
        bool frame_buffer_equals (
                int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
@@ -86,15 +89,22 @@ protected:
                ) const;
 
        bool descriptor_equals (
-               ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function<void (NoteType, std::string)>
+               ASDCP::JP2K::PictureDescriptor const & a,
+               ASDCP::JP2K::PictureDescriptor const & b,
+               boost::function<void (NoteType, std::string)>
                ) const;
 
+       void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &);
+
        /** picture size in pixels */
        Size _size;
+       Fraction _frame_rate;
+       Fraction _screen_aspect_ratio;
 
 private:
-       std::string key_type () const;
-       virtual int edit_rate_factor () const = 0;
+       std::string asdcp_kind () const {
+               return "Picture";
+       }
 };