Ignore FFmpeg warnings in a nicer way.
[dcpomatic.git] / src / lib / dcp_video.cc
index 6f32b6686dca1ac44eeeb4d8d7a575f4c1e004fe..d6b9d4f278fb20a9437cbaecbce9e860dd6f26be 100644 (file)
 #include "cross.h"
 #include "player_video.h"
 #include "compose.hpp"
+#include "warnings.h"
 #include <libcxml/cxml.h>
 #include <dcp/raw_convert.h>
 #include <dcp/openjpeg_image.h>
 #include <dcp/rgb_xyz.h>
 #include <dcp/j2k.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/asio.hpp>
 #include <boost/thread.hpp>
 #include <stdint.h>
@@ -115,12 +118,15 @@ DCPVideo::convert_to_xyz (shared_ptr<const PlayerVideo> frame, dcp::NoteHandler
 Data
 DCPVideo::encode_locally ()
 {
+       string const comment = Config::instance()->dcp_j2k_comment();
+
        Data enc = compress_j2k (
                convert_to_xyz (_frame, boost::bind(&Log::dcp_log, dcpomatic_log.get(), _1, _2)),
                _j2k_bandwidth,
                _frames_per_second,
                _frame->eyes() == EYES_LEFT || _frame->eyes() == EYES_RIGHT,
-               _resolution == RESOLUTION_4K
+               _resolution == RESOLUTION_4K,
+               comment.empty() ? "libdcp" : comment
                );
 
        switch (_frame->eyes()) {
@@ -165,23 +171,31 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout)
 
        LOG_DEBUG_ENCODE (N_("Sending frame %1 to remote"), _index);
 
-       /* Send XML metadata */
-       string xml = doc.write_to_string ("UTF-8");
-       socket->write (xml.length() + 1);
-       socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
+       {
+               Socket::WriteDigestScope ds (socket);
+
+               /* Send XML metadata */
+               string xml = doc.write_to_string ("UTF-8");
+               socket->write (xml.length() + 1);
+               socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
 
-       /* Send binary data */
-       LOG_TIMING("start-remote-send thread=%1", thread_id ());
-       _frame->send_binary (socket);
+               /* Send binary data */
+               LOG_TIMING("start-remote-send thread=%1", thread_id ());
+               _frame->write_to_socket (socket);
+       }
 
        /* Read the response (JPEG2000-encoded data); this blocks until the data
           is ready and sent back.
        */
+       Socket::ReadDigestScope ds (socket);
        LOG_TIMING("start-remote-encode thread=%1", thread_id ());
        Data e (socket->read_uint32 ());
        LOG_TIMING("start-remote-receive thread=%1", thread_id ());
        socket->read (e.data().get(), e.size());
        LOG_TIMING("finish-remote-receive thread=%1", thread_id ());
+       if (!ds.check()) {
+               throw NetworkError ("Checksums do not match");
+       }
 
        LOG_DEBUG_ENCODE (N_("Finished remotely-encoded frame %1"), _index);