Cleanup: fix more comments/guards (and add check script).
[libdcp.git] / src / reel_subtitle_asset.cc
index 0981d1c02c3e21f63f5f96de9aab0f2de05b05cc..436aa69f6c84458589d5c7eee36c37ed5770949b 100644 (file)
 
 
 #include "language_tag.h"
-#include "subtitle_asset.h"
 #include "reel_subtitle_asset.h"
 #include "smpte_subtitle_asset.h"
+#include "subtitle_asset.h"
+#include "warnings.h"
+LIBDCP_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
+LIBDCP_ENABLE_WARNINGS
 
 
 using std::string;
@@ -52,16 +55,21 @@ using namespace dcp;
 
 
 ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
-       : ReelAsset (asset->id(), edit_rate, intrinsic_duration, entry_point)
-       , ReelFileAsset (asset)
+       : ReelFileAsset (
+               asset,
+               dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : boost::none,
+               asset->id(),
+               edit_rate,
+               intrinsic_duration,
+               entry_point
+               )
 {
 
 }
 
 
 ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<const cxml::Node> node)
-       : ReelAsset (node)
-       , ReelFileAsset (node)
+       : ReelFileAsset (node)
 {
        _language = node->optional_string_child("Language");
 }
@@ -82,16 +90,27 @@ ReelSubtitleAsset::set_language (dcp::LanguageTag language)
 
 
 bool
-ReelSubtitleAsset::equals (shared_ptr<const ReelSubtitleAsset> other, EqualityOptions opt, NoteHandler note) const
+ReelSubtitleAsset::equals(shared_ptr<const ReelSubtitleAsset> other, EqualityOptions const& opt, NoteHandler note) const
 {
        if (!asset_equals (other, opt, note)) {
                return false;
        }
-
-       if (_asset_ref.resolved() && other->_asset_ref.resolved()) {
-               return _asset_ref->equals (other->_asset_ref.asset(), opt, note);
+       if (!file_asset_equals (other, opt, note)) {
+               return false;
        }
 
        return true;
 }
 
+
+xmlpp::Element *
+ReelSubtitleAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
+{
+       auto asset = ReelFileAsset::write_to_cpl (node, standard);
+       if (_language) {
+               cxml::add_text_child(asset, "Language", *_language);
+       }
+       return asset;
+}
+
+