Rename EncodedData -> Data and trim it a bit.
authorCarl Hetherington <cth@carlh.net>
Wed, 10 Jun 2015 13:04:10 +0000 (14:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 10 Jun 2015 13:04:10 +0000 (14:04 +0100)
18 files changed:
src/lib/data.cc [new file with mode: 0644]
src/lib/data.h [new file with mode: 0644]
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/lib/encoded_data.cc [deleted file]
src/lib/encoded_data.h [deleted file]
src/lib/encoder.cc
src/lib/encoder.h
src/lib/j2k_image_proxy.cc
src/lib/j2k_image_proxy.h
src/lib/player_video.cc
src/lib/player_video.h
src/lib/server.cc
src/lib/writer.cc
src/lib/writer.h
src/lib/wscript
src/tools/server_test.cc
test/client_server_test.cc

diff --git a/src/lib/data.cc b/src/lib/data.cc
new file mode 100644 (file)
index 0000000..e117199
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+    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 "data.h"
+#include "cross.h"
+#include "exceptions.h"
+
+#include "i18n.h"
+
+using boost::shared_array;
+
+Data::Data (int size)
+       : _data (new uint8_t[size])
+       , _size (size)
+{
+
+}
+
+Data::Data (uint8_t const * data, int size)
+       : _data (new uint8_t[size])
+       , _size (size)
+{
+       memcpy (_data.get(), data, size);
+}
+
+Data::Data (boost::filesystem::path file)
+{
+       _size = boost::filesystem::file_size (file);
+       _data.reset (new uint8_t[_size]);
+
+       FILE* f = fopen_boost (file, "rb");
+       if (!f) {
+               throw FileError (_("could not open file for reading"), file);
+       }
+       
+       size_t const r = fread (_data.get(), 1, _size, f);
+       if (r != size_t (_size)) {
+               fclose (f);
+               throw FileError (_("could not read from file"), file);
+       }
+               
+       fclose (f);
+}
+
+void
+Data::write (boost::filesystem::path file) const
+{
+       FILE* f = fopen_boost (file, "wb");
+       if (!f) {
+               throw WriteFileError (file, errno);
+       }
+       size_t const r = fwrite (_data.get(), 1, _size, f);
+       if (r != size_t (_size)) {
+               fclose (f);
+               throw FileError ("could not write to file", file);
+       }
+       fclose (f);
+}
+
+void
+Data::write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const
+{
+       write (temp);
+       boost::filesystem::rename (temp, final);
+}
diff --git a/src/lib/data.h b/src/lib/data.h
new file mode 100644 (file)
index 0000000..84ff667
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    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 <boost/shared_array.hpp>
+#include <boost/filesystem.hpp>
+#include <stdint.h>
+
+class Data
+{
+public:
+       Data (int size);
+       Data (uint8_t const * data, int size);
+       Data (boost::filesystem::path file);
+
+       virtual ~Data () {}
+
+       void write (boost::filesystem::path file) const;
+       void write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const;
+
+       boost::shared_array<uint8_t> data () const {
+               return _data;
+       }
+
+       int size () const {
+               return _size;
+       }
+
+private:
+       boost::shared_array<uint8_t> _data;
+       int _size;
+};
index f2d765f7d68ef61e3a53c0d09f4fa539e0e980b1..af614a10f2d12d6322033211387566466a843fa6 100644 (file)
@@ -38,7 +38,7 @@
 #include "cross.h"
 #include "player_video.h"
 #include "raw_convert.h"
-#include "encoded_data.h"
+#include "data.h"
 #include <libcxml/cxml.h>
 #include <dcp/xyz_image.h>
 #include <dcp/rgb_xyz.h>
@@ -104,7 +104,7 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::
 /** J2K-encode this frame on the local host.
  *  @return Encoded data.
  */
-shared_ptr<EncodedData>
+shared_ptr<Data>
 DCPVideo::encode_locally (dcp::NoteHandler note)
 {
        shared_ptr<dcp::XYZImage> xyz;
@@ -236,7 +236,7 @@ DCPVideo::encode_locally (dcp::NoteHandler note)
                break;
        }
 
-       shared_ptr<EncodedData> enc (new LocallyEncodedData (cio->buffer, cio_tell (cio)));
+       shared_ptr<Data> enc (new Data (cio->buffer, cio_tell (cio)));
 
        opj_cio_close (cio);
        free (parameters.cp_comment);
@@ -249,7 +249,7 @@ DCPVideo::encode_locally (dcp::NoteHandler note)
  *  @param serv Server to send to.
  *  @return Encoded data.
  */
-shared_ptr<EncodedData>
+shared_ptr<Data>
 DCPVideo::encode_remotely (ServerDescription serv)
 {
        boost::asio::io_service io_service;
@@ -280,8 +280,8 @@ DCPVideo::encode_remotely (ServerDescription serv)
        /* Read the response (JPEG2000-encoded data); this blocks until the data
           is ready and sent back.
        */
-       shared_ptr<EncodedData> e (new RemotelyEncodedData (socket->read_uint32 ()));
-       socket->read (e->data(), e->size());
+       shared_ptr<Data> e (new Data (socket->read_uint32 ()));
+       socket->read (e->data().get(), e->size());
 
        LOG_GENERAL (N_("Finished remotely-encoded frame %1"), _index);
        
index 125e2c8186ccef960fd45eac476454656bdf4efe..37d95826c5103a7c4fc283fb26250cee5a71ffb8 100644 (file)
@@ -32,7 +32,7 @@ class Image;
 class Log;
 class Subtitle;
 class PlayerVideo;
-class EncodedData;
+class Data;
 
 /** @class DCPVideo
  *  @brief A single frame of video destined for a DCP.
@@ -49,8 +49,8 @@ public:
        DCPVideo (boost::shared_ptr<const PlayerVideo>, int, int, int, Resolution, bool b, boost::shared_ptr<Log>);
        DCPVideo (boost::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr, boost::shared_ptr<Log>);
 
-       boost::shared_ptr<EncodedData> encode_locally (dcp::NoteHandler note);
-       boost::shared_ptr<EncodedData> encode_remotely (ServerDescription);
+       boost::shared_ptr<Data> encode_locally (dcp::NoteHandler note);
+       boost::shared_ptr<Data> encode_remotely (ServerDescription);
 
        int index () const {
                return _index;
diff --git a/src/lib/encoded_data.cc b/src/lib/encoded_data.cc
deleted file mode 100644 (file)
index 4f8aaab..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-    Copyright (C) 2012-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 "encoded_data.h"
-#include "cross.h"
-#include "exceptions.h"
-#include "film.h"
-#include "dcpomatic_socket.h"
-
-#include "i18n.h"
-
-using boost::shared_ptr;
-
-EncodedData::EncodedData (int s)
-       : _data (new uint8_t[s])
-       , _size (s)
-{
-
-}
-
-EncodedData::EncodedData (uint8_t const * d, int s)
-       : _data (new uint8_t[s])
-       , _size (s)
-{
-       memcpy (_data, d, s);
-}
-
-EncodedData::EncodedData (boost::filesystem::path file)
-{
-       _size = boost::filesystem::file_size (file);
-       _data = new uint8_t[_size];
-
-       FILE* f = fopen_boost (file, "rb");
-       if (!f) {
-               throw FileError (_("could not open file for reading"), file);
-       }
-       
-       size_t const r = fread (_data, 1, _size, f);
-       if (r != size_t (_size)) {
-               fclose (f);
-               throw FileError (_("could not read encoded data"), file);
-       }
-               
-       fclose (f);
-}
-
-
-EncodedData::~EncodedData ()
-{
-       delete[] _data;
-}
-
-/** Write this data to a J2K file.
- *  @param Film Film.
- *  @param frame DCP frame index.
- */
-void
-EncodedData::write (shared_ptr<const Film> film, int frame, Eyes eyes) const
-{
-       boost::filesystem::path const tmp_j2c = film->j2c_path (frame, eyes, true);
-
-       FILE* f = fopen_boost (tmp_j2c, "wb");
-       
-       if (!f) {
-               throw WriteFileError (tmp_j2c, errno);
-       }
-
-       fwrite (_data, 1, _size, f);
-       fclose (f);
-
-       boost::filesystem::path const real_j2c = film->j2c_path (frame, eyes, false);
-
-       /* Rename the file from foo.j2c.tmp to foo.j2c now that it is complete */
-       boost::filesystem::rename (tmp_j2c, real_j2c);
-}
-
-void
-EncodedData::write_info (shared_ptr<const Film> film, int frame, Eyes eyes, dcp::FrameInfo info) const
-{
-       FILE* file = fopen_boost (film->info_file(), "ab");
-       if (!file) {
-               throw OpenFileError (film->info_file ());
-       }
-       write_frame_info (file, frame, eyes, info);
-       fclose (file);
-}
-
-/** Send this data to a socket.
- *  @param socket Socket
- */
-void
-EncodedData::send (shared_ptr<Socket> socket)
-{
-       socket->write (_size);
-       socket->write (_data, _size);
-}
-
-LocallyEncodedData::LocallyEncodedData (uint8_t* d, int s)
-       : EncodedData (s)
-{
-       memcpy (_data, d, s);
-}
-
-/** @param s Size of data in bytes */
-RemotelyEncodedData::RemotelyEncodedData (int s)
-       : EncodedData (s)
-{
-
-}
diff --git a/src/lib/encoded_data.h b/src/lib/encoded_data.h
deleted file mode 100644 (file)
index 368f267..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-    Copyright (C) 2012-2014 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 "types.h"
-#include <dcp/picture_asset_writer.h>
-#include <boost/noncopyable.hpp>
-#include <boost/filesystem.hpp>
-
-class Socket;
-class Film;
-
-/** @class EncodedData
- *  @brief Container for J2K-encoded data.
- */
-class EncodedData : public boost::noncopyable
-{
-public:
-       /** @param s Size of data, in bytes */
-       EncodedData (int s);
-       EncodedData (uint8_t const * d, int s);
-
-       EncodedData (boost::filesystem::path);
-
-       virtual ~EncodedData ();
-
-       void send (boost::shared_ptr<Socket> socket);
-       void write (boost::shared_ptr<const Film>, int, Eyes) const;
-       void write_info (boost::shared_ptr<const Film>, int, Eyes, dcp::FrameInfo) const;
-
-       /** @return data */
-       uint8_t* data () const {
-               return _data;
-       }
-
-       /** @return data size, in bytes */
-       int size () const {
-               return _size;
-       }
-
-protected:
-       uint8_t* _data; ///< data
-       int _size;      ///< data size in bytes
-};
-
-/** @class LocallyEncodedData
- *  @brief EncodedData that was encoded locally; this class
- *  just keeps a pointer to the data, but does no memory
- *  management.
- */
-class LocallyEncodedData : public EncodedData
-{
-public:
-       /** @param d Data (which will be copied by this class)
-        *  @param s Size of data, in bytes.
-        */
-       LocallyEncodedData (uint8_t* d, int s);
-};
-
-/** @class RemotelyEncodedData
- *  @brief EncodedData that is being read from a remote server;
- *  this class allocates and manages memory for the data.
- */
-class RemotelyEncodedData : public EncodedData
-{
-public:
-       RemotelyEncodedData (int s);
-};
index 7a0295e4c52dc9a85e7d20980cd7fa6840eb7eab..c6cb8b9dfdd72f651b052d6ff96d6a90651b36be 100644 (file)
@@ -279,7 +279,7 @@ try
        */
        int remote_backoff = 0;
        shared_ptr<DCPVideo> last_dcp_video;
-       shared_ptr<EncodedData> last_encoded;
+       shared_ptr<Data> last_encoded;
        
        while (true) {
 
@@ -300,7 +300,7 @@ try
                
                lock.unlock ();
 
-               shared_ptr<EncodedData> encoded;
+               shared_ptr<Data> encoded;
 
                if (last_dcp_video && vf->same (last_dcp_video)) {
                        /* We already have encoded data for the same input as this one, so take a short-cut */
index a4fe558740de69b8673de52027137120e3d06d58..3b8c233bb82710e619f20c1f6609aa9fb44d487e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-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
@@ -45,10 +45,8 @@ class AudioBuffers;
 class Film;
 class ServerDescription;
 class DCPVideo;
-class EncodedData;
 class Writer;
 class Job;
-class ServerFinder;
 class PlayerVideo;
 
 /** @class Encoder
index 59106098a8351a1634f3e2023816856b9137a681..3fc6ce9b252e50cd7c951069bc04dbe967fca7db 100644 (file)
@@ -20,7 +20,7 @@
 #include "j2k_image_proxy.h"
 #include "dcpomatic_socket.h"
 #include "image.h"
-#include "encoded_data.h"
+#include "data.h"
 #include "raw_convert.h"
 #include <dcp/mono_picture_frame.h>
 #include <dcp/stereo_picture_frame.h>
@@ -116,16 +116,16 @@ J2KImageProxy::send_binary (shared_ptr<Socket> socket) const
        }
 }
 
-shared_ptr<EncodedData>
+shared_ptr<Data>
 J2KImageProxy::j2k () const
 {
        if (_mono) {
-               return shared_ptr<EncodedData> (new EncodedData (_mono->j2k_data(), _mono->j2k_size()));
+               return shared_ptr<Data> (new Data (_mono->j2k_data(), _mono->j2k_size()));
        } else {
                if (_eye.get() == dcp::EYE_LEFT) {
-                       return shared_ptr<EncodedData> (new EncodedData (_stereo->left_j2k_data(), _stereo->left_j2k_size()));
+                       return shared_ptr<Data> (new Data (_stereo->left_j2k_data(), _stereo->left_j2k_size()));
                } else {
-                       return shared_ptr<EncodedData> (new EncodedData (_stereo->right_j2k_data(), _stereo->right_j2k_size()));
+                       return shared_ptr<Data> (new Data (_stereo->right_j2k_data(), _stereo->right_j2k_size()));
                }
        }
 }
index 67609dfce082d362dc25ed8d0099e3741644b80e..1392f66b9cd9b33620c73c5f78c164a66a245a2d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    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
@@ -20,7 +20,7 @@
 #include "image_proxy.h"
 #include <dcp/util.h>
 
-class EncodedData;
+class Data;
 
 class J2KImageProxy : public ImageProxy
 {
@@ -34,7 +34,7 @@ public:
        void add_metadata (xmlpp::Node *) const;
        void send_binary (boost::shared_ptr<Socket>) const;
 
-       boost::shared_ptr<EncodedData> j2k () const;
+       boost::shared_ptr<Data> j2k () const;
        dcp::Size size () const {
                return _size;
        }
index 0375fa01bbb726a80b43b53ef6c7d4c714ee2714..4faed9da394017b21545629c01d730027bb3dda6 100644 (file)
@@ -177,7 +177,7 @@ PlayerVideo::has_j2k () const
        return _crop == Crop () && _inter_size == j2k->size();
 }
 
-shared_ptr<EncodedData>
+shared_ptr<Data>
 PlayerVideo::j2k () const
 {
        shared_ptr<const J2KImageProxy> j2k = dynamic_pointer_cast<const J2KImageProxy> (_in);
index c4537f713432907376756669fff488d813152b8f..3abca82675ad46b2ac74dbcb6ecf696e072a999b 100644 (file)
@@ -29,7 +29,7 @@ extern "C" {
 class Image;
 class ImageProxy;
 class Socket;
-class EncodedData;
+class Data;
 
 /** Everything needed to describe a video frame coming out of the player, but with the
  *  bits still their raw form.  We may want to combine the bits on a remote machine,
@@ -60,7 +60,7 @@ public:
        void send_binary (boost::shared_ptr<Socket> socket, bool send_subtitles) const;
 
        bool has_j2k () const;
-       boost::shared_ptr<EncodedData> j2k () const;
+       boost::shared_ptr<Data> j2k () const;
 
        DCPTime time () const {
                return _time;
index 50ac4e786b6258a16f366a77dbfb4eaff674c82e..6dc79ec653e362de65c6d78f13eea7f500578018 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "cross.h"
 #include "player_video.h"
-#include "encoded_data.h"
+#include "data.h"
 #include "safe_stringstream.h"
 #include "raw_convert.h"
 #include <libcxml/cxml.h>
@@ -119,12 +119,13 @@ Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct t
 
        gettimeofday (&after_read, 0);
        
-       shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally (boost::bind (&Log::dcp_log, _log.get(), _1, _2));
+       shared_ptr<Data> encoded = dcp_video_frame.encode_locally (boost::bind (&Log::dcp_log, _log.get(), _1, _2));
 
        gettimeofday (&after_encode, 0);
        
        try {
-               encoded->send (socket);
+               socket->write (encoded->size ());
+               socket->write (encoded->data ().get (), encoded->size ());
        } catch (std::exception& e) {
                cerr << "Send failed; frame " << dcp_video_frame.index() << "\n";
                LOG_ERROR ("Send failed; frame %1", dcp_video_frame.index());
index 97b8eefbe08db89db49a417752ea8356c72c292d..a0a57e0bbd84a66a506ba547757f9c6edc9e8e27 100644 (file)
@@ -30,7 +30,7 @@
 #include "cross.h"
 #include "audio_buffers.h"
 #include "md5_digester.h"
-#include "encoded_data.h"
+#include "data.h"
 #include "version.h"
 #include "font.h"
 #include "util.h"
@@ -158,7 +158,7 @@ Writer::~Writer ()
 }
 
 void
-Writer::write (shared_ptr<const EncodedData> encoded, int frame, Eyes eyes)
+Writer::write (shared_ptr<const Data> encoded, int frame, Eyes eyes)
 {
        boost::mutex::scoped_lock lock (_mutex);
 
@@ -328,11 +328,16 @@ try
                        {
                                LOG_GENERAL (N_("Writer FULL-writes %1 (%2)"), qi.frame, qi.eyes);
                                if (!qi.encoded) {
-                                       qi.encoded.reset (new EncodedData (_film->j2c_path (qi.frame, qi.eyes, false)));
+                                       qi.encoded.reset (new Data (_film->j2c_path (qi.frame, qi.eyes, false)));
                                }
 
-                               dcp::FrameInfo fin = _picture_asset_writer->write (qi.encoded->data(), qi.encoded->size());
-                               qi.encoded->write_info (_film, qi.frame, qi.eyes, fin);
+                               dcp::FrameInfo fin = _picture_asset_writer->write (qi.encoded->data().get (), qi.encoded->size());
+                               FILE* file = fopen_boost (_film->info_file(), "ab");
+                               if (!file) {
+                                       throw OpenFileError (_film->info_file ());
+                               }
+                               write_frame_info (file, qi.frame, qi.eyes, fin);
+                               fclose (file);
                                _last_written[qi.eyes] = qi.encoded;
                                ++_full_written;
                                break;
@@ -390,8 +395,8 @@ try
                                _last_written_frame + 1,
                                _last_written_eyes, i->frame
                                );
-                       
-                       i->encoded->write (_film, i->frame, i->eyes);
+
+                       i->encoded->write_via_temp (_film->j2c_path (i->frame, i->eyes, true), _film->j2c_path (i->frame, i->eyes, false));
                        
                        lock.lock ();
                        i->encoded.reset ();
@@ -596,15 +601,15 @@ Writer::check_existing_picture_asset_frame (FILE* asset, int f, Eyes eyes)
        
        /* Read the data from the asset and hash it */
        dcpomatic_fseek (asset, info.offset, SEEK_SET);
-       EncodedData data (info.size);
-       size_t const read = fread (data.data(), 1, data.size(), asset);
+       Data data (info.size);
+       size_t const read = fread (data.data().get(), 1, data.size(), asset);
        if (read != static_cast<size_t> (data.size ())) {
                LOG_GENERAL ("Existing frame %1 is incomplete", f);
                return false;
        }
 
        MD5Digester digester;
-       digester.add (data.data(), data.size());
+       digester.add (data.data().get(), data.size());
        if (digester.get() != info.hash) {
                LOG_GENERAL ("Existing frame %1 failed hash check", f);
                return false;
index a176eb191f99209112cc6c46c3703cc9a1afe26d..bc274d2b869c150ebeb6076befc88f5a560c47a3 100644 (file)
@@ -31,7 +31,7 @@
 #include <list>
 
 class Film;
-class EncodedData;
+class Data;
 class AudioBuffers;
 class Job;
 class Font;
@@ -62,7 +62,7 @@ public:
        } type;
 
        /** encoded data for FULL */
-       boost::shared_ptr<const EncodedData> encoded;
+       boost::shared_ptr<const Data> encoded;
        /** size of data for FAKE */
        int size;
        /** frame index */
@@ -76,11 +76,11 @@ bool operator== (QueueItem const & a, QueueItem const & b);
 /** @class Writer
  *  @brief Class to manage writing JPEG2000 and audio data to assets on disk.
  *
- *  This class creates sound and picture assets, then takes EncodedData
+ *  This class creates sound and picture assets, then takes Data
  *  or AudioBuffers objects (containing image or sound data respectively)
  *  and writes them to the assets.
  *
- *  ::write() for EncodedData can be called out of order, and the Writer
+ *  ::write() for Data can be called out of order, and the Writer
  *  will sort it out.  write() for AudioBuffers must be called in order.
  */
 
@@ -92,7 +92,7 @@ public:
 
        bool can_fake_write (int) const;
        
-       void write (boost::shared_ptr<const EncodedData>, int, Eyes);
+       void write (boost::shared_ptr<const Data>, int, Eyes);
        void fake_write (int, Eyes);
        void write (boost::shared_ptr<const AudioBuffers>);
        void write (PlayerSubtitles subs);
@@ -131,7 +131,7 @@ private:
        /** condition to manage thread wakeups when we have too much to do */
        boost::condition _full_condition;
        /** the data of the last written frame, or 0 if there isn't one */
-       boost::shared_ptr<const EncodedData> _last_written[EYES_COUNT];
+       boost::shared_ptr<const Data> _last_written[EYES_COUNT];
        /** the index of the last written frame */
        int _last_written_frame;
        Eyes _last_written_eyes;
index 258ad96a0818fe7eb2850a55dc12db50cfa6d338..85cbcb7b6a20476305c09497ff7ce26b33676d56 100644 (file)
@@ -38,6 +38,7 @@ sources = """
           content_factory.cc
           content_subtitle.cc
           cross.cc
+          data.cc
           dcp_content.cc
           dcp_content_type.cc
           dcp_decoder.cc
@@ -50,7 +51,6 @@ sources = """
           dcpomatic_time.cc
           dolby_cp750.cc
           encoder.cc
-          encoded_data.cc
           environment_info.cc
           examine_content_job.cc
           exceptions.cc
index f27e25fde3dab9ac53d19409a89dd0163970abfe..62cc9a7b275ebe04e9308b1b4915e656c25c15d7 100644 (file)
@@ -33,7 +33,7 @@
 #include "lib/video_decoder.h"
 #include "lib/player.h"
 #include "lib/player_video.h"
-#include "lib/encoded_data.h"
+#include "lib/data.h"
 
 using std::cout;
 using std::cerr;
@@ -57,8 +57,8 @@ process_video (shared_ptr<PlayerVideo> pvf)
 
        ++frame_count;
 
-       shared_ptr<EncodedData> local_encoded = local->encode_locally (boost::bind (&Log::dcp_log, log_.get(), _1, _2));
-       shared_ptr<EncodedData> remote_encoded;
+       shared_ptr<Data> local_encoded = local->encode_locally (boost::bind (&Log::dcp_log, log_.get(), _1, _2));
+       shared_ptr<Data> remote_encoded;
 
        string remote_error;
        try {
@@ -77,8 +77,8 @@ process_video (shared_ptr<PlayerVideo> pvf)
                return;
        }
                
-       uint8_t* p = local_encoded->data();
-       uint8_t* q = remote_encoded->data();
+       uint8_t* p = local_encoded->data().get ();
+       uint8_t* q = remote_encoded->data().get ();
        for (int i = 0; i < local_encoded->size(); ++i) {
                if (*p++ != *q++) {
                        cout << "\033[0;31mdata differ\033[0m at byte " << i << "\n";
index 9ad36138746e54877cf697608a889d9f8ffdc16a..396e6609f3a3d37b263b954140dcfd20e285cc32 100644 (file)
@@ -33,7 +33,7 @@
 #include "lib/dcp_video.h"
 #include "lib/player_video.h"
 #include "lib/raw_image_proxy.h"
-#include "lib/encoded_data.h"
+#include "lib/data.h"
 
 using std::list;
 using boost::shared_ptr;
@@ -41,14 +41,14 @@ using boost::thread;
 using boost::optional;
 
 void
-do_remote_encode (shared_ptr<DCPVideo> frame, ServerDescription description, shared_ptr<EncodedData> locally_encoded)
+do_remote_encode (shared_ptr<DCPVideo> frame, ServerDescription description, shared_ptr<Data> locally_encoded)
 {
-       shared_ptr<EncodedData> remotely_encoded;
+       shared_ptr<Data> remotely_encoded;
        BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
        BOOST_CHECK (remotely_encoded);
        
        BOOST_CHECK_EQUAL (locally_encoded->size(), remotely_encoded->size());
-       BOOST_CHECK_EQUAL (memcmp (locally_encoded->data(), remotely_encoded->data(), locally_encoded->size()), 0);
+       BOOST_CHECK_EQUAL (memcmp (locally_encoded->data().get(), remotely_encoded->data().get(), locally_encoded->size()), 0);
 }
 
 BOOST_AUTO_TEST_CASE (client_server_test_rgb)
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                        )
                );
 
-       shared_ptr<EncodedData> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
+       shared_ptr<Data> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
        BOOST_ASSERT (locally_encoded);
        
        Server* server = new Server (log, true);
@@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                        )
                );
 
-       shared_ptr<EncodedData> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
+       shared_ptr<Data> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
        BOOST_ASSERT (locally_encoded);
        
        Server* server = new Server (log, true);