summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-06-01 11:28:48 +0200
committerCarl Hetherington <cth@carlh.net>2021-06-01 14:25:17 +0200
commitddd767fd647b2fd585d75ada000d3d01c4c43cb2 (patch)
treea8807a0e60aac0cf39adee3a7a2d7c5c37cb94ad /src/lib
parent8a0ab373363c34daf5d926e951ee79fc422fdb3d (diff)
Put audio language back in the Film.
It feels neat to have audio language in the audio tab, to match the subtitle language in the subtitle tab. It also avoids the potential confusion of there being an audio language setting in the DCP metadata but no subtitle language setting. However: - I am yet to find a need to describe multiple audio languages in the same DCP (all previous users of Film::audio_languages() were just taking the first language off the list). - As Carsten points out it's fiddly to have to set the audio language for 5 separate-channel WAV files, for example (you wouldn't actually have had to do this, but it would have felt like you did). I think subtitle language remains neater where it is (per-content) as there is this additional subtitle language metadata and it makes much more sense (and is much more likely) that there are multiple subtitle languages in a DCP than it does multiple audio languages.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_content.cc20
-rw-r--r--src/lib/audio_content.h9
-rw-r--r--src/lib/dcp_content.cc1
-rw-r--r--src/lib/film.cc36
-rw-r--r--src/lib/film.h9
-rw-r--r--src/lib/reel_writer.cc4
-rw-r--r--src/lib/writer.cc6
7 files changed, 30 insertions, 55 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index 3d9f6ac05..748cbb7d0 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -52,7 +52,6 @@ using namespace dcpomatic;
int const AudioContentProperty::STREAMS = 200;
int const AudioContentProperty::GAIN = 201;
int const AudioContentProperty::DELAY = 202;
-int const AudioContentProperty::LANGUAGE = 203;
AudioContent::AudioContent (Content* parent)
@@ -90,10 +89,6 @@ AudioContent::AudioContent (Content* parent, cxml::ConstNodePtr node)
{
_gain = node->number_child<double> ("AudioGain");
_delay = node->number_child<int> ("AudioDelay");
- auto lang = node->optional_node_child ("Language");
- if (lang) {
- _language = dcp::LanguageTag (lang->content());
- }
/* Backwards compatibility */
auto r = node->optional_number_child<double>("AudioVideoFrameRate");
@@ -117,16 +112,11 @@ AudioContent::AudioContent (Content* parent, vector<shared_ptr<Content> > c)
if (c[i]->audio->delay() != ref->delay()) {
throw JoinError (_("Content to be joined must have the same audio delay."));
}
-
- if (c[i]->audio->language() != ref->language()) {
- throw JoinError (_("Content to be joined must have the same audio language."));
- }
}
_gain = ref->gain ();
_delay = ref->delay ();
_streams = ref->streams ();
- _language = ref->language ();
}
@@ -136,9 +126,6 @@ AudioContent::as_xml (xmlpp::Node* node) const
boost::mutex::scoped_lock lm (_mutex);
node->add_child("AudioGain")->add_child_text(raw_convert<string>(_gain));
node->add_child("AudioDelay")->add_child_text(raw_convert<string>(_delay));
- if (_language) {
- node->add_child("Language")->add_child_text(_language->to_string());
- }
}
@@ -156,13 +143,6 @@ AudioContent::set_delay (int d)
}
-void
-AudioContent::set_language (optional<dcp::LanguageTag> language)
-{
- maybe_set (_language, language, AudioContentProperty::LANGUAGE);
-}
-
-
string
AudioContent::technical_summary () const
{
diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h
index adb5c9556..67183d0a4 100644
--- a/src/lib/audio_content.h
+++ b/src/lib/audio_content.h
@@ -31,7 +31,6 @@
#include "content_part.h"
#include "audio_stream.h"
#include "audio_mapping.h"
-#include <dcp/language_tag.h>
/** @class AudioContentProperty
@@ -43,7 +42,6 @@ public:
static int const STREAMS;
static int const GAIN;
static int const DELAY;
- static int const LANGUAGE;
};
@@ -65,7 +63,6 @@ public:
void set_gain (double);
void set_delay (int);
- void set_language (boost::optional<dcp::LanguageTag> langauge);
double gain () const {
boost::mutex::scoped_lock lm (_mutex);
@@ -77,11 +74,6 @@ public:
return _delay;
}
- boost::optional<dcp::LanguageTag> language () const {
- boost::mutex::scoped_lock lm (_mutex);
- return _language;
- }
-
std::string processing_description (std::shared_ptr<const Film> film) const;
std::vector<AudioStreamPtr> streams () const {
@@ -108,7 +100,6 @@ private:
/** Delay to apply to audio (positive moves audio later) in milliseconds */
int _delay = 0;
std::vector<AudioStreamPtr> _streams;
- boost::optional<dcp::LanguageTag> _language;
};
#endif
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index f6a74501c..c380e6f84 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -242,7 +242,6 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
boost::mutex::scoped_lock lm (_mutex);
audio = make_shared<AudioContent>(this);
}
- audio->set_language (examiner->audio_language());
auto as = make_shared<AudioStream>(examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels());
audio->set_stream (as);
auto m = as->mapping ();
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 62cbf0e50..44c49220b 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -505,6 +505,9 @@ Film::metadata (bool with_content_paths) const
}
root->add_child("UserExplicitContainer")->add_child_text(_user_explicit_container ? "1" : "0");
root->add_child("UserExplicitResolution")->add_child_text(_user_explicit_resolution ? "1" : "0");
+ if (_audio_language) {
+ root->add_child("AudioLanguage")->add_child_text(_audio_language->to_string());
+ }
_playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
return doc;
@@ -685,6 +688,11 @@ Film::read_metadata (optional<boost::filesystem::path> path)
_user_explicit_container = f.optional_bool_child("UserExplicitContainer").get_value_or(true);
_user_explicit_resolution = f.optional_bool_child("UserExplicitResolution").get_value_or(true);
+ auto audio_language = f.optional_string_child("AudioLanguage");
+ if (audio_language) {
+ _audio_language = dcp::LanguageTag(*audio_language);
+ }
+
list<string> notes;
_playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
@@ -760,23 +768,6 @@ Film::mapped_audio_channels () const
}
-vector<dcp::LanguageTag>
-Film::audio_languages () const
-{
- vector<dcp::LanguageTag> result;
- for (auto i: content()) {
- if (i->audio && !i->audio->mapping().mapped_output_channels().empty() && i->audio->language()) {
- result.push_back (i->audio->language().get());
- }
- }
-
- std::sort (result.begin(), result.end());
- auto last = std::unique (result.begin(), result.end());
- result.erase (last, result.end());
- return result;
-}
-
-
pair<optional<dcp::LanguageTag>, vector<dcp::LanguageTag>>
Film::subtitle_languages () const
{
@@ -922,8 +913,7 @@ Film::isdcf_name (bool if_created_now) const
}
}
- auto audio_langs = audio_languages();
- auto audio_language = (audio_langs.empty() || !audio_langs.front().language()) ? "XX" : audio_langs.front().language()->subtag();
+ auto audio_language = (_audio_language && _audio_language->language()) ? _audio_language->language()->subtag() : "XX";
d += "_" + to_upper (audio_language);
@@ -2147,3 +2137,11 @@ Film::set_two_d_version_of_three_d (bool t)
_two_d_version_of_three_d = t;
}
+
+void
+Film::set_audio_language (optional<dcp::LanguageTag> language)
+{
+ FilmChangeSignaller ch (this, Property::AUDIO_LANGUAGE);
+ _audio_language = language;
+}
+
diff --git a/src/lib/film.h b/src/lib/film.h
index bb868ffad..d46f5e6b7 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -186,7 +186,11 @@ public:
std::list<dcpomatic::DCPTimePeriod> reels () const;
std::list<int> mapped_audio_channels () const;
- std::vector<dcp::LanguageTag> audio_languages () const;
+
+ boost::optional<dcp::LanguageTag> audio_language () const {
+ return _audio_language;
+ }
+
std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> subtitle_languages () const;
std::string content_summary (dcpomatic::DCPTimePeriod period) const;
@@ -395,6 +399,7 @@ public:
return _luminance;
}
+
/* SET */
void set_directory (boost::filesystem::path);
@@ -439,6 +444,7 @@ public:
void set_two_d_version_of_three_d (bool t);
void set_distributor (boost::optional<std::string> d = boost::none);
void set_luminance (boost::optional<dcp::Luminance> l = boost::none);
+ void set_audio_language (boost::optional<dcp::LanguageTag> language);
void add_ffoc_lfoc (Markers& markers) const;
@@ -546,6 +552,7 @@ private:
bool _red_band = false;
bool _two_d_version_of_three_d = false;
boost::optional<dcp::Luminance> _luminance;
+ boost::optional<dcp::LanguageTag> _audio_language;
int _state_version;
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index 0b367ae38..521ba55df 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -168,12 +168,12 @@ ReelWriter::ReelWriter (
}
if (film()->audio_channels()) {
- auto langs = film()->audio_languages();
+ auto lang = film()->audio_language();
_sound_asset = make_shared<dcp::SoundAsset> (
dcp::Fraction(film()->video_frame_rate(), 1),
film()->audio_frame_rate(),
film()->audio_channels(),
- langs.empty() ? dcp::LanguageTag("en-US") : langs.front(),
+ lang ? *lang : dcp::LanguageTag("en-US"),
standard
);
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index bc299414b..3d8d9fe78 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -718,9 +718,9 @@ Writer::write_cover_sheet (boost::filesystem::path output_dcp)
boost::algorithm::replace_all (text, "$TYPE", film()->dcp_content_type()->pretty_name());
boost::algorithm::replace_all (text, "$CONTAINER", film()->container()->container_nickname());
- auto audio_languages = film()->audio_languages();
- if (!audio_languages.empty()) {
- boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", audio_languages.front().description());
+ auto audio_language = film()->audio_language();
+ if (audio_language) {
+ boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", audio_language->description());
} else {
boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _("None"));
}