Remove stream _legacy_id stuff.
authorCarl Hetherington <cth@carlh.net>
Fri, 21 Feb 2014 11:20:15 +0000 (11:20 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 21 Feb 2014 11:20:15 +0000 (11:20 +0000)
src/lib/content.cc
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/film.cc
src/lib/film.h
src/tools/dcpomatic.cc

index ccca46bc02fbedd91e79b6665f6d7858736cb788..1883dfb4a9276d7773a8fe8b3ba34f32ace08662 100644 (file)
@@ -195,7 +195,7 @@ Content::clone () const
        xmlpp::Document doc;
        xmlpp::Node* node = doc.create_root_node ("Content");
        as_xml (node);
-       return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::state_version);
+       return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version);
 }
 
 string
index bb2b629c8cfdcee73c5337cf1f03f0b9e9c7454f..34486d08b22ce50af841c49ae65e3e5eac07ec64 100644 (file)
@@ -66,7 +66,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, shared_ptr<const cxml::N
 {
        list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
        for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
-               _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i, version)));
+               _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i)));
                if ((*i)->optional_number_child<int> ("Selected")) {
                        _subtitle_stream = _subtitle_streams.back ();
                }
@@ -337,14 +337,11 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b)
        return a._id != b._id;
 }
 
-FFmpegStream::FFmpegStream (shared_ptr<const cxml::Node> node, int version)
+FFmpegStream::FFmpegStream (shared_ptr<const cxml::Node> node)
        : name (node->string_child ("Name"))
        , _id (node->number_child<int> ("Id"))
-       , _legacy_id (false)
 {
-       if (version == 4 || node->optional_bool_child ("LegacyId")) {
-               _legacy_id = true;
-       }
+
 }
 
 void
@@ -352,16 +349,10 @@ FFmpegStream::as_xml (xmlpp::Node* root) const
 {
        root->add_child("Name")->add_child_text (name);
        root->add_child("Id")->add_child_text (lexical_cast<string> (_id));
-       if (_legacy_id) {
-               /* Write this so that version > 4 files are read in correctly
-                  if the Id came originally from a version <= 4 file.
-               */
-               root->add_child("LegacyId")->add_child_text ("1");
-       }
 }
 
 FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node, int version)
