Front-end to set up referencing of DCPs.
authorCarl Hetherington <cth@carlh.net>
Wed, 16 Sep 2015 09:31:18 +0000 (10:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 Sep 2015 09:31:18 +0000 (10:31 +0100)
src/lib/analyse_audio_job.cc
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/wx/audio_panel.cc
src/wx/audio_panel.h
src/wx/content_colour_conversion_dialog.h
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/video_panel.cc
src/wx/video_panel.h

index f0fd351b45c2223a5b4923fb1a7c05630c4cd654..525ac6c911d9940fb0eb09ece3c2a344cda3d7b0 100644 (file)
@@ -74,6 +74,7 @@ AnalyseAudioJob::run ()
        shared_ptr<Player> player (new Player (_film, _playlist));
        player->set_ignore_video ();
        player->set_fast ();
+       player->set_play_referenced ();
 
        DCPTime const start = _playlist->start().get_value_or (DCPTime ());
        DCPTime const length = _playlist->length ();
index 15bcd0b56096c03795c86b915416e37743e255fc..cb9dcf53d6dc184caaa47f098fb3954b2a3eec8a 100644 (file)
@@ -39,7 +39,10 @@ using std::list;
 using boost::shared_ptr;
 using boost::optional;
 
-int const DCPContentProperty::CAN_BE_PLAYED = 600;
+int const DCPContentProperty::CAN_BE_PLAYED      = 600;
+int const DCPContentProperty::REFERENCE_VIDEO    = 601;
+int const DCPContentProperty::REFERENCE_AUDIO    = 602;
+int const DCPContentProperty::REFERENCE_SUBTITLE = 603;
 
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
@@ -209,3 +212,36 @@ DCPContent::set_default_colour_conversion ()
        /* Default to no colour conversion for DCPs */
        unset_colour_conversion ();
 }
