summaryrefslogtreecommitdiff
path: root/src/lib/font.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-13 00:19:41 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-13 00:19:41 +0100
commit9979e28b2511c15982ca8d083947eedf513b14f3 (patch)
tree1775e3c6fabe4b089d864b1389b6e2b38164c51b /src/lib/font.cc
parentbbee721034df747169f7d75ef142e57a8a8ed646 (diff)
WIP: partially restore PlayerVideo transfer over network.faster-subtitle-moving
Diffstat (limited to 'src/lib/font.cc')
-rw-r--r--src/lib/font.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/lib/font.cc b/src/lib/font.cc
index 019c9ab07..c817d3610 100644
--- a/src/lib/font.cc
+++ b/src/lib/font.cc
@@ -20,10 +20,15 @@
#include "font.h"
#include "dcpomatic_assert.h"
+#include "dcpomatic_socket.h"
+#include <dcp/data.h>
+#include <dcp/raw_convert.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
using std::string;
+using boost::shared_ptr;
+using dcp::raw_convert;
using namespace dcpomatic;
Font::Font (cxml::NodePtr node)
@@ -38,7 +43,7 @@ Font::Font (cxml::NodePtr node)
}
void
-Font::as_xml (xmlpp::Node* node)
+Font::as_xml (xmlpp::Node* node) const
{
node->add_child("Id")->add_child_text (_id);
if (_file) {
@@ -46,6 +51,27 @@ Font::as_xml (xmlpp::Node* node)
}
}
+/** Add things to an XML node to describe this font for transfer across
+ * a network to another machine. The companion method send_binary() will be called
+ * to send binary parts.
+ */
+void
+Font::transfer_xml (xmlpp::Node* node) const
+{
+ node->add_child("Id")->add_child_text (_id);
+ if (_file) {
+ node->add_child("FileLength")->add_child_text(raw_convert<string>(boost::filesystem::file_size(*_file)));
+ }
+}
+
+void
+Font::transfer_binary (shared_ptr<Socket> socket) const
+{
+ if (_file) {
+ dcp::Data data (*_file);
+ socket->write (data.data().get(), data.size());
+ }
+}
bool
dcpomatic::operator== (Font const & a, Font const & b)