/*
Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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,
+ DCP-o-matic 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.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#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 "md5_digester.h"
+#include "digester.h"
#include "compose.hpp"
#include "screen.h"
#include "audio_content.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>
*
* 32 -> 33
* Changed <Period> to <Subtitle> in FFmpegSubtitleStream
+ * 33 -> 34
+ * Content only contains audio/subtitle-related tags if those things
+ * 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 = 33;
+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()
{
boost::filesystem::path p = dir ("analysis");
- MD5Digester digester;
+ Digester digester;
BOOST_FOREACH (shared_ptr<Content> i, playlist->content ()) {
if (!i->audio) {
continue;
}
digester.add (i->digest ());
- digester.add (i->audio->audio_mapping().digest ());
+ digester.add (i->audio->mapping().digest ());
if (playlist->content().size() != 1) {
/* Analyses should be considered equal regardless of gain
if they were made from just one piece of content. This
analysis at the plotting stage rather than having to
recompute it.
*/
- digester.add (i->audio->audio_gain ());
+ digester.add (i->audio->gain ());
}
}
string
Film::isdcf_name (bool if_created_now) const
{
- SafeStringStream d;
+ locked_stringstream d;
string raw_name = name ();
if (i->video->scale().ratio ()) {
content_ratio = i->video->scale().ratio ();
} else {
- content_ratio = Ratio::from_ratio (i->video->video_size().ratio ());
+ content_ratio = Ratio::from_ratio (i->video->size().ratio ());
}
break;
}
continue;
}
- if (i->subtitle->use_subtitles() && !i->subtitle->burn_subtitles()) {
+ if (i->subtitle->use() && !i->subtitle->burn()) {
burnt_in = false;
}
}
switch (p) {
case Film::CONTENT:
- set_video_frame_rate (_playlist->best_dcp_frame_rate ());
+ set_video_frame_rate (_playlist->best_video_frame_rate ());
break;
case Film::VIDEO_FRAME_RATE:
case Film::SEQUENCE:
p /= "j2c";
p /= video_identifier ();
- SafeStringStream s;
+ locked_stringstream s;
s.width (8);
s << setfill('0') << reel << "_" << frame;
int
Film::best_video_frame_rate () const
{
- return _playlist->best_dcp_frame_rate ();
+ return _playlist->best_video_frame_rate ();
}
FrameRateChange
{
_dirty = true;
- if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
- set_video_frame_rate (_playlist->best_dcp_frame_rate ());
- } else if (p == AudioContentProperty::AUDIO_STREAMS) {
+ if (p == ContentProperty::VIDEO_FRAME_RATE) {
+ set_video_frame_rate (_playlist->best_video_frame_rate ());
+ } else if (p == AudioContentProperty::STREAMS) {
signal_changed (NAME);
}
ContentList cl = content ();
BOOST_FOREACH (shared_ptr<Content>& c, cl) {
if (c->subtitle) {
- languages.insert (c->subtitle->subtitle_language ());
+ languages.insert (c->subtitle->language ());
}
}
/** 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()) {