diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-09-16 00:51:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-09-16 00:51:07 +0100 |
| commit | 14848004f619d11bd6810735637d428f101e6b51 (patch) | |
| tree | e2aa460b25f98db37523c2ea92cc3997c3745336 | |
| parent | a6070a8af446620ab16ad172b94041601c95700d (diff) | |
Consider assets outside the DCP as referenced assets (i.e.1.0-vf
not to be written to the asset map). Return a value from
finalize() to say whether a writer has written anything.
Other small related tweaks.
| -rw-r--r-- | src/asset.cc | 15 | ||||
| -rw-r--r-- | src/asset_writer.cc | 4 | ||||
| -rw-r--r-- | src/asset_writer.h | 2 | ||||
| -rw-r--r-- | src/mono_picture_asset_writer.cc | 13 | ||||
| -rw-r--r-- | src/mono_picture_asset_writer.h | 2 | ||||
| -rw-r--r-- | src/reel_asset.h | 4 | ||||
| -rw-r--r-- | src/sound_asset_writer.cc | 4 | ||||
| -rw-r--r-- | src/sound_asset_writer.h | 3 | ||||
| -rw-r--r-- | src/stereo_picture_asset_writer.cc | 12 | ||||
| -rw-r--r-- | src/stereo_picture_asset_writer.h | 2 |
10 files changed, 36 insertions, 25 deletions
diff --git a/src/asset.cc b/src/asset.cc index 3ee95227..a800e8ee 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -75,20 +75,23 @@ Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const { DCP_ASSERT (!_file.empty ()); - xmlpp::Node* asset = node->add_child ("Asset"); - asset->add_child("Id")->add_child_text ("urn:uuid:" + _id); - xmlpp::Node* chunk_list = asset->add_child ("ChunkList"); - xmlpp::Node* chunk = chunk_list->add_child ("Chunk"); - optional<boost::filesystem::path> path = relative_to_root ( boost::filesystem::canonical (root), boost::filesystem::canonical (_file) ); if (!path) { - throw MiscError (String::compose ("Asset %1 is not within the directory %2", _file, root)); + /* The path of this asset is not within our DCP, so we assume it's an external + (referenced) one. + */ + return; } + xmlpp::Node* asset = node->add_child ("Asset"); + asset->add_child("Id")->add_child_text ("urn:uuid:" + _id); + xmlpp::Node* chunk_list = asset->add_child ("ChunkList"); + xmlpp::Node* chunk = chunk_list->add_child ("Chunk"); + /* On Windows path.string() will contain back-slashes; replace these with forward-slashes. XXX: perhaps there is a nicer way to do this with boost. */ diff --git a/src/asset_writer.cc b/src/asset_writer.cc index db2d4c53..13adc50e 100644 --- a/src/asset_writer.cc +++ b/src/asset_writer.cc @@ -61,9 +61,11 @@ AssetWriter::~AssetWriter () delete _encryption_context; } -void +/** @return true if anything was written by this writer */ +bool AssetWriter::finalize () { DCP_ASSERT (!_finalized); _finalized = true; + return _started; } diff --git a/src/asset_writer.h b/src/asset_writer.h index 66d7396f..f9022899 100644 --- a/src/asset_writer.h +++ b/src/asset_writer.h @@ -44,7 +44,7 @@ class AssetWriter : public boost::noncopyable { public: virtual ~AssetWriter (); - virtual void finalize (); + virtual bool finalize (); protected: AssetWriter (MXF* mxf, boost::filesystem::path file); diff --git a/src/mono_picture_asset_writer.cc b/src/mono_picture_asset_writer.cc index 0f09f8fe..564a5ea1 100644 --- a/src/mono_picture_asset_writer.cc +++ b/src/mono_picture_asset_writer.cc @@ -97,15 +97,16 @@ MonoPictureAssetWriter::fake_write (int size) ++_frames_written; } -void +bool MonoPictureAssetWriter::finalize () { - Kumu::Result_t r = _state->mxf_writer.Finalize(); - if (ASDCP_FAILURE (r)) { - boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r)); + if (_started) { + Kumu::Result_t r = _state->mxf_writer.Finalize(); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r)); + } } _picture_asset->_intrinsic_duration = _frames_written; - PictureAssetWriter::finalize (); + return PictureAssetWriter::finalize (); } - diff --git a/src/mono_picture_asset_writer.h b/src/mono_picture_asset_writer.h index 81782454..a9ff4015 100644 --- a/src/mono_picture_asset_writer.h +++ b/src/mono_picture_asset_writer.h @@ -48,7 +48,7 @@ class MonoPictureAssetWriter : public PictureAssetWriter public: FrameInfo write (uint8_t *, int); void fake_write (int size); - void finalize (); + bool finalize (); private: friend class MonoPictureAsset; diff --git a/src/reel_asset.h b/src/reel_asset.h index ddd0f362..a1ad3cb1 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -68,6 +68,10 @@ public: return _asset_ref; } + int64_t intrinsic_duration () const { + return _intrinsic_duration; + } + int64_t entry_point () const { return _entry_point; } diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc index f24605bb..02029f18 100644 --- a/src/sound_asset_writer.cc +++ b/src/sound_asset_writer.cc @@ -108,7 +108,7 @@ SoundAssetWriter::write_current_frame () ++_frames_written; } -void +bool SoundAssetWriter::finalize () { if (_frame_buffer_offset > 0) { @@ -120,5 +120,5 @@ SoundAssetWriter::finalize () } _sound_asset->_intrinsic_duration = _frames_written; - AssetWriter::finalize (); + return AssetWriter::finalize (); } diff --git a/src/sound_asset_writer.h b/src/sound_asset_writer.h index 3516efcb..468d64be 100644 --- a/src/sound_asset_writer.h +++ b/src/sound_asset_writer.h @@ -44,7 +44,7 @@ class SoundAssetWriter : public AssetWriter { public: void write (float const * const *, int); - void finalize (); + bool finalize (); private: friend class SoundAsset; @@ -65,4 +65,3 @@ private: }; } - diff --git a/src/stereo_picture_asset_writer.cc b/src/stereo_picture_asset_writer.cc index f17e3d2f..322c7b00 100644 --- a/src/stereo_picture_asset_writer.cc +++ b/src/stereo_picture_asset_writer.cc @@ -110,14 +110,16 @@ StereoPictureAssetWriter::fake_write (int size) } } -void +bool StereoPictureAssetWriter::finalize () { - Kumu::Result_t r = _state->mxf_writer.Finalize(); - if (ASDCP_FAILURE (r)) { - boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r)); + if (_started) { + Kumu::Result_t r = _state->mxf_writer.Finalize(); + if (ASDCP_FAILURE (r)) { + boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r)); + } } _picture_asset->_intrinsic_duration = _frames_written; - PictureAssetWriter::finalize (); + return PictureAssetWriter::finalize (); } diff --git a/src/stereo_picture_asset_writer.h b/src/stereo_picture_asset_writer.h index f45aac3c..24f35ef4 100644 --- a/src/stereo_picture_asset_writer.h +++ b/src/stereo_picture_asset_writer.h @@ -46,7 +46,7 @@ public: */ FrameInfo write (uint8_t* data, int size); void fake_write (int size); - void finalize (); + bool finalize (); private: friend class StereoPictureAsset; |
