#include <dcp/reel_subtitle_asset.h>
#include <dcp/dcp.h>
#include <dcp/cpl.h>
-#include <dcp/signer.h>
+#include <dcp/certificate_chain.h>
#include <dcp/interop_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
#include <boost/foreach.hpp>
#include "i18n.h"
#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
+#define LOG_DEBUG_ENCODE(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_DEBUG_ENCODE);
#define LOG_TIMING(...) _film->log()->microsecond_log (String::compose (__VA_ARGS__), Log::TYPE_TIMING);
#define LOG_WARNING_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_WARNING);
#define LOG_WARNING(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_WARNING);
}
/* Check that the signer is OK if we need one */
- if (_film->is_signed() && !Config::instance()->signer()->valid ()) {
+ if (_film->is_signed() && !Config::instance()->signer_chain()->valid ()) {
throw InvalidSignerError ();
}
void
Writer::write (Data encoded, int frame, Eyes eyes)
{
- boost::mutex::scoped_lock lock (_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
while (_queued_full_in_memory > _maximum_frames_in_memory) {
/* The queue is too big; wait until that is sorted out */
void
Writer::repeat (int frame, Eyes eyes)
{
- boost::mutex::scoped_lock lock (_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
while (_queued_full_in_memory > _maximum_frames_in_memory) {
/* The queue is too big; wait until that is sorted out */
void
Writer::fake_write (int frame, Eyes eyes)
{
- boost::mutex::scoped_lock lock (_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
while (_queued_full_in_memory > _maximum_frames_in_memory) {
/* The queue is too big; wait until that is sorted out */
void
Writer::write_frame_info (int frame, Eyes eyes, dcp::FrameInfo info) const
{
- FILE* file = fopen_boost (_film->info_file(), "ab");
+ FILE* file = 0;
+ if (boost::filesystem::exists (_film->info_file ())) {
+ file = fopen_boost (_film->info_file(), "r+b");
+ } else {
+ file = fopen_boost (_film->info_file(), "wb");
+ }
if (!file) {
throw OpenFileError (_film->info_file ());
}
{
while (true)
{
- boost::mutex::scoped_lock lock (_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
while (true) {
}
/* Nothing to do: wait until something happens which may indicate that we do */
- LOG_TIMING (N_("writer sleeps with a queue of %1"), _queue.size());
+ LOG_TIMING (N_("writer-sleep queue=%1"), _queue.size());
_empty_condition.wait (lock);
- LOG_TIMING (N_("writer wakes with a queue of %1"), _queue.size());
+ LOG_TIMING (N_("writer-wake queue=%1"), _queue.size());
}
if (_finish && _queue.empty()) {
switch (qi.type) {
case QueueItem::FULL:
{
- LOG_GENERAL (N_("Writer FULL-writes %1 (%2)"), qi.frame, qi.eyes);
+ LOG_DEBUG_ENCODE (N_("Writer FULL-writes %1 (%2)"), qi.frame, qi.eyes);
if (!qi.encoded) {
qi.encoded = Data (_film->j2c_path (qi.frame, qi.eyes, false));
}
break;
}
case QueueItem::FAKE:
- LOG_GENERAL (N_("Writer FAKE-writes %1"), qi.frame);
+ LOG_DEBUG_ENCODE (N_("Writer FAKE-writes %1"), qi.frame);
_picture_asset_writer->fake_write (qi.size);
_last_written[qi.eyes].reset ();
++_fake_written;
break;
case QueueItem::REPEAT:
- LOG_GENERAL (N_("Writer REPEAT-writes %1"), qi.frame);
+ LOG_DEBUG_ENCODE (N_("Writer REPEAT-writes %1"), qi.frame);
dcp::FrameInfo fin = _picture_asset_writer->write (
_last_written[qi.eyes]->data().get(),
_last_written[qi.eyes]->size()
shared_ptr<Job> job = _job.lock ();
DCPOMATIC_ASSERT (job);
- int64_t total = _film->length().frames (_film->video_frame_rate ());
+ int64_t total = _film->length().frames_round (_film->video_frame_rate ());
if (_film->three_d ()) {
/* _full_written and so on are incremented for each eye, so we need to double the total
frames to get the correct progress.
total *= 2;
}
if (total) {
- job->set_progress (float (_full_written + _fake_written) / total);
+ job->set_progress (float (_full_written + _fake_written + _repeat_written) / total);
}
}
void
Writer::terminate_thread (bool can_throw)
{
- boost::mutex::scoped_lock lock (_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
if (_thread == 0) {
return;
}
}
if (_subtitle_asset) {
- boost::filesystem::path const liberation = shared_path () / "LiberationSans-Regular.ttf";
+ boost::filesystem::path liberation;
+ try {
+ liberation = shared_path () / "LiberationSans-Regular.ttf";
+ } catch (boost::filesystem::filesystem_error& e) {
+ /* Hack: try the debian/ubuntu location if getting the shared path failed */
+ liberation = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+ }
/* Add all the fonts to the subtitle content */
BOOST_FOREACH (shared_ptr<Font> i, _fonts) {
}
dcp::XMLMetadata meta;
+ meta.creator = Config::instance()->dcp_creator ();
+ if (meta.creator.empty ()) {
+ meta.creator = String::compose ("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit);
+ }
meta.issuer = Config::instance()->dcp_issuer ();
- meta.creator = String::compose ("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit);
+ if (meta.issuer.empty ()) {
+ meta.issuer = String::compose ("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit);
+ }
meta.set_issue_date_now ();
- shared_ptr<const dcp::Signer> signer;
+ cpl->set_metadata (meta);
+
+ shared_ptr<const dcp::CertificateChain> signer;
if (_film->is_signed ()) {
- signer = Config::instance()->signer ();
+ signer = Config::instance()->signer_chain ();
/* We did check earlier, but check again here to be on the safe side */
if (!signer->valid ()) {
throw InvalidSignerError ();
}
}
- LOG_GENERAL ("Have existing frame %1", _first_nonexistant_frame);
+ LOG_DEBUG_ENCODE ("Have existing frame %1", _first_nonexistant_frame);
++_first_nonexistant_frame;
}
void
Writer::set_encoder_threads (int threads)
{
- _maximum_frames_in_memory = rint (threads * 1.1);
+ _maximum_frames_in_memory = lrint (threads * 1.1);
}
long
DCPOMATIC_ASSERT (false);
}
-
DCPOMATIC_ASSERT (false);
}