Move things round a bit.
[dcpomatic.git] / src / lib / make_mxf_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/make_mxf_job.cc
21  *  @brief A job that creates a MXF file from some data.
22  */
23
24 #include <iostream>
25 #include "make_mxf_job.h"
26 #include "film.h"
27 #include "film_state.h"
28 #include "options.h"
29
30 using namespace std;
31 using namespace boost;
32
33 /** @class MakeMXFJob
34  *  @brief A job that creates a MXF file from some data.
35  */
36
37 MakeMXFJob::MakeMXFJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, Type t)
38         : ShellCommandJob (s, o, l)
39         , _type (t)
40 {
41
42 }
43
44 string
45 MakeMXFJob::name () const
46 {
47         stringstream s;
48         switch (_type) {
49         case VIDEO:
50                 s << "Make video MXF for " << _fs->name;
51                 break;
52         case AUDIO:
53                 s << "Make audio MXF for " << _fs->name;
54                 break;
55         }
56         
57         return s.str ();
58 }
59
60 void
61 MakeMXFJob::run ()
62 {
63         set_progress_unknown ();
64
65         /* We round for DCP: not sure if this is right */
66         float fps = rintf (_fs->frames_per_second);
67         
68         stringstream c;
69         c << "opendcp_mxf -r " << fps << " -i ";
70         switch (_type) {
71         case VIDEO:
72                 c << "\"" << _opt->frame_out_path () << "\" -o \"" << _fs->file ("video.mxf") << "\"";
73                 break;
74         case AUDIO:
75                 c << "\"" << _opt->multichannel_audio_out_path () << "\" -o \"" << _fs->file ("audio.mxf") << "\"";
76                 break;
77         }
78
79         command (c.str ());
80         set_progress (1);
81 }