Remove never-tested DVD ripping / title code.
authorCarl Hetherington <cth@carlh.net>
Mon, 19 Nov 2012 00:12:52 +0000 (00:12 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 19 Nov 2012 00:12:52 +0000 (00:12 +0000)
src/lib/copy_from_dvd_job.cc [deleted file]
src/lib/copy_from_dvd_job.h [deleted file]
src/lib/dvd.cc [deleted file]
src/lib/dvd.h [deleted file]
src/lib/film.cc
src/lib/film.h
src/lib/wscript
src/tools/dvdomatic.cc
src/wx/dvd_title_dialog.cc [deleted file]
src/wx/dvd_title_dialog.h [deleted file]
test/test.cc

diff --git a/src/lib/copy_from_dvd_job.cc b/src/lib/copy_from_dvd_job.cc
deleted file mode 100644 (file)
index dcf53ac..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-    Copyright (C) 2012 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.
-
-*/
-
-/** @file src/copy_from_dvd_job.cc
- *  @brief A job to copy a film from a DVD.
- */
-
-#include <stdio.h>
-#include <boost/algorithm/string.hpp>
-#include <boost/filesystem.hpp>
-#include "copy_from_dvd_job.h"
-#include "dvd.h"
-#include "cross.h"
-#include "film.h"
-
-using std::string;
-using std::list;
-using std::stringstream;
-using boost::shared_ptr;
-
-/** @param f Film to write DVD data into.
- */
-CopyFromDVDJob::CopyFromDVDJob (shared_ptr<Film> f, shared_ptr<Job> req)
-       : Job (f, req)
-{
-
-}
-
-string
-CopyFromDVDJob::name () const
-{
-       return "Copy film from DVD";
-}
-
-void
-CopyFromDVDJob::run ()
-{
-       /* Remove any old DVD rips */
-       boost::filesystem::remove_all (_film->dir ("dvd"));
-
-       string const dvd = find_dvd ();
-       if (dvd.empty ()) {
-               set_error ("could not find DVD");
-               set_state (FINISHED_ERROR);
-       }
-
-       list<DVDTitle> const t = dvd_titles (dvd);
-       if (t.empty ()) {
-               set_error ("no titles found on DVD");
-               set_state (FINISHED_ERROR);
-       }
-
-       int longest_title = 0;
-       uint64_t longest_size = 0;
-       for (list<DVDTitle>::const_iterator i = t.begin(); i != t.end(); ++i) {
-               if (longest_size < i->size) {
-                       longest_size = i->size;
-                       longest_title = i->number;
-               }
-       }
-
-       stringstream c;
-       c << "vobcopy -n " << longest_title << " -l -o \"" << _film->dir ("dvd") << "\" 2>&1";
-
-       FILE* f = popen (c.str().c_str(), "r");
-       if (f == 0) {
-               set_error ("could not run vobcopy command");
-               set_state (FINISHED_ERROR);
-               return;
-       }
-
-       while (!feof (f)) {
-               char buf[256];
-               if (fscanf (f, "%s", buf)) {
-                       string s (buf);
-                       if (!s.empty () && s[s.length() - 1] == '%') {
-                               set_progress (atof (s.substr(0, s.length() - 1).c_str()) / 100.0);
-                       }
-               }
-       }
-
-       const string dvd_dir = _film->dir ("dvd");
-
-       string largest_file;
-       uintmax_t largest_size = 0;
-       for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dvd_dir); i != boost::filesystem::directory_iterator(); ++i) {
-               uintmax_t const s = boost::filesystem::file_size (*i);
-               if (s > largest_size) {
-
-#if BOOST_FILESYSTEM_VERSION == 3              
-                       largest_file = boost::filesystem::path(*i).generic_string();
-#else
-                       largest_file = i->string ();
-#endif
-                       largest_size = s;
-               }
-       }
-
-       _film->set_content (largest_file);
-       
-       int const r = pclose (f);
-       if (WEXITSTATUS (r) != 0) {
-               set_error ("call to vobcopy failed");
-               set_state (FINISHED_ERROR);
-       } else {
-               set_state (FINISHED_OK);
-       }
-}
diff --git a/src/lib/copy_from_dvd_job.h b/src/lib/copy_from_dvd_job.h
deleted file mode 100644 (file)
index 063e943..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-    Copyright (C) 2012 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.
-
-*/
-
-/** @file src/copy_from_dvd_job.h
- *  @brief A job to copy a film from a DVD.
- */
-
-#include "job.h"
-
-/** @class CopyFromDVDJob
- *  @brief A job to copy a film from a DVD using `vobcopy'.
- */
-class CopyFromDVDJob : public Job
-{
-public:
-       CopyFromDVDJob (boost::shared_ptr<Film>, boost::shared_ptr<Job> req);
-
-       std::string name () const;
-       void run ();
-};
diff --git a/src/lib/dvd.cc b/src/lib/dvd.cc
deleted file mode 100644 (file)
index 19b59b5..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-    Copyright (C) 2012 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 <fstream>
-#include <boost/filesystem.hpp>
-#include <boost/algorithm/string.hpp>
-#include "dvd.h"
-
-using namespace std;
-using namespace boost;
-
-string
-find_dvd ()
-{
-       ifstream f ("/etc/mtab");
-       while (f.good ()) {
-               string s;
-               getline (f, s);
-               vector<string> b;
-               split (b, s, is_any_of (" "));
-               if (b.size() >= 3 && b[2] == "udf") {
-                       replace_all (b[1], "\\040", " ");
-                       return b[1];
-               }
-       }
-
-       return "";
-}
-
-list<DVDTitle>
-dvd_titles (string dvd)
-{
-       filesystem::path video (dvd);
-       video /= "VIDEO_TS";
-
-       list<DVDTitle> titles;
-       
-       for (filesystem::directory_iterator i = filesystem::directory_iterator (video); i != filesystem::directory_iterator(); ++i) {
-#if BOOST_FILESYSTEM_VERSION == 3              
-               string const n = filesystem::path(*i).filename().generic_string();
-#else          
-               string const n = filesystem::path(*i).filename();
-#endif
-               if (starts_with (n, "VTS_") && ends_with (n, ".VOB")) {
-                       uint64_t const size = filesystem::file_size (filesystem::path (*i));
-                       vector<string> p;
-                       split (p, n, is_any_of ("_."));
-                       if (p.size() == 4) {
-                               int const a = atoi (p[1].c_str ());
-                               int const b = atoi (p[2].c_str ());
-                               if (b == 0) {
-                                       continue;
-                               }
-
-                               list<DVDTitle>::iterator j = titles.begin ();
-                               while (j != titles.end() && j->number != a) {
-                                       ++j;
-                               }
-
-                               if (j == titles.end ()) {
-                                       titles.push_back (DVDTitle (a, size));
-                               } else {
-                                       j->size += size;
-                               }
-                       }
-               }
-       }
-
-       titles.sort ();
-                                       
-       return titles;
-}
-
-
-bool
-operator< (DVDTitle const & a, DVDTitle const & b)
-{
-       return a.number < b.number;
-}
diff --git a/src/lib/dvd.h b/src/lib/dvd.h
deleted file mode 100644 (file)
index 28fef4d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-    Copyright (C) 2012 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 <list>
-#include <stdint.h>
-
-class DVDTitle
-{
-public:
-       DVDTitle () : number (-1), size (0) {}
-       DVDTitle (int n, int s) : number (n), size (s) {}
-       
-       int number;
-       uint64_t size;
-};
-
-extern bool operator< (DVDTitle const &, DVDTitle const &);
-
-extern std::list<DVDTitle> dvd_titles (std::string);
-extern std::string find_dvd ();
index 333fe139b8a311ac30719fbf69c7fc39be16c5e9..3f92100802ade784a839bef4a790a939fa547a2b 100644 (file)
@@ -40,7 +40,6 @@
 #include "ab_transcode_job.h"
 #include "transcode_job.h"
 #include "scp_dcp_job.h"
