2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "dcpomatic_time.h"
23 #include "referenced_reel_asset.h"
24 #include "player_subtitles.h"
25 #include <dcp/picture_asset_writer.h>
26 #include <boost/shared_ptr.hpp>
34 class MonoPictureAsset;
35 class MonoPictureAssetWriter;
36 class StereoPictureAsset;
37 class StereoPictureAssetWriter;
39 class PictureAssetWriter;
41 class SoundAssetWriter;
50 ReelWriter (boost::shared_ptr<const Film> film, DCPTimePeriod period, boost::shared_ptr<Job> job);
52 void write (boost::optional<dcp::Data> encoded, Frame frame, Eyes eyes);
53 void fake_write (Frame frame, Eyes eyes, int size);
54 void repeat_write (Frame frame, Eyes eyes);
55 void write (boost::shared_ptr<const AudioBuffers> audio);
56 void write (PlayerSubtitles subs);
59 boost::shared_ptr<dcp::Reel> create_reel (std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<Font> > const & fonts);
60 void calculate_digests (boost::shared_ptr<Job> job);
64 DCPTimePeriod period () const {
68 int total_written_audio_frames () const {
69 return _total_written_audio_frames;
72 int last_written_video_frame () const {
73 return _last_written_video_frame;
76 Eyes last_written_eyes () const {
77 return _last_written_eyes;
80 int first_nonexistant_frame () const {
81 return _first_nonexistant_frame;
84 dcp::FrameInfo read_frame_info (FILE* file, Frame frame, Eyes eyes) const;
88 void write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const;
89 long frame_info_position (Frame frame, Eyes eyes) const;
90 void check_existing_picture_asset ();
91 bool existing_picture_frame_ok (FILE* asset_file, FILE* info_file) const;
93 boost::shared_ptr<const Film> _film;
95 DCPTimePeriod _period;
96 /** the first frame index that does not already exist in our MXF */
97 int _first_nonexistant_frame;
98 /** the data of the last written frame, if there is one */
99 boost::optional<dcp::Data> _last_written[EYES_COUNT];
100 /** the index of the last written video frame within the reel */
101 int _last_written_video_frame;
102 Eyes _last_written_eyes;
103 /** the number of audio frames that have been written to the reel */
104 int _total_written_audio_frames;
106 boost::shared_ptr<dcp::PictureAsset> _picture_asset;
107 boost::shared_ptr<dcp::PictureAssetWriter> _picture_asset_writer;
108 boost::shared_ptr<dcp::SoundAsset> _sound_asset;
109 boost::shared_ptr<dcp::SoundAssetWriter> _sound_asset_writer;
110 boost::shared_ptr<dcp::SubtitleAsset> _subtitle_asset;
112 static int const _info_size;