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