-#include "copy_from_dvd_job.h"
 #include "make_dcp_job.h"
 #include "log.h"
 #include "options.h"
@@ -337,13 +336,6 @@ Film::send_dcp_to_tms ()
        JobManager::instance()->add (j);
 }
 
-void
-Film::copy_from_dvd ()
-{
-       shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
-       JobManager::instance()->add (j);
-}
-
 /** Count the number of frames that have been encoded for this film.
  *  @return frame count.
  */
index 5e75eefe84f927931435325bac20b2b52d974c74..76fe9871068098a9ac2edf4051c5f45c1eeb37b8 100644 (file)
@@ -65,7 +65,6 @@ public:
 
        void examine_content ();
        void send_dcp_to_tms ();
-       void copy_from_dvd ();
 
        void make_dcp (bool);
 
index 5284dc97f7fb44c73753e612825952f90c49578e..942975b32fd8006e2125b437fbebed9daaa61f0e 100644 (file)
@@ -12,7 +12,6 @@ def build(bld):
                  audio_source.cc
                  check_hashes_job.cc
                 config.cc
-                copy_from_dvd_job.cc
                  combiner.cc
                  cross.cc
                 dcp_content_type.cc
@@ -21,7 +20,6 @@ def build(bld):
                  decoder_factory.cc
                  delay_line.cc
                  dolby_cp750.cc
