Split EncodedData classes into their own file.
[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
37         EncodedData (boost::filesystem::path);
38
39         virtual ~EncodedData ();
40
41         void send (boost::shared_ptr<Socket> socket);
42         void write (boost::shared_ptr<const Film>, int, Eyes) const;
43         void write_info (boost::shared_ptr<const Film>, int, Eyes, dcp::FrameInfo) const;
44
45         /** @return data */
46         uint8_t* data () const {
47                 return _data;
48         }
49
50         /** @return data size, in bytes */
51         int size () const {
52                 return _size;
53         }
54
55 protected:
56         uint8_t* _data; ///< data
57         int _size;      ///< data size in bytes
58 };
59
60 /** @class LocallyEncodedData
61  *  @brief EncodedData that was encoded locally; this class
62  *  just keeps a pointer to the data, but does no memory
63  *  management.
64  */
65 class LocallyEncodedData : public EncodedData
66 {
67 public:
68         /** @param d Data (which will be copied by this class)
69          *  @param s Size of data, in bytes.
70          */
71         LocallyEncodedData (uint8_t* d, int s);
72 };
73
74 /** @class RemotelyEncodedData
75  *  @brief EncodedData that is being read from a remote server;
76  *  this class allocates and manages memory for the data.
77  */
78 class RemotelyEncodedData : public EncodedData
79 {
80 public:
81         RemotelyEncodedData (int s);
82 };