Debug.
[libdcp.git] / src / reel_picture_asset.cc
index e8ee1d7e028c963b0a77fc632c51778071d31456..3052c616c67533fe6f5384a2b6313b38706199db 100644 (file)
     You should have received a copy of the GNU General Public License
     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
 
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
 */
 
 /** @file  src/reel_picture_asset.h
 
 using std::bad_cast;
 using std::string;
-using std::stringstream;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using namespace dcp;
 
-ReelPictureAsset::ReelPictureAsset ()
-       : _frame_rate (Fraction (24, 1))
-       , _screen_aspect_ratio (Fraction (1998, 1080))
-{
-
-}
-
 ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entry_point)
-       : ReelAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelMXF (asset->key_id())
+       : ReelAsset (asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
+       , ReelMXF (asset, asset->key_id())
        , _frame_rate (asset->frame_rate ())
        , _screen_aspect_ratio (asset->screen_aspect_ratio ())
 {
@@ -74,15 +79,12 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
        }
 }
 
-void
+xmlpp::Node*
 ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-       ReelAsset::write_to_cpl (node, standard);
+       xmlpp::Node* asset = write_to_cpl_asset (node, standard, hash());
 
-       /* Find <MainPicture> */
-       xmlpp::Node* mp = find_child (node, cpl_node_name ());
-
-       mp->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+       asset->add_child("FrameRate")->add_child_text(String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
        if (standard == INTEROP) {
 
                /* Allowed values for this tag from the standard */
@@ -103,18 +105,16 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
                        }
                }
 
-               mp->add_child ("ScreenAspectRatio")->add_child_text (raw_convert<string> (closest.get(), 2, true));
+               asset->add_child ("ScreenAspectRatio")->add_child_text (raw_convert<string> (closest.get(), 2, true));
        } else {
-               mp->add_child ("ScreenAspectRatio")->add_child_text (
+               asset->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 ());
-        }
+       write_to_cpl_mxf (asset);
+
+       return asset;
 }
 
 string
@@ -124,9 +124,12 @@ ReelPictureAsset::key_type () const
 }
 
 bool
-ReelPictureAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, NoteHandler note) const
+ReelPictureAsset::equals (shared_ptr<const ReelPictureAsset> other, EqualityOptions opt, NoteHandler note) const
 {
-       if (!ReelAsset::equals (other, opt, note)) {
+       if (!asset_equals (other, opt, note)) {
+               return false;
+       }
+       if (!mxf_equals (other, opt, note)) {
                return false;
        }