diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-02 17:20:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-02 17:20:04 +0100 |
| commit | 568d433830710baa7b0c64a5b7491758beb95b1c (patch) | |
| tree | a37742ed23776b3df3fe2f05900aaaa5cb9aa551 /src | |
| parent | 49fb66ee26be51bee67ae552c9cf4f8d21495b79 (diff) | |
Move edit rate / durations / entry point etc. into Asset from MXFAsset.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset.cc | 28 | ||||
| -rw-r--r-- | src/asset.h | 40 | ||||
| -rw-r--r-- | src/dcp.cc | 5 | ||||
| -rw-r--r-- | src/mxf_asset.cc | 29 | ||||
| -rw-r--r-- | src/mxf_asset.h | 28 |
5 files changed, 74 insertions, 56 deletions
diff --git a/src/asset.cc b/src/asset.cc index 305fc9a7..58c821a7 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -35,10 +35,14 @@ using namespace std; using namespace boost; using namespace libdcp; -Asset::Asset (string directory, string file_name) +Asset::Asset (string directory, string file_name, int edit_rate, int intrinsic_duration) : _directory (directory) , _file_name (file_name) , _uuid (make_uuid ()) + , _edit_rate (edit_rate) + , _entry_point (0) + , _intrinsic_duration (intrinsic_duration) + , _duration (intrinsic_duration) { if (_file_name.empty ()) { _file_name = _uuid + ".xml"; @@ -91,3 +95,25 @@ Asset::digest () const return _digest; } + + +bool +Asset::equals (shared_ptr<const Asset> other, EqualityOptions, boost::function<void (NoteType, string)> note) const +{ + if (_edit_rate != other->_edit_rate) { + note (ERROR, "MXF edit rates differ"); + return false; + } + + if (_intrinsic_duration != other->_intrinsic_duration) { + note (ERROR, "MXF intrinsic durations differ"); + return false; + } + + if (_duration != other->_duration) { + note (ERROR, "MXF durations differ"); + return false; + } + + return true; +} diff --git a/src/asset.h b/src/asset.h index 1b1bf4c6..06c66356 100644 --- a/src/asset.h +++ b/src/asset.h @@ -48,7 +48,7 @@ public: * @param directory Directory where our XML or MXF file is. * @param file_name Name of our file within directory, or empty to make one up based on UUID. */ - Asset (std::string directory, std::string file_name = ""); + Asset (std::string directory, std::string file_name = "", int edit_rate = 0, int intrinsic_duration = 0); virtual ~Asset() {} @@ -80,8 +80,36 @@ public: void set_file_name (std::string f) { _file_name = f; } + + int entry_point () const { + return _entry_point; + } + + int duration () const { + return _duration; + } + + int intrinsic_duration () const { + return _intrinsic_duration; + } + + int edit_rate () const { + return _edit_rate; + } + + void set_entry_point (int e) { + _entry_point = e; + } - virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const = 0; + void set_duration (int d) { + _duration = d; + } + + void set_intrinsic_duration (int d) { + _intrinsic_duration = d; + } + + virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const; protected: @@ -93,6 +121,14 @@ protected: std::string _file_name; /** Our UUID */ std::string _uuid; + /** The edit rate; this is normally equal to the number of video frames per second */ + int _edit_rate; + /** Start point to present in frames */ + int _entry_point; + /** Total length in frames */ + int _intrinsic_duration; + /** Length to present in frames */ + int _duration; private: /** Digest of our MXF or XML file */ @@ -365,7 +365,8 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b ) ); - picture->set_entry_point ((*i)->asset_list->main_picture->entry_point); + picture->set_entry_point (p->entry_point); + picture->set_duration (p->duration); } catch (MXFFileError) { if (require_mxfs) { throw; @@ -384,6 +385,7 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b ); picture->set_entry_point (p->entry_point); + picture->set_duration (p->duration); } catch (MXFFileError) { if (require_mxfs) { @@ -403,6 +405,7 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b ); sound->set_entry_point ((*i)->asset_list->main_sound->entry_point); + sound->set_duration ((*i)->asset_list->main_sound->duration); } catch (MXFFileError) { if (require_mxfs) { throw; diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc index 144532f8..229c332f 100644 --- a/src/mxf_asset.cc +++ b/src/mxf_asset.cc @@ -39,21 +39,13 @@ using namespace libdcp; MXFAsset::MXFAsset (string directory, string file_name) : Asset (directory, file_name) , _progress (0) - , _edit_rate (0) - , _entry_point (0) - , _intrinsic_duration (0) - , _duration (0) { } MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<void (float)>* progress, int edit_rate, int intrinsic_duration) - : Asset (directory, file_name) + : Asset (directory, file_name, edit_rate, intrinsic_duration) , _progress (progress) - , _edit_rate (edit_rate) - , _entry_point (0) - , _intrinsic_duration (intrinsic_duration) - , _duration (intrinsic_duration) { } @@ -73,6 +65,10 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid) bool MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { + if (!Asset::equals (other, opt, note)) { + return false; + } + shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other); if (!other_mxf) { note (ERROR, "comparing an MXF asset with a non-MXF asset"); @@ -85,21 +81,6 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::fun return false; } } - - if (_edit_rate != other_mxf->_edit_rate) { - note (ERROR, "MXF edit rates differ"); - return false; - } - - if (_intrinsic_duration != other_mxf->_intrinsic_duration) { - note (ERROR, "MXF intrinsic durations differ"); - return false; - } - - if (_duration != other_mxf->_duration) { - note (ERROR, "MXF durations differ"); - return false; - } return true; } diff --git a/src/mxf_asset.h b/src/mxf_asset.h index 29b3c1b0..5815fd90 100644 --- a/src/mxf_asset.h +++ b/src/mxf_asset.h @@ -49,27 +49,7 @@ public: */ MXFAsset (std::string directory, std::string file_name, boost::signals2::signal<void (float)>* progress, int edit_rate, int intrinsic_duration); - void set_entry_point (int e) { - _entry_point = e; - } - - void set_duration (int d) { - _duration = d; - } - - void set_intrinsic_duration (int d) { - _intrinsic_duration = d; - } - virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const; - - int intrinsic_duration () const { - return _intrinsic_duration; - } - - int edit_rate () const { - return _edit_rate; - } /** Fill in a ADSCP::WriteInfo struct. * @param w struct to fill in. @@ -81,14 +61,6 @@ protected: /** Signal to emit to report progress, or 0 */ boost::signals2::signal<void (float)>* _progress; - /** The edit rate; this is normally equal to the number of video frames per second */ - int _edit_rate; - /** Start point to present in frames */ - int _entry_point; - /** Total length in frames */ - int _intrinsic_duration; - /** Length to present in frames */ - int _duration; }; } |
