Split up some files.
[libdcp.git] / src / picture_asset.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBDCP_PICTURE_ASSET_H
21 #define LIBDCP_PICTURE_ASSET_H
22
23 /** @file  src/picture_asset.h
24  *  @brief An asset made up of JPEG2000 data
25  */
26
27 #include <openjpeg.h>
28 #include "mxf_asset.h"
29 #include "util.h"
30 #include "metadata.h"
31
32 namespace libdcp
33 {
34
35 class MonoPictureFrame; 
36 class StereoPictureFrame;
37 class PictureAssetWriter;
38
39 /** @brief An asset made up of JPEG2000 data */
40 class PictureAsset : public MXFAsset
41 {
42 public:
43         /** Construct a PictureAsset.
44          *  
45          *  @param directory Directory where MXF file is.
46          *  @param mxf_name Name of MXF file.
47          */
48         PictureAsset (boost::filesystem::path directory, std::string mxf_name);
49
50         /** Start a progressive write to this asset.
51          *  @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
52          *  MXF file does not exist.
53          */
54         virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite) = 0;
55
56         virtual void read () = 0;
57         virtual void create (std::vector<boost::filesystem::path> const &) {}
58         virtual void create (boost::function<boost::filesystem::path (int)>) {}
59         
60         bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
61
62         Size size () const {
63                 return _size;
64         }
65
66         void set_size (Size s) {
67                 _size = s;
68         }
69
70         void write_to_cpl (xmlpp::Element *, bool) const;
71
72 protected:      
73
74         bool frame_buffer_equals (
75                 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
76                 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
77                 ) const;
78
79         /** picture size in pixels */
80         Size _size;
81
82 private:
83         std::string key_type () const;
84         virtual int edit_rate_factor () const = 0;
85 };
86         
87
88 }
89
90 #endif