/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
* @brief ReelPictureAsset class.
*/
-#include "content.h"
#include "reel_picture_asset.h"
-#include "picture_mxf.h"
+#include "picture_asset.h"
#include "dcp_assert.h"
#include "compose.hpp"
#include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
#include <iomanip>
using std::bad_cast;
}
-ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureMXF> content, int64_t entry_point)
- : ReelMXFAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
- , _frame_rate (content->frame_rate ())
- , _screen_aspect_ratio (content->screen_aspect_ratio ())
+ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entry_point)
+ : ReelAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point)
+ , ReelMXF (asset->key_id())
+ , _frame_rate (asset->frame_rate ())
+ , _screen_aspect_ratio (asset->screen_aspect_ratio ())
{
-
+
}
ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
- : ReelMXFAsset (node)
+ : ReelAsset (node)
+ , ReelMXF (node)
{
_frame_rate = Fraction (node->string_child ("FrameRate"));
try {
_screen_aspect_ratio = Fraction (node->string_child ("ScreenAspectRatio"));
} catch (XMLError& e) {
- /* Maybe it's not a fraction */
- }
- try {
- float f = node->number_child<float> ("ScreenAspectRatio");
- _screen_aspect_ratio = Fraction (f * 1000, 1000);
- } catch (bad_cast& e) {
+ /* It's not a fraction */
+ try {
+ float f = node->number_child<float> ("ScreenAspectRatio");
+ _screen_aspect_ratio = Fraction (f * 1000, 1000);
+ } catch (bad_cast& e) {
+ }
}
}
void
ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
{
- ReelMXFAsset::write_to_cpl (node, standard);
+ ReelAsset::write_to_cpl (node, standard);
- xmlpp::Node::NodeList c = node->get_children ();
- xmlpp::Node::NodeList::iterator i = c.begin();
- while (i != c.end() && (*i)->get_name() != cpl_node_name ()) {
- ++i;
- }
+ /* Find <MainPicture> */
+ xmlpp::Node* mp = find_child (node, cpl_node_name ());
- DCP_ASSERT (i != c.end ());
-
- (*i)->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+ mp->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
if (standard == INTEROP) {
stringstream s;
s << std::fixed << std::setprecision (2) << (float (_screen_aspect_ratio.numerator) / _screen_aspect_ratio.denominator);
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (s.str ());
+ mp->add_child ("ScreenAspectRatio")->add_child_text (s.str ());
} else {
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (
+ mp->add_child ("ScreenAspectRatio")->add_child_text (
String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
);
}
+
+ if (key_id ()) {
+ /* Find <Hash> */
+ xmlpp::Node* hash = find_child (mp, "Hash");
+ mp->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ());
+ }
}
string
if (!ReelAsset::equals (other, opt, note)) {
return false;
}
-
+
shared_ptr<const ReelPictureAsset> rpa = dynamic_pointer_cast<const ReelPictureAsset> (other);
if (!rpa) {
return false;