+
+void
+DCPContent::set_reference_video (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_video = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_VIDEO);
+}
+
+void
+DCPContent::set_reference_audio (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_audio = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_AUDIO);
+}
+
+void
+DCPContent::set_reference_subtitle (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_subtitle = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_SUBTITLE);
+}
index 5a0559df2212dd28d1a65a062c637bb62673990f..8f01bbc4e43e3331b1d9ea550425291676ba434f 100644 (file)
@@ -34,6 +34,9 @@ class DCPContentProperty
 {
 public:
        static int const CAN_BE_PLAYED;
+       static int const REFERENCE_VIDEO;
+       static int const REFERENCE_AUDIO;
+       static int const REFERENCE_SUBTITLE;
 };
 
 /** @class DCPContent
@@ -85,16 +88,22 @@ public:
 
        bool can_be_played () const;
 
+       void set_reference_video (bool r);
+
        bool reference_video () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _reference_video;
        }
 
+       void set_reference_audio (bool r);
+
        bool reference_audio () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _reference_audio;
        }
 
+       void set_reference_subtitle (bool r);
+
        bool reference_subtitle () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _reference_subtitle;
index b89cbb01fc34f7b1cc30ef3670a7ac7a6a78d3ef..a4976b8c1bca172e888692f0aff3f78c71c3d429 100644 (file)
@@ -27,6 +27,7 @@
 #include "lib/ffmpeg_content.h"
 #include "lib/cinema_sound_processor.h"
 #include "lib/job_manager.h"
+#include "lib/dcp_content.h"
 #include <wx/spinctrl.h>
 #include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
@@ -51,6 +52,10 @@ AudioPanel::AudioPanel (ContentPanel* p)
 
        int r = 0;
 
+       _reference = new wxCheckBox (this, wxID_ANY, _("Refer to existing DCP"));
+       grid->Add (_reference, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       ++r;
+
        {
                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                _show = new wxButton (this, wxID_ANY, _("Show graph of audio levels..."));
@@ -107,8 +112,9 @@ AudioPanel::AudioPanel (ContentPanel* p)
        _gain->wrapped()->SetIncrement (0.5);
        _delay->wrapped()->SetRange (-1000, 1000);
 
-       _show->Bind                  (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::show_clicked, this));
-       _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
+       _reference->Bind             (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AudioPanel::reference_clicked, this));
+       _show->Bind                  (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&AudioPanel::show_clicked, this));
+       _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
 
        _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
 
@@ -143,8 +149,8 @@ AudioPanel::film_changed (Film::Property property)
 void
 AudioPanel::film_content_changed (int property)
 {
+       AudioContentList ac = _parent->selected_audio ();
        if (property == AudioContentProperty::AUDIO_STREAMS) {
-               AudioContentList ac = _parent->selected_audio ();
                if (ac.size() == 1) {
                        _mapping->set (ac.front()->audio_mapping());
                        _mapping->set_input_channels (ac.front()->audio_channel_names ());
@@ -156,6 +162,15 @@ AudioPanel::film_content_changed (int property)
                _sizer->Layout ();
        } else if (property == AudioContentProperty::AUDIO_GAIN) {
                setup_peak ();
+       } else if (property == DCPContentProperty::REFERENCE_AUDIO) {
+               if (ac.size() == 1) {
+                       shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (ac.front ());
+                       checked_set (_reference, dcp ? dcp->reference_audio () : false);
+               } else {
+                       checked_set (_reference, false);
+               }
+
+               setup_sensitivity ();
        }
 }
 
@@ -214,10 +229,32 @@ AudioPanel::content_selection_changed ()
        _gain->set_content (sel);
        _delay->set_content (sel);
 
-       _gain_calculate_button->Enable (sel.size() == 1);
-       _mapping->Enable (sel.size() == 1);
-
        film_content_changed (AudioContentProperty::AUDIO_STREAMS);
+
+       setup_sensitivity ();
+}
+
+void
+AudioPanel::setup_sensitivity ()
+{
+       AudioContentList sel = _parent->selected_audio ();
+       _reference->Enable (sel.size() == 1 && dynamic_pointer_cast<DCPContent> (sel.front ()));
+
+       if (_reference->GetValue ()) {
+               _gain->wrapped()->Enable (false);
+               _gain_calculate_button->Enable (false);
+               _peak->Enable (false);
+               _delay->wrapped()->Enable (false);
+               _mapping->Enable (false);
+               _description->Enable (false);
+       } else {
+               _gain->wrapped()->Enable (true);
+               _gain_calculate_button->Enable (sel.size() == 1);
+               _peak->Enable (true);
+               _delay->wrapped()->Enable (true);
+               _mapping->Enable (sel.size() == 1);
+               _description->Enable (true);
+       }
 }
 
 void
@@ -280,3 +317,19 @@ AudioPanel::active_jobs_changed (optional<string> j)
                setup_peak ();
        }
 }
+
+void
+AudioPanel::reference_clicked ()
+{
+       ContentList c = _parent->selected ();
+       if (c.size() != 1) {
+               return;
+       }
+
+       shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
+       if (!d) {
+               return;
+       }
+
+       d->set_reference_audio (_reference->GetValue ());
+}
index 00b06442e75dc7a56ee9aeda498257f7ec75eb21..47deaf261e6777f5e48143b28674f401a495f3ed 100644 (file)
@@ -45,7 +45,10 @@ private:
        void setup_description ();
        void setup_peak ();
        void active_jobs_changed (boost::optional<std::string>);
+       void setup_sensitivity ();
+       void reference_clicked ();
 
+       wxCheckBox* _reference;
        wxButton* _show;
        ContentSpinCtrlDouble<AudioContent>* _gain;
        wxButton* _gain_calculate_button;
index 407f3f0c8b78dc885cc9533455bcf03f9cb9096e..f5687a060fccd8196227bcb570655f3170d3bd0b 100644 (file)
@@ -17,6 +17,7 @@
 
 */
 
+#include "lib/colour_conversion.h"
 #include <wx/wx.h>
 
 class ColourConversionEditor;
