#include "exceptions.h"
#include "examine_content_job.h"
#include "config.h"
-#include "ui_signaller.h"
#include "playlist.h"
#include "player.h"
#include "dcp_content_type.h"
#include "cinema.h"
#include "safe_stringstream.h"
#include "environment_info.h"
+#include "raw_convert.h"
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/signer.h>
#include <dcp/util.h>
#include <dcp/local_time.h>
-#include <dcp/raw_convert.h>
#include <dcp/decrypted_kdm.h>
#include <libxml++/libxml++.h>
#include <boost/filesystem.hpp>
using boost::is_any_of;
using dcp::Size;
using dcp::Signer;
-using dcp::raw_convert;
-using dcp::raw_convert;
#define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
#define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
return s.str ();
}
-/** @return The path to the directory to write video frame info files to */
+/** @return The file to write video frame info to */
boost::filesystem::path
-Film::info_dir () const
+Film::info_file () const
{
boost::filesystem::path p;
p /= "info";
p /= video_identifier ();
- return dir (p);
+ return file (p);
}
boost::filesystem::path
JobManager::instance()->add (j);
}
-/** Count the number of frames that have been encoded for this film.
- * @return frame count.
- */
-int
-Film::encoded_frames () const
-{
- if (container() == 0) {
- return 0;
- }
-
- int N = 0;
- for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (info_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
- ++N;
- boost::this_thread::interruption_point ();
- }
-
- return N;
-}
-
shared_ptr<xmlpp::Document>
Film::metadata () const
{
int non_lfe = 0;
int lfe = 0;
for (list<dcp::Channel>::const_iterator i = mapped.begin(); i != mapped.end(); ++i) {
+ if (static_cast<int> (*i) >= audio_channels()) {
+ /* This channel is mapped but is not included in the DCP */
+ continue;
+ }
+
if ((*i) == dcp::LFE) {
++lfe;
} else {
break;
}
- if (ui_signaller) {
- ui_signaller->emit (boost::bind (boost::ref (Changed), p));
- }
+ emit (boost::bind (boost::ref (Changed), p));
}
void
_isdcf_date = boost::gregorian::day_clock::local_day ();
}
-boost::filesystem::path
-Film::info_path (int f, Eyes e) const
-{
- boost::filesystem::path p;
- p /= info_dir ();
-
- SafeStringStream s;
- s.width (8);
- s << setfill('0') << f;
-
- if (e == EYES_LEFT) {
- s << ".L";
- } else if (e == EYES_RIGHT) {
- s << ".R";
- }
-
- s << ".md5";
-
- p /= s.str();
-
- /* info_dir() will already have added any initial bit of the path,
- so don't call file() on this.
- */
- return p;
-}
-
boost::filesystem::path
Film::j2c_path (int f, Eyes e, bool t) const
{
signal_changed (ENCRYPTED);
}
+void
+Film::set_key (dcp::Key key)
+{
+ _key = key;
+ signal_changed (KEY);
+}
+
shared_ptr<Playlist>
Film::playlist () const
{
signal_changed (NAME);
}
- if (ui_signaller) {
- ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p));
- }
+ emit (boost::bind (boost::ref (ContentChanged), c, p));
}
void
dcp::Size
Film::frame_size () const
{
- return fit_ratio_within (container()->ratio(), full_frame (), 1);
+ return fit_ratio_within (container()->ratio(), full_frame ());
}
dcp::EncryptedKDM
* Note: the decision made by this method isn't, of course, 100% reliable.
*/
bool
-Film::should_be_enough_disk_space (double& required, double& available) const
-{
+Film::should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const
+{
+ /* Create a test file and see if we can hard-link it */
+ boost::filesystem::path test = internal_video_mxf_dir() / "test";
+ boost::filesystem::path test2 = internal_video_mxf_dir() / "test2";
+ can_hard_link = true;
+ FILE* f = fopen_boost (test, "w");
+ if (f) {
+ fclose (f);
+ boost::system::error_code ec;
+ boost::filesystem::create_hard_link (test, test2, ec);
+ if (ec) {
+ can_hard_link = false;
+ }
+ boost::filesystem::remove (test);
+ boost::filesystem::remove (test2);
+ }
+
boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ());
required = double (required_disk_space ()) / 1073741824.0f;
+ if (!can_hard_link) {
+ required *= 2;
+ }
available = double (s.available) / 1073741824.0f;
return (available - required) > 1;
}