-       : FFmpegStream (node, version)
+       : FFmpegStream (node)
        , mapping (node->node_child ("Mapping"), version)
 {
        frame_rate = node->number_child<int> ("FrameRate");
@@ -384,10 +375,6 @@ FFmpegAudioStream::as_xml (xmlpp::Node* root) const
 bool
 FFmpegStream::uses_index (AVFormatContext const * fc, int index) const
 {
-       if (_legacy_id) {
-               return _id == index;
-       }
-       
        size_t i = 0;
        while (i < fc->nb_streams) {
                if (fc->streams[i]->id == _id) {
@@ -402,14 +389,6 @@ FFmpegStream::uses_index (AVFormatContext const * fc, int index) const
 AVStream *
 FFmpegStream::stream (AVFormatContext const * fc) const
 {
-       if (_legacy_id) {
-               if (_id >= int (fc->nb_streams)) {
-                       return 0;
-               }
-               
-               return fc->streams[_id];
-       }
-       
        size_t i = 0;
        while (i < fc->nb_streams) {
                if (fc->streams[i]->id == _id) {
@@ -426,8 +405,8 @@ FFmpegStream::stream (AVFormatContext const * fc) const
  *  @param t String returned from to_string().
  *  @param v State file version.
  */
-FFmpegSubtitleStream::FFmpegSubtitleStream (shared_ptr<const cxml::Node> node, int version)
-       : FFmpegStream (node, version)
+FFmpegSubtitleStream::FFmpegSubtitleStream (shared_ptr<const cxml::Node> node)
+       : FFmpegStream (node)
 {
        
 }
index 2339705d0d17377768b9bd1dbae0f7d2cbda3f2c..ed2169de0b83387d2284a588be0dd2f0ea8c980a 100644 (file)
@@ -38,10 +38,9 @@ public:
        FFmpegStream (std::string n, int i)
                : name (n)
                , _id (i)
-               , _legacy_id (false)
        {}
                                
-       FFmpegStream (boost::shared_ptr<const cxml::Node>, int);
+       FFmpegStream (boost::shared_ptr<const cxml::Node>);
 
        void as_xml (xmlpp::Node *) const;
 
@@ -62,8 +61,6 @@ public:
        
 private:
        int _id;
-       /** If this is true, id is in fact the index */
-       bool _legacy_id;
 };
 
 class FFmpegAudioStream : public FFmpegStream
@@ -106,7 +103,7 @@ public:
                : FFmpegStream (n, i)
        {}
        
-       FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>, int);
+       FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
 
        void as_xml (xmlpp::Node *) const;
 };
index fb5014b3a08be4b7ae6e90329ee1d35e3f762961..1d07ec77f4a0ff50ebc105970709cde687c29099 100644 (file)
@@ -86,7 +86,7 @@ using libdcp::Signer;
  * 6 -> 7
  * Subtitle offset changed to subtitle y offset, and subtitle x offset added.
  */
-int const Film::state_version = 7;
+int const Film::current_state_version = 7;
 
 /** Construct a Film object in a given directory.
  *
@@ -110,6 +110,7 @@ Film::Film (boost::filesystem::path dir, bool log)
        , _three_d (false)
        , _sequence_video (true)
        , _interop (false)
+       , _state_version (current_state_version)
        , _dirty (false)
 {
        set_dci_date_today ();
@@ -339,7 +340,7 @@ Film::metadata () const
        shared_ptr<xmlpp::Document> doc (new xmlpp::Document);
        xmlpp::Element* root = doc->create_root_node ("Metadata");
 
-       root->add_child("Version")->add_child_text (lexical_cast<string> (state_version));
+       root->add_child("Version")->add_child_text (lexical_cast<string> (current_state_version));
        root->add_child("Name")->add_child_text (_name);
        root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0");
 
@@ -393,7 +394,7 @@ Film::read_metadata ()
        cxml::Document f ("Metadata");
        f.read_file (file ("metadata.xml"));
 
-       int const version = f.number_child<int> ("Version");
+       _state_version = f.number_child<int> ("Version");
        
        _name = f.string_child ("Name");
        _use_dci_name = f.bool_child ("UseDCIName");
@@ -426,7 +427,7 @@ Film::read_metadata ()
        _three_d = f.bool_child ("ThreeD");
        _interop = f.bool_child ("Interop");
        _key = libdcp::Key (f.string_child ("Key"));
-       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), version);
+       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version);
 
        _dirty = false;
 }
index 06d19e67ef9f948689de3f61f8236921033f0503..7e65ecb16346107efe63da496176f5cf2f014adf 100644 (file)
@@ -138,6 +138,10 @@ public:
                return _key;
        }
 
+       int state_version () const {
+               return _state_version;
+       }
+
        /** Identifiers for the parts of our state;
            used for signalling changes.
        */
@@ -271,7 +275,7 @@ public:
        mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
 
        /** Current version number of the state file */
-       static int const state_version;
+       static int const current_state_version;
 
 private:
 
@@ -325,6 +329,8 @@ private:
        bool _interop;
        libdcp::Key _key;
 
+       int _state_version;
+
        /** true if our state has changed since we last saved it */
        mutable bool _dirty;
 
index 1f546b64f0d073e8ff952e0c02eb04391b931474..ce00cb13fbc30456acc71fce05a36af368d0b19b 100644 (file)
@@ -324,6 +324,17 @@ public:
                overall_panel->SetSizer (main_sizer);
        }
 
+       void check_film_state_version (int v)
+       {
+               if (v == 4) {
+                       error_dialog (
+                               this,
+                               _("This film was created with an old version of DVD-o-matic and may not load correctly "
+                                 "in this version.  Please check the film's settings carefully.")
+                               );
+               }
+       }
+
 private:
 
        void set_film ()
@@ -405,6 +416,7 @@ private:
                        try {
                                film.reset (new Film (wx_to_std (c->GetPath ())));
                                film->read_metadata ();
+                               check_film_state_version (film->state_version ());
                                film->log()->set_level (log_level);
                                set_film ();
                        } catch (std::exception& e) {
@@ -662,6 +674,8 @@ class App : public wxApp
                _timer.reset (new wxTimer (this));
                _timer->Start (1000);
 
+               _frame->check_film_state_version (film->state_version ());
+
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
                if (Config::instance()->check_for_updates ()) {
                        UpdateChecker::instance()->run ();
@@ -746,7 +760,7 @@ class App : public wxApp
                }
        }
 
-       wxFrame* _frame;
+       Frame* _frame;
        shared_ptr<wxTimer> _timer;
 };