#include <algorithm>
#include <fstream>
#include <cstdlib>
-#include <sstream>
#include <iomanip>
#include <unistd.h>
#include <boost/filesystem.hpp>
#include "ratio.h"
#include "cross.h"
#include "cinema.h"
+#include "safe_stringstream.h"
#include "i18n.h"
using std::string;
-using std::stringstream;
using std::multimap;
using std::pair;
using std::map;
using boost::ends_with;
using boost::starts_with;
using boost::optional;
+using boost::is_any_of;
using libdcp::Size;
using libdcp::Signer;
using libdcp::raw_convert;
* 7 -> 8
* Use <Scale> tag in <VideoContent> rather than <Ratio>.
* 8 -> 9
- * DCI -> ISDCF
+ * DCI -> ISDCF.
+ * 9 -> 10
+ * Subtitle X and Y scale.
*/
-int const Film::current_state_version = 9;
+int const Film::current_state_version = 10;
/** Construct a Film object in a given directory.
*
{
assert (container ());
- stringstream s;
+ SafeStringStream s;
s.imbue (std::locale::classic ());
s << container()->id()
string
Film::isdcf_name (bool if_created_now) const
{
- stringstream d;
+ SafeStringStream d;
string raw_name = name ();
+
+ /* Split the raw name up into words */
+ vector<string> words;
+ split (words, raw_name, is_any_of (" "));
+
string fixed_name;
- bool cap_next = true;
- for (size_t i = 0; i < raw_name.length(); ++i) {
- if (raw_name[i] == ' ') {
- cap_next = true;
- } else if (cap_next) {
- fixed_name += toupper (raw_name[i]);
- cap_next = false;
- } else {
- fixed_name += tolower (raw_name[i]);
+
+ /* Add each word to fixed_name */
+ for (vector<string>::const_iterator i = words.begin(); i != words.end(); ++i) {
+ string w = *i;
+
+ /* First letter is always capitalised */
+ w[0] = toupper (w[0]);
+
+ /* Count caps in w */
+ size_t caps = 0;
+ for (size_t i = 0; i < w.size(); ++i) {
+ if (isupper (w[i])) {
+ ++caps;
+ }
+ }
+
+ /* If w is all caps make the rest of it lower case, otherwise
+ leave it alone.
+ */
+ if (caps == w.size ()) {
+ for (size_t i = 1; i < w.size(); ++i) {
+ w[i] = tolower (w[i]);
+ }
+ }
+
+ for (size_t i = 0; i < w.size(); ++i) {
+ fixed_name += w[i];
}
}
d << "_" << container()->isdcf_name();
}
- /* XXX: this only works for content which has been scaled to a given ratio,
- and uses the first bit of content only.
- */
+ /* XXX: this uses the first bit of content only */
/* The standard says we don't do this for trailers, for some strange reason */
if (dcp_content_type() && dcp_content_type()->libdcp_kind() != libdcp::TRAILER) {
- ContentList cl = content ();
Ratio const * content_ratio = 0;
- for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
+ ContentList cl = content ();
+ for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
- if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) {
- content_ratio = vc->scale().ratio();
+ if (vc) {
+ /* Here's the first piece of video content */
+ if (vc->scale().ratio ()) {
+ content_ratio = vc->scale().ratio ();
+ } else {
+ content_ratio = Ratio::from_ratio (vc->video_size().ratio ());
+ }
+ break;
}
}
boost::filesystem::path p;
p /= info_dir ();
- stringstream s;
+ SafeStringStream s;
s.width (8);
s << setfill('0') << f;
p /= "j2c";
p /= video_identifier ();
- stringstream s;
+ SafeStringStream s;
s.width (8);
s << setfill('0') << f;
shared_ptr<libdcp::Certificate> target,
boost::filesystem::path cpl_file,
boost::posix_time::ptime from,
- boost::posix_time::ptime until
+ boost::posix_time::ptime until,
+ libdcp::KDM::Formulation formulation
) const
{
shared_ptr<const Signer> signer = make_signer ();
struct tm* tm = localtime (&now);
string const issue_date = libdcp::tm_to_string (tm);
- return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date);
+ return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date, formulation);
}
list<libdcp::KDM>
list<shared_ptr<Screen> > screens,
boost::filesystem::path dcp,
boost::posix_time::ptime from,
- boost::posix_time::ptime until
+ boost::posix_time::ptime until,
+ libdcp::KDM::Formulation formulation
) const
{
list<libdcp::KDM> kdms;
for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
- kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until));
+ kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation));
}
return kdms;