Shaka Packager SDK
Loading...
Searching...
No Matches
text_stream_info.h
1// Copyright 2015 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
8#define PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
9
10#include <cstdint>
11#include <map>
12#include <memory>
13#include <string>
14#include <utility>
15
16#include <packager/media/base/stream_info.h>
17#include <packager/media/base/text_sample.h>
18
19namespace shaka {
20namespace media {
21
22struct TextRegion {
24 TextNumber width{100, TextUnitType::kPercent};
26 TextNumber height{100, TextUnitType::kPercent};
27
31 TextNumber window_anchor_x{0, TextUnitType::kPercent};
32 TextNumber window_anchor_y{0, TextUnitType::kPercent};
38 TextNumber region_anchor_x{0, TextUnitType::kPercent};
39 TextNumber region_anchor_y{0, TextUnitType::kPercent};
40
43 bool scroll = false;
44};
45
49 std::string language;
50};
51
52class TextStreamInfo : public StreamInfo {
53 public:
66 TextStreamInfo(int track_id,
67 int32_t time_scale,
68 int64_t duration,
69 Codec codec,
70 const std::string& codec_string,
71 const std::string& codec_config,
72 uint16_t width,
73 uint16_t height,
74 const std::string& language);
75
76 ~TextStreamInfo() override;
77
78 bool IsValidConfig() const override;
79
80 std::string ToString() const override;
81 std::unique_ptr<StreamInfo> Clone() const override;
82
83 uint16_t width() const { return width_; }
84 uint16_t height() const { return height_; }
85 const std::map<std::string, TextRegion>& regions() const { return regions_; }
86 void AddRegion(const std::string& id, const TextRegion& region) {
87 regions_[id] = region;
88 }
89 const std::string& css_styles() const { return css_styles_; }
90 void set_css_styles(const std::string& styles) { css_styles_ = styles; }
91
92 void AddSubStream(uint16_t index, TextSubStreamInfo info) {
93 sub_streams_.emplace(index, std::move(info));
94 }
95 const std::map<uint16_t, TextSubStreamInfo>& sub_streams() const {
96 return sub_streams_;
97 }
98
99 private:
100 std::map<std::string, TextRegion> regions_;
101 std::map<uint16_t, TextSubStreamInfo> sub_streams_;
102 std::string css_styles_;
103 uint16_t width_;
104 uint16_t height_;
105
106 // Allow copying. This is very light weight.
107};
108
109} // namespace media
110} // namespace shaka
111
112#endif // PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
Abstract class holds stream information.
Definition stream_info.h:73
std::string ToString() const override
std::unique_ptr< StreamInfo > Clone() const override
bool IsValidConfig() const override
All the methods that are virtual are virtual for mocking.
TextNumber width
The width of the region; percent units are relative to the window.
TextNumber height
The height of the region; percent units are relative to the window.