2020-10-08 21:46:37 +00:00
|
|
|
// 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 <list>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/media/base/text_sample.h>
|
|
|
|
#include <packager/media/base/text_stream_info.h>
|
|
|
|
#include <packager/mpd/base/xml/xml_node.h>
|
2020-10-08 21:46:37 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
namespace ttml {
|
|
|
|
|
|
|
|
class TtmlGenerator {
|
|
|
|
public:
|
|
|
|
explicit TtmlGenerator();
|
|
|
|
~TtmlGenerator();
|
|
|
|
|
2020-10-13 21:43:18 +00:00
|
|
|
static const char* kTtNamespace;
|
|
|
|
|
2020-10-08 21:46:37 +00:00
|
|
|
void Initialize(const std::map<std::string, TextRegion>& regions,
|
|
|
|
const std::string& language,
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t time_scale);
|
2020-10-08 21:46:37 +00:00
|
|
|
void AddSample(const TextSample& sample);
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
bool Dump(std::string* result) const;
|
|
|
|
|
|
|
|
private:
|
2020-11-20 21:03:16 +00:00
|
|
|
bool AddSampleToXml(const TextSample& sample,
|
|
|
|
xml::XmlNode* body,
|
|
|
|
xml::XmlNode* metadata,
|
|
|
|
size_t* image_count) const;
|
2020-10-08 21:46:37 +00:00
|
|
|
bool ConvertFragmentToXml(const TextFragment& fragment,
|
2020-11-20 21:03:16 +00:00
|
|
|
xml::XmlNode* parent,
|
|
|
|
xml::XmlNode* metadata,
|
|
|
|
size_t* image_count) const;
|
2020-10-08 21:46:37 +00:00
|
|
|
|
|
|
|
std::list<TextSample> samples_;
|
|
|
|
std::map<std::string, TextRegion> regions_;
|
|
|
|
std::string language_;
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t time_scale_;
|
2020-12-01 19:32:39 +00:00
|
|
|
// This is modified in "const" methods to create unique IDs.
|
|
|
|
mutable uint32_t region_id_ = 0;
|
2020-10-08 21:46:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ttml
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|
|
|
|
|
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_TTML_TTML_GENERATOR_H_
|