Shaka Packager SDK
Loading...
Searching...
No Matches
subtitle_composer.h
1// Copyright 2020 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_DVB_SUBTITLE_COMPOSER_H_
8#define PACKAGER_MEDIA_DVB_SUBTITLE_COMPOSER_H_
9
10#include <cstdint>
11#include <memory>
12#include <unordered_map>
13#include <vector>
14
15#include <packager/macros/classes.h>
16#include <packager/media/base/text_sample.h>
17#include <packager/media/formats/dvb/dvb_image.h>
18
19namespace shaka {
20namespace media {
21
25 public:
28
29 DISALLOW_COPY_AND_ASSIGN(SubtitleComposer);
30
31 void SetDisplaySize(uint16_t width, uint16_t height);
32 bool SetRegionPosition(uint8_t region_id, uint16_t x, uint16_t y);
33 bool SetRegionInfo(uint8_t region_id,
34 uint8_t color_space_id,
35 uint16_t width,
36 uint16_t height);
37 bool SetObjectInfo(uint16_t object_id,
38 uint8_t region_id,
39 uint16_t x,
40 uint16_t y,
41 int default_color_code);
42
43 DvbImageColorSpace* GetColorSpace(uint8_t color_space_id);
44 DvbImageColorSpace* GetColorSpaceForObject(uint16_t object_id);
45 DvbImageBuilder* GetObjectImage(uint16_t object_id);
46
47 bool GetSamples(int64_t start,
48 int64_t end,
49 std::vector<std::shared_ptr<TextSample>>* samples) const;
50 void ClearObjects();
51
52 private:
53 struct RegionInfo {
54 DvbImageColorSpace* color_space = nullptr;
55 uint16_t x = 0;
56 uint16_t y = 0;
57 uint16_t width = 0;
58 uint16_t height = 0;
59 };
60
61 struct ObjectInfo {
62 RegionInfo* region = nullptr;
63 int default_color_code = -1;
64 uint16_t x = 0;
65 uint16_t y = 0;
66 };
67
68 // Maps of IDs to their respective object.
69 std::unordered_map<uint8_t, RegionInfo> regions_;
70 std::unordered_map<uint8_t, DvbImageColorSpace> color_spaces_;
71 std::unordered_map<uint16_t, ObjectInfo> objects_;
72 std::unordered_map<uint16_t, DvbImageBuilder> images_; // Uses object_id.
73 uint16_t display_width_;
74 uint16_t display_height_;
75};
76
77} // namespace media
78} // namespace shaka
79
80#endif // PACKAGER_MEDIA_DVB_SUBTITLE_COMPOSER_H_
All the methods that are virtual are virtual for mocking.