Merge master.
authorCarl Hetherington <cth@carlh.net>
Wed, 3 Sep 2014 23:05:04 +0000 (00:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 3 Sep 2014 23:05:04 +0000 (00:05 +0100)
1  2 
ChangeLog
debian/changelog
platform/osx/make_dmg.sh
src/lib/film.cc
src/lib/ratio.cc
src/lib/ratio.h
src/tools/dcpomatic.cc
src/wx/dcp_panel.cc
src/wx/wx_util.cc

diff --combined ChangeLog
index bdfdadfef8e7eb7b072633771838ce766010999c,0fcb2da4dd0be53bddc211a2dca9f3f8e26c9080..ca321f9720eb0e0055b13ff470d1be2832051a10
+++ b/ChangeLog
@@@ -1,3 -1,19 +1,19 @@@
+ 2014-09-03  Carl Hetherington  <cth@carlh.net>
+       * Version 1.73.2 released.
+ 2014-09-03  Carl Hetherington  <cth@carlh.net>
+       * Fix server certificate downloads on OS X (#376).
+ 2014-09-02  Carl Hetherington  <cth@carlh.net>
+       * Improve behaviour of batch converter window when it is shrunk (#338).
+ 2014-09-01  Carl Hetherington  <cth@carlh.net>
+       * Version 1.73.1 released.
  2014-08-31  Carl Hetherington  <cth@carlh.net>
  
        * Remove configurable CPL <Creator> and use "DCP-o-matic (version) (git)"
  
  2014-08-29  Carl Hetherington  <cth@carlh.net>
  
 +      * Version 2.0.4 released.
 +
 +2014-08-24  Carl Hetherington  <cth@carlh.net>
 +
 +      * Version 2.0.3 released.
 +
 +2014-08-24  Carl Hetherington  <cth@carlh.net>
 +
 +      * Version 2.0.2 released.
 +
 +2014-08-06  Carl Hetherington  <cth@carlh.net>
 +
 +      * Version 2.0.1 released.
 +
 +2014-07-15  Carl Hetherington  <cth@carlh.net>
 +
 +      * A variety of changes were made on the 2.0 branch
 +      but not documented in the ChangeLog.  Most sigificantly:
 +
 +      - DCP import
 +      - Creation of DCPs with proper XML subtitles
 +      - Import of .srt and .xml subtitles
 +      - Audio processing framework (with some basic processors).
 +
 +2014-03-07  Carl Hetherington  <cth@carlh.net>
 +
 +      * Add subtitle view.
        * Some improvements to the manual.
  
  2014-08-26  Carl Hetherington  <cth@carlh.net>
@@@ -71,7 -60,6 +87,7 @@@
        * Attempt to fix random crashes on OS X (especially during encodes)
        thought to be caused by multiple threads using (different) stringstreams
        at the same time; see src/lib/safe_stringstream.
 +>>>>>>> origin/master
  
  2014-08-09  Carl Hetherington  <cth@carlh.net>
  
  2014-07-10  Carl Hetherington  <cth@carlh.net>
  
        * Version 1.72.2 released.
 +>>>>>>> origin/master
  
  2014-07-10  Carl Hetherington  <cth@carlh.net>
  
diff --combined debian/changelog
index a671a9e8dd38df8a602e17b626ab8b705cbb2b66,63e999b725830bf20f87c88253ed16826a7f3022..99cdc4f584e257115a9bf41656bfbcdd3a4f69b8
@@@ -1,8 -1,4 +1,4 @@@
- <<<<<<< HEAD
 -dcpomatic (1.73.2-1) UNRELEASED; urgency=low
 +dcpomatic (2.0.4-1) UNRELEASED; urgency=low
- =======
- dcpomatic (1.73.0-1) UNRELEASED; urgency=low
- >>>>>>> origin/master
  
    * New upstream release.
    * New upstream release.
    * New upstream release.
    * New upstream release.
    * New upstream release.
 -  * New upstream release.
 -  * New upstream release.
 -  * New upstream release.
 -  * New upstream release.
  
 - -- Carl Hetherington <carl@d1stkfactory>  Wed, 03 Sep 2014 23:36:54 +0100
 + -- Carl Hetherington <carl@d1stkfactory>  Fri, 29 Aug 2014 19:04:40 +0100
  
  dcpomatic (0.87-1) UNRELEASED; urgency=low
  
diff --combined platform/osx/make_dmg.sh
index 2e6b444b2960e6d00f760f0ba86766c8012eb471,52bff13494af84aef430ae3ef40a63d5b952239b..a14f3cf8c3ad41ccac515dd90c6b0aae0227ad78
@@@ -15,7 -15,7 +15,7 @@@ WORK=build/platform/os
  ENV=/Users/carl/Environments/osx/10.6
  ROOT=$1
  
 -appdir="DCP-o-matic.app"
 +appdir="DCP-o-matic 2.app"
  approot="$appdir/Contents"
  libs="$approot/lib"
  macos="$approot/MacOS"
@@@ -53,16 -53,16 +53,16 @@@ function universal_copy_lib 
      relink="$relink|$2"
  }
  
 -universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic "$WORK/$macos"
 -universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic_cli "$WORK/$macos"
 -universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic_server_cli "$WORK/$macos"
 -universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic_batch "$WORK/$macos"
 -universal_copy $ROOT src/dcpomatic/build/src/lib/libdcpomatic.dylib "$WORK/$libs"
 -universal_copy $ROOT src/dcpomatic/build/src/wx/libdcpomatic-wx.dylib "$WORK/$libs"
 +universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2 "$WORK/$macos"
 +universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_cli "$WORK/$macos"
 +universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_server_cli "$WORK/$macos"
 +universal_copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_batch "$WORK/$macos"
 +universal_copy $ROOT src/dcpomatic/build/src/lib/libdcpomatic2.dylib "$WORK/$libs"
 +universal_copy $ROOT src/dcpomatic/build/src/wx/libdcpomatic2-wx.dylib "$WORK/$libs"
  universal_copy_lib $ROOT libcxml "$WORK/$libs"
 -universal_copy_lib $ROOT libdcp "$WORK/$libs"
 -universal_copy_lib $ROOT libasdcp-libdcp "$WORK/$libs"
 -universal_copy_lib $ROOT libkumu-libdcp "$WORK/$libs"
 +universal_copy_lib $ROOT libdcp-1.0 "$WORK/$libs"
 +universal_copy_lib $ROOT libasdcp-libdcp-1.0 "$WORK/$libs"
 +universal_copy_lib $ROOT libkumu-libdcp-1.0 "$WORK/$libs"
  universal_copy_lib $ROOT libopenjpeg "$WORK/$libs"
  universal_copy_lib $ROOT libavdevice "$WORK/$libs"
  universal_copy_lib $ROOT libavformat "$WORK/$libs"
@@@ -108,11 -108,10 +108,11 @@@ universal_copy_lib $ENV libcairo "$WORK
  
  relink=`echo $relink | sed -e "s/\+//g"`
  
 -for obj in "$WORK/$macos/dcpomatic" "$WORK/$macos/dcpomatic_batch" "$WORK/$macos/dcpomatic_cli" "$WORK/$macos/dcpomatic_server_cli" "$WORK/$macos/ffprobe" "$WORK/$libs/"*.dylib; do
 +for obj in "$WORK/$macos/dcpomatic2" "$WORK/$macos/dcpomatic2_batch" "$WORK/$macos/dcpomatic2_cli" "$WORK/$macos/dcpomatic2_server_cli" "$WORK/$macos/ffprobe" "$WORK/$libs/"*.dylib; do
    deps=`otool -L "$obj" | awk '{print $1}' | egrep "($relink)" | egrep "($ENV|$ROOT|boost)"`
    changes=""
    for dep in $deps; do
 +      echo "Relinking $dep into $obj"
        base=`basename $dep`
        # $dep will be a path within 64/; make a 32/ path too
        dep32=`echo $dep | sed -e "s/\/64\//\/32\//g"`
@@@ -130,11 -129,10 +130,11 @@@ cp icons/defaults.png "$WORK/$resources
  cp icons/kdm_email.png "$WORK/$resources"
  cp icons/servers.png "$WORK/$resources"
  cp icons/tms.png "$WORK/$resources"
 +cp icons/keys.png "$WORK/$resources"
  
  # i18n: DCP-o-matic .mo files
  for lang in de_DE es_ES fr_FR it_IT sv_SE nl_NL; do
-   mkdir "$WORK/$resources/$lang/LC_MESSAGES"
+   mkdir -p "$WORK/$resources/$lang/LC_MESSAGES"
    cp build/src/lib/mo/$lang/*.mo "$WORK/$resources/$lang/LC_MESSAGES"
    cp build/src/wx/mo/$lang/*.mo "$WORK/$resources/$lang/LC_MESSAGES"
    cp build/src/tools/mo/$lang/*.mo "$WORK/$resources/$lang/LC_MESSAGES"
@@@ -171,7 -169,7 +171,7 @@@ echo 
             set theViewOptions to the icon view options of container window
             set arrangement of theViewOptions to not arranged
             set icon size of theViewOptions to 64
 -           set position of item "DCP-o-matic.app" of container window to {90, 80}
 +           set position of item "DCP-o-matic 2.app" of container window to {90, 80}
             set position of item "Applications" of container window to {310, 80}
             close
             open
diff --combined src/lib/film.cc
index 577c29e3a55afeb8a7c85e29883c2bf7c30bcff6,b4d12a062949ffe4a3ca2e49daed3c76a14b60bb..475dd68448628afba155ac59981b133f1b1e84f7
  #include <unistd.h>
  #include <boost/filesystem.hpp>
  #include <boost/algorithm/string.hpp>
 -#include <boost/date_time.hpp>
 +#include <boost/lexical_cast.hpp>
  #include <libxml++/libxml++.h>
  #include <libcxml/cxml.h>
 -#include <libdcp/signer_chain.h>
 -#include <libdcp/cpl.h>
 -#include <libdcp/signer.h>
 -#include <libdcp/util.h>
 -#include <libdcp/kdm.h>
 -#include <libdcp/raw_convert.h>
 +#include <dcp/cpl.h>
 +#include <dcp/signer.h>
 +#include <dcp/util.h>
 +#include <dcp/local_time.h>
 +#include <dcp/raw_convert.h>
  #include "film.h"
  #include "job.h"
  #include "util.h"
@@@ -76,10 -77,9 +76,10 @@@ using boost::ends_with
  using boost::starts_with;
  using boost::optional;
  using boost::is_any_of;
 -using libdcp::Size;
 -using libdcp::Signer;
 -using libdcp::raw_convert;
 +using dcp::Size;
 +using dcp::Signer;
 +using dcp::raw_convert;
 +using dcp::raw_convert;
  
  #define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
  #define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
   * Use <Scale> tag in <VideoContent> rather than <Ratio>.
   * 8 -> 9
   * DCI -> ISDCF
 + *
 + * Bumped to 32 for 2.0 branch; some times are expressed in Times rather
 + * than frames now.
   */
 -int const Film::current_state_version = 9;
 +int const Film::current_state_version = 32;
  
  /** Construct a Film object in a given directory.
   *
@@@ -110,6 -107,7 +110,6 @@@ Film::Film (boost::filesystem::path dir
        , _container (Config::instance()->default_container ())
        , _resolution (RESOLUTION_2K)
        , _scaler (Scaler::from_id ("bicubic"))
 -      , _with_subtitles (false)
        , _signed (true)
        , _encrypted (false)
        , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
        , _three_d (false)
        , _sequence_video (true)
        , _interop (false)
 +      , _burn_subtitles (false)
        , _state_version (current_state_version)
        , _dirty (false)
  {
@@@ -183,12 -180,12 +183,12 @@@ Film::video_identifier () cons
                s << "_S";
        }
  
 -      if (_three_d) {
 -              s << "_3D";
 +      if (_burn_subtitles) {
 +              s << "_B";
        }
  
 -      if (_with_subtitles) {
 -              s << "_WS";
 +      if (_three_d) {
 +              s << "_3D";
        }
  
        return s.str ();
@@@ -228,12 -225,6 +228,12 @@@ Film::audio_mxf_filename () cons
        return filename_safe_name() + "_audio.mxf";
  }
  
 +boost::filesystem::path
 +Film::subtitle_xml_filename () const
 +{
 +      return filename_safe_name() + "_subtitle.xml";
 +}
 +
  string
  Film::filename_safe_name () const
  {
@@@ -376,6 -367,7 +376,6 @@@ Film::metadata () cons
  
        root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution));
        root->add_child("Scaler")->add_child_text (_scaler->id ());
 -      root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0");
        root->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth));
        _isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata"));
        root->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate));
        root->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
        root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0");
        root->add_child("Interop")->add_child_text (_interop ? "1" : "0");
 +      root->add_child("BurnSubtitles")->add_child_text (_burn_subtitles ? "1" : "0");
        root->add_child("Signed")->add_child_text (_signed ? "1" : "0");
        root->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0");
        root->add_child("Key")->add_child_text (_key.hex ());
@@@ -448,6 -439,7 +448,6 @@@ Film::read_metadata (
  
        _resolution = string_to_resolution (f.string_child ("Resolution"));
        _scaler = Scaler::from_id (f.string_child ("Scaler"));
 -      _with_subtitles = f.bool_child ("WithSubtitles");
        _j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
        _video_frame_rate = f.number_child<int> ("VideoFrameRate");
        _signed = f.optional_bool_child("Signed").get_value_or (true);
        _sequence_video = f.bool_child ("SequenceVideo");
        _three_d = f.bool_child ("ThreeD");
        _interop = f.bool_child ("Interop");
 -      _key = libdcp::Key (f.string_child ("Key"));
 +      if (_state_version >= 32) {
 +              _burn_subtitles = f.bool_child ("BurnSubtitles");
 +      }
 +      _key = dcp::Key (f.string_child ("Key"));
  
        list<string> notes;
        /* This method is the only one that can return notes (so far) */
@@@ -591,18 -580,22 +591,22 @@@ Film::isdcf_name (bool if_created_now) 
                d << "_" << container()->isdcf_name();
        }
  
-       /* XXX: this only works for content which has been scaled to a given ratio,
-          and uses the first bit of content only.
-       */
+       /* XXX: this uses the first bit of content only */
  
        /* The standard says we don't do this for trailers, for some strange reason */
 -      if (dcp_content_type() && dcp_content_type()->libdcp_kind() != libdcp::TRAILER) {
 -              Ratio const * content_ratio = 0;
 +      if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) {
                ContentList cl = content ();
-               for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
 +              Ratio const * content_ratio = 0;
+               for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
                        shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
-                       if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) {
-                               content_ratio = vc->scale().ratio();
+                       if (vc) {
+                               /* Here's the first piece of video content */
+                               if (vc->scale().ratio ()) {
+                                       content_ratio = vc->scale().ratio ();
+                               } else {
+                                       content_ratio = Ratio::from_ratio (vc->video_size().ratio ());
+                               }
+                               break;
                        }
                }
                
@@@ -694,6 -687,7 +698,6 @@@ Film::dcp_name (bool if_created_now) co
        return name();
  }
  
 -
  void
  Film::set_directory (boost::filesystem::path d)
  {
@@@ -743,6 -737,13 +747,6 @@@ Film::set_scaler (Scaler const * s
        signal_changed (SCALER);
  }
  
 -void
 -Film::set_with_subtitles (bool w)
 -{
 -      _with_subtitles = w;
 -      signal_changed (WITH_SUBTITLES);
 -}
 -
  void
  Film::set_j2k_bandwidth (int b)
  {
@@@ -785,13 -786,6 +789,13 @@@ Film::set_interop (bool i
        signal_changed (INTEROP);
  }
  
 +void
 +Film::set_burn_subtitles (bool b)
 +{
 +      _burn_subtitles = b;
 +      signal_changed (BURN_SUBTITLES);
 +}
 +
  void
  Film::signal_changed (Property p)
  {
@@@ -873,7 -867,7 +877,7 @@@ Film::j2c_path (int f, Eyes e, bool t) 
        return file (p);
  }
  
 -/** Find all the DCPs in our directory that can be libdcp::DCP::read() and return details of their CPLs */
 +/** Find all the DCPs in our directory that can be dcp::DCP::read() and return details of their CPLs */
  vector<CPLSummary>
  Film::cpls () const
  {
                        ) {
  
                        try {
 -                              libdcp::DCP dcp (*i);
 +                              dcp::DCP dcp (*i);
                                dcp.read ();
                                out.push_back (
                                        CPLSummary (
 -                                              i->path().leaf().string(), dcp.cpls().front()->id(), dcp.cpls().front()->name(), dcp.cpls().front()->filename()
 +                                              i->path().leaf().string(),
 +                                              dcp.cpls().front()->id(),
 +                                              dcp.cpls().front()->annotation_text(),
 +                                              dcp.cpls().front()->file()
                                                )
                                        );
                        } catch (...) {
@@@ -938,13 -929,6 +942,13 @@@ Film::content () cons
        return _playlist->content ();
  }
  
 +void
 +Film::examine_content (shared_ptr<Content> c)
 +{
 +      shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
 +      JobManager::instance()->add (j);
 +}
 +
  void
  Film::examine_and_add_content (shared_ptr<Content> c)
  {
@@@ -1000,22 -984,22 +1004,22 @@@ Film::move_content_later (shared_ptr<Co
        _playlist->move_later (c);
  }
  
 -Time
 +DCPTime
  Film::length () const
  {
        return _playlist->length ();
  }
  
 -bool
 -Film::has_subtitles () const
 +int
 +Film::best_video_frame_rate () const
  {
 -      return _playlist->has_subtitles ();
 +      return _playlist->best_dcp_frame_rate ();
  }
  
 -OutputVideoFrame
 -Film::best_video_frame_rate () const
 +FrameRateChange
 +Film::active_frame_rate_change (DCPTime t) const
  {
 -      return _playlist->best_dcp_frame_rate ();
 +      return _playlist->active_frame_rate_change (t, video_frame_rate ());
  }
  
  void
@@@ -1036,7 -1020,31 +1040,7 @@@ Film::playlist_changed (
        signal_changed (CONTENT);
  }     
  
 -OutputAudioFrame
 -Film::time_to_audio_frames (Time t) const
 -{
 -      return divide_with_round (t * audio_frame_rate (), TIME_HZ);
 -}
 -
 -OutputVideoFrame
 -Film::time_to_video_frames (Time t) const
 -{
 -      return divide_with_round (t * video_frame_rate (), TIME_HZ);
 -}
 -
 -Time
 -Film::audio_frames_to_time (OutputAudioFrame f) const
 -{
 -      return divide_with_round (f * TIME_HZ, audio_frame_rate ());
 -}
 -
 -Time
 -Film::video_frames_to_time (OutputVideoFrame f) const
 -{
 -      return divide_with_round (f * TIME_HZ, video_frame_rate ());
 -}
 -
 -OutputAudioFrame
 +int
  Film::audio_frame_rate () const
  {
        /* XXX */
@@@ -1052,62 -1060,61 +1056,62 @@@ Film::set_sequence_video (bool s
  }
  
  /** @return Size of the largest possible image in whatever resolution we are using */
 -libdcp::Size
 +dcp::Size
  Film::full_frame () const
  {
        switch (_resolution) {
        case RESOLUTION_2K:
 -              return libdcp::Size (2048, 1080);
 +              return dcp::Size (2048, 1080);
        case RESOLUTION_4K:
 -              return libdcp::Size (4096, 2160);
 +              return dcp::Size (4096, 2160);
        }
  
        assert (false);
 -      return libdcp::Size ();
 +      return dcp::Size ();
  }
  
  /** @return Size of the frame */
 -libdcp::Size
 +dcp::Size
  Film::frame_size () const
  {
 -      return fit_ratio_within (container()->ratio(), full_frame ());
 +      return fit_ratio_within (container()->ratio(), full_frame (), 1);
  }
  
 -/** @param from KDM from time in local time.
 - *  @param to KDM to time in local time.
 - */
 -libdcp::KDM
 +dcp::EncryptedKDM
  Film::make_kdm (
 -      shared_ptr<libdcp::Certificate> target,
 +      dcp::Certificate target,
        boost::filesystem::path cpl_file,
 -      boost::posix_time::ptime from,
 -      boost::posix_time::ptime until,
 -      libdcp::KDM::Formulation formulation
 +      dcp::LocalTime from,
 +      dcp::LocalTime until,
 +      dcp::Formulation formulation
        ) const
  {
 -      shared_ptr<const Signer> signer = make_signer ();
 -
 -      time_t now = time (0);
 -      struct tm* tm = localtime (&now);
 -      string const issue_date = libdcp::tm_to_string (tm);
 +      shared_ptr<const dcp::CPL> cpl (new dcp::CPL (cpl_file));
 +      shared_ptr<const dcp::Signer> signer = Config::instance()->signer();
 +      if (!signer->valid ()) {
 +              throw InvalidSignerError ();
 +      }
        
 -      return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date, formulation);
 +      return dcp::DecryptedKDM (
 +              cpl, key(), from, until, "DCP-o-matic", cpl->content_title_text(), dcp::LocalTime().as_string()
 +              ).encrypt (signer, target, formulation);
  }
  
 -list<libdcp::KDM>
 +list<dcp::EncryptedKDM>
  Film::make_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path dcp,
 -      boost::posix_time::ptime from,
 -      boost::posix_time::ptime until,
 -      libdcp::KDM::Formulation formulation
 +      dcp::LocalTime from,
 +      dcp::LocalTime until,
 +      dcp::Formulation formulation
        ) const
  {
 -      list<libdcp::KDM> kdms;
 +      list<dcp::EncryptedKDM> kdms;
  
        for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
 -              kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation));
 +              if ((*i)->certificate) {
 +                      kdms.push_back (make_kdm ((*i)->certificate.get(), dcp, from, until, formulation));
 +              }
        }
  
        return kdms;
  uint64_t
  Film::required_disk_space () const
  {
 -      return uint64_t (j2k_bandwidth() / 8) * length() / TIME_HZ;
 +      return uint64_t (j2k_bandwidth() / 8) * length().seconds();
  }
  
  /** This method checks the disk that the Film is on and tries to decide whether or not
@@@ -1137,3 -1144,10 +1141,3 @@@ Film::should_be_enough_disk_space (doub
        available = double (s.available) / 1073741824.0f;
        return (available - required) > 1;
  }
 -
 -FrameRateChange
 -Film::active_frame_rate_change (Time t) const
 -{
 -      return _playlist->active_frame_rate_change (t, video_frame_rate ());
 -}
 -
diff --combined src/lib/ratio.cc
index bb69636584167d12b19d358e99d5a25193394d76,554d3c36c6c551f93e30b0d1305de5f94b9cdde4..fc36415c50638e161e73c8bd1df1ed19d3e01e99
@@@ -17,7 -17,7 +17,7 @@@
  
  */
  
 -#include <libdcp/types.h>
 +#include <dcp/types.h>
  #include "ratio.h"
  #include "util.h"
  
@@@ -56,3 -56,20 +56,20 @@@ Ratio::from_id (string i
  
        return *j;
  }
+ /** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */
+ Ratio const *
+ Ratio::from_ratio (float r)
+ {
+       vector<Ratio const *>::iterator j = _ratios.begin ();
+       while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) {
+               ++j;
+       }
+       if (j == _ratios.end ()) {
+               return 0;
+       }
+       return *j;
+ }
+    
diff --combined src/lib/ratio.h
index 22fc7662c9c9cf28d2a625d45256f8cfcaf789a7,ab157a9bcb4a65404d1531973d02fbd61d39ec76..69e3726c83f201e91cf48e5b955e215c6eea8d2c
@@@ -22,7 -22,7 +22,7 @@@
  
  #include <vector>
  #include <boost/utility.hpp>
 -#include <libdcp/util.h>
 +#include <dcp/util.h>
  
  class Ratio : public boost::noncopyable
  {
@@@ -52,6 -52,7 +52,7 @@@ public
  
        static void setup_ratios ();
        static Ratio const * from_id (std::string i);
+       static Ratio const * from_ratio (float r);
        static std::vector<Ratio const *> all () {
                return _ratios;
        }
diff --combined src/tools/dcpomatic.cc
index 8763e35cb2abc2e2000323c2dd06ba62787f0595,6b7ad027303392c638fffc043916150ef2b266d8..3bef7bce300f663be2ca9340f7e8d4f9313d6dab
@@@ -30,7 -30,7 +30,7 @@@
  #include <wx/stdpaths.h>
  #include <wx/cmdline.h>
  #include <wx/preferences.h>
 -#include <libdcp/exceptions.h>
 +#include <dcp/exceptions.h>
  #include "wx/film_viewer.h"
  #include "wx/film_editor.h"
  #include "wx/job_manager_view.h"
@@@ -45,7 -45,6 +45,7 @@@
  #include "wx/servers_list_dialog.h"
  #include "wx/hints_dialog.h"
  #include "wx/update_dialog.h"
 +#include "wx/content_panel.h"
  #include "lib/film.h"
  #include "lib/config.h"
  #include "lib/util.h"
@@@ -403,7 -402,7 +403,7 @@@ private
                                        shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
                                        );
                        }
 -              } catch (libdcp::NotEncryptedError& e) {
 +              } catch (dcp::NotEncryptedError& e) {
                        error_dialog (this, _("CPL's content is not encrypted."));
                } catch (exception& e) {
                        error_dialog (this, e.what ());
  
        void content_scale_to_fit_width ()
        {
 -              VideoContentList vc = _film_editor->selected_video_content ();
 +              VideoContentList vc = _film_editor->content_panel()->selected_video ();
                for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
                        (*i)->scale_and_crop_to_fit_width ();
                }
  
        void content_scale_to_fit_height ()
        {
 -              VideoContentList vc = _film_editor->selected_video_content ();
 +              VideoContentList vc = _film_editor->content_panel()->selected_video ();
                for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
                        (*i)->scale_and_crop_to_fit_height ();
                }
                }
                bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
                bool const have_cpl = _film && !_film->cpls().empty ();
 -              bool const have_selected_video_content = !_film_editor->selected_video_content().empty();
 +              bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
                
                for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
                        
