+#include <iostream>
#include "cpl.h"
using namespace std;
creator = string_node ("Creator");
content_title_text = string_node ("ContentTitleText");
content_kind = kind_node ("ContentKind");
- content_version = sub_node<ContentVersion> ("ContentVersion");
+ content_version = optional_sub_node<ContentVersion> ("ContentVersion");
ignore_node ("RatingList");
reels = sub_nodes<Reel> ("ReelList", "Reel");
+ ignore_node ("Issuer");
+ ignore_node ("Signer");
+ ignore_node ("Signature");
+
done ();
}
: XMLNode (node)
{
id = string_node ("Id");
- annotation_text = string_node ("AnnotationText");
+ annotation_text = optional_string_node ("AnnotationText");
edit_rate = fraction_node ("EditRate");
intrinsic_duration = int64_node ("IntrinsicDuration");
entry_point = int64_node ("EntryPoint");
duration = int64_node ("Duration");
frame_rate = fraction_node ("FrameRate");
- screen_aspect_ratio = fraction_node ("ScreenAspectRatio");
+ try {
+ screen_aspect_ratio = fraction_node ("ScreenAspectRatio");
+ } catch (XMLError& e) {
+ /* Maybe it's not a fraction */
+ }
+ float f = float_node ("ScreenAspectRatio");
+ screen_aspect_ratio = Fraction (f * 1000, 1000);
+
+ ignore_node ("Hash");
done ();
}
: XMLNode (node)
{
id = string_node ("Id");
- annotation_text = string_node ("AnnotationText");
+ annotation_text = optional_string_node ("AnnotationText");
edit_rate = fraction_node ("EditRate");
intrinsic_duration = int64_node ("IntrinsicDuration");
entry_point = int64_node ("EntryPoint");
duration = int64_node ("Duration");
+ ignore_node ("Hash");
+
done ();
}
#include <fstream>
#include <iomanip>
#include <cassert>
+#include <iostream>
#include <boost/filesystem.hpp>
+#include <libxml++/libxml++.h>
#include "dcp.h"
#include "asset.h"
#include "sound_asset.h"
string asset_map_file;
for (filesystem::directory_iterator i = filesystem::directory_iterator(directory); i != filesystem::directory_iterator(); ++i) {
+
string const t = i->path().string ();
- if (ends_with (t, "_cpl.xml")) {
+
+ if (ends_with (t, ".mxf")) {
+ continue;
+ }
+
+ xmlpp::DomParser* p = new xmlpp::DomParser;
+
+ try {
+ p->parse_file (t);
+ } catch (std::exception& e) {
+ delete p;
+ continue;
+ }
+
+ if (!p) {
+ delete p;
+ continue;
+ }
+
+ string const root = p->get_document()->get_root_node()->get_name ();
+ delete p;
+
+ if (root == "CompositionPlaylist") {
if (cpl_file.empty ()) {
cpl_file = t;
} else {
throw DCPReadError ("duplicate CPLs found");
}
- } else if (ends_with (t, "_pkl.xml")) {
+ } else if (root == "PackingList") {
if (pkl_file.empty ()) {
pkl_file = t;
} else {
throw DCPReadError ("duplicate PKLs found");
}
- } else if (ends_with (t, "ASSETMAP.xml")) {
+ } else if (root == "AssetMap") {
if (asset_map_file.empty ()) {
asset_map_file = t;
} else {
throw DCPReadError ("duplicate AssetMaps found");
}
+ asset_map_file = t;
}
}
_fps = cpl_assets->main_picture->frame_rate.numerator;
_length = cpl_assets->main_picture->duration;
+ string n = cpl_assets->main_picture->annotation_text;
+ if (n.empty ()) {
+ n = pkl->asset_from_id(cpl_assets->main_picture->id)->original_file_name;
+ }
+
_assets.push_back (shared_ptr<PictureAsset> (
new PictureAsset (
_directory,
- cpl_assets->main_picture->annotation_text,
+ n,
_fps,
_length,
cpl_assets->main_picture->screen_aspect_ratio.numerator,
)
));
+ n = cpl_assets->main_sound->annotation_text;
+ if (n.empty ()) {
+ n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name;
+ }
+
if (cpl_assets->main_sound) {
_assets.push_back (shared_ptr<SoundAsset> (
new SoundAsset (
_directory,
- cpl_assets->main_sound->annotation_text,
+ n,
_fps,
_length
)
std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
boost::shared_ptr<const PictureFrame> get_frame (int n) const;
+
+ int width () const {
+ return _width;
+ }
+
+ int height () const {
+ return _height;
+ }
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
+#include <iostream>
#include "pkl.h"
using namespace std;
+using namespace boost;
using namespace libdcp;
PKL::PKL (string file)
hash = string_node ("Hash");
size = int64_node ("Size");
type = string_node ("Type");
+ original_file_name = optional_string_node ("OriginalFileName");
}
+shared_ptr<PKLAsset>
+PKL::asset_from_id (string id) const
+{
+ for (list<shared_ptr<PKLAsset> >::const_iterator i = assets.begin (); i != assets.end(); ++i) {
+ if ((*i)->id == id) {
+ return *i;
+ }
+ }
+
+ return shared_ptr<PKLAsset> ();
+}
+
std::string hash;
int64_t size;
std::string type;
+ std::string original_file_name;
};
class PKL : public XMLFile
public:
PKL (std::string file);
+ boost::shared_ptr<PKLAsset> asset_from_id (std::string id) const;
+
std::string id;
std::string annotation_text;
std::string issue_date;
return lexical_cast<int64_t> (string_node (name));
}
+int64_t
+XMLNode::optional_int64_node (string name)
+{
+ list<xmlpp::Node*> nodes = xml_nodes (name);
+ if (nodes.size() > 2) {
+ throw XMLError ("duplicate XML tag " + name);
+ }
+
+ if (nodes.empty ()) {
+ return 0;
+ }
+
+ return int64_node (name);
+}
+
+float
+XMLNode::float_node (string name)
+{
+ return lexical_cast<float> (string_node (name));
+}
+
void
XMLNode::ignore_node (string name)
{
ContentKind kind_node (std::string);
Fraction fraction_node (std::string);
int64_t int64_node (std::string);
+ int64_t optional_int64_node (std::string);
+ float float_node (std::string);
void ignore_node (std::string);
void done ();