int const AudioContentProperty::STREAMS = 200;
int const AudioContentProperty::GAIN = 201;
int const AudioContentProperty::DELAY = 202;
+int const AudioContentProperty::LANGUAGE = 203;
AudioContent::AudioContent (Content* parent)
{
_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");
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 ();
}
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());
+ }
}
}
+void
+AudioContent::set_language (optional<dcp::LanguageTag> language)
+{
+ maybe_set (_language, language, AudioContentProperty::LANGUAGE);
+}
+
+
string
AudioContent::technical_summary () const
{
#include "content_part.h"
#include "audio_stream.h"
#include "audio_mapping.h"
+#include <dcp/language_tag.h>
/** @class AudioContentProperty
static int const STREAMS;
static int const GAIN;
static int const DELAY;
+ static int const LANGUAGE;
};
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);
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 {
/** Delay to apply to audio (positive moves audio later) in milliseconds */
int _delay = 0;
std::vector<AudioStreamPtr> _streams;
+ boost::optional<dcp::LanguageTag> _language;
};
#endif
}
+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
{
}
}
- auto const audio_language = dm.audio_language.empty() ? "XX" : dm.audio_language;
+ auto audio_langs = audio_languages();
+ auto audio_language = (audio_langs.empty() || !audio_langs.front().language()) ? "XX" : audio_langs.front().language()->subtag();
+ transform (audio_language.begin(), audio_language.end(), audio_language.begin(), ::toupper);
d += "_" + audio_language;
}
}
- auto sublangs = subtitle_languages();
- if (sublangs.first && sublangs.first->language()) {
- auto lang = sublangs.first->language()->subtag();
+ auto sub_langs = subtitle_languages();
+ if (sub_langs.first && sub_langs.first->language()) {
+ auto lang = sub_langs.first->language()->subtag();
if (burnt_in) {
transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
} else {
std::list<dcpomatic::DCPTimePeriod> reels () const;
std::list<int> mapped_audio_channels () const;
+ std::vector<dcp::LanguageTag> audio_languages () const;
std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> subtitle_languages () const;
std::string content_summary (dcpomatic::DCPTimePeriod period) const;
DISTRIBUTOR,
FACILITY,
LUMINANCE,
- SUBTITLE_LANGUAGES
};
ISDCFMetadata::ISDCFMetadata (cxml::ConstNodePtr node)
: content_version (node->number_child<int> ("ContentVersion"))
- , audio_language (node->string_child ("AudioLanguage"))
, territory (node->string_child ("Territory"))
, rating (node->string_child ("Rating"))
, studio (node->string_child ("Studio"))
ISDCFMetadata::as_xml (xmlpp::Node* root) const
{
root->add_child("ContentVersion")->add_child_text (raw_convert<string> (content_version));
- root->add_child("AudioLanguage")->add_child_text (audio_language);
root->add_child("Territory")->add_child_text (territory);
root->add_child("Rating")->add_child_text (rating);
root->add_child("Studio")->add_child_text (studio);
operator== (ISDCFMetadata const & a, ISDCFMetadata const & b)
{
return a.content_version == b.content_version &&
- a.audio_language == b.audio_language &&
a.territory == b.territory &&
a.rating == b.rating &&
a.studio == b.studio &&
void read_old_metadata (std::string, std::string);
int content_version;
- std::string audio_language;
std::string territory;
std::string rating;
std::string studio;
boost::algorithm::replace_all (text, "$CPL_NAME", film()->name());
boost::algorithm::replace_all (text, "$TYPE", film()->dcp_content_type()->pretty_name());
boost::algorithm::replace_all (text, "$CONTAINER", film()->container()->container_nickname());
- boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", film()->isdcf_metadata().audio_language);
+
+ auto audio_languages = film()->audio_languages();
+ if (!audio_languages.empty()) {
+ boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", audio_languages.front().description());
+ } else {
+ boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _("None"));
+ }
auto subtitle_languages = film()->subtitle_languages();
if (subtitle_languages.first) {
boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_languages.first->description());
} else {
- boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", "None");
+ boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", _("None"));
}
boost::uintmax_t size = 0;
*/
-#include "audio_panel.h"
-#include "audio_mapping_view.h"
-#include "wx_util.h"
-#include "gain_calculator_dialog.h"
-#include "content_panel.h"
+
#include "audio_dialog.h"
-#include "static_text.h"
+#include "audio_mapping_view.h"
+#include "audio_panel.h"
#include "check_box.h"
+#include "content_panel.h"
#include "dcpomatic_button.h"
+#include "gain_calculator_dialog.h"
+#include "language_tag_widget.h"
+#include "static_text.h"
+#include "wx_util.h"
#include "lib/config.h"
#include "lib/ffmpeg_audio_stream.h"
#include "lib/ffmpeg_content.h"
#include <wx/spinctrl.h>
#include <iostream>
+
using std::vector;
using std::cout;
using std::string;
using namespace boost::placeholders;
#endif
+
AudioPanel::AudioPanel (ContentPanel* p)
: ContentSubPanel (p, _("Audio"))
, _audio_dialog (0)
/// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
_delay_ms_label = create_label (this, _("ms"), false);
+ _enable_language = new wxCheckBox (this, wxID_ANY, _("Language"));
+ _language = new LanguageTagWidget (this, _("Language used for the dialogue in this content"), boost::none);
+
_mapping = new AudioMappingView (this, _("Content"), _("content"), _("DCP"), _("DCP"));
_sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6);
_reference->Bind (wxEVT_CHECKBOX, boost::bind (&AudioPanel::reference_clicked, this));
_show->Bind (wxEVT_BUTTON, boost::bind (&AudioPanel::show_clicked, this));
_gain_calculate_button->Bind (wxEVT_BUTTON, boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
+ _enable_language->Bind (wxEVT_CHECKBOX, boost::bind (&AudioPanel::enable_language_clicked, this));
+ _language->Changed.connect (boost::bind(&AudioPanel::language_changed, this));
_mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
_active_jobs_connection = JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&AudioPanel::active_jobs_changed, this, _1, _2));
add_label_to_sizer (_grid, _gain_label, true, wxGBPosition(r, 0));
{
auto s = new wxBoxSizer (wxHORIZONTAL);
- s->Add (_gain->wrapped(), 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
+ s->Add (_gain->wrapped(), 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
s->Add (_gain_db_label, 0, wxALIGN_CENTER_VERTICAL);
_grid->Add (s, wxGBPosition(r, 1));
}
add_label_to_sizer (_grid, _delay_label, true, wxGBPosition(r, 0));
auto s = new wxBoxSizer (wxHORIZONTAL);
- s->Add (_delay->wrapped(), 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
+ s->Add (_delay->wrapped(), 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
s->Add (_delay_ms_label, 0, wxALIGN_CENTER_VERTICAL);
_grid->Add (s, wxGBPosition(r, 1));
++r;
+
+ s = new wxBoxSizer (wxHORIZONTAL);
+ s->Add (_enable_language, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
+ s->Add (_language->sizer(), 1, wxALIGN_CENTER_VERTICAL | wxRIGHT);
+ _grid->Add (s, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND);
+ ++r;
}
AudioPanel::~AudioPanel ()
setup_sensitivity ();
} else if (property == ContentProperty::VIDEO_FRAME_RATE) {
setup_description ();
+ } else if (property == AudioContentProperty::LANGUAGE) {
+ if (ac.size() == 1 && ac.front()->audio->language()) {
+ _enable_language->SetValue (true);
+ _language->set (ac.front()->audio->language());
+ } else {
+ _enable_language->SetValue (false);
+ _language->set (boost::none);
+ }
}
}
film_content_changed (AudioContentProperty::STREAMS);
film_content_changed (AudioContentProperty::GAIN);
+ film_content_changed (AudioContentProperty::LANGUAGE);
film_content_changed (DCPContentProperty::REFERENCE_AUDIO);
setup_sensitivity ();
_mapping->Enable (sel.size() == 1);
_description->Enable (sel.size() == 1);
}
+
+ _language->enable (_enable_language->GetValue());
}
void
_audio_dialog = nullptr;
}
}
+
+
+void
+AudioPanel::enable_language_clicked ()
+{
+ setup_sensitivity ();
+ auto sel = _parent->selected_audio ();
+ if (sel.size() == 1) {
+ sel.front()->audio->set_language (_enable_language->GetValue() ? _language->get() : boost::none);
+ }
+}
+
+
+void
+AudioPanel::language_changed ()
+{
+ auto sel = _parent->selected_audio ();
+ if (sel.size() == 1) {
+ sel.front()->audio->set_language (_language->get());
+ }
+}
+
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/audio_mapping.h"
#include "content_sub_panel.h"
#include "content_widget.h"
+
class wxSpinCtrlDouble;
class wxButton;
class wxChoice;
class wxStaticText;
class AudioMappingView;
class AudioDialog;
+class LanguageTagWidget;
+
class AudioPanel : public ContentSubPanel
{
void setup_sensitivity ();
void reference_clicked ();
void add_to_grid ();
+ void enable_language_clicked ();
+ void language_changed ();
boost::optional<float> peak () const;
wxCheckBox* _reference;
wxStaticText* _delay_label;
wxStaticText* _delay_ms_label;
ContentSpinCtrl<AudioContent>* _delay;
+ wxCheckBox* _enable_language = nullptr;
+ LanguageTagWidget* _language = nullptr;
AudioMappingView* _mapping;
wxStaticText* _description;
AudioDialog* _audio_dialog;
break;
}
case Film::Property::ISDCF_METADATA:
- case Film::Property::SUBTITLE_LANGUAGES:
setup_dcp_name ();
break;
case Film::Property::VIDEO_FRAME_RATE:
DCPPanel::film_content_changed (int property)
{
if (property == AudioContentProperty::STREAMS ||
+ property == AudioContentProperty::LANGUAGE ||
property == TextContentProperty::USE ||
property == TextContentProperty::BURN ||
property == TextContentProperty::LANGUAGE ||
add (_("Content version"), true);
_content_version = add (new wxSpinCtrl (this, wxID_ANY));
- add (_("Audio Language (e.g. EN)"), true);
- _audio_language = add (new wxTextCtrl (this, wxID_ANY));
-
add (_("Territory (e.g. UK)"), true);
_territory = add (new wxTextCtrl (this, wxID_ANY));
_content_version->SetRange (1, 1024);
_content_version->SetValue (dm.content_version);
- _audio_language->SetValue (std_to_wx (dm.audio_language));
_territory->SetValue (std_to_wx (dm.territory));
_rating->SetValue (std_to_wx (dm.rating));
_studio->SetValue (std_to_wx (dm.studio));
ISDCFMetadata dm;
dm.content_version = _content_version->GetValue ();
- dm.audio_language = wx_to_std (_audio_language->GetValue ());
dm.territory = wx_to_std (_territory->GetValue ());
dm.rating = wx_to_std (_rating->GetValue ());
dm.studio = wx_to_std (_studio->GetValue ());
private:
wxSpinCtrl* _content_version;
- wxTextCtrl* _audio_language;
wxTextCtrl* _territory;
wxTextCtrl* _rating;
wxTextCtrl* _studio;
);
sizer->Add (_name_language->sizer(), 0, wxEXPAND);
- add_label_to_sizer (sizer, panel, _("Audio language"), true, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL);
- _audio_language = new LanguageTagWidget(
- panel,
- _("The main language that is spoken in the film's soundtrack"),
- film()->audio_language()
- );
- sizer->Add (_audio_language->sizer(), 0, wxEXPAND);
-
{
int flags = wxALIGN_TOP | wxRIGHT | wxTOP;
#ifdef __WXOSX__
_luminance_unit->Append (_("foot lambert"));
_name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1));
- _audio_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::audio_language_changed, this, _1));
_edit_release_territory->Bind (wxEVT_BUTTON, boost::bind(&SMPTEMetadataDialog::edit_release_territory, this));
_version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this));
_status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this));
film_changed (ChangeType::DONE, Film::Property::FACILITY);
film_changed (ChangeType::DONE, Film::Property::CONTENT_VERSIONS);
film_changed (ChangeType::DONE, Film::Property::LUMINANCE);
- film_changed (ChangeType::DONE, Film::Property::SUBTITLE_LANGUAGES);
setup_sensitivity ();
}
}
-void
-SMPTEMetadataDialog::audio_language_changed (dcp::LanguageTag tag)
-{
- film()->set_audio_language (tag);
-}
-
-
void
SMPTEMetadataDialog::edit_release_territory ()
{
std::vector<std::string> content_versions () const;
void set_content_versions (std::vector<std::string> v);
void name_language_changed (dcp::LanguageTag tag);
- void audio_language_changed (dcp::LanguageTag tag);
void edit_release_territory ();
void version_number_changed ();
void status_changed ();
void enable_facility_changed ();
LanguageTagWidget* _name_language;
- LanguageTagWidget* _audio_language;
wxCheckBox* _enable_release_territory;
/** The current release territory displayed in the UI; since we can't easily convert
* the string in _release_territory_text to a RegionSubtag we just store the RegionSubtag
-Subproject commit c488ee62e04b03b915dac49a258bd13d64f281e4
+Subproject commit 451d2a5f010df7b722475952e5a7a3db1d6d72e8
*/
+
/** @file test/isdcf_name_test.cc
* @brief Test creation of ISDCF names.
* @ingroup feature
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/film.h"
#include "lib/ratio.h"
#include "test.h"
#include <iostream>
+
using std::cout;
using std::shared_ptr;
+using std::make_shared;
+
BOOST_AUTO_TEST_CASE (isdcf_name_test)
{
film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
film->set_container (Ratio::from_id ("185"));
film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
+ auto audio = content_factory("test/data/sine_440.wav").front();
+ film->examine_and_add_content (audio);
+ BOOST_REQUIRE (!wait_for_jobs());
+ BOOST_REQUIRE (audio->audio);
+ audio->audio->set_language(dcp::LanguageTag("en-US"));
ISDCFMetadata m;
m.content_version = 1;
- m.audio_language = "EN";
m.territory = "UK";
m.rating = "PG";
m.studio = "ST";
m.facility = "FA";
film->set_isdcf_metadata (m);
film->set_interop (true);
- BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_MOS_2K_ST_20140704_FA_IOP_OV");
+ BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_10_2K_ST_20140704_FA_IOP_OV");
/* Check that specifying no audio language writes XX */
- m.audio_language = "";
+ audio->audio->set_language (boost::none);
film->set_isdcf_metadata (m);
- BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_XX-XX_UK-PG_MOS_2K_ST_20140704_FA_IOP_OV");
+ BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_XX-XX_UK-PG_10_2K_ST_20140704_FA_IOP_OV");
/* Test a long name and some different data */
film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
film->set_audio_channels (1);
film->set_resolution (Resolution::FOUR_K);
- shared_ptr<Content> text = content_factory("test/data/subrip.srt").front();
+ auto text = content_factory("test/data/subrip.srt").front();
BOOST_REQUIRE_EQUAL (text->text.size(), 1U);
text->text.front()->set_burn (true);
text->text.front()->set_language (dcp::LanguageTag("fr-FR"));
film->examine_and_add_content (text);
BOOST_REQUIRE (!wait_for_jobs());
m.content_version = 2;
- m.audio_language = "DE";
+ audio = content_factory("test/data/sine_440.wav").front();
+ film->examine_and_add_content (audio);
+ BOOST_REQUIRE (!wait_for_jobs());
+ BOOST_REQUIRE (audio->audio);
+ audio->audio->set_language (dcp::LanguageTag("de-DE"));
m.territory = "US";
m.rating = "R";
m.studio = "DI";
/* Test audio channel markup */
film->set_audio_channels (6);
- shared_ptr<FFmpegContent> sound (new FFmpegContent("test/data/sine_440.wav"));
+ auto sound = make_shared<FFmpegContent>("test/data/sine_440.wav");
film->examine_and_add_content (sound);
BOOST_REQUIRE (!wait_for_jobs());
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_10_4K_DI_20140704_PP_SMPTE_OV");