@@@ -694,9 -693,6 +694,9 @@@ static const wxCmdLineEntryDesc command
        { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
  };
  
 +/** @class App
 + *  @brief The magic App class for wxWidgets.
 + */
  class App : public wxApp
  {
        bool OnInit ()
                return true;
        }
  
+       /* An unhandled exception has occurred inside the main event loop */
        bool OnExceptionInMainLoop ()
        {
-               error_dialog (0, _("An unknown exception occurred.  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
+               try {
+                       throw;
+               } catch (exception& e) {
+                       error_dialog (0, wxString::Format (_("An exception occurred (%s).  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."), e.what ()));
+               } catch (...) {
+                       error_dialog (0, _("An unknown exception occurred.  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
+               }
+               /* This will terminate the program */
                return false;
        }
-               
+       
        void OnUnhandledException ()
        {
                error_dialog (0, _("An unknown exception occurred.  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
diff --combined src/wx/dcp_panel.cc
index ce02c46c8663296b5752da7e0768b008962dc4d0,0000000000000000000000000000000000000000..d68edefc897c0d6e9d3031a59dfe87b0d7e2d904
mode 100644,000000..100644
--- /dev/null
@@@ -1,624 -1,0 +1,626 @@@
-       if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::USE_SUBTITLES) {
 +/*
 +    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 +
 +    This program 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.
 +
 +    This program 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 this program; if not, write to the Free Software
 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 +
 +*/
 +
 +#include "dcp_panel.h"
 +#include "wx_util.h"
 +#include "isdcf_metadata_dialog.h"
 +#include "lib/ratio.h"
 +#include "lib/scaler.h"
 +#include "lib/config.h"
 +#include "lib/dcp_content_type.h"
 +#include "lib/util.h"
 +#include "lib/film.h"
 +#include "lib/ffmpeg_content.h"
 +#include <wx/wx.h>
 +#include <wx/notebook.h>
 +#include <wx/gbsizer.h>
 +#include <wx/spinctrl.h>
 +#include <boost/lexical_cast.hpp>
 +
 +using std::cout;
 +using std::list;
 +using std::string;
 +using std::vector;
 +using boost::lexical_cast;
 +using boost::shared_ptr;
 +
 +DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
 +      : _film (f)
 +      , _generally_sensitive (true)
 +{
 +      _panel = new wxPanel (n);
 +      _sizer = new wxBoxSizer (wxVERTICAL);
 +      _panel->SetSizer (_sizer);
 +
 +      wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
 +      _sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
 +
 +      int r = 0;
 +      
 +      add_label_to_grid_bag_sizer (grid, _panel, _("Name"), true, wxGBPosition (r, 0));
 +      _name = new wxTextCtrl (_panel, wxID_ANY);
 +      grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
 +      ++r;
 +      
 +      add_label_to_grid_bag_sizer (grid, _panel, _("DCP Name"), true, wxGBPosition (r, 0));
 +      _dcp_name = new wxStaticText (_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
 +      grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxEXPAND);
 +      ++r;
 +
 +      int flags = wxALIGN_CENTER_VERTICAL;
 +#ifdef __WXOSX__
 +      flags |= wxALIGN_RIGHT;
 +#endif        
 +
 +      _use_isdcf_name = new wxCheckBox (_panel, wxID_ANY, _("Use ISDCF name"));
 +      grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
 +      _edit_isdcf_button = new wxButton (_panel, wxID_ANY, _("Details..."));
 +      grid->Add (_edit_isdcf_button, wxGBPosition (r, 1));
 +      ++r;
 +
 +      add_label_to_grid_bag_sizer (grid, _panel, _("Content Type"), true, wxGBPosition (r, 0));
 +      _dcp_content_type = new wxChoice (_panel, wxID_ANY);
 +      grid->Add (_dcp_content_type, wxGBPosition (r, 1));
 +      ++r;
 +
 +      _notebook = new wxNotebook (_panel, wxID_ANY);
 +      _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
 +
 +      _notebook->AddPage (make_video_panel (), _("Video"), false);
 +      _notebook->AddPage (make_audio_panel (), _("Audio"), false);
 +      
 +      _signed = new wxCheckBox (_panel, wxID_ANY, _("Signed"));
 +      grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
 +      ++r;
 +      
 +      _encrypted = new wxCheckBox (_panel, wxID_ANY, _("Encrypted"));
 +      grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
 +      ++r;
 +
 +      add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
 +      _standard = new wxChoice (_panel, wxID_ANY);
 +      grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
 +      ++r;
 +
 +      _name->Bind             (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&DCPPanel::name_changed, this));
 +      _use_isdcf_name->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
 +      _edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::edit_isdcf_button_clicked, this));
 +      _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::dcp_content_type_changed, this));
 +      _signed->Bind           (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::signed_toggled, this));
 +      _encrypted->Bind        (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::encrypted_toggled, this));
 +      _standard->Bind         (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::standard_changed, this));
 +
 +      vector<DCPContentType const *> const ct = DCPContentType::all ();
 +      for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
 +              _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
 +      }
 +
 +      _standard->Append (_("SMPTE"));
 +      _standard->Append (_("Interop"));
 +
 +      Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
 +}
 +
 +void
 +DCPPanel::name_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_name (string (_name->GetValue().mb_str()));
 +}
 +
 +void
 +DCPPanel::j2k_bandwidth_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +      
 +      _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
 +}
 +
 +void
 +DCPPanel::signed_toggled ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_signed (_signed->GetValue ());
 +}
 +
 +void
 +DCPPanel::burn_subtitles_toggled ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_burn_subtitles (_burn_subtitles->GetValue ());
 +}
 +
 +void
 +DCPPanel::encrypted_toggled ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_encrypted (_encrypted->GetValue ());
 +}
 +                             
 +/** Called when the frame rate choice widget has been changed */
 +void
 +DCPPanel::frame_rate_choice_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_video_frame_rate (
 +              boost::lexical_cast<int> (
 +                      wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
 +                      )
 +              );
 +}
 +
 +/** Called when the frame rate spin widget has been changed */
 +void
 +DCPPanel::frame_rate_spin_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
 +}
 +
 +void
 +DCPPanel::audio_channels_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_audio_channels (_audio_channels->GetValue ());
 +}
 +
 +void
 +DCPPanel::resolution_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
 +}
 +
 +void
 +DCPPanel::standard_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_interop (_standard->GetSelection() == 1);
 +}
 +
 +void
 +DCPPanel::film_changed (int p)
 +{
 +      switch (p) {
 +      case Film::NONE:
 +              break;
 +      case Film::CONTAINER:
 +              setup_container ();
 +              break;
 +      case Film::NAME:
 +              checked_set (_name, _film->name());
 +              setup_dcp_name ();
 +              break;
 +      case Film::DCP_CONTENT_TYPE:
 +              checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
 +              setup_dcp_name ();
 +              break;
 +      case Film::SCALER:
 +              checked_set (_scaler, Scaler::as_index (_film->scaler ()));
 +              break;
 +      case Film::BURN_SUBTITLES:
 +              checked_set (_burn_subtitles, _film->burn_subtitles ());
 +              break;
 +      case Film::SIGNED:
 +              checked_set (_signed, _film->is_signed ());
 +              break;
 +      case Film::ENCRYPTED:
 +              checked_set (_encrypted, _film->encrypted ());
 +              if (_film->encrypted ()) {
 +                      _film->set_signed (true);
 +                      _signed->Enable (false);
 +              } else {
 +                      _signed->Enable (_generally_sensitive);
 +              }
 +              break;
 +      case Film::RESOLUTION:
 +              checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
 +              setup_dcp_name ();
 +              break;
 +      case Film::J2K_BANDWIDTH:
 +              checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
 +              break;
 +      case Film::USE_ISDCF_NAME:
 +              checked_set (_use_isdcf_name, _film->use_isdcf_name ());
 +              setup_dcp_name ();
 +              break;
 +      case Film::ISDCF_METADATA:
 +              setup_dcp_name ();
 +              break;
 +      case Film::VIDEO_FRAME_RATE:
 +      {
 +              bool done = false;
 +              for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
 +                      if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
 +                              checked_set (_frame_rate_choice, i);
 +                              done = true;
 +                              break;
 +                      }
 +              }
 +
 +              if (!done) {
 +                      checked_set (_frame_rate_choice, -1);
 +              }
 +
 +              _frame_rate_spin->SetValue (_film->video_frame_rate ());
 +
 +              _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
 +              break;
 +      }
 +      case Film::AUDIO_CHANNELS:
 +              checked_set (_audio_channels, _film->audio_channels ());
 +              setup_dcp_name ();
 +              break;
 +      case Film::THREE_D:
 +              checked_set (_three_d, _film->three_d ());
 +              setup_dcp_name ();
 +              break;
 +      case Film::INTEROP:
 +              checked_set (_standard, _film->interop() ? 1 : 0);
 +              break;
 +      default:
 +              break;
 +      }
 +}
 +
 +void
 +DCPPanel::film_content_changed (int property)
 +{
++      if (property == FFmpegContentProperty::AUDIO_STREAM ||
++          property == SubtitleContentProperty::USE_SUBTITLES ||
++          property == VideoContentProperty::VIDEO_SCALE) {
 +              setup_dcp_name ();
 +      }
 +}
 +
 +
 +void
 +DCPPanel::setup_container ()
 +{
 +      int n = 0;
 +      vector<Ratio const *> ratios = Ratio::all ();
 +      vector<Ratio const *>::iterator i = ratios.begin ();
 +      while (i != ratios.end() && *i != _film->container ()) {
 +              ++i;
 +              ++n;
 +      }
 +      
 +      if (i == ratios.end()) {
 +              checked_set (_container, -1);
 +      } else {
 +              checked_set (_container, n);
 +      }
 +      
 +      setup_dcp_name ();
 +}     
 +
 +/** Called when the container widget has been changed */
 +void
 +DCPPanel::container_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      int const n = _container->GetSelection ();
 +      if (n >= 0) {
 +              vector<Ratio const *> ratios = Ratio::all ();
 +              assert (n < int (ratios.size()));
 +              _film->set_container (ratios[n]);
 +      }
 +}
 +
 +/** Called when the DCP content type widget has been changed */
 +void
 +DCPPanel::dcp_content_type_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      int const n = _dcp_content_type->GetSelection ();
 +      if (n != wxNOT_FOUND) {
 +              _film->set_dcp_content_type (DCPContentType::from_index (n));
 +      }
 +}
 +
 +void
 +DCPPanel::set_film (shared_ptr<Film> film)
 +{
 +      _film = film;
 +      
 +      film_changed (Film::NAME);
 +      film_changed (Film::USE_ISDCF_NAME);
 +      film_changed (Film::CONTENT);
 +      film_changed (Film::DCP_CONTENT_TYPE);
 +      film_changed (Film::CONTAINER);
 +      film_changed (Film::RESOLUTION);
 +      film_changed (Film::SCALER);
 +      film_changed (Film::SIGNED);
 +      film_changed (Film::BURN_SUBTITLES);
 +      film_changed (Film::ENCRYPTED);
 +      film_changed (Film::J2K_BANDWIDTH);
 +      film_changed (Film::ISDCF_METADATA);
 +      film_changed (Film::VIDEO_FRAME_RATE);
 +      film_changed (Film::AUDIO_CHANNELS);
 +      film_changed (Film::SEQUENCE_VIDEO);
 +      film_changed (Film::THREE_D);
 +      film_changed (Film::INTEROP);
 +}
 +
 +void
 +DCPPanel::set_general_sensitivity (bool s)
 +{
 +      _name->Enable (s);
 +      _use_isdcf_name->Enable (s);
 +      _edit_isdcf_button->Enable (s);
 +      _dcp_content_type->Enable (s);
 +
 +      bool si = s;
 +      if (_film && _film->encrypted ()) {
 +              si = false;
 +      }
 +      _burn_subtitles->Enable (s);
 +      _signed->Enable (si);
 +      
 +      _encrypted->Enable (s);
 +      _frame_rate_choice->Enable (s);
 +      _frame_rate_spin->Enable (s);
 +      _audio_channels->Enable (s);
 +      _j2k_bandwidth->Enable (s);
 +      _container->Enable (s);
 +      _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
 +      _resolution->Enable (s);
 +      _scaler->Enable (s);
 +      _three_d->Enable (s);
 +      _standard->Enable (s);
 +}
 +
 +/** Called when the scaler widget has been changed */
 +void
 +DCPPanel::scaler_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      int const n = _scaler->GetSelection ();
 +      if (n >= 0) {
 +              _film->set_scaler (Scaler::from_index (n));
 +      }
 +}
 +
 +void
 +DCPPanel::use_isdcf_name_toggled ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
 +}
 +
 +void
 +DCPPanel::edit_isdcf_button_clicked ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata ());
 +      d->ShowModal ();
 +      _film->set_isdcf_metadata (d->isdcf_metadata ());
 +      d->Destroy ();
 +}
 +
 +void
 +DCPPanel::setup_dcp_name ()
 +{
 +      string s = _film->dcp_name (true);
 +      if (s.length() > 28) {
 +              _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
 +              _dcp_name->SetToolTip (std_to_wx (s));
 +      } else {
 +              _dcp_name->SetLabel (std_to_wx (s));
 +      }
 +}
 +
 +void
 +DCPPanel::best_frame_rate_clicked ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +      
 +      _film->set_video_frame_rate (_film->best_video_frame_rate ());
 +}
 +
 +void
 +DCPPanel::three_d_changed ()
 +{
 +      if (!_film) {
 +              return;
 +      }
 +
 +      _film->set_three_d (_three_d->GetValue ());
 +}
 +
 +void
 +DCPPanel::config_changed ()
 +{
 +      _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
 +      setup_frame_rate_widget ();
 +}
 +
 +void
 +DCPPanel::setup_frame_rate_widget ()
 +{
 +      if (Config::instance()->allow_any_dcp_frame_rate ()) {
 +              _frame_rate_choice->Hide ();
 +              _frame_rate_spin->Show ();
 +      } else {
 +              _frame_rate_choice->Show ();
 +              _frame_rate_spin->Hide ();
 +      }
 +
 +      _frame_rate_sizer->Layout ();
 +}
 +
 +wxPanel *
 +DCPPanel::make_video_panel ()
 +{
 +      wxPanel* panel = new wxPanel (_notebook);
 +      wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
 +      wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
 +      sizer->Add (grid, 0, wxALL, 8);
 +      panel->SetSizer (sizer);
 +
 +      int r = 0;
 +      
 +      add_label_to_grid_bag_sizer (grid, panel, _("Container"), true, wxGBPosition (r, 0));
 +      _container = new wxChoice (panel, wxID_ANY);
 +      grid->Add (_container, wxGBPosition (r, 1));
 +      ++r;
 +
 +      {
 +              add_label_to_grid_bag_sizer (grid, panel, _("Frame Rate"), true, wxGBPosition (r, 0));
 +              _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
 +              _frame_rate_choice = new wxChoice (panel, wxID_ANY);
 +              _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
 +              _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
 +              _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
 +              setup_frame_rate_widget ();
 +              _best_frame_rate = new wxButton (panel, wxID_ANY, _("Use best"));
 +              _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
 +              grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
 +      }
 +      ++r;
 +
 +      _burn_subtitles = new wxCheckBox (panel, wxID_ANY, _("Burn subtitles into image"));
 +      grid->Add (_burn_subtitles, wxGBPosition (r, 0), wxGBSpan (1, 2));
 +      ++r;
 +
 +      _three_d = new wxCheckBox (panel, wxID_ANY, _("3D"));
 +      grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
 +      ++r;
 +
 +      add_label_to_grid_bag_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
 +      _resolution = new wxChoice (panel, wxID_ANY);
 +      grid->Add (_resolution, wxGBPosition (r, 1));
 +      ++r;
 +
 +      {
 +              add_label_to_grid_bag_sizer (grid, panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
 +              wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
 +              _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
 +              s->Add (_j2k_bandwidth, 1);
 +              add_label_to_sizer (s, panel, _("Mbit/s"), false);
 +              grid->Add (s, wxGBPosition (r, 1));
 +      }
 +      ++r;
 +
 +      add_label_to_grid_bag_sizer (grid, panel, _("Scaler"), true, wxGBPosition (r, 0));
 +      _scaler = new wxChoice (panel, wxID_ANY);
 +      grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
 +      ++r;
 +
 +      _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::container_changed, this));
 +      _scaler->Bind           (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::scaler_changed, this));
 +      _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::frame_rate_choice_changed, this));
 +      _frame_rate_spin->Bind  (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::frame_rate_spin_changed, this));
 +      _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::best_frame_rate_clicked, this));
 +      _burn_subtitles->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::burn_subtitles_toggled, this));
 +      _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
 +      _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::resolution_changed, this));
 +      _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::three_d_changed, this));
 +
 +      vector<Scaler const *> const sc = Scaler::all ();
 +      for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
 +              _scaler->Append (std_to_wx ((*i)->name()));
 +      }
 +
 +      vector<Ratio const *> const ratio = Ratio::all ();
 +      for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
 +              _container->Append (std_to_wx ((*i)->nickname ()));
 +      }
 +
 +      list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
 +      for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
 +              _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
 +      }
 +
 +      _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
 +      _frame_rate_spin->SetRange (1, 480);
 +
 +      _resolution->Append (_("2K"));
 +      _resolution->Append (_("4K"));
 +
 +      return panel;
 +}
 +
 +wxPanel *
 +DCPPanel::make_audio_panel ()
 +{
 +      wxPanel* panel = new wxPanel (_notebook);
 +      wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
 +      wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
 +      sizer->Add (grid, 0, wxALL, 8);
 +      panel->SetSizer (sizer);
 +
 +      int r = 0;
 +      add_label_to_grid_bag_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0));
 +      _audio_channels = new wxSpinCtrl (panel, wxID_ANY);
 +      grid->Add (_audio_channels, wxGBPosition (r, 1));
 +      ++r;
 +
 +      _audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DCPPanel::audio_channels_changed, this));
 +
 +      _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS);
 +
 +      return panel;
 +}
