#include "bitmap_text.h"
#include "image.h"
+#include "dcpomatic_socket.h"
+#include <dcp/raw_convert.h>
+
+using boost::shared_ptr;
+using dcp::raw_convert;
bool
operator== (BitmapText const & a, BitmapText const & b)
return !(a == b);
}
+void
+BitmapText::transfer_xml (xmlpp::Node* node) const
+{
+ node->add_child("Width")->add_child_text(raw_convert<std::string>(image->size().width));
+ node->add_child("Height")->add_child_text(raw_convert<std::string>(image->size().height));
+ node->add_child("RectX")->add_child_text(raw_convert<std::string>(rectangle.x));
+ node->add_child("RectY")->add_child_text(raw_convert<std::string>(rectangle.y));
+ node->add_child("RectWidth")->add_child_text(raw_convert<std::string>(rectangle.width));
+ node->add_child("RectHeight")->add_child_text(raw_convert<std::string>(rectangle.height));
+}
+
+void
+BitmapText::transfer_binary (shared_ptr<Socket> socket) const
+{
+ image->write_to_socket (socket);
+}
#define DCPOMATIC_BITMAP_CAPTION_H
#include "rect.h"
+#include <libxml++/libxml++.h>
#include <boost/shared_ptr.hpp>
class Image;
+class Socket;
class BitmapText
{
, rectangle (r)
{}
+ void transfer_xml (xmlpp::Node* node) const;
+ void transfer_binary (boost::shared_ptr<Socket> socket) const;
+
boost::shared_ptr<Image> image;
/** Area that the subtitle covers on its corresponding video, expressed in
* proportions of the image size; e.g. rectangle.x = 0.5 would mean that
#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)
}
void
-Font::as_xml (xmlpp::Node* node)
+Font::as_xml (xmlpp::Node* node) const
{
node->add_child("Id")->add_child_text (_id);
if (_file) {
}
}
+/** 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)
#include <boost/filesystem.hpp>
#include <string>
+class Socket;
+
namespace dcpomatic {
class Font
explicit Font (cxml::NodePtr node);
- void as_xml (xmlpp::Node* node);
+ void as_xml (xmlpp::Node* node) const;
+
+ void transfer_xml (xmlpp::Node* node) const;
+ void transfer_binary (boost::shared_ptr<Socket> socket) const;
std::string id () const {
return _id;
#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_)
{
class Font;
}
+class Socket;
+
/** A set of text (subtitle/CCAP) which span the same time period */
class PlayerText
{
public:
+ void add_metadata (xmlpp::Node* node) const;
+ void send_binary (boost::shared_ptr<Socket> socket) const;
+
void add_fonts (std::list<boost::shared_ptr<dcpomatic::Font> > fonts_);
std::list<boost::shared_ptr<dcpomatic::Font> > fonts;
if (_colour_conversion) {
_colour_conversion.get().as_xml (node);
}
- /* XXX_c
- if (_text) {
- node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_text->image->size().width));
- node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_text->image->size().height));
- node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_text->position.x));
- node->add_child ("SubtitleY")->add_child_text (raw_convert<string> (_text->position.y));
+ BOOST_FOREACH (PlayerText i, _text) {
+ i.add_metadata(node->add_child("Text"));
}
- */
}
void
PlayerVideo::send_binary (shared_ptr<Socket> socket) const
{
_in->send_binary (socket);
- /* XXX_c
- if (_text) {
- _text->image->write_to_socket (socket);
+ BOOST_FOREACH (PlayerText i, _text) {
+ i.send_binary (socket);
}
- */
}
bool
/*
- Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
#include "string_text.h"
+#include <dcp/raw_convert.h>
+#include <libxml++/libxml++.h>
+
+using std::string;
+using dcp::raw_convert;
bool
operator== (StringText const & a, StringText const & b)
return static_cast<dcp::SubtitleString const &>(a) == static_cast<dcp::SubtitleString const &>(b) && a.outline_width == b.outline_width;
}
+void
+StringText::transfer_xml (xmlpp::Node* node) const
+{
+ if (font()) {
+ node->add_child("Font")->add_child_text(*font());
+ }
+ node->add_child("Italic")->add_child_text(italic() ? "1" : "0");
+ node->add_child("Bold")->add_child_text(bold() ? "1" : "0");
+ node->add_child("Underline")->add_child_text(underline() ? "1" : "0");
+ node->add_child("Colour")->add_child_text(colour().to_argb_string());
+ node->add_child("Size")->add_child_text(raw_convert<string>(size()));
+ node->add_child("AspectAdjust")->add_child_text(raw_convert<string>(aspect_adjust()));
+ node->add_child("Direction")->add_child_text(dcp::direction_to_string(direction()));
+ node->add_child("Text")->add_child_text(text());
+ node->add_child("Effect")->add_child_text(dcp::effect_to_string(effect()));
+ node->add_child("EffectColour")->add_child_text(effect_colour().to_argb_string());
+
+ node->add_child("OutlineWidth")->add_child_text(raw_convert<string>(outline_width));
+}
+
+
, outline_width (outline_width_)
{}
+ void transfer_xml (xmlpp::Node* node) const;
+
int outline_width;
};