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