Allow CCAP reel nodes to have language tags.
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Aug 2018 10:55:10 +0000 (11:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Aug 2018 10:55:10 +0000 (11:55 +0100)
12 files changed:
src/reel_asset.cc
src/reel_asset.h
src/reel_atmos_asset.cc
src/reel_atmos_asset.h
src/reel_closed_caption_asset.cc
src/reel_closed_caption_asset.h
src/reel_picture_asset.cc
src/reel_picture_asset.h
src/reel_sound_asset.cc
src/reel_sound_asset.h
src/reel_subtitle_asset.cc
src/reel_subtitle_asset.h

index f96ee2c08b6aca83a416ab5232a0d09e7f02e274..72a1937cc89f2a9ebc54935bc757ea459251ba00 100644 (file)
@@ -92,7 +92,7 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> 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<string, string>
index af367cd3a0a79ac067ff746cfb89f691d5a4426e..42409ab968d81cece48c499ca46819b995ed604c 100644 (file)
@@ -69,7 +69,7 @@ public:
        ReelAsset (boost::shared_ptr<Asset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelAsset (boost::shared_ptr<const cxml::Node>);
 
-       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<const ReelAsset>, 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;
        }
index 8c1c21aeefb6b7a6bc8f4ac63798087af4c97557..9b59c56c409dfe0b5ba24c641d21b652c5017f5e 100644 (file)
@@ -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 <axd:AuxData> */
-       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;
 }
index 31f5293e135887372ca495672568a733a1aa9fd9..e93a54148a4fe9ff75ba4cbca49ef777a036e5d1 100644 (file)
@@ -59,7 +59,7 @@ public:
                return asset_of_type<AtmosAsset> ();
        }
 
-       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;
index 4fb729c679fa47b507c1c25b50c59d9347d31ab5..b7629011694253325f45798b94dc01e5ab3fc7bf 100644 (file)
@@ -60,7 +60,7 @@ ReelClosedCaptionAsset::ReelClosedCaptionAsset (boost::shared_ptr<const cxml::No
        : ReelAsset (node)
        , ReelMXF (node)
 {
-       node->ignore_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 <Hash> */
-               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;
 }
index 2cf65ad82721c799e4ae6cf2df6ad3f257580d4d..80e444d9391315c1ccad073665485f90046f3195 100644 (file)
@@ -55,16 +55,30 @@ public:
        ReelClosedCaptionAsset (boost::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
        explicit ReelClosedCaptionAsset (boost::shared_ptr<const cxml::Node>);
 
-       void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
 
        boost::shared_ptr<SubtitleAsset> asset () const {
                return asset_of_type<SubtitleAsset> ();
        }
 
+       void set_language (std::string l) {
+               _language = l;
+       }
+
+       void unset_language () {
+               _language = boost::optional<std::string> ();
+       }
+
+       boost::optional<std::string> language () const {
+               return _language;
+       }
+
 private:
        std::string key_type () const;
        std::string cpl_node_name (Standard standard) const;
        std::pair<std::string, std::string> cpl_node_namespace (Standard standard) const;
+
+       boost::optional<std::string> _language;
 };
 
 }
index 644024ec08501a9c6937f868ad81382da6da1e7e..1933c769d3ae5687c4aa6894199db938e7c39cd1 100644 (file)
@@ -86,15 +86,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 = ReelAsset::write_to_cpl (node, standard);
 
-       /* Find <MainPicture> */
-       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<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 ());
+               xmlpp::Node* hash = find_child (asset, "Hash");
+               asset->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get());
         }
+
+       return asset;
 }
 
 string
index 979bd8f6a9acf68fc99892b25484d49f32258706..a20c216f0abb9f4dedc5293d29eb229264a25f8b 100644 (file)
@@ -54,7 +54,7 @@ public:
        ReelPictureAsset (boost::shared_ptr<PictureAsset> asset, int64_t entry_point);
        explicit ReelPictureAsset (boost::shared_ptr<const cxml::Node>);
 
-       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<const ReelAsset>, EqualityOptions, NoteHandler) const;
 
        /** @return the PictureAsset that this object refers to */
index 178b0a08ed72062e90ec548b9d2b595917356d35..baacfe720ff77b29e4718938c3d19cbfc4aab98a 100644 (file)
@@ -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 <MainSound> */
-               xmlpp::Node* ms = find_child (node, cpl_node_name (standard));
                /* Find <Hash> */
-               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;
 }
index d95b83dcd41ededcd9d3bcb038d8fe0049feafa6..2fb01c8d110c06a6c06c87a9fb7a5d07794babf1 100644 (file)
@@ -52,7 +52,7 @@ public:
        ReelSoundAsset (boost::shared_ptr<dcp::SoundAsset> content, int64_t entry_point);
        explicit ReelSoundAsset (boost::shared_ptr<const cxml::Node>);
 
-       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<SoundAsset> asset () {
index 77c001d5e8a3e30a29eb5144f58251bf3d731071..75116b2b6782202a58497d990bc480d41fd0b034 100644 (file)
@@ -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 <MainSubtitle> */
-               xmlpp::Node* ms = find_child (node, cpl_node_name (standard));
                /* Find <Hash> */
-               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;
 }
index 976ff56d2d976adbf83268ef998fa4bf6b4b0730..8e0edc49567c59d56c93fb77935ce4f31eac7b2e 100644 (file)
@@ -55,7 +55,7 @@ public:
        ReelSubtitleAsset (boost::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelSubtitleAsset (boost::shared_ptr<const cxml::Node>);
 
-       void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
 
        boost::shared_ptr<SubtitleAsset> asset () const {
                return asset_of_type<SubtitleAsset> ();