diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-07-31 00:07:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-07-31 00:07:08 +0100 |
| commit | d8c9cbec9d87f28da338350880b7618b94f4da81 (patch) | |
| tree | c1e853ab494ac3731982c075046215f670153232 /src | |
| parent | 9a9d4e014c16be88d72914a9480343445bc785a5 (diff) | |
Bits.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_map.cc | 18 | ||||
| -rw-r--r-- | src/asset_map.h | 27 | ||||
| -rw-r--r-- | src/cpl.cc | 9 | ||||
| -rw-r--r-- | src/cpl.h | 13 | ||||
| -rw-r--r-- | src/dcp.cc | 37 | ||||
| -rw-r--r-- | src/picture_asset.cc | 8 | ||||
| -rw-r--r-- | src/picture_asset.h | 2 | ||||
| -rw-r--r-- | src/pkl.cc | 8 | ||||
| -rw-r--r-- | src/pkl.h | 11 | ||||
| -rw-r--r-- | src/sound_asset.cc | 7 | ||||
| -rw-r--r-- | src/sound_asset.h | 6 | ||||
| -rw-r--r-- | src/wscript | 3 | ||||
| -rw-r--r-- | src/xml.cc | 2 | ||||
| -rw-r--r-- | src/xml.h | 5 |
14 files changed, 89 insertions, 67 deletions
diff --git a/src/asset_map.cc b/src/asset_map.cc index b5e621d4..11e80284 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -4,20 +4,14 @@ using namespace std; using namespace libdcp; AssetMap::AssetMap (string file) - : XMLFile (file) + : XMLFile (file, "AssetMap") { id = string_node ("Id"); creator = string_node ("Creator"); volume_count = int_node ("VolumeCount"); issue_date = string_node ("IssueDate"); issuer = string_node ("Issuer"); - asset_list = sub_node<AssetList> ("AssetMapAssetList"); -} - -AssetMapAssetList::AssetMapAssetList (xmlpp::Node const * node) - : XMLNode (node) -{ - assets = sub_nodes<AssetMapAsset> ("Asset"); + assets = sub_nodes<AssetMapAsset> ("AssetList", "Asset"); } AssetMapAsset::AssetMapAsset (xmlpp::Node const * node) @@ -25,13 +19,7 @@ AssetMapAsset::AssetMapAsset (xmlpp::Node const * node) { id = string_node ("Id"); packing_list = optional_string_node ("PackingList"); - chunk_list = sub_node<ChunkList> ("ChunkList"); -} - -ChunkList::ChunkList (xmlpp::Node const * node) - : XMLNode (node) -{ - chunks = sub_nodes<Chunk> ("Chunk"); + chunks = sub_nodes<Chunk> ("ChunkList", "Chunk"); } Chunk::Chunk (xmlpp::Node const * node) diff --git a/src/asset_map.h b/src/asset_map.h index 56370ab9..754528ec 100644 --- a/src/asset_map.h +++ b/src/asset_map.h @@ -3,24 +3,27 @@ namespace libdcp { -class AssetMapAsset : public XMLNode +class Chunk : public XMLNode { public: - AssetMapAsset (); - AssetMapAsset (xmlpp::Node const * node); + Chunk (); + Chunk (xmlpp::Node const * node); - std::string id; - std::string packing_list; - boost::shared_ptr<ChunkList> + std::string path; + int volume_index; + int offset; + int length; }; -class AssetMapAssetList : public XMLNode +class AssetMapAsset : public XMLNode { public: - AssetMapAssetList (); - AssetMapAssetList (xmlpp::Node const * node); + AssetMapAsset (); + AssetMapAsset (xmlpp::Node const * node); - std::list<boost::shared_ptr<AssetMapAsset> > assets; + std::string id; + std::string packing_list; + std::list<boost::shared_ptr<Chunk> > chunks; }; class AssetMap : public XMLFile @@ -33,5 +36,7 @@ public: int volume_count; std::string issue_date; std::string issuer; - boost::shared_ptr<AssetMapAssetList> asset_list; + std::list<boost::shared_ptr<AssetMapAsset> > assets; }; + +} @@ -14,7 +14,7 @@ CPL::CPL (string file) content_kind = kind_node ("ContentKind"); content_version = sub_node<ContentVersion> ("ContentVersion"); ignore_node ("RatingList"); - reel_list = sub_node<ReelList> ("ReelList"); + reels = sub_nodes<Reel> ("ReelList", "Reel"); done (); } @@ -27,13 +27,6 @@ ContentVersion::ContentVersion (xmlpp::Node const * node) done (); } -ReelList::ReelList (xmlpp::Node const * node) - : XMLNode (node) -{ - reels = sub_nodes<Reel> ("Reel"); - done (); -} - Reel::Reel (xmlpp::Node const * node) : XMLNode (node) { @@ -53,15 +53,6 @@ public: boost::shared_ptr<CPLAssetList> asset_list; }; -class ReelList : public XMLNode -{ -public: - ReelList () {} - ReelList (xmlpp::Node const * node); - - std::list<boost::shared_ptr<Reel> > reels; -}; - class ContentVersion : public XMLNode { public: @@ -82,9 +73,9 @@ public: std::string issue_date; std::string creator; std::string content_title_text; - std::string content_kind; + ContentKind content_kind; boost::shared_ptr<ContentVersion> content_version; - boost::shared_ptr<ReelList> reel_list; + std::list<boost::shared_ptr<Reel> > reels; }; } @@ -35,6 +35,7 @@ #include "exceptions.h" #include "cpl.h" #include "pkl.h" +#include "asset_map.h" using namespace std; using namespace boost; @@ -273,7 +274,43 @@ DCP::DCP (string directory) } } + /* Read the XML */ CPL cpl (cpl_file); PKL pkl (pkl_file); + AssetMap asset_map (asset_map_file); + + /* Cross-check */ + /* XXX */ + + /* Now cherry-pick the required bits into our own data structure */ + + _name = cpl.annotation_text; + _content_kind = cpl.content_kind; + + shared_ptr<CPLAssetList> cpl_assets = cpl.reels.front()->asset_list; + + /* XXX */ + _fps = cpl_assets->main_picture->frame_rate.numerator; + _length = cpl_assets->main_picture->duration; + + _assets.push_back (shared_ptr<PictureAsset> ( + new PictureAsset ( + cpl_assets->main_picture->annotation_text, + _fps, + _length, + cpl_assets->main_picture->screen_aspect_ratio.numerator, + cpl_assets->main_picture->screen_aspect_ratio.denominator + ) + )); + + if (cpl_assets->main_sound) { + _assets.push_back (shared_ptr<SoundAsset> ( + new SoundAsset ( + cpl_assets->main_picture->annotation_text, + _fps, + _length + ) + )); + } } diff --git a/src/picture_asset.cc b/src/picture_asset.cc index eb06012f..2f8a622a 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -66,6 +66,14 @@ PictureAsset::PictureAsset ( construct (sigc::bind (sigc::mem_fun (*this, &PictureAsset::path_from_list), files)); } +PictureAsset::PictureAsset (string mxf_path, int fps, int length, int width, int height) + : Asset (mxf_path, 0, fps, length) + , _width (width) + , _height (height) +{ + +} + string PictureAsset::path_from_list (int f, vector<string> const & files) const { diff --git a/src/picture_asset.h b/src/picture_asset.h index 26b9b55a..e540c074 100644 --- a/src/picture_asset.h +++ b/src/picture_asset.h @@ -69,6 +69,8 @@ public: int width, int height ); + + PictureAsset (std::string mxf_path, int fps, int length, int width, int height); /** Write details of this asset to a CPL stream. * @param s Stream. @@ -11,13 +11,7 @@ PKL::PKL (string file) issue_date = string_node ("IssueDate"); issuer = string_node ("Issuer"); creator = string_node ("Creator"); - asset_list = sub_node<PKLAssetList> ("AssetList"); -} - -PKLAssetList::PKLAssetList (xmlpp::Node const * node) - : XMLNode (node) -{ - assets = sub_nodes<PKLAsset> ("Asset"); + assets = sub_nodes<PKLAsset> ("AssetList", "Asset"); } PKLAsset::PKLAsset (xmlpp::Node const * node) @@ -16,15 +16,6 @@ public: std::string type; }; -class PKLAssetList : public XMLNode -{ -public: - PKLAssetList (); - PKLAssetList (xmlpp::Node const * node); - - std::list<boost::shared_ptr<PKLAsset> > assets; -}; - class PKL : public XMLFile { public: @@ -35,7 +26,7 @@ public: std::string issue_date; std::string issuer; std::string creator; - boost::shared_ptr<PKLAssetList> asset_list; + std::list<boost::shared_ptr<PKLAsset> > assets; }; } diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 3546bb5b..a0d17f29 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -51,6 +51,13 @@ SoundAsset::SoundAsset ( construct (get_path); } +SoundAsset::SoundAsset (string mxf_path, int fps, int length) + : Asset (mxf_path, 0, fps, length) + , _channels (0) +{ + +} + string SoundAsset::path_from_channel (Channel channel, vector<string> const & files) { diff --git a/src/sound_asset.h b/src/sound_asset.h index 6e85a407..914823a2 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -67,6 +67,12 @@ public: int length, int channels ); + + SoundAsset ( + std::string mxf_path, + int fps, + int length + ); /** Write details of this asset to a CPL stream. * @param s Stream. diff --git a/src/wscript b/src/wscript index 1505edcc..6c4f483e 100644 --- a/src/wscript +++ b/src/wscript @@ -6,9 +6,10 @@ def build(bld): obj.uselib = 'BOOST_FILESYSTEM OPENSSL SIGC++ LIBXML++' obj.use = 'libkumu-libdcp libasdcp-libdcp' obj.source = """ + asset.cc + asset_map.cc cpl.cc dcp.cc - asset.cc sound_asset.cc picture_asset.cc pkl.cc @@ -135,8 +135,6 @@ XMLFile::XMLFile (string file, string root_name) if (_node->get_name() != root_name) { throw XMLError ("unrecognised root node"); } - - cout << this << " root node is " << _node->get_name() << "\n"; } XMLFile::~XMLFile () @@ -48,8 +48,9 @@ protected: } template <class T> - std::list<boost::shared_ptr<T> > sub_nodes (std::string name) { - std::list<xmlpp::Node*> n = xml_nodes (name); + std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) { + XMLNode p (xml_node (name)); + std::list<xmlpp::Node*> n = p.xml_nodes (sub); std::list<boost::shared_ptr<T> > r; for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) { r.push_back (boost::shared_ptr<T> (new T (*i))); |