index 40a48a5a283496bcd2b7b6679c85de9459ef9467..d2f0e4c111e3b1f7e013c7654fd12140e7ad271d 100644 (file)
@@ -29,6 +29,7 @@
 #include "lib/dcp_subtitle_content.h"
 #include "lib/subrip_decoder.h"
 #include "lib/dcp_subtitle_decoder.h"
+#include "lib/dcp_content.h"
 #include <wx/spinctrl.h>
 #include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
@@ -47,6 +48,10 @@ SubtitlePanel::SubtitlePanel (ContentPanel* p)
        wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        _sizer->Add (grid, 0, wxALL, 8);
 
+       _reference = new wxCheckBox (this, wxID_ANY, _("Refer to existing DCP"));
+       grid->Add (_reference);
+       grid->AddSpacer (0);
+
        _use = new wxCheckBox (this, wxID_ANY, _("Use subtitles"));
        grid->Add (_use);
        grid->AddSpacer (0);
@@ -112,6 +117,7 @@ SubtitlePanel::SubtitlePanel (ContentPanel* p)
        _x_scale->SetRange (10, 1000);
        _y_scale->SetRange (10, 1000);
 
+       _reference->Bind            (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::reference_clicked, this));
        _use->Bind                  (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::use_toggled, this));
        _burn->Bind                 (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::burn_toggled, this));
        _x_offset->Bind             (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::x_offset_changed, this));
@@ -178,6 +184,15 @@ SubtitlePanel::film_content_changed (int property)
                checked_set (_y_scale, scs ? lrint (scs->subtitle_y_scale() * 100) : 100);
        } else if (property == SubtitleContentProperty::SUBTITLE_LANGUAGE) {
                checked_set (_language, scs ? scs->subtitle_language() : "");
+       } else if (property == DCPContentProperty::REFERENCE_SUBTITLE) {
+               if (scs) {
+                       shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (scs);
+                       checked_set (_reference, dcp ? dcp->reference_subtitle () : false);
+               } else {
+                       checked_set (_reference, false);
+               }
+
+               setup_sensitivity ();
        }
 }
 
@@ -227,17 +242,19 @@ SubtitlePanel::setup_sensitivity ()
                }
        }
 
-       _use->Enable (any_subs > 0);
+       bool const reference = _reference->GetValue ();
+
+       _use->Enable (!reference && any_subs > 0);
        bool const use = _use->GetValue ();
-       _burn->Enable (any_subs > 0 && use && image_subs == 0);
-       _x_offset->Enable (any_subs > 0 && use);
-       _y_offset->Enable (any_subs > 0 && use);
-       _x_scale->Enable (any_subs > 0 && use);
-       _y_scale->Enable (any_subs > 0 && use);
-       _language->Enable (any_subs > 0 && use);
-       _stream->Enable (ffmpeg_subs == 1);
-       _subtitle_view_button->Enable (subrip_or_dcp_subs == 1);
-       _fonts_dialog_button->Enable (subrip_or_dcp_subs == 1);
+       _burn->Enable (!reference && any_subs > 0 && use && image_subs == 0);
+       _x_offset->Enable (!reference && any_subs > 0 && use);
+       _y_offset->Enable (!reference && any_subs > 0 && use);
+       _x_scale->Enable (!reference && any_subs > 0 && use);
+       _y_scale->Enable (!reference && any_subs > 0 && use);
+       _language->Enable (!reference && any_subs > 0 && use);
+       _stream->Enable (!reference && ffmpeg_subs == 1);
+       _subtitle_view_button->Enable (!reference && subrip_or_dcp_subs == 1);
+       _fonts_dialog_button->Enable (!reference && subrip_or_dcp_subs == 1);
 }
 
 void
@@ -360,3 +377,19 @@ SubtitlePanel::fonts_dialog_clicked ()
        _fonts_dialog = new FontsDialog (this, c.front ());
        _fonts_dialog->Show ();
 }
