summaryrefslogtreecommitdiff
path: root/src/lib/j2k_image_proxy.h
blob: 1d34e7f84e1a218ebc40b052e78a1b6b1cb1feb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
    Copyright (C) 2015 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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "image_proxy.h"
#include "data.h"
#include <dcp/util.h>

namespace dcp {
	class MonoPictureFrame;
	class StereoPictureFrame;
}

class Data;

class J2KImageProxy : public ImageProxy
{
public:
	J2KImageProxy (boost::filesystem::path path, dcp::Size);
	J2KImageProxy (boost::shared_ptr<const dcp::MonoPictureFrame> frame, dcp::Size);
	J2KImageProxy (boost::shared_ptr<const dcp::StereoPictureFrame> frame, dcp::Size, dcp::Eye);
	J2KImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);

	boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
	void add_metadata (xmlpp::Node *) const;
	void send_binary (boost::shared_ptr<Socket>) const;
	/** @return true if our image is definitely the same as another, false if it is probably not */
	bool same (boost::shared_ptr<const ImageProxy>) const;
	AVPixelFormat pixel_format () const;

	Data j2k () const {
		return _data;
	}

	dcp::Size size () const {
		return _size;
	}

private:
	friend struct client_server_test_j2k;

	/* For tests */
	J2KImageProxy (Data data, dcp::Size size);
	void ensure_j2k () const;

	Data _data;
	dcp::Size _size;
	boost::optional<dcp::Eye> _eye;
	mutable boost::shared_ptr<dcp::OpenJPEGImage> _j2k;
};