#include "dcp_content_type.h"
#include "ratio.h"
#include "cross.h"
-#include "safe_stringstream.h"
#include "environment_info.h"
#include "raw_convert.h"
#include "audio_processor.h"
#include "dcp_content.h"
#include "screen_kdm.h"
#include "cinema.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/certificate_chain.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+#include <boost/regex.hpp>
#include <unistd.h>
#include <stdexcept>
#include <iostream>
* are present.
* 34 -> 35
* VideoFrameType in VideoContent is a string rather than an integer.
+ * 35 -> 36
+ * EffectColour rather than OutlineColour in Subtitle.
*/
-int const Film::current_state_version = 35;
+int const Film::current_state_version = 36;
/** Construct a Film object in a given directory.
*
, _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
, _isdcf_metadata (Config::instance()->default_isdcf_metadata ())
, _video_frame_rate (24)
- , _audio_channels (6)
+ , _audio_channels (Config::instance()->default_dcp_audio_channels ())
, _three_d (false)
, _sequence (true)
, _interop (Config::instance()->default_interop ())
{
DCPOMATIC_ASSERT (container ());
- SafeStringStream s;
+ locked_stringstream s;
s.imbue (std::locale::classic ());
s << container()->id()
string
Film::isdcf_name (bool if_created_now) const
{
- SafeStringStream d;
+ locked_stringstream d;
string raw_name = name ();
p /= "j2c";
p /= video_identifier ();
- SafeStringStream s;
+ locked_stringstream s;
s.width (8);
s << setfill('0') << reel << "_" << frame;
/** Change the gains of the supplied AudioMapping to make it a default
* for this film. The defaults are guessed based on what processor (if any)
- * is in use and the number of input channels.
+ * is in use, the number of input channels and any filename supplied.
*/
void
-Film::make_audio_mapping_default (AudioMapping& mapping) const
+Film::make_audio_mapping_default (AudioMapping& mapping, optional<boost::filesystem::path> filename) const
{
+ static string const regex[] = {
+ ".*[\\._-]L[\\._-].*",
+ ".*[\\._-]R[\\._-].*",
+ ".*[\\._-]C[\\._-].*",
+ ".*[\\._-]Lfe[\\._-].*",
+ ".*[\\._-]Ls[\\._-].*",
+ ".*[\\._-]Rs[\\._-].*"
+ };
+
+ static int const regexes = sizeof(regex) / sizeof(*regex);
+
if (audio_processor ()) {
audio_processor()->make_audio_mapping_default (mapping);
} else {
mapping.make_zero ();
if (mapping.input_channels() == 1) {
- /* Mono -> Centre */
- mapping.set (0, static_cast<int> (dcp::CENTRE), 1);
+ bool guessed = false;
+
+ /* See if we can guess where this stream should go */
+ if (filename) {
+ for (int i = 0; i < regexes; ++i) {
+ boost::regex e (regex[i], boost::regex::icase);
+ if (boost::regex_match (filename->string(), e) && i < mapping.output_channels()) {
+ mapping.set (0, i, 1);
+ guessed = true;
+ }
+ }
+ }
+
+ if (!guessed) {
+ /* If we have no idea, just put it on centre */
+ mapping.set (0, static_cast<int> (dcp::CENTRE), 1);
+ }
} else {
/* 1:1 mapping */
for (int i = 0; i < min (mapping.input_channels(), mapping.output_channels()); ++i) {
{
optional<DCPTime> last_split;
shared_ptr<Content> last_video;
- ContentList cl = content ();
BOOST_FOREACH (shared_ptr<Content> c, content ()) {
if (c->video) {
BOOST_FOREACH (DCPTime t, c->reel_split_points()) {