Move things round a bit.
[dcpomatic.git] / src / lib / thumbs_job.cc
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file src/thumbs_job.cc
21  *  @brief A job to create thumbnails.
22  */
23
24 #include <exception>
25 #include "thumbs_job.h"
26 #include "film_state.h"
27 #include "tiff_encoder.h"
28 #include "transcoder.h"
29 #include "options.h"
30
31 using namespace std;
32 using namespace boost;
33
34 /** @param s FilmState to use.
35  *  @param o Options.
36  *  @param l A log that we can write to.
37  */
38 ThumbsJob::ThumbsJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
39         : Job (s, o, l)
40 {
41         
42 }
43
44 string
45 ThumbsJob::name () const
46 {
47         stringstream s;
48         s << "Update thumbs for " << _fs->name;
49         return s.str ();
50 }
51
52 void
53 ThumbsJob::run ()
54 {
55         try {
56                 shared_ptr<TIFFEncoder> e (new TIFFEncoder (_fs, _opt, _log));
57                 Transcoder w (_fs, _opt, this, _log, e);
58                 w.go ();
59                 set_progress (1);
60                 set_state (FINISHED_OK);
61
62         } catch (std::exception& e) {
63
64                 set_progress (1);
65                 set_error (e.what ());
66                 set_state (FINISHED_ERROR);
67         }
68 }