def4878e3e1e5d6f52d16d29ec0f101e3c8c22f2
[dcpomatic.git] / src / lib / image_proxy.h
1 /*
2     Copyright (C) 2014 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 DCPOMATIC_IMAGE_PROXY_H
21 #define DCPOMATIC_IMAGE_PROXY_H
22
23 /** @file  src/lib/image_proxy.h
24  *  @brief ImageProxy and subclasses.
25  */
26
27 extern "C" {
28 #include <libavutil/pixfmt.h>
29 }
30 #include <dcp/types.h>
31 #include <boost/shared_ptr.hpp>
32 #include <boost/optional.hpp>
33 #include <boost/utility.hpp>
34
35 class Image;
36 class Socket;
37
38 namespace xmlpp {
39         class Node;
40 }
41
42 namespace cxml {
43         class Node;
44 }
45
46 /** @class ImageProxy
47  *  @brief A class which holds an Image, and can produce it on request.
48  *
49  *  This is so that decoding of source images can be postponed until
50  *  the encoder thread, where multi-threading is happening, instead
51  *  of happening in a single-threaded decoder.
52  *
53  *  For example, large TIFFs are slow to decode, so this class will keep
54  *  the TIFF data compressed until the decompressed image is needed.
55  *  At this point, the class decodes the TIFF to an Image.
56  */
57 class ImageProxy : public boost::noncopyable
58 {
59 public:
60         virtual ~ImageProxy () {}
61
62         /** @return Image (which must be aligned) */
63         virtual boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const = 0;
64         virtual void add_metadata (xmlpp::Node *) const = 0;
65         virtual void send_binary (boost::shared_ptr<Socket>) const = 0;
66         /** @return true if our image is definitely the same as another, false if it is probably not */
67         virtual bool same (boost::shared_ptr<const ImageProxy>) const = 0;
68         virtual AVPixelFormat pixel_format () const = 0;
69 };
70
71 boost::shared_ptr<ImageProxy> image_proxy_factory (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
72
73 #endif