diff --combined src/wx/wx_util.cc
index 94a08f37289625eaf4c660ab4ba5c81d6b5cab36,23a85534a2123fbbad1fb58c8ec5e1f43b52618c..cf8b75dd24b78a66a6c0c7438514ca2b57bd2292
@@@ -1,5 -1,5 +1,5 @@@
  /*
-     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
  
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
@@@ -123,7 -123,7 +123,7 @@@ int const ThreadedStaticText::_update_e
   *  @param initial Initial text for the wxStaticText while the computation is being run.
   *  @param fn Function which works out what the wxStaticText content should be and returns it.
   */
 -ThreadedStaticText::ThreadedStaticText (wxWindow* parent, wxString initial, function<string ()> fn)
 +ThreadedStaticText::ThreadedStaticText (wxWindow* parent, wxString initial, boost::function<string ()> fn)
        : wxStaticText (parent, wxID_ANY, initial)
  {
        Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ThreadedStaticText::thread_finished, this, _1), _update_event_id);
@@@ -139,7 -139,7 +139,7 @@@ ThreadedStaticText::~ThreadedStaticTex
  
  /** Run our thread and post the result to the GUI thread via AddPendingEvent */
  void
 -ThreadedStaticText::run (function<string ()> fn)
 +ThreadedStaticText::run (boost::function<string ()> fn)
  try
  {
        wxCommandEvent ev (wxEVT_COMMAND_TEXT_UPDATED, _update_event_id);
@@@ -312,14 -312,6 +312,6 @@@ wx_get (wxSpinCtrlDouble* w
        return w->GetValue ();
  }
  
- void
- run_gui_loop ()
- {
-       while (wxTheApp->Pending ()) {
-               wxTheApp->Dispatch ();
-       }
- }
  /** @param s String of the form Context|String
   *  @return translation, or String if no translation is available.
   */