Rename SafeStringStream -> locked_stringstream. Bump deps for removal of stringstream.
[dcpomatic.git] / src / lib / image_proxy.h
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_IMAGE_PROXY_H
22 #define DCPOMATIC_IMAGE_PROXY_H
23
24 /** @file  src/lib/image_proxy.h
25  *  @brief ImageProxy and subclasses.
26  */
27
28 extern "C" {
29 #include <libavutil/pixfmt.h>
30 }
31 #include <dcp/types.h>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/optional.hpp>
34 #include <boost/utility.hpp>
35
36 class Image;
37 class Socket;
38
39 namespace xmlpp {
40         class Node;
41 }
42
43 namespace cxml {
44         class Node;
45 }
46
47 /** @class ImageProxy
48  *  @brief A class which holds an Image, and can produce it on request.
49  *
50  *  This is so that decoding of source images can be postponed until
51  *  the encoder thread, where multi-threading is happening, instead
52  *  of happening in a single-threaded decoder.
53  *
54  *  For example, large TIFFs are slow to decode, so this class will keep
55  *  the TIFF data compressed until the decompressed image is needed.
56  *  At this point, the class decodes the TIFF to an Image.
57  */
58 class ImageProxy : public boost::noncopyable
59 {
60 public:
61         virtual ~ImageProxy () {}
62
63         /** @return Image (which must be aligned) */
64         virtual boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const = 0;
65         virtual void add_metadata (xmlpp::Node *) const = 0;
66         virtual void send_binary (boost::shared_ptr<Socket>) const = 0;
67         /** @return true if our image is definitely the same as another, false if it is probably not */
68         virtual bool same (boost::shared_ptr<const ImageProxy>) const = 0;
69         virtual AVPixelFormat pixel_format () const = 0;
70 };
71
72 boost::shared_ptr<ImageProxy> image_proxy_factory (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
73
74 #endif