Shaka Player Embedded
text_track.h
Go to the documentation of this file.
1 // Copyright 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_MEDIA_TEXT_TRACK_H_
16 #define SHAKA_EMBEDDED_MEDIA_TEXT_TRACK_H_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "../macros.h"
23 #include "vtt_cue.h"
24 
25 namespace shaka {
26 namespace media {
27 
33 enum class TextTrackKind : uint8_t {
35  Subtitles,
36 
38  Captions,
39 
44 
46  Chapters,
47 
52  Metadata,
53 };
54 
60 enum class TextTrackMode : uint8_t {
65  Disabled,
66 
71  Hidden,
72 
74  Showing,
75 };
76 
87  public:
93  class Client {
94  public:
96 
98  virtual void OnCueAdded(std::shared_ptr<VTTCue> cue) = 0;
99 
101  virtual void OnCueRemoved(std::shared_ptr<VTTCue> cue) = 0;
102  };
103 
104  TextTrack(TextTrackKind kind, const std::string& label,
105  const std::string& language, const std::string& id);
106  virtual ~TextTrack();
107 
109 
112 
114  const std::string label;
115 
117  const std::string language;
118 
120  const std::string id;
121 
122 
124  virtual TextTrackMode mode() const;
125 
127  virtual void SetMode(TextTrackMode mode);
128 
129 
131  virtual std::vector<std::shared_ptr<VTTCue>> cues() const;
132 
134  virtual std::vector<std::shared_ptr<VTTCue>> active_cues(double time) const;
135 
145  double NextCueChangeTime(double time) const;
146 
148  virtual void AddCue(std::shared_ptr<VTTCue> cue);
149 
151  virtual void RemoveCue(std::shared_ptr<VTTCue> cue);
152 
153 
155  void AddClient(Client* client);
156 
158  void RemoveClient(Client* client);
159 
160  private:
161  class Impl;
162  std::unique_ptr<Impl> impl_;
163 };
164 
165 } // namespace media
166 } // namespace shaka
167 
168 #endif // SHAKA_EMBEDDED_MEDIA_TEXT_TRACK_H_
#define SHAKA_EXPORT
Definition: macros.h:30
const std::string language
Definition: text_track.h:117
#define SHAKA_NON_COPYABLE_OR_MOVABLE_TYPE(Type)
Definition: macros.h:51
const TextTrackKind kind
Definition: text_track.h:111
const std::string label
Definition: text_track.h:114
#define SHAKA_DECLARE_INTERFACE_METHODS(Type)
Definition: macros.h:55
const std::string id
Definition: text_track.h:120