From 647771abdbbf52737278e59898063c799b64f22d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 00:07:40 +0200 Subject: Use a BOOST_FOREACH and remove an old #include. --- src/lib/dcp_content_type.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/dcp_content_type.cc b/src/lib/dcp_content_type.cc index 613ed15a5..9ff903231 100644 --- a/src/lib/dcp_content_type.cc +++ b/src/lib/dcp_content_type.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -24,7 +24,7 @@ #include "dcp_content_type.h" #include "dcpomatic_assert.h" -#include +#include #include "i18n.h" @@ -60,9 +60,9 @@ DCPContentType::setup_dcp_content_types () DCPContentType const * DCPContentType::from_isdcf_name (string n) { - for (vector::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) { - if ((*i)->isdcf_name() == n) { - return *i; + BOOST_FOREACH (DCPContentType const * i, _dcp_content_types) { + if (i->isdcf_name() == n) { + return i; } } -- cgit v1.2.3 From 5c64790793651e0647bf4eb2de899750d5b6da9a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 00:11:38 +0200 Subject: Add a getter for _standard in DCPContent. --- src/lib/dcp_content.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/lib') diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 65bed29bc..fb8d91781 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -144,6 +144,12 @@ public: return _content_kind; } + dcp::Standard standard () const { + boost::mutex::scoped_lock lm (_mutex); + DCPOMATIC_ASSERT (_standard); + return _standard.get (); + } + bool kdm_timing_window_valid () const; private: -- cgit v1.2.3 From f525fad0c38e198f35055e639184fa983a3d5d56 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 00:18:34 +0200 Subject: Add DCPContent::from_libdcp_kind. --- src/lib/dcp_content_type.cc | 14 ++++++++++++++ src/lib/dcp_content_type.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src/lib') diff --git a/src/lib/dcp_content_type.cc b/src/lib/dcp_content_type.cc index 9ff903231..4fedd366c 100644 --- a/src/lib/dcp_content_type.cc +++ b/src/lib/dcp_content_type.cc @@ -69,6 +69,20 @@ DCPContentType::from_isdcf_name (string n) return 0; } +DCPContentType const * +DCPContentType::from_libdcp_kind (dcp::ContentKind kind) +{ + BOOST_FOREACH (DCPContentType const * i, _dcp_content_types) { + if (i->libdcp_kind() == kind) { + return i; + } + } + + DCPOMATIC_ASSERT (false); + return 0; +} + + DCPContentType const * DCPContentType::from_index (int n) { diff --git a/src/lib/dcp_content_type.h b/src/lib/dcp_content_type.h index 2685e6edf..eea698217 100644 --- a/src/lib/dcp_content_type.h +++ b/src/lib/dcp_content_type.h @@ -51,6 +51,7 @@ public: } static DCPContentType const * from_isdcf_name (std::string); + static DCPContentType const * from_libdcp_kind (dcp::ContentKind); static DCPContentType const * from_index (int); static int as_index (DCPContentType const *); static std::vector all (); -- cgit v1.2.3 From 736745c86cefc6d5d4d8098799efc86f0f639061 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 02:10:35 +0200 Subject: Allow DCPContent to recover and serialise marker positions. --- src/lib/dcp_content.cc | 17 +++++++++++++- src/lib/dcp_content.h | 5 +++++ src/lib/dcp_examiner.cc | 9 +++++++- src/lib/dcp_examiner.h | 8 ++++++- test/import_dcp_test.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 95 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 52ac6132c..94d5c010b 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2018 Carl Hetherington + Copyright (C) 2014-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -49,6 +49,7 @@ using std::distance; using std::pair; using std::vector; using std::list; +using std::map; using boost::shared_ptr; using boost::scoped_ptr; using boost::optional; @@ -146,6 +147,10 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version) BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("ReelLength")) { _reel_lengths.push_back (raw_convert (i->content ())); } + + BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Marker")) { + _markers[dcp::marker_from_string(i->string_attribute("type"))] = ContentTime(raw_convert(i->content())); + } } void @@ -240,6 +245,10 @@ DCPContent::examine (shared_ptr film, shared_ptr job) _content_kind = examiner->content_kind (); _cpl = examiner->cpl (); _reel_lengths = examiner->reel_lengths (); + map markers = examiner->markers(); + for (map::const_iterator i = markers.begin(); i != markers.end(); ++i) { + _markers[i->first] = ContentTime(i->second.as_editable_units(DCPTime::HZ)); + } } if (old_texts == texts) { @@ -339,6 +348,12 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const BOOST_FOREACH (int64_t i, _reel_lengths) { node->add_child("ReelLength")->add_child_text (raw_convert (i)); } + + for (map::const_iterator i = _markers.begin(); i != _markers.end(); ++i) { + xmlpp::Element* marker = node->add_child("Marker"); + marker->set_attribute("type", dcp::marker_to_string(i->first)); + marker->add_child_text(raw_convert(i->second.get())); + } } DCPTime diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index fb8d91781..b9c4d9ee5 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -150,6 +150,10 @@ public: return _standard.get (); } + std::map markers () const { + return _markers; + } + bool kdm_timing_window_valid () const; private: @@ -198,6 +202,7 @@ private: boost::optional _cpl; /** List of the lengths of the reels in this DCP */ std::list _reel_lengths; + std::map _markers; }; #endif diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 9bf401125..a7d451eca 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ using std::list; using std::cout; using std::runtime_error; +using std::map; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -183,6 +185,11 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) _text_count[TEXT_CLOSED_CAPTION]++; } + if (i->main_markers ()) { + map rm = i->main_markers()->get(); + _markers.insert (rm.begin(), rm.end()); + } + if (i->main_picture()) { _reel_lengths.push_back (i->main_picture()->actual_duration()); } else if (i->main_sound()) { diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index e52234e36..c1ba54dee 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -25,6 +25,7 @@ #include "video_examiner.h" #include "audio_examiner.h" #include "dcp.h" +#include class DCPContent; @@ -118,6 +119,10 @@ public: return _reel_lengths; } + std::map markers () const { + return _markers; + } + private: boost::optional _video_frame_rate; boost::optional _video_size; @@ -140,4 +145,5 @@ private: dcp::ContentKind _content_kind; std::string _cpl; std::list _reel_lengths; + std::map _markers; }; diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index 16ebfa454..4c227ac34 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -35,12 +35,16 @@ #include "lib/job_manager.h" #include "lib/config.h" #include "lib/cross.h" +#include "lib/video_content.h" +#include "lib/content_factory.h" #include #include using std::vector; using std::string; +using std::map; using boost::shared_ptr; +using boost::dynamic_pointer_cast; /** Make an encrypted DCP, import it and make a new unencrypted DCP */ BOOST_AUTO_TEST_CASE (import_dcp_test) @@ -94,3 +98,57 @@ BOOST_AUTO_TEST_CASE (import_dcp_test) /* Should be 1s red, 1s green, 1s blue */ check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name()); } + + +/** Check that DCP markers are imported correctly */ +BOOST_AUTO_TEST_CASE (import_dcp_markers_test) +{ + /* Make a DCP with some markers */ + shared_ptr film = new_test_film2 ("import_dcp_markers_test"); + shared_ptr content = content_factory("test/data/flat_red.png").front(); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs()); + + content->video->set_length (24 * 60 * 10); + + film->set_marker(dcp::FFOC, dcpomatic::DCPTime::from_seconds(1.91)); + film->set_marker(dcp::FFMC, dcpomatic::DCPTime::from_seconds(9.4)); + film->set_marker(dcp::LFMC, dcpomatic::DCPTime::from_seconds(9.99)); + + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + /* Import the DCP to a new film and check the markers */ + shared_ptr film2 = new_test_film2 ("import_dcp_markers_test2"); + shared_ptr imported (new DCPContent(film->dir(film->dcp_name()))); + film2->examine_and_add_content (imported); + BOOST_REQUIRE (!wait_for_jobs()); + film2->write_metadata (); + + BOOST_CHECK_EQUAL (imported->markers().size(), 3); + + map markers = imported->markers(); + BOOST_REQUIRE(markers.find(dcp::FFOC) != markers.end()); + BOOST_CHECK(markers[dcp::FFOC] == dcpomatic::ContentTime(184000)); + BOOST_REQUIRE(markers.find(dcp::FFMC) != markers.end()); + BOOST_CHECK(markers[dcp::FFMC] == dcpomatic::ContentTime(904000)); + BOOST_REQUIRE(markers.find(dcp::LFMC) != markers.end()); + BOOST_CHECK(markers[dcp::LFMC] == dcpomatic::ContentTime(960000)); + + /* Load that film and check that the markers have been loaded */ + shared_ptr film3(new Film(boost::filesystem::path("build/test/import_dcp_markers_test2"))); + film3->read_metadata (); + BOOST_REQUIRE (film3->content().size() == 1); + shared_ptr reloaded = dynamic_pointer_cast(film3->content().front()); + BOOST_REQUIRE (reloaded); + + BOOST_CHECK_EQUAL (reloaded->markers().size(), 3); + + markers = reloaded->markers(); + BOOST_REQUIRE(markers.find(dcp::FFOC) != markers.end()); + BOOST_CHECK(markers[dcp::FFOC] == dcpomatic::ContentTime(184000)); + BOOST_REQUIRE(markers.find(dcp::FFMC) != markers.end()); + BOOST_CHECK(markers[dcp::FFMC] == dcpomatic::ContentTime(904000)); + BOOST_REQUIRE(markers.find(dcp::LFMC) != markers.end()); + BOOST_CHECK(markers[dcp::LFMC] == dcpomatic::ContentTime(960000)); +} -- cgit v1.2.3 From 142f7dee139074294d35c630ecee67b85e8a98fc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 23:02:48 +0200 Subject: Add Film::clear_markers(). --- src/lib/film.cc | 9 +++++++++ src/lib/film.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index ed2c5a372..a89d58a1f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1778,6 +1778,15 @@ Film::unset_marker (dcp::Marker type) _markers.erase (type); } + +void +Film::clear_markers () +{ + ChangeSignaller ch (this, MARKERS); + _markers.clear (); +} + + void Film::set_ratings (vector r) { diff --git a/src/lib/film.h b/src/lib/film.h index c4cd8bef1..86e9be6d9 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -381,6 +381,7 @@ public: void set_reencode_j2k (bool); void set_marker (dcp::Marker type, dcpomatic::DCPTime time); void unset_marker (dcp::Marker type); + void clear_markers (); void set_ratings (std::vector r); void set_content_version (std::string v); -- cgit v1.2.3 From 561eed2dc9978e890a020b6435ceb0333bb69a61 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 23:07:07 +0200 Subject: Add DCPContent::resolution(). --- src/lib/dcp_content.cc | 21 ++++++++++++++------- src/lib/dcp_content.h | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 94d5c010b..6c2db91d3 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -606,13 +606,8 @@ DCPContent::can_reference_video (shared_ptr film, string& why_not) c return false; } - Resolution video_res = RESOLUTION_2K; - if (video->size().width > 2048 || video->size().height > 1080) { - video_res = RESOLUTION_4K; - } - - if (film->resolution() != video_res) { - if (video_res == RESOLUTION_4K) { + if (film->resolution() != resolution()) { + if (resolution() == RESOLUTION_4K) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("it is 4K and the film is 2K."); } else { @@ -738,3 +733,15 @@ DCPContent::kdm_timing_window_valid () const dcp::LocalTime now; return _kdm->not_valid_before() < now && now < _kdm->not_valid_after(); } + + +Resolution +DCPContent::resolution () const +{ + if (video->size().width > 2048 || video->size().height > 1080) { + return RESOLUTION_4K; + } + + return RESOLUTION_2K; +} + diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index b9c4d9ee5..8658ac5ed 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -156,6 +156,8 @@ public: bool kdm_timing_window_valid () const; + Resolution resolution () const; + private: friend class reels_test5; -- cgit v1.2.3 From f5980767b7d1d9b39186dd13f12b9d8297a87aef Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 23:32:05 +0200 Subject: Add list_to_vector(). --- src/lib/util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib') diff --git a/src/lib/util.h b/src/lib/util.h index 12c79ea5a..f8e9409f1 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -128,6 +128,17 @@ vector_to_list (std::vector v) return l; } +template +std::vector +list_to_vector (std::list v) +{ + std::vector l; + BOOST_FOREACH (T& i, v) { + l.push_back (i); + } + return l; +} + extern double db_to_linear (double db); extern double linear_to_db (double linear); -- cgit v1.2.3 From 5f3a88d3ab1e9c1a13d7e61fc37a0c4cef8df9a5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 23:32:42 +0200 Subject: Allow DCP content to store and serialise metadata. --- src/lib/dcp_content.cc | 15 +++++++++++++++ src/lib/dcp_content.h | 10 ++++++++++ src/lib/dcp_examiner.cc | 3 +++ src/lib/dcp_examiner.h | 10 ++++++++++ test/import_dcp_test.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+) (limited to 'src/lib') diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 6c2db91d3..4280ad13a 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -151,6 +151,12 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version) BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Marker")) { _markers[dcp::marker_from_string(i->string_attribute("type"))] = ContentTime(raw_convert(i->content())); } + + BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Rating")) { + _ratings.push_back (dcp::Rating(i)); + } + + _content_version = node->optional_string_child("ContentVersion").get_value_or(""); } void @@ -249,6 +255,8 @@ DCPContent::examine (shared_ptr film, shared_ptr job) for (map::const_iterator i = markers.begin(); i != markers.end(); ++i) { _markers[i->first] = ContentTime(i->second.as_editable_units(DCPTime::HZ)); } + _ratings = examiner->ratings (); + _content_version = examiner->content_version (); } if (old_texts == texts) { @@ -354,6 +362,13 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const marker->set_attribute("type", dcp::marker_to_string(i->first)); marker->add_child_text(raw_convert(i->second.get())); } + + BOOST_FOREACH (dcp::Rating i, _ratings) { + xmlpp::Element* rating = node->add_child("Rating"); + i.as_xml (rating); + } + + node->add_child("ContentVersion")->add_child_text (_content_version); } DCPTime diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 8658ac5ed..6d707670f 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -158,6 +158,14 @@ public: Resolution resolution () const; + std::vector ratings () const { + return _ratings; + } + + std::string content_version () const { + return _content_version; + } + private: friend class reels_test5; @@ -205,6 +213,8 @@ private: /** List of the lengths of the reels in this DCP */ std::list _reel_lengths; std::map _markers; + std::vector _ratings; + std::string _content_version; }; #endif diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index a7d451eca..d04dacdd6 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -23,6 +23,7 @@ #include "exceptions.h" #include "image.h" #include "config.h" +#include "util.h" #include #include #include @@ -236,6 +237,8 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) _standard = cpl->standard().get(); _three_d = !cpl->reels().empty() && cpl->reels().front()->main_picture() && dynamic_pointer_cast (cpl->reels().front()->main_picture()->asset()); + _ratings = list_to_vector (cpl->ratings()); + _content_version = cpl->content_version_label_text (); _cpl = cpl->id (); } diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index c1ba54dee..21aa8d3ab 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -123,6 +123,14 @@ public: return _markers; } + std::vector ratings () const { + return _ratings; + } + + std::string content_version () const { + return _content_version; + } + private: boost::optional _video_frame_rate; boost::optional _video_size; @@ -146,4 +154,6 @@ private: std::string _cpl; std::list _reel_lengths; std::map _markers; + std::vector _ratings; + std::string _content_version; }; diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index 4c227ac34..83dd0c6de 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -152,3 +152,47 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) BOOST_REQUIRE(markers.find(dcp::LFMC) != markers.end()); BOOST_CHECK(markers[dcp::LFMC] == dcpomatic::ContentTime(960000)); } + + +/** Check that DCP metadata (ratings and content version) are imported correctly */ +BOOST_AUTO_TEST_CASE (import_dcp_metadata_test) +{ + /* Make a DCP with some ratings and a content version */ + shared_ptr film = new_test_film2 ("import_dcp_metadata_test"); + shared_ptr content = content_factory("test/data/flat_red.png").front(); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs()); + + content->video->set_length (10); + + std::vector ratings; + ratings.push_back (dcp::Rating("BBFC", "15")); + ratings.push_back (dcp::Rating("MPAA", "NC-17")); + film->set_ratings (ratings); + + film->set_content_version ("Fred"); + + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + /* Import the DCP to a new film and check the metadata */ + shared_ptr film2 = new_test_film2 ("import_dcp_metadata_test2"); + shared_ptr imported (new DCPContent(film->dir(film->dcp_name()))); + film2->examine_and_add_content (imported); + BOOST_REQUIRE (!wait_for_jobs()); + film2->write_metadata (); + + BOOST_CHECK (imported->ratings() == ratings); + BOOST_CHECK_EQUAL (imported->content_version(), "Fred"); + + /* Load that film and check that the metadata has been loaded */ + shared_ptr film3(new Film(boost::filesystem::path("build/test/import_dcp_metadata_test2"))); + film3->read_metadata (); + BOOST_REQUIRE (film3->content().size() == 1); + shared_ptr reloaded = dynamic_pointer_cast(film3->content().front()); + BOOST_REQUIRE (reloaded); + + BOOST_CHECK (reloaded->ratings() == ratings); + BOOST_CHECK_EQUAL (reloaded->content_version(), "Fred"); +} + -- cgit v1.2.3 From 4873cbc567d2c97c6587ab624e4c53abcd23cf23 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Apr 2020 23:33:33 +0200 Subject: Add code to copy the data and hook it up to a menu item. --- src/lib/copy_dcp_details_to_film.cc | 73 +++++++++++++++++++++++++++++++++++++ src/lib/copy_dcp_details_to_film.h | 26 +++++++++++++ src/lib/wscript | 1 + src/wx/content_menu.cc | 23 ++++++++++++ src/wx/content_menu.h | 2 + 5 files changed, 125 insertions(+) create mode 100644 src/lib/copy_dcp_details_to_film.cc create mode 100644 src/lib/copy_dcp_details_to_film.h (limited to 'src/lib') diff --git a/src/lib/copy_dcp_details_to_film.cc b/src/lib/copy_dcp_details_to_film.cc new file mode 100644 index 000000000..a009735fb --- /dev/null +++ b/src/lib/copy_dcp_details_to_film.cc @@ -0,0 +1,73 @@ +/* + Copyright (C) 2020 Carl Hetherington + + 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. + + 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 DCP-o-matic. If not, see . + +*/ + +#include "copy_dcp_details_to_film.h" +#include "dcp_content.h" +#include "film.h" +#include "types.h" +#include "video_content.h" +#include "audio_content.h" +#include "ratio.h" +#include "dcp_content_type.h" +#include +#include + +using std::map; +using std::string; +using boost::shared_ptr; + +void +copy_dcp_details_to_film (shared_ptr dcp, shared_ptr film) +{ + string name = dcp->name (); + name = name.substr (0, name.find("_")); + film->set_name (name); + film->set_use_isdcf_name (true); + if (dcp->content_kind()) { + film->set_dcp_content_type (DCPContentType::from_libdcp_kind(dcp->content_kind().get())); + } + film->set_encrypted (dcp->encrypted()); + film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT); + film->set_interop (dcp->standard() == dcp::INTEROP); + film->set_three_d (dcp->three_d()); + + if (dcp->video) { + film->set_container (Ratio::nearest_from_ratio(dcp->video->size().ratio())); + film->set_resolution (dcp->resolution()); + DCPOMATIC_ASSERT (dcp->video_frame_rate()); + film->set_video_frame_rate (*dcp->video_frame_rate()); + } + + if (dcp->audio) { + film->set_audio_channels (dcp->audio->stream()->channels()); + } + + map dcp_markers; + map film_markers; + film->clear_markers (); + for (map::const_iterator i = dcp_markers.begin(); i != dcp_markers.end(); ++i) { + film->set_marker (i->first, dcpomatic::DCPTime(i->second.get())); + } + + film->set_ratings (dcp->ratings()); + film->set_content_version (dcp->content_version()); +} + + diff --git a/src/lib/copy_dcp_details_to_film.h b/src/lib/copy_dcp_details_to_film.h new file mode 100644 index 000000000..38eb7fcc9 --- /dev/null +++ b/src/lib/copy_dcp_details_to_film.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2020 Carl Hetherington + + 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. + + 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 DCP-o-matic. If not, see . + +*/ + +#include + +class DCPContent; +class Film; + +extern void copy_dcp_details_to_film (boost::shared_ptr dcp, boost::shared_ptr film); diff --git a/src/lib/wscript b/src/lib/wscript index 67bcf8d8b..17f96d61e 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -52,6 +52,7 @@ sources = """ config.cc content.cc content_factory.cc + copy_dcp_details_to_film.cc create_cli.cc cross_common.cc crypto.cc diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 7cb924a73..d28253c6a 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -36,6 +36,7 @@ #include "lib/ffmpeg_content.h" #include "lib/audio_content.h" #include "lib/config.h" +#include "lib/copy_dcp_details_to_film.h" #include #include #include @@ -61,6 +62,7 @@ enum { ID_kdm, ID_ov, ID_choose_cpl, + ID_set_dcp_settings, ID_remove }; @@ -79,6 +81,7 @@ ContentMenu::ContentMenu (wxWindow* p) _ov = _menu->Append (ID_ov, _("Add OV...")); _cpl_menu = new wxMenu (); _choose_cpl = _menu->Append (ID_choose_cpl, _("Choose CPL..."), _cpl_menu); + _set_dcp_settings = _menu->Append (ID_set_dcp_settings, _("Set project DCP settings from this DCP")); _menu->AppendSeparator (); _remove = _menu->Append (ID_remove, _("Remove")); @@ -89,6 +92,7 @@ ContentMenu::ContentMenu (wxWindow* p) _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::re_examine, this), ID_re_examine); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::kdm, this), ID_kdm); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::ov, this), ID_ov); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::set_dcp_settings, this), ID_set_dcp_settings); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::remove, this), ID_remove); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::cpl_selected, this, _1), 1, ID_repeat - 1); } @@ -125,6 +129,7 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList if (dcp) { _kdm->Enable (dcp->encrypted ()); _ov->Enable (dcp->needs_assets ()); + _set_dcp_settings->Enable (static_cast(dcp)); try { DCPExaminer ex (dcp, true); list > cpls = ex.cpls (); @@ -153,9 +158,11 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _kdm->Enable (false); _ov->Enable (false); _choose_cpl->Enable (false); + _set_dcp_settings->Enable (false); } } else { _kdm->Enable (false); + _set_dcp_settings->Enable (false); } _remove->Enable (!_content.empty ()); @@ -165,6 +172,22 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _pop_up_open = false; } + +void +ContentMenu::set_dcp_settings () +{ + shared_ptr film = _film.lock (); + if (!film) { + return; + } + + DCPOMATIC_ASSERT (_content.size() == 1); + shared_ptr dcp = dynamic_pointer_cast(_content.front()); + DCPOMATIC_ASSERT (dcp); + copy_dcp_details_to_film (dcp, film); +} + + void ContentMenu::repeat () { diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h index a38109b07..fe8cbb56f 100644 --- a/src/wx/content_menu.h +++ b/src/wx/content_menu.h @@ -46,6 +46,7 @@ private: void re_examine (); void kdm (); void ov (); + void set_dcp_settings (); void remove (); void maybe_found_missing (boost::weak_ptr, boost::weak_ptr, boost::weak_ptr); void cpl_selected (wxCommandEvent& ev); @@ -66,6 +67,7 @@ private: wxMenuItem* _kdm; wxMenuItem* _ov; wxMenuItem* _choose_cpl; + wxMenuItem* _set_dcp_settings; wxMenuItem* _remove; }; -- cgit v1.2.3