2 Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 #include "raw_image_proxy.h"
23 #include <dcp/raw_convert.h>
25 #include <libcxml/cxml.h>
27 #include <libavutil/pixfmt.h>
29 #include <libxml++/libxml++.h>
36 using boost::shared_ptr;
37 using boost::dynamic_pointer_cast;
38 using boost::optional;
39 using dcp::raw_convert;
41 RawImageProxy::RawImageProxy (shared_ptr<Image> image)
47 RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket)
50 xml->number_child<int> ("Width"), xml->number_child<int> ("Height")
53 _image.reset (new Image (static_cast<AVPixelFormat> (xml->number_child<int> ("PixelFormat")), size, true));
54 _image->read_from_socket (socket);
57 pair<shared_ptr<Image>, int>
58 RawImageProxy::image (optional<dcp::Size>) const
60 return make_pair (_image, 0);
64 RawImageProxy::add_metadata (xmlpp::Node* node) const
66 node->add_child("Type")->add_child_text (N_("Raw"));
67 node->add_child("Width")->add_child_text (raw_convert<string> (_image->size().width));
68 node->add_child("Height")->add_child_text (raw_convert<string> (_image->size().height));
69 node->add_child("PixelFormat")->add_child_text (raw_convert<string> (static_cast<int> (_image->pixel_format ())));
73 RawImageProxy::send_binary (shared_ptr<Socket> socket) const
75 _image->write_to_socket (socket);
79 RawImageProxy::same (shared_ptr<const ImageProxy> other) const
81 shared_ptr<const RawImageProxy> rp = dynamic_pointer_cast<const RawImageProxy> (other);
86 return (*_image.get()) == (*rp->image().first.get());
90 RawImageProxy::memory_used () const
92 return _image->memory_used ();