Support content version metadata (#782).
authorCarl Hetherington <cth@carlh.net>
Sat, 14 Dec 2019 23:47:53 +0000 (00:47 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 14 Dec 2019 23:47:53 +0000 (00:47 +0100)
src/lib/film.cc
src/lib/film.h
src/lib/writer.cc
src/wx/metadata_dialog.cc
src/wx/metadata_dialog.h

index f7fd96a01a35e4f405bb0f575ec9cb161092de03..2a50e8c81dd732d360cf2f93147c253d355b7942 100644 (file)
@@ -427,6 +427,7 @@ Film::metadata (bool with_content_paths) const
        BOOST_FOREACH (dcp::Rating i, _ratings) {
                i.as_xml (root->add_child("Rating"));
        }
+       root->add_child("ContentVersion")->add_child_text(_content_version);
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
@@ -570,6 +571,8 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                _ratings.push_back (dcp::Rating(i));
        }
 
+       _content_version = f.optional_string_child("ContentVersion").get_value_or("");
+
        list<string> notes;
        _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
@@ -1763,6 +1766,13 @@ Film::set_ratings (vector<dcp::Rating> r)
        _ratings = r;
 }
 
+void
+Film::set_content_version (string v)
+{
+       ChangeSignaller<Film> ch (this, CONTENT_VERSION);
+       _content_version = v;
+}
+
 optional<DCPTime>
 Film::marker (dcp::Marker type) const
 {
index 4c45c4ffc70efc1a22cbd1edf464c2c704c08112..68f8b5334a4f1ec9c6eaff5288d56aecae415d54 100644 (file)
@@ -239,7 +239,8 @@ public:
                UPLOAD_AFTER_MAKE_DCP,
                REENCODE_J2K,
                MARKERS,
-               RATINGS
+               RATINGS,
+               CONTENT_VERSION
        };
 
 
@@ -344,6 +345,10 @@ public:
                return _ratings;
        }
 
+       std::string content_version () const {
+               return _content_version;
+       }
+
        /* SET */
 
        void set_directory (boost::filesystem::path);
@@ -377,6 +382,7 @@ public:
        void set_marker (dcp::Marker type, dcpomatic::DCPTime time);
        void unset_marker (dcp::Marker type);
        void set_ratings (std::vector<dcp::Rating> r);
+       void set_content_version (std::string v);
 
        /** Emitted when some property has of the Film is about to change or has changed */
        mutable boost::signals2::signal<void (ChangeType, Property)> Change;
@@ -461,6 +467,7 @@ private:
        bool _user_explicit_video_frame_rate;
        std::map<dcp::Marker, dcpomatic::DCPTime> _markers;
        std::vector<dcp::Rating> _ratings;
+       std::string _content_version;
 
        int _state_version;
 
index 48f40334ab98825478545412a60d309da6ea98dd..cc645c8b07c82451428f352054dad25bfeec71e1 100644 (file)
@@ -561,6 +561,7 @@ Writer::finish ()
 
        cpl->set_metadata (meta);
        cpl->set_ratings (vector_to_list(_film->ratings()));
+       cpl->set_content_version_label_text (_film->content_version());
 
        shared_ptr<const dcp::CertificateChain> signer;
        if (_film->is_signed ()) {
index 339ff869cb2a6414c37bba1994fe01fc91a6067a..5462db6a45d45000fac6eb876fce2decc0b2754e 100644 (file)
@@ -73,6 +73,14 @@ MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> film)
                );
        sizer->Add (_ratings, 1, wxEXPAND);
 
+       add_label_to_sizer (sizer, this, _("Content version"), true);
+       _content_version = new wxTextCtrl (this, wxID_ANY);
+       sizer->Add (_content_version, 1, wxEXPAND);
+
+       shared_ptr<Film> f = _film.lock();
+       DCPOMATIC_ASSERT (f);
+       _content_version->SetValue (std_to_wx(f->content_version()));
+
        overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
@@ -82,6 +90,8 @@ MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> film)
 
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
+
+       _content_version->Bind (wxEVT_TEXT, boost::bind(&MetadataDialog::content_version_changed, this));
 }
 
 vector<dcp::Rating>
@@ -99,3 +109,11 @@ MetadataDialog::set_ratings (vector<dcp::Rating> r)
        DCPOMATIC_ASSERT (film);
        film->set_ratings (r);
 }
+
+void
+MetadataDialog::content_version_changed ()
+{
+       shared_ptr<Film> film = _film.lock ();
+       DCPOMATIC_ASSERT (film);
+       film->set_content_version (wx_to_std(_content_version->GetValue()));
+}
index 5c574a32bc23a94f14a7e640045674555515f0e8..892aa89dfb3ccd14dddc81c0a05a4d22ab40e415 100644 (file)
@@ -36,7 +36,9 @@ public:
 private:
        std::vector<dcp::Rating> ratings () const;
        void set_ratings (std::vector<dcp::Rating> r);
+       void content_version_changed ();
 
        boost::weak_ptr<Film> _film;
        EditableList<dcp::Rating, RatingDialog>* _ratings;
+       wxTextCtrl* _content_version;
 };