WIP: partially restore PlayerVideo transfer over network.
[dcpomatic.git] / src / lib / player_text.cc
index 16e89b0f10681d756724dd9e0cd49cf8f57aaff0..736421705b0c7bbc49f31acfa1c44c000ab10837 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 #include "player_text.h"
 #include "font.h"
+#include "util.h"
+#include "dcpomatic_socket.h"
+#include "image.h"
+#include <dcp/raw_convert.h>
+#include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
 
 using std::list;
 using boost::shared_ptr;
+using dcp::raw_convert;
+using namespace dcpomatic;
+
+void
+PlayerText::add_metadata (xmlpp::Node* node) const
+{
+       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
+               /* XXX: transferring a font file for every frame that needs it seems a bit wasteful,
+                  but probably not so bad in the great scheme of things.
+               */
+               i->transfer_xml (node->add_child("Font"));
+       }
+
+       BOOST_FOREACH (BitmapText i, bitmap) {
+               i.transfer_xml (node->add_child("Bitmap"));
+       }
+
+       BOOST_FOREACH (StringText i, string) {
+               i.transfer_xml (node->add_child("String"));
+       }
+}
+
+void
+PlayerText::send_binary (shared_ptr<Socket> socket) const
+{
+       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
+               i->transfer_binary (socket);
+       }
+
+       BOOST_FOREACH (BitmapText i, bitmap) {
+               i.transfer_binary (socket);
+       }
+}
 
 void
 PlayerText::add_fonts (list<shared_ptr<Font> > fonts_)
@@ -40,3 +78,15 @@ PlayerText::add_fonts (list<shared_ptr<Font> > fonts_)
                }
        }
 }
+
+bool
+operator== (PlayerText const & a, PlayerText const & b)
+{
+       return deep_equals(a.fonts, b.fonts) && deep_equals(a.bitmap, b.bitmap) && deep_equals(a.string, b.string);
+}
+
+bool
+operator!= (PlayerText const & a, PlayerText const & b)
+{
+       return !(a == b);
+}