-                 dvd.cc
                 encoder.cc
                  encoder_factory.cc
                 examine_content_job.cc
index 46c53e7f7192e9bdeaeef180090afa89b95828f6..7700a38ef5514c69b7276222da35d0eac5270c12 100644 (file)
@@ -27,7 +27,6 @@
 #include "wx/job_manager_view.h"
 #include "wx/config_dialog.h"
 #include "wx/job_wrapper.h"
-//#include "gtk/dvd_title_dialog.h"
 #include "wx/wx_util.h"
 #include "wx/new_film_dialog.h"
 #include "wx/properties_dialog.h"
@@ -136,7 +135,6 @@ enum {
        ID_edit_preferences,
        ID_jobs_make_dcp,
        ID_jobs_send_dcp_to_tms,
-       ID_jobs_copy_from_dvd,
        ID_jobs_examine_content,
        ID_jobs_make_dcp_from_existing_transcode,
        ID_help_about
@@ -161,9 +159,6 @@ setup_menu (wxMenuBar* m)
        wxMenu* jobs = new wxMenu;
        add_item (jobs, "&Make DCP", ID_jobs_make_dcp, NEEDS_FILM);
        add_item (jobs, "&Send DCP to TMS", ID_jobs_send_dcp_to_tms, NEEDS_FILM);
-#ifdef DVDOMATIC_POSIX 
-       add_item (jobs, "Copy from &DVD...", ID_jobs_copy_from_dvd, NEEDS_FILM);
-#endif 
        jobs->AppendSeparator ();
        add_item (jobs, "&Examine content", ID_jobs_examine_content, NEEDS_FILM);
        add_item (jobs, "Make DCP from existing &transcode", ID_jobs_make_dcp_from_existing_transcode, NEEDS_FILM);
@@ -202,7 +197,6 @@ public:
                Connect (ID_edit_preferences, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::edit_preferences));
                Connect (ID_jobs_make_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp));
                Connect (ID_jobs_send_dcp_to_tms, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_send_dcp_to_tms));
-               Connect (ID_jobs_copy_from_dvd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_copy_from_dvd));
                Connect (ID_jobs_examine_content, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_examine_content));
                Connect (ID_jobs_make_dcp_from_existing_transcode, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp_from_existing_transcode));
                Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about));
@@ -334,20 +328,6 @@ public:
                JobWrapper::make_dcp (this, film, false);
        }
        
