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 <map>
11#include <string>
12
13#include <packager/media/base/stream_info.h>
14#include <packager/media/base/text_sample.h>
15
16namespace shaka {
17namespace media {
18
19struct TextRegion {
21 TextNumber width{100, TextUnitType::kPercent};
23 TextNumber height{100, TextUnitType::kPercent};
24
28 TextNumber window_anchor_x{0, TextUnitType::kPercent};
29 TextNumber window_anchor_y{0, TextUnitType::kPercent};
35 TextNumber region_anchor_x{0, TextUnitType::kPercent};
36 TextNumber region_anchor_y{0, TextUnitType::kPercent};
37
40 bool scroll = false;
41};
42
46 std::string language;
47};
48
49class TextStreamInfo : public StreamInfo {
50 public:
63 TextStreamInfo(int track_id,
64 int32_t time_scale,
65 int64_t duration,
66 Codec codec,
67 const std::string& codec_string,
68 const std::string& codec_config,
69 uint16_t width,
70 uint16_t height,
71 const std::string& language);
72
73 ~TextStreamInfo() override;
74
75 bool IsValidConfig() const override;
76
77 std::string ToString() const override;
78 std::unique_ptr<StreamInfo> Clone() const override;
79
80 uint16_t width() const { return width_; }
81 uint16_t height() const { return height_; }
82 const std::map<std::string, TextRegion>& regions() const { return regions_; }
83 void AddRegion(const std::string& id, const TextRegion& region) {
84 regions_[id] = region;
85 }
86 const std::string& css_styles() const { return css_styles_; }
87 void set_css_styles(const std::string& styles) { css_styles_ = styles; }
88
89 void AddSubStream(uint16_t index, TextSubStreamInfo info) {
90 sub_streams_.emplace(index, std::move(info));
91 }
92 const std::map<uint16_t, TextSubStreamInfo>& sub_streams() const {
93 return sub_streams_;
94 }
95
96 private:
97 std::map<std::string, TextRegion> regions_;
98 std::map<uint16_t, TextSubStreamInfo> sub_streams_;
99 std::string css_styles_;
100 uint16_t width_;
101 uint16_t height_;
102
103 // Allow copying. This is very light weight.
104};
105
106} // namespace media
107} // namespace shaka
108
109#endif // PACKAGER_MEDIA_BASE_TEXT_STREAM_INFO_H_
Abstract class holds stream information.
Definition stream_info.h:71
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.