Merge master.
[dcpomatic.git] / src / lib / encoded_data.h
1 /*
2     Copyright (C) 2012-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 #include <boost/noncopyable.hpp>
21 #include <boost/filesystem.hpp>
22 #include <dcp/picture_mxf_writer.h>
23 #include "types.h"
24
25 class Socket;
26 class Film;
27
28 /** @class EncodedData
29  *  @brief Container for J2K-encoded data.
30  */
31 class EncodedData : public boost::noncopyable
32 {
33 public:
34         /** @param s Size of data, in bytes */
35         EncodedData (int s);
36         EncodedData (uint8_t const * d, int s);
37
38         EncodedData (boost::filesystem::path);
39
40         virtual ~EncodedData ();
41
42         void send (boost::shared_ptr<Socket> socket);
43         void write (boost::shared_ptr<const Film>, int, Eyes) const;
44         void write_info (boost::shared_ptr<const Film>, int, Eyes, dcp::FrameInfo) const;
45
46         /** @return data */
47         uint8_t* data () const {
48                 return _data;
49         }
50
51         /** @return data size, in bytes */
52         int size () const {
53                 return _size;
54         }
55
56 protected:
57         uint8_t* _data; ///< data
58         int _size;      ///< data size in bytes
59 };
60
61 /** @class LocallyEncodedData
62  *  @brief EncodedData that was encoded locally; this class
63  *  just keeps a pointer to the data, but does no memory
64  *  management.
65  */
66 class LocallyEncodedData : public EncodedData
67 {
68 public:
69         /** @param d Data (which will be copied by this class)
70          *  @param s Size of data, in bytes.
71          */
72         LocallyEncodedData (uint8_t* d, int s);
73 };
74
75 /** @class RemotelyEncodedData
76  *  @brief EncodedData that is being read from a remote server;
77  *  this class allocates and manages memory for the data.
78  */
79 class RemotelyEncodedData : public EncodedData
80 {
81 public:
82         RemotelyEncodedData (int s);
83 };