-       void jobs_copy_from_dvd (wxCommandEvent &)
-       {
-               try {
-
-//             DVDTitleDialog d;
-//             if (d.run () != Gtk::RESPONSE_OK) {
-//                     return;
-//             }
-                       film->copy_from_dvd ();
-               } catch (DVDError& e) {
-                       error_dialog (this, e.what ());
-               }
-       }
-       
        void jobs_send_dcp_to_tms (wxCommandEvent &)
        {
                film->send_dcp_to_tms ();
diff --git a/src/wx/dvd_title_dialog.cc b/src/wx/dvd_title_dialog.cc
deleted file mode 100644 (file)
index e9606d3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-    Copyright (C) 2012 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 <cassert>
-#include <iostream>
-#include "lib/exceptions.h"
-#include "dvd_title_dialog.h"
-#include "gtk_util.h"
-
-using namespace std;
-
-DVDTitleDialog::DVDTitleDialog ()
-{
-       string const dvd = find_dvd ();
-       if (dvd.empty ()) {
-               throw DVDError ("could not find DVD");
-       }
-
-       list<DVDTitle> t = dvd_titles (dvd);
-       if (t.empty ()) {
-               throw DVDError ("no titles found on DVD");
-       }
-
-       set_title ("Choose DVD title");
-       get_vbox()->set_border_width (6);
-       get_vbox()->set_spacing (3);
-
-       Gtk::RadioButtonGroup g;
-       for (list<DVDTitle>::const_iterator i = t.begin(); i != t.end(); ++i) {
-               Gtk::RadioButton* b = manage (new Gtk::RadioButton);
-               stringstream s;
-#if HAVE_G_FORMAT_SIZE         
-               s << "Title " << i->number << ": " << g_format_size (i->size);
-#else          
-               s << "Title " << i->number << ": " << g_format_size_for_display (i->size);
-#endif         
-               b->set_label (s.str ());
-               if (i == t.begin ()) {
-                       b->set_active ();
-                       g = b->get_group ();
-               } else {
-                       b->set_group (g);
-               }
-               get_vbox()->pack_start (*b);
-               _buttons[*i] = b;
-       }
-
-       add_button ("Cancel", Gtk::RESPONSE_CANCEL);
-       add_button ("Copy Title", Gtk::RESPONSE_OK);
-
-       show_all ();
-}
-
-DVDTitle
-DVDTitleDialog::selected ()
-{
-       std::map<DVDTitle, Gtk::RadioButton *>::const_iterator i = _buttons.begin ();
-       while (i != _buttons.end() && i->second->get_active() == false) {
-               ++i;
-       }
-
-       assert (i != _buttons.end ());
-       return i->first;
-}
diff --git a/src/wx/dvd_title_dialog.h b/src/wx/dvd_title_dialog.h
deleted file mode 100644 (file)
index 26aef28..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-    Copyright (C) 2012 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 <gtkmm.h>
-#include "lib/dvd.h"
-
-class DVDTitleDialog : public Gtk::Dialog
-{
-public:
-       DVDTitleDialog ();
-
-       DVDTitle selected ();
-
-private:
-       std::map<DVDTitle, Gtk::RadioButton *> _buttons;
-};
index 87ec15be9886e38bb93a0edd0fb532ec6955ea6e..e2f9f41ee9c2802df295e6ca2700f62072bb2743 100644 (file)
@@ -27,7 +27,6 @@
 #include "job_manager.h"
 #include "util.h"
 #include "exceptions.h"
-#include "dvd.h"
 #include "delay_line.h"
 #include "image.h"
 #include "log.h"
@@ -195,24 +194,6 @@ BOOST_AUTO_TEST_CASE (util_test)
        BOOST_CHECK_EQUAL (*i++, "them");
 }
 
-BOOST_AUTO_TEST_CASE (dvd_test)
-{
-       list<DVDTitle> const t = dvd_titles ("test/dvd");
-       BOOST_CHECK_EQUAL (t.size(), 3);
-       list<DVDTitle>::const_iterator i = t.begin ();
-       
-       BOOST_CHECK_EQUAL (i->number, 1);
-       BOOST_CHECK_EQUAL (i->size, 0);
-       ++i;
-       
-       BOOST_CHECK_EQUAL (i->number, 2);
-       BOOST_CHECK_EQUAL (i->size, 14);
-       ++i;
-       
-       BOOST_CHECK_EQUAL (i->number, 3);
-       BOOST_CHECK_EQUAL (i->size, 7);
-}
-
 class NullLog : public Log
 {
 public: