summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-12-24 00:18:03 +0000
committerCarl Hetherington <cth@carlh.net>2013-12-24 00:18:03 +0000
commite194f0003b60b2607da0822485c56cd8267e78dc (patch)
tree85aa72e1c8131372ec813c3d5a3a7f0cbb53568e /src/lib
parent6d39d3df8e2fed1ec5e13d54ce6cd22c59b69eba (diff)
parent3318969a7ad685fc2f624ac0af302ca1e454e62b (diff)
Merge 1.0.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc6
-rw-r--r--src/lib/config.h18
-rw-r--r--src/lib/dcp_video_frame.cc9
-rw-r--r--src/lib/dcp_video_frame.h3
-rw-r--r--src/lib/encoder.cc2
-rw-r--r--src/lib/kdm.cc39
-rw-r--r--src/lib/kdm.h6
-rw-r--r--src/lib/send_kdm_email_job.cc69
-rw-r--r--src/lib/send_kdm_email_job.h44
-rw-r--r--src/lib/types.h3
-rw-r--r--src/lib/video_content.cc2
-rw-r--r--src/lib/video_decoder.cc7
-rw-r--r--src/lib/wscript1
13 files changed, 188 insertions, 21 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 93eec9bc0..1c34619b4 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -66,7 +66,7 @@ Config::Config ()
, _default_j2k_bandwidth (200000000)
, _default_audio_delay (0)
, _kdm_email (
- "Dear Projectionist\n\nPlease find attached KDMs for $CPL_NAME.\n\nBest regards,\nDCP-o-matic"
+ "Dear Projectionist\n\nPlease find attached KDMs for $CPL_NAME.\n\nThe KDMs are valid from $START_TIME until $END_TIME.\n\nBest regards,\nDCP-o-matic"
)
{
_allowed_dcp_frame_rates.push_back (24);
@@ -176,6 +176,8 @@ Config::read ()
}
_mail_server = f.string_child ("MailServer");
+ _mail_user = f.optional_string_child("MailUser").get_value_or ("");
+ _mail_password = f.optional_string_child("MailPassword").get_value_or ("");
_kdm_from = f.string_child ("KDMFrom");
_kdm_email = f.string_child ("KDMEmail");
}
@@ -347,6 +349,8 @@ Config::write () const
}
root->add_child("MailServer")->add_child_text (_mail_server);
+ root->add_child("MailUser")->add_child_text (_mail_user);
+ root->add_child("MailPassword")->add_child_text (_mail_password);
root->add_child("KDMFrom")->add_child_text (_kdm_from);
root->add_child("KDMEmail")->add_child_text (_kdm_email);
diff --git a/src/lib/config.h b/src/lib/config.h
index 14c707dd2..67d293884 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -155,6 +155,14 @@ public:
return _mail_server;
}
+ std::string mail_user () const {
+ return _mail_user;
+ }
+
+ std::string mail_password () const {
+ return _mail_password;
+ }
+
std::string kdm_from () const {
return _kdm_from;
}
@@ -261,6 +269,14 @@ public:
_mail_server = s;
}
+ void set_mail_user (std::string u) {
+ _mail_user = u;
+ }
+
+ void set_mail_password (std::string p) {
+ _mail_password = p;
+ }
+
void set_kdm_from (std::string f) {
_kdm_from = f;
}
@@ -321,6 +337,8 @@ private:
std::vector<PresetColourConversion> _colour_conversions;
std::list<boost::shared_ptr<Cinema> > _cinemas;
std::string _mail_server;
+ std::string _mail_user;
+ std::string _mail_password;
std::string _kdm_from;
std::string _kdm_email;
diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc
index 679a0490e..e719d7ef4 100644
--- a/src/lib/dcp_video_frame.cc
+++ b/src/lib/dcp_video_frame.cc
@@ -79,7 +79,7 @@ using libdcp::Size;
* @param l Log to write to.
*/
DCPVideoFrame::DCPVideoFrame (
- shared_ptr<const Image> image, int f, Eyes eyes, ColourConversion c, int dcp_fps, int bw, shared_ptr<Log> l
+ shared_ptr<const Image> image, int f, Eyes eyes, ColourConversion c, int dcp_fps, int bw, Resolution r, shared_ptr<Log> l
)
: _image (image)
, _frame (f)
@@ -87,6 +87,7 @@ DCPVideoFrame::DCPVideoFrame (
, _conversion (c)
, _frames_per_second (dcp_fps)
, _j2k_bandwidth (bw)
+ , _resolution (r)
, _log (l)
{
@@ -110,6 +111,7 @@ DCPVideoFrame::DCPVideoFrame (shared_ptr<const Image> image, shared_ptr<const cx
_conversion = ColourConversion (node->node_child ("ColourConversion"));
_frames_per_second = node->number_child<int> ("FramesPerSecond");
_j2k_bandwidth = node->number_child<int> ("J2KBandwidth");
+ _resolution = Resolution (node->optional_number_child<int>("J2KBandwidth").get_value_or (RESOLUTION_2K));
}
/** J2K-encode this frame on the local host.
@@ -194,9 +196,9 @@ DCPVideoFrame::encode_locally ()
parameters.tcp_rates[0] = 0;
parameters.tcp_numlayers++;
parameters.cp_disto_alloc = 1;
- parameters.cp_rsiz = CINEMA2K;
+ parameters.cp_rsiz = _resolution == RESOLUTION_2K ? CINEMA2K : CINEMA4K;
parameters.cp_comment = strdup (N_("DCP-o-matic"));
- parameters.cp_cinema = CINEMA2K_24;
+ parameters.cp_cinema = _resolution == RESOLUTION_2K ? CINEMA2K_24 : CINEMA4K_24;
/* 3 components, so use MCT */
parameters.tcp_mct = 1;
@@ -317,6 +319,7 @@ DCPVideoFrame::add_metadata (xmlpp::Element* el) const
el->add_child("FramesPerSecond")->add_child_text (lexical_cast<string> (_frames_per_second));
el->add_child("J2KBandwidth")->add_child_text (lexical_cast<string> (_j2k_bandwidth));
+ el->add_child("Resolution")->add_child_text (lexical_cast<string> (int (_resolution)));
}
EncodedData::EncodedData (int s)
diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h
index c642fb4db..40f758c74 100644
--- a/src/lib/dcp_video_frame.h
+++ b/src/lib/dcp_video_frame.h
@@ -102,7 +102,7 @@ public:
class DCPVideoFrame : public boost::noncopyable
{
public:
- DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, ColourConversion, int, int, boost::shared_ptr<Log>);
+ DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, ColourConversion, int, int, Resolution, boost::shared_ptr<Log>);
DCPVideoFrame (boost::shared_ptr<const Image>, boost::shared_ptr<const cxml::Node>, boost::shared_ptr<Log>);
boost::shared_ptr<EncodedData> encode_locally ();
@@ -126,6 +126,7 @@ private:
ColourConversion _conversion;
int _frames_per_second; ///< Frames per second that we will use for the DCP
int _j2k_bandwidth; ///< J2K bandwidth to use
+ Resolution _resolution; ///< Resolution (2K or 4K)
boost::shared_ptr<Log> _log; ///< log
};
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 046a3248e..475c230da 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -217,7 +217,7 @@ Encoder::process_video (shared_ptr<PlayerImage> image, Eyes eyes, ColourConversi
_queue.push_back (shared_ptr<DCPVideoFrame> (
new DCPVideoFrame (
image->image(PIX_FMT_RGB24, false), _video_frames_out, eyes, conversion, _film->video_frame_rate(),
- _film->j2k_bandwidth(), _film->log()
+ _film->j2k_bandwidth(), _film->resolution(), _film->log()
)
));
diff --git a/src/lib/kdm.cc b/src/lib/kdm.cc
index 4d8f29723..cf551285b 100644
--- a/src/lib/kdm.cc
+++ b/src/lib/kdm.cc
@@ -31,6 +31,7 @@
using std::list;
using std::string;
+using std::stringstream;
using boost::shared_ptr;
struct ScreenKDM
@@ -45,7 +46,7 @@ struct ScreenKDM
};
static string
-kdm_filename (shared_ptr<Film> film, ScreenKDM kdm)
+kdm_filename (shared_ptr<const Film> film, ScreenKDM kdm)
{
return tidy_for_filename (film->name()) + "_" + tidy_for_filename (kdm.screen->cinema->name) + "_" + tidy_for_filename (kdm.screen->name) + ".kdm.xml";
}
@@ -55,7 +56,7 @@ struct CinemaKDMs
shared_ptr<Cinema> cinema;
list<ScreenKDM> screen_kdms;
- void make_zip_file (shared_ptr<Film> film, boost::filesystem::path zip_file) const
+ void make_zip_file (shared_ptr<const Film> film, boost::filesystem::path zip_file) const
{
int error;
struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error);
@@ -99,7 +100,7 @@ operator== (ScreenKDM const & a, ScreenKDM const & b)
static list<ScreenKDM>
make_screen_kdms (
- shared_ptr<Film> film,
+ shared_ptr<const Film> film,
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -123,7 +124,7 @@ make_screen_kdms (
static list<CinemaKDMs>
make_cinema_kdms (
- shared_ptr<Film> film,
+ shared_ptr<const Film> film,
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -165,7 +166,7 @@ make_cinema_kdms (
void
write_kdm_files (
- shared_ptr<Film> film,
+ shared_ptr<const Film> film,
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -185,7 +186,7 @@ write_kdm_files (
void
write_kdm_zip_files (
- shared_ptr<Film> film,
+ shared_ptr<const Film> film,
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -204,7 +205,7 @@ write_kdm_zip_files (
void
email_kdms (
- shared_ptr<Film> film,
+ shared_ptr<const Film> film,
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -226,14 +227,30 @@ email_kdms (
quickmail_add_to (mail, i->cinema->email.c_str ());
string body = Config::instance()->kdm_email().c_str();
- boost::algorithm::replace_all (body, "$DCP_NAME", film->dcp_name ());
-
+ boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ());
+ stringstream start;
+ start << from.date() << " " << from.time_of_day();
+ boost::algorithm::replace_all (body, "$START_TIME", start.str ());
+ stringstream end;
+ end << to.date() << " " << to.time_of_day();
+ boost::algorithm::replace_all (body, "$END_TIME", end.str ());
+
quickmail_set_body (mail, body.c_str());
quickmail_add_attachment_file (mail, zip_file.string().c_str(), "application/zip");
- char const* error = quickmail_send (mail, Config::instance()->mail_server().c_str(), 25, "", "");
+
+ int const port = Config::instance()->mail_user().empty() ? 25 : 587;
+
+ char const* error = quickmail_send (
+ mail,
+ Config::instance()->mail_server().c_str(),
+ port,
+ Config::instance()->mail_user().c_str(),
+ Config::instance()->mail_password().c_str()
+ );
+
if (error) {
quickmail_destroy (mail);
- throw StringError (String::compose ("Failed to send KDM email (%1)", error));
+ throw KDMError (String::compose ("Failed to send KDM email (%1)", error));
}
quickmail_destroy (mail);
}
diff --git a/src/lib/kdm.h b/src/lib/kdm.h
index 5701a8bf8..c4fd43d49 100644
--- a/src/lib/kdm.h
+++ b/src/lib/kdm.h
@@ -24,7 +24,7 @@ class Screen;
class Film;
extern void write_kdm_files (
- boost::shared_ptr<Film> film,
+ boost::shared_ptr<const Film> film,
std::list<boost::shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -33,7 +33,7 @@ extern void write_kdm_files (
);
extern void write_kdm_zip_files (
- boost::shared_ptr<Film> film,
+ boost::shared_ptr<const Film> film,
std::list<boost::shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
@@ -42,7 +42,7 @@ extern void write_kdm_zip_files (
);
extern void email_kdms (
- boost::shared_ptr<Film> film,
+ boost::shared_ptr<const Film> film,
std::list<boost::shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc
new file mode 100644
index 000000000..89bce9a14
--- /dev/null
+++ b/src/lib/send_kdm_email_job.cc
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "send_kdm_email_job.h"
+#include "compose.hpp"
+#include "film.h"
+#include "kdm.h"
+
+#include "i18n.h"
+
+using std::string;
+using std::list;
+using boost::shared_ptr;
+
+SendKDMEmailJob::SendKDMEmailJob (
+ shared_ptr<const Film> f,
+ list<shared_ptr<Screen> > screens,
+ boost::filesystem::path dcp,
+ boost::posix_time::ptime from,
+ boost::posix_time::ptime to
+ )
+ : Job (f)
+ , _screens (screens)
+ , _dcp (dcp)
+ , _from (from)
+ , _to (to)
+{
+
+}
+
+string
+SendKDMEmailJob::name () const
+{
+ return String::compose (_("Email KDMs for %1"), _film->name());
+}
+
+void
+SendKDMEmailJob::run ()
+{
+ try {
+
+ set_progress_unknown ();
+ email_kdms (_film, _screens, _dcp, _from, _to);
+ set_progress (1);
+ set_state (FINISHED_OK);
+
+ } catch (std::exception& e) {
+
+ set_progress (1);
+ set_state (FINISHED_ERROR);
+ throw;
+ }
+}
diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h
new file mode 100644
index 000000000..fcab56ce5
--- /dev/null
+++ b/src/lib/send_kdm_email_job.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/filesystem.hpp>
+#include "job.h"
+
+class Screen;
+
+class SendKDMEmailJob : public Job
+{
+public:
+ SendKDMEmailJob (
+ boost::shared_ptr<const Film>,
+ std::list<boost::shared_ptr<Screen> >,
+ boost::filesystem::path,
+ boost::posix_time::ptime,
+ boost::posix_time::ptime
+ );
+
+ std::string name () const;
+ void run ();
+
+private:
+ std::list<boost::shared_ptr<Screen> > _screens;
+ boost::filesystem::path _dcp;
+ boost::posix_time::ptime _from;
+ boost::posix_time::ptime _to;
+};
diff --git a/src/lib/types.h b/src/lib/types.h
index 1ab6a94d4..33c0c171f 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -69,7 +69,8 @@ struct TimedAudioBuffers
enum VideoFrameType
{
VIDEO_FRAME_TYPE_2D,
- VIDEO_FRAME_TYPE_3D_LEFT_RIGHT
+ VIDEO_FRAME_TYPE_3D_LEFT_RIGHT,
+ VIDEO_FRAME_TYPE_3D_TOP_BOTTOM
};
enum Eyes
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index ebec8b6db..404549532 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -327,6 +327,8 @@ VideoContent::video_size_after_3d_split () const
return s;
case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
return libdcp::Size (s.width / 2, s.height);
+ case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
+ return libdcp::Size (s.width, s.height / 2);
}
assert (false);
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index 3a8891111..1503af955 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -48,5 +48,12 @@ VideoDecoder::video (shared_ptr<const Image> image, bool same, ContentTime time)
_pending.push_back (shared_ptr<DecodedVideo> (new DecodedVideo (image->crop (Crop (half, 0, 0, 0), true), EYES_RIGHT, same, time)));
break;
}
+ case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
+ {
+ int const half = image->size().height / 2;
+ Video (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, same, frame);
+ Video (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, same, frame);
+ break;
+ }
}
}
diff --git a/src/lib/wscript b/src/lib/wscript
index 1699c5ec8..25186a3d3 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -44,6 +44,7 @@ sources = """
resampler.cc
scp_dcp_job.cc
scaler.cc
+ send_kdm_email_job.cc
server.cc
server_finder.cc
sndfile_content.cc