+
+void
+SubtitlePanel::reference_clicked ()
+{
+       ContentList c = _parent->selected ();
+       if (c.size() != 1) {
+               return;
+       }
+
+       shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
+       if (!d) {
+               return;
+       }
+
+       d->set_reference_subtitle (_reference->GetValue ());
+}
index 04f21860fa684f78bdc79eccd58e03e3a55ed226..7eb9cd27e8aab4e6913048db6a97491e4e043f21 100644 (file)
@@ -44,9 +44,11 @@ private:
        void stream_changed ();
        void subtitle_view_clicked ();
        void fonts_dialog_clicked ();
+       void reference_clicked ();
 
        void setup_sensitivity ();
 
+       wxCheckBox* _reference;
        wxCheckBox* _use;
        wxCheckBox* _burn;
        wxSpinCtrl* _x_offset;
index 86a738bca16d66a412c1fcfc34b54e2bbf5af3e4..dd9bb58489dfadac1a6f93ac610c3c416db36fa2 100644 (file)
 
 */
 
+#include "filter_dialog.h"
+#include "video_panel.h"
+#include "wx_util.h"
+#include "content_colour_conversion_dialog.h"
+#include "content_widget.h"
+#include "content_panel.h"
 #include "lib/filter.h"
 #include "lib/ffmpeg_content.h"
 #include "lib/colour_conversion.h"
 #include "lib/util.h"
 #include "lib/ratio.h"
 #include "lib/frame_rate_change.h"
-#include "filter_dialog.h"
-#include "video_panel.h"
-#include "wx_util.h"
-#include "content_colour_conversion_dialog.h"
-#include "content_widget.h"
-#include "content_panel.h"
+#include "lib/dcp_content.h"
 #include <wx/spinctrl.h>
 #include <boost/foreach.hpp>
 #include <set>
@@ -76,6 +77,10 @@ VideoPanel::VideoPanel (ContentPanel* p)
 
        int r = 0;
 
+       _reference = new wxCheckBox (this, wxID_ANY, _("Refer to existing DCP"));
+       grid->Add (_reference, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       ++r;
+
        add_label_to_grid_bag_sizer (grid, this, _("Type"), true, wxGBPosition (r, 0));
        _frame_type = new ContentChoice<VideoContent, VideoFrameType> (
                this,
@@ -226,9 +231,10 @@ VideoPanel::VideoPanel (ContentPanel* p)
        _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this));
        _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this));
 
-       _filters_button->Bind                (wxEVT_COMMAND_BUTTON_CLICKED,  boost::bind (&VideoPanel::edit_filters_clicked, this));
-       _colour_conversion->Bind             (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::colour_conversion_changed, this));
-       _edit_colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,  boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
+       _reference->Bind                     (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&VideoPanel::reference_clicked, this));
+       _filters_button->Bind                (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&VideoPanel::edit_filters_clicked, this));
+       _colour_conversion->Bind             (wxEVT_COMMAND_CHOICE_SELECTED,  boost::bind (&VideoPanel::colour_conversion_changed, this));
+       _edit_colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
 }
 
 void
@@ -316,6 +322,15 @@ VideoPanel::film_content_changed (int property)
                } else {
                        _fade_out->clear ();
                }
+       } else if (property == DCPContentProperty::REFERENCE_VIDEO) {
+               if (vc.size() == 1) {
+                       shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (vc.front ());
+                       checked_set (_reference, dcp ? dcp->reference_video () : false);
+               } else {
+                       checked_set (_reference, false);
+               }
+
+               setup_sensitivity ();
        }
 }
 
