From 367b43df1630a5e4e4173fb50e234803f248f00f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Aug 2018 11:55:10 +0100 Subject: [PATCH] Allow CCAP reel nodes to have language tags. --- src/reel_asset.cc | 3 ++- src/reel_asset.h | 6 +++++- src/reel_atmos_asset.cc | 10 ++++------ src/reel_atmos_asset.h | 2 +- src/reel_closed_caption_asset.cc | 20 ++++++++++++-------- src/reel_closed_caption_asset.h | 16 +++++++++++++++- src/reel_picture_asset.cc | 19 +++++++++---------- src/reel_picture_asset.h | 2 +- src/reel_sound_asset.cc | 12 ++++++------ src/reel_sound_asset.h | 2 +- src/reel_subtitle_asset.cc | 15 ++++++--------- src/reel_subtitle_asset.h | 2 +- 12 files changed, 63 insertions(+), 46 deletions(-) diff --git a/src/reel_asset.cc b/src/reel_asset.cc index f96ee2c0..72a1937c 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -92,7 +92,7 @@ ReelAsset::ReelAsset (shared_ptr node) } -void +xmlpp::Node* ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { xmlpp::Element* a = node->add_child (cpl_node_name (standard)); @@ -113,6 +113,7 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const if (_hash) { a->add_child("Hash")->add_child_text (_hash.get()); } + return a; } pair diff --git a/src/reel_asset.h b/src/reel_asset.h index af367cd3..42409ab9 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -69,7 +69,7 @@ public: ReelAsset (boost::shared_ptr asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); explicit ReelAsset (boost::shared_ptr); - virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; + virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; virtual bool equals (boost::shared_ptr, EqualityOptions, NoteHandler) const; /** @return a Ref to our actual asset */ @@ -113,6 +113,10 @@ public: return _hash; } + std::string annotation_text () const { + return _annotation_text; + } + void set_annotation_text (std::string at) { _annotation_text = at; } diff --git a/src/reel_atmos_asset.cc b/src/reel_atmos_asset.cc index 8c1c21ae..9b59c56c 100644 --- a/src/reel_atmos_asset.cc +++ b/src/reel_atmos_asset.cc @@ -77,12 +77,10 @@ ReelAtmosAsset::key_type () const return "MDEK"; } -void +xmlpp::Node * ReelAtmosAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { - ReelAsset::write_to_cpl (node, standard); - - /* Find */ - xmlpp::Node* mp = find_child (node, cpl_node_name (standard)); - mp->add_child("axd:DataType")->add_child_text ("urn:smpte:ul:060e2b34.04010105.0e090604.00000000"); + xmlpp::Node* asset = ReelAsset::write_to_cpl (node, standard); + asset->add_child("axd:DataType")->add_child_text("urn:smpte:ul:060e2b34.04010105.0e090604.00000000"); + return asset; } diff --git a/src/reel_atmos_asset.h b/src/reel_atmos_asset.h index 31f5293e..e93a5414 100644 --- a/src/reel_atmos_asset.h +++ b/src/reel_atmos_asset.h @@ -59,7 +59,7 @@ public: return asset_of_type (); } - void write_to_cpl (xmlpp::Node* node, Standard standard) const; + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; private: std::string key_type () const; diff --git a/src/reel_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc index 4fb729c6..b7629011 100644 --- a/src/reel_closed_caption_asset.cc +++ b/src/reel_closed_caption_asset.cc @@ -60,7 +60,7 @@ ReelClosedCaptionAsset::ReelClosedCaptionAsset (boost::shared_ptrignore_child ("Language"); + _language = node->optional_string_child ("Language"); node->done (); } @@ -96,16 +96,20 @@ ReelClosedCaptionAsset::key_type () const return "MDSK"; } -void +xmlpp::Node * ReelClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { - ReelAsset::write_to_cpl (node, standard); + xmlpp::Node* asset = ReelAsset::write_to_cpl (node, standard); - if (key_id ()) { - /* Find our main tag */ - xmlpp::Node* ms = find_child (node, cpl_node_name (standard)); + if (key_id()) { /* Find */ - xmlpp::Node* hash = find_child (ms, "Hash"); - ms->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ()); + xmlpp::Node* hash = find_child (asset, "Hash"); + asset->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get()); } + + if (_language) { + asset->add_child("Language")->add_child_text(*_language); + } + + return asset; } diff --git a/src/reel_closed_caption_asset.h b/src/reel_closed_caption_asset.h index 2cf65ad8..80e444d9 100644 --- a/src/reel_closed_caption_asset.h +++ b/src/reel_closed_caption_asset.h @@ -55,16 +55,30 @@ public: ReelClosedCaptionAsset (boost::shared_ptr asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point); explicit ReelClosedCaptionAsset (boost::shared_ptr); - void write_to_cpl (xmlpp::Node* node, Standard standard) const; + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; boost::shared_ptr asset () const { return asset_of_type (); } + void set_language (std::string l) { + _language = l; + } + + void unset_language () { + _language = boost::optional (); + } + + boost::optional language () const { + return _language; + } + private: std::string key_type () const; std::string cpl_node_name (Standard standard) const; std::pair cpl_node_namespace (Standard standard) const; + + boost::optional _language; }; } diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 644024ec..1933c769 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -86,15 +86,12 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr node) } } -void +xmlpp::Node* ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { - ReelAsset::write_to_cpl (node, standard); + xmlpp::Node* asset = ReelAsset::write_to_cpl (node, standard); - /* Find */ - xmlpp::Node* mp = find_child (node, cpl_node_name (standard)); - - 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 */ @@ -115,18 +112,20 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const } } - mp->add_child ("ScreenAspectRatio")->add_child_text (raw_convert (closest.get(), 2, true)); + asset->add_child ("ScreenAspectRatio")->add_child_text (raw_convert (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 */ - xmlpp::Node* hash = find_child (mp, "Hash"); - mp->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ()); + xmlpp::Node* hash = find_child (asset, "Hash"); + asset->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get()); } + + return asset; } string diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h index 979bd8f6..a20c216f 100644 --- a/src/reel_picture_asset.h +++ b/src/reel_picture_asset.h @@ -54,7 +54,7 @@ public: ReelPictureAsset (boost::shared_ptr asset, int64_t entry_point); explicit ReelPictureAsset (boost::shared_ptr); - virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; + virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; virtual bool equals (boost::shared_ptr, EqualityOptions, NoteHandler) const; /** @return the PictureAsset that this object refers to */ diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc index 178b0a08..baacfe72 100644 --- a/src/reel_sound_asset.cc +++ b/src/reel_sound_asset.cc @@ -71,16 +71,16 @@ ReelSoundAsset::key_type () const return "MDAK"; } -void +xmlpp::Node * ReelSoundAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { - ReelAsset::write_to_cpl (node, standard); + xmlpp::Node* asset = ReelAsset::write_to_cpl (node, standard); if (key_id ()) { - /* Find */ - xmlpp::Node* ms = find_child (node, cpl_node_name (standard)); /* Find */ - xmlpp::Node* hash = find_child (ms, "Hash"); - ms->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ()); + xmlpp::Node* hash = find_child (asset, "Hash"); + asset->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get()); } + + return asset; } diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index d95b83dc..2fb01c8d 100644 --- a/src/reel_sound_asset.h +++ b/src/reel_sound_asset.h @@ -52,7 +52,7 @@ public: ReelSoundAsset (boost::shared_ptr content, int64_t entry_point); explicit ReelSoundAsset (boost::shared_ptr); - void write_to_cpl (xmlpp::Node* node, Standard standard) const; + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; /** @return the SoundAsset that this object refers to */ boost::shared_ptr asset () { diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc index 77c001d5..75116b2b 100644 --- a/src/reel_subtitle_asset.cc +++ b/src/reel_subtitle_asset.cc @@ -73,19 +73,16 @@ ReelSubtitleAsset::key_type () const return "MDSK"; } -void +xmlpp::Node * ReelSubtitleAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { - ReelAsset::write_to_cpl (node, standard); + xmlpp::Node* asset = ReelAsset::write_to_cpl (node, standard); - /* XXX: couldn't this stuff be in the parent class? All child - classes seem to do the same thing...? - */ if (key_id ()) { - /* Find */ - xmlpp::Node* ms = find_child (node, cpl_node_name (standard)); /* Find */ - xmlpp::Node* hash = find_child (ms, "Hash"); - ms->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ()); + xmlpp::Node* hash = find_child (asset, "Hash"); + asset->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get()); } + + return asset; } diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h index 976ff56d..8e0edc49 100644 --- a/src/reel_subtitle_asset.h +++ b/src/reel_subtitle_asset.h @@ -55,7 +55,7 @@ public: ReelSubtitleAsset (boost::shared_ptr asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); explicit ReelSubtitleAsset (boost::shared_ptr); - void write_to_cpl (xmlpp::Node* node, Standard standard) const; + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; boost::shared_ptr asset () const { return asset_of_type (); -- 2.30.2