Add _sign_language property to Content.
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Sep 2022 18:44:23 +0000 (20:44 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 22 Dec 2022 23:12:00 +0000 (00:12 +0100)
src/lib/content.cc
src/lib/video_content.cc
src/lib/video_content.h
src/lib/video_type.cc [new file with mode: 0644]
src/lib/video_type.h [new file with mode: 0644]
src/lib/wscript
src/wx/content_advanced_dialog.cc
src/wx/content_advanced_dialog.h
src/wx/content_menu.cc

index e77a3638ca6f2d4d73deacf7b2fb3a97f5225b71..527cfab6c196b93cbbd5507e1fab3c55429880d8 100644 (file)
@@ -566,3 +566,4 @@ Content::changed () const
 
        return (write_time_changed || calculate_digest() != digest());
 }
+
index 9abb2b39483e2529b1896eee30e37c6a21aa198a..2472edd0924043a89ba22c2a5a6324e4d7a385cf 100644 (file)
@@ -52,6 +52,7 @@ int const VideoContentProperty::RANGE             = 7;
 int const VideoContentProperty::CUSTOM_RATIO      = 8;
 int const VideoContentProperty::CUSTOM_SIZE       = 9;
 int const VideoContentProperty::BURNT_SUBTITLE_LANGUAGE = 10;
+int const VideoContentProperty::TYPE              = 11;
 
 
 using std::cout;
@@ -76,6 +77,7 @@ VideoContent::VideoContent (Content* parent)
        : ContentPart (parent)
        , _use (true)
        , _length (0)
+       , _type(VideoType::MAIN)
        , _frame_type (VideoFrameType::TWO_D)
        , _yuv (true)
        , _fade_in (0)
@@ -108,6 +110,8 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
        _use = node->optional_bool_child("Use").get_value_or(true);
        _length = node->number_child<Frame> ("VideoLength");
 
+       _type = string_to_video_type(node->optional_string_child("VideoType").get_value_or("main"));
+
        if (version <= 34) {
                /* Snapshot of the VideoFrameType enum at version 34 */
                switch (node->number_child<int> ("VideoFrameType")) {
@@ -221,6 +225,10 @@ VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
                        throw JoinError (_("Content to be joined must have the same picture size."));
                }
 
+               if (c[i]->video->type() != ref->type()) {
+                       throw JoinError(_("Content to be joined must have the same video type."));
+               }
+
                if (c[i]->video->frame_type() != ref->frame_type()) {
                        throw JoinError (_("Content to be joined must have the same video frame type."));
                }
@@ -260,6 +268,7 @@ VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
 
        _use = ref->use ();
        _size = ref->size ();
+       _type = ref->type();
        _frame_type = ref->frame_type ();
        _crop = ref->requested_crop ();
        _custom_ratio = ref->custom_ratio ();
@@ -279,6 +288,7 @@ VideoContent::as_xml (xmlpp::Node* node) const
        node->add_child("VideoLength")->add_child_text (raw_convert<string> (_length));
        node->add_child("VideoWidth")->add_child_text (raw_convert<string> (_size.width));
        node->add_child("VideoHeight")->add_child_text (raw_convert<string> (_size.height));
+       node->add_child("VideoType")->add_child_text(video_type_to_string(_type));
        node->add_child("VideoFrameType")->add_child_text (video_frame_type_to_string (_frame_type));
        if (_sample_aspect_ratio) {
                node->add_child("SampleAspectRatio")->add_child_text (raw_convert<string> (_sample_aspect_ratio.get ()));
@@ -556,6 +566,13 @@ VideoContent::set_bottom_crop (int c)
 }
 
 
+void
+VideoContent::set_type(VideoType type)
+{
+       maybe_set(_type, type, VideoContentProperty::TYPE);
+}
+
+
 void
 VideoContent::set_frame_type (VideoFrameType t)
 {
index 25e43b0ebc8de4b37176e3dc90c38cfe26091013..864fa11aa87eb36262dcb95e7499dea64b514ef7 100644 (file)
@@ -31,6 +31,7 @@
 #include "user_property.h"
 #include "video_frame_type.h"
 #include "video_range.h"
+#include "video_type.h"
 #include "types.h"
 #include <dcp/language_tag.h>
 #include <boost/thread/mutex.hpp>
@@ -56,6 +57,7 @@ public:
        static int const CUSTOM_RATIO;
        static int const CUSTOM_SIZE;
        static int const BURNT_SUBTITLE_LANGUAGE;
+       static int const TYPE;
 };
 
 
@@ -90,6 +92,7 @@ public:
                return _size;
        }
 
+       void set_type(VideoType type);
        void set_frame_type (VideoFrameType);
 
        void set_crop (Crop crop);
@@ -112,6 +115,11 @@ public:
 
        void set_burnt_subtitle_language (boost::optional<dcp::LanguageTag> language);
 
+       VideoType type() const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _type;
+       }
+
        VideoFrameType frame_type () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _frame_type;
@@ -238,6 +246,7 @@ private:
        Frame _length;
        boost::optional<ColourConversion> _colour_conversion;
        dcp::Size _size;
+       VideoType _type;
        VideoFrameType _frame_type;
        Crop _crop;
        /** ratio to scale cropped image to (or none to guess); i.e. if set, scale to _custom_ratio:1 */
diff --git a/src/lib/video_type.cc b/src/lib/video_type.cc
new file mode 100644 (file)
index 0000000..64cac7e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+    Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+    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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "dcpomatic_assert.h"
+#include "video_type.h"
+#include <string>
+
+
+using std::string;
+
+
+string
+video_type_to_string(VideoType type)
+{
+       switch (type) {
+       case VideoType::MAIN:
+               return "main";
+       case VideoType::SIGN_LANGUAGE:
+               return "sign-language";
+       default:
+               DCPOMATIC_ASSERT(false);
+       }
+}
+
+
+VideoType
+string_to_video_type(string type)
+{
+       if (type == "main") {
+               return VideoType::MAIN;
+       } else if (type == "sign-language") {
+               return VideoType::SIGN_LANGUAGE;
+       }
+
+       DCPOMATIC_ASSERT(false);
+}
+
diff --git a/src/lib/video_type.h b/src/lib/video_type.h
new file mode 100644 (file)
index 0000000..ca19285
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+    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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_VIDEO_TYPE_H
+#define DCPOMATIC_VIDEO_TYPE_H
+
+
+#include <string>
+
+
+enum class VideoType
+{
+       MAIN,
+       SIGN_LANGUAGE,
+       COUNT
+};
+
+
+VideoType string_to_video_type(std::string type);
+std::string video_type_to_string(VideoType type);
+
+
+#endif
index 43ccead77669a74137113402ac2165d456c0e904..9d7e5abaef529fd74c274308b8d5ed2991acda41 100644 (file)
@@ -207,6 +207,7 @@ sources = """
           video_mxf_examiner.cc
           video_range.cc
           video_ring_buffers.cc
+          video_type.cc
           writer.cc
           zipper.cc
           """
index 35343d78d409b87bfde09ac1fb17dd596ff290cb..5153e0befefeb3c654f40d189a22ae6ed5bfd6a5 100644 (file)
@@ -105,6 +105,10 @@ ContentAdvancedDialog::ContentAdvancedDialog (wxWindow* parent, shared_ptr<Conte
        sizer->Add(_ignore_video, wxGBPosition(r, 0), wxGBSpan(1, 3));
        ++r;
 
+       _sign_language = new CheckBox(this, _("Video contains sign language"));
+       sizer->Add(_sign_language, wxGBPosition(r, 0), wxGBSpan(1, 3));
+       ++r;
+
        auto overall = new wxBoxSizer (wxVERTICAL);
        overall->Add (sizer, 1, wxALL, DCPOMATIC_DIALOG_BORDER);
        auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
@@ -136,6 +140,9 @@ ContentAdvancedDialog::ContentAdvancedDialog (wxWindow* parent, shared_ptr<Conte
        _burnt_subtitle->SetValue (_content->video && static_cast<bool>(_content->video->burnt_subtitle_language()));
        _burnt_subtitle_language->set (_content->video ? _content->video->burnt_subtitle_language() : boost::none);
 
+       _sign_language->Enable(static_cast<bool>(_content->video));
+       _sign_language->SetValue(_content->video ? (_content->video->type() == VideoType::SIGN_LANGUAGE) : false);
+
        _filters_button->Bind (wxEVT_BUTTON, bind(&ContentAdvancedDialog::edit_filters, this));
        _set_video_frame_rate->Bind (wxEVT_BUTTON, bind(&ContentAdvancedDialog::set_video_frame_rate, this));
        _video_frame_rate->Bind (wxEVT_TEXT, boost::bind(&ContentAdvancedDialog::video_frame_rate_changed, this));
@@ -145,6 +152,14 @@ ContentAdvancedDialog::ContentAdvancedDialog (wxWindow* parent, shared_ptr<Conte
 }
 
 
+VideoType
+ContentAdvancedDialog::video_type() const
+{
+       DCPOMATIC_ASSERT(_content->video);
+       return _sign_language->GetValue() ? VideoType::SIGN_LANGUAGE : VideoType::MAIN;
+}
+
+
 bool
 ContentAdvancedDialog::ignore_video() const
 {
index 517ad04e538426a73eac4068ef98a0b1b495e028..8f5080dfd87098c75bf32a02166f80b523c302c4 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 
+#include "lib/video_type.h"
 #include <dcp/language_tag.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -48,6 +49,7 @@ public:
 
        boost::optional<double> video_frame_rate() const;
        boost::optional<dcp::LanguageTag> burnt_subtitle_language() const;
+       VideoType video_type() const;
 
 private:
        void edit_filters ();
@@ -69,5 +71,6 @@ private:
        CheckBox* _burnt_subtitle;
        LanguageTagWidget* _burnt_subtitle_language;
        CheckBox* _ignore_video;
+       CheckBox* _sign_language;
 };
 
index 80976e5f678b80c5f152a33821d0d06fa10320c7..41ac70f20d66183ffc7a9c987e46e465effe48fc 100644 (file)
@@ -476,6 +476,7 @@ ContentMenu::advanced ()
        if (content->video) {
                content->video->set_use(!dialog->ignore_video());
                content->video->set_burnt_subtitle_language(dialog->burnt_subtitle_language());
+               content->video->set_type(dialog->video_type());
        }
 
        auto ffmpeg = dynamic_pointer_cast<FFmpegContent>(content);