@@ -396,28 +411,64 @@ void
 VideoPanel::content_selection_changed ()
 {
        VideoContentList video_sel = _parent->selected_video ();
-       FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg ();
-
-       bool const single = video_sel.size() == 1;
 
        _frame_type->set_content (video_sel);
        _left_crop->set_content (video_sel);
        _right_crop->set_content (video_sel);
        _top_crop->set_content (video_sel);
        _bottom_crop->set_content (video_sel);
-       _fade_in->Enable (!video_sel.empty ());
-       _fade_out->Enable (!video_sel.empty ());
        _scale->set_content (video_sel);
 
-       _colour_conversion->Enable (single && !video_sel.empty ());
-       _filters_button->Enable (single && !ffmpeg_sel.empty ());
-
        film_content_changed (VideoContentProperty::VIDEO_CROP);
        film_content_changed (VideoContentProperty::VIDEO_FRAME_RATE);
        film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
        film_content_changed (VideoContentProperty::VIDEO_FADE_IN);
        film_content_changed (VideoContentProperty::VIDEO_FADE_OUT);
        film_content_changed (FFmpegContentProperty::FILTERS);
+       film_content_changed (DCPContentProperty::REFERENCE_VIDEO);
+
+       setup_sensitivity ();
+}
+
+void
+VideoPanel::setup_sensitivity ()
+{
+       ContentList sel = _parent->selected ();
+       _reference->Enable (sel.size() == 1 && dynamic_pointer_cast<DCPContent> (sel.front ()));
+
+       if (_reference->GetValue ()) {
+               _frame_type->wrapped()->Enable (false);
+               _left_crop->wrapped()->Enable (false);
+               _right_crop->wrapped()->Enable (false);
+               _top_crop->wrapped()->Enable (false);
+               _bottom_crop->wrapped()->Enable (false);
+               _fade_in->Enable (false);
+               _fade_out->Enable (false);
+               _scale->wrapped()->Enable (false);
+               _description->Enable (false);
+               _filters->Enable (false);
+               _filters_button->Enable (false);
+               _colour_conversion->Enable (false);
+               _edit_colour_conversion_button->Enable (false);
+       } else {
+               VideoContentList video_sel = _parent->selected_video ();
+               FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg ();
+               bool const single = video_sel.size() == 1;
+
+               _frame_type->wrapped()->Enable (true);
+               _left_crop->wrapped()->Enable (true);
+               _right_crop->wrapped()->Enable (true);
+               _top_crop->wrapped()->Enable (true);
+               _bottom_crop->wrapped()->Enable (true);
+               _fade_in->Enable (!video_sel.empty ());
+               _fade_out->Enable (!video_sel.empty ());
+               _scale->wrapped()->Enable (true);
+               _description->Enable (true);
+               _filters->Enable (true);
+               _filters_button->Enable (single && !ffmpeg_sel.empty ());
+               _colour_conversion->Enable (single && !video_sel.empty ());
+               _edit_colour_conversion_button->Enable (true);
+       }
 }
 
 void
@@ -437,3 +488,19 @@ VideoPanel::fade_out_changed ()
                i->set_fade_out (_fade_out->get (vfr).frames_round (vfr));
        }
 }
+
+void
+VideoPanel::reference_clicked ()
+{
+       ContentList c = _parent->selected ();
+       if (c.size() != 1) {
+               return;
+       }
+
+       shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
+       if (!d) {
+               return;
+       }
+
+       d->set_reference_video (_reference->GetValue ());
+}
index b4b4c77662f1fcff662f8d1db2b986ffbef12580..1b59b4f100d75af14308ef54a8941f890a28e3aa 100644 (file)
@@ -45,6 +45,7 @@ public:
        void content_selection_changed ();
 
 private:
+       void reference_clicked ();
        void edit_filters_clicked ();
        void colour_conversion_changed ();
        void edit_colour_conversion_clicked ();
@@ -52,7 +53,9 @@ private:
        void fade_out_changed ();
 
        void setup_description ();
+       void setup_sensitivity ();
 
+       wxCheckBox* _reference;
        ContentChoice<VideoContent, VideoFrameType>*    _frame_type;
        ContentSpinCtrl<VideoContent>*                  _left_crop;
        ContentSpinCtrl<VideoContent>*                  _right_crop;