#include "film_state.h"
#include "options.h"
#include "log.h"
+#include "job_manager.h"
+#include "ab_transcode_job.h"
+#include "transcode_job.h"
using namespace std;
using namespace boost;
string
CheckHashesJob::name () const
{
- stringstream s;
- s << "Check hashes of " << _fs->name;
- return s.str ();
+ return String::compose ("Check hashes of %1", _fs->name);
}
void
CheckHashesJob::run ()
{
_bad = 0;
+
+ int const N = _fs->dcp_length ();
- for (int i = 0; i < _fs->length; ++i) {
+ for (int i = 0; i < N; ++i) {
string const j2k_file = _opt->frame_out_path (i, false);
string const hash_file = j2k_file + ".md5";
set_progress (float (i) / _fs->length);
}
+ if (_bad) {
+ shared_ptr<Job> tc;
+
+ if (_fs->dcp_ab) {
+ tc.reset (new ABTranscodeJob (_fs, _opt, _log));
+ } else {
+ tc.reset (new TranscodeJob (_fs, _opt, _log));
+ }
+
+ JobManager::instance()->add_after (shared_from_this(), tc);
+ JobManager::instance()->add_after (tc, shared_ptr<Job> (new CheckHashesJob (_fs, _opt, _log)));
+ }
+
set_progress (1);
set_state (FINISHED_OK);
}
CheckHashesJob::status () const
{
stringstream s;
- s << Job::status () << "; " << _bad << " bad frames found";
+ s << Job::status ();
+ if (overall_progress() > 0) {
+ if (_bad == 0) {
+ s << "; no bad frames found";
+ } else if (_bad == 1) {
+ s << "; 1 bad frame found";
+ } else {
+ s << "; " << _bad << " bad frames found";
+ }
+ }
return s.str ();
}