#include "player_video.h"
#include "image.h"
#include "image_proxy.h"
+#include "j2k_image_proxy.h"
#include "scaler.h"
using std::string;
using std::cout;
-using boost::shared_ptr;
using dcp::raw_convert;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
PlayerVideo::PlayerVideo (
shared_ptr<const ImageProxy> in,
+ DCPTime time,
Crop crop,
dcp::Size inter_size,
dcp::Size out_size,
ColourConversion colour_conversion
)
: _in (in)
+ , _time (time)
, _crop (crop)
, _inter_size (inter_size)
, _out_size (out_size)
PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket, shared_ptr<Log> log)
{
+ _time = DCPTime (node->number_child<DCPTime::Type> ("Time"));
_crop = Crop (node);
_inter_size = dcp::Size (node->number_child<int> ("InterWidth"), node->number_child<int> ("InterHeight"));
}
shared_ptr<Image>
-PlayerVideo::image () const
+PlayerVideo::image (bool burn_subtitle) const
{
shared_ptr<Image> im = _in->image ();
Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
- if (_subtitle.image) {
+ if (burn_subtitle && _subtitle.image) {
out->alpha_blend (_subtitle.image, _subtitle.position);
}
}
void
-PlayerVideo::add_metadata (xmlpp::Node* node) const
+PlayerVideo::add_metadata (xmlpp::Node* node, bool send_subtitles) const
{
+ node->add_child("Time")->add_child_text (raw_convert<string> (_time.get ()));
_crop.as_xml (node);
_in->add_metadata (node->add_child ("In"));
node->add_child("InterWidth")->add_child_text (raw_convert<string> (_inter_size.width));
node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes));
node->add_child("Part")->add_child_text (raw_convert<string> (_part));
_colour_conversion.as_xml (node);
- if (_subtitle.image) {
+ if (send_subtitles && _subtitle.image) {
node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_subtitle.image->size().width));
node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_subtitle.image->size().height));
node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_subtitle.position.x));
}
void
-PlayerVideo::send_binary (shared_ptr<Socket> socket) const
+PlayerVideo::send_binary (shared_ptr<Socket> socket, bool send_subtitles) const
{
_in->send_binary (socket);
- if (_subtitle.image) {
+ if (send_subtitles && _subtitle.image) {
_subtitle.image->write_to_socket (socket);
}
}
+
+bool
+PlayerVideo::has_j2k () const
+{
+ /* XXX: burnt-in subtitle; maybe other things */
+
+ shared_ptr<const J2KImageProxy> j2k = dynamic_pointer_cast<const J2KImageProxy> (_in);
+ if (!j2k) {
+ return false;
+ }
+
+ return _crop == Crop () && _inter_size == j2k->size();
+}
+
+shared_ptr<EncodedData>
+PlayerVideo::j2k () const
+{
+ shared_ptr<const J2KImageProxy> j2k = dynamic_pointer_cast<const J2KImageProxy> (_in);
+ assert (j2k);
+ return j2k->j2k ();
+}