// Copyright 2020 Google LLC. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd #ifndef PACKAGER_MEDIA_FORMATS_TTML_TTML_GENERATOR_H_ #define PACKAGER_MEDIA_FORMATS_TTML_TTML_GENERATOR_H_ #include #include #include #include #include #include #include namespace shaka { namespace media { namespace ttml { class TtmlGenerator { public: explicit TtmlGenerator(); ~TtmlGenerator(); static const char* kTtNamespace; void Initialize(const std::map& regions, const std::string& language, int32_t time_scale); void AddSample(const TextSample& sample); void Reset(); bool Dump(std::string* result) const; private: bool AddSampleToXml(const TextSample& sample, xml::XmlNode* body, xml::XmlNode* metadata, std::unordered_set& fragmentStyles, size_t* image_count) const; bool ConvertFragmentToXml(const TextFragment& fragment, xml::XmlNode* parent, xml::XmlNode* metadata, std::unordered_set& fragmentStyles, size_t* image_count) const; bool addStyling(xml::XmlNode& styling, const std::unordered_set& fragmentStyles) const; bool addRegions(xml::XmlNode& layout) const; std::vector usedRegions() const; bool isEbuTTTD() const; std::list samples_; std::map regions_; std::string language_; int32_t time_scale_; // This is modified in "const" methods to create unique IDs. mutable uint32_t region_id_ = 0; }; } // namespace ttml } // namespace media } // namespace shaka #endif // PACKAGER_MEDIA_FORMATS_TTML_TTML_GENERATOR_H_