// 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 "packager/media/base/text_sample.h" #include "packager/media/base/text_stream_info.h" #include "packager/mpd/base/xml/xml_node.h" 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, size_t* image_count) const; bool ConvertFragmentToXml(const TextFragment& fragment, xml::XmlNode* parent, xml::XmlNode* metadata, size_t* image_count) 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_