Shaka Packager SDK
text_chunker.h
1 // Copyright 2017 Google Inc. 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_CHUNKING_TEXT_CHUNKER_H_
8 #define PACKAGER_MEDIA_CHUNKING_TEXT_CHUNKER_H_
9 
10 #include <list>
11 
12 #include "packager/media/base/media_handler.h"
13 
14 namespace shaka {
15 namespace media {
16 
17 class TextChunker : public MediaHandler {
18  public:
19  explicit TextChunker(int64_t segment_duration_ms);
20 
21  private:
22  TextChunker(const TextChunker&) = delete;
23  TextChunker& operator=(const TextChunker&) = delete;
24 
25  Status InitializeInternal() override;
26 
27  Status Process(std::unique_ptr<StreamData> stream_data) override;
28  Status OnFlushRequest(size_t input_stream_index) override;
29 
30  Status OnStreamInfo(std::shared_ptr<const StreamInfo> info);
31  Status OnCueEvent(std::shared_ptr<const CueEvent> cue);
32  Status OnTextSample(std::shared_ptr<const TextSample> sample);
33 
34  Status EndSegment(int64_t segment_actual_end_ms);
35  void StartNewSegment(int64_t start_ms);
36 
37  int64_t segment_duration_ms_;
38 
39  // The segment that we are currently outputting samples for. The segment
40  // will end once a new sample with start time greater or equal to the
41  // segment's end time arrives.
42  int64_t segment_start_ms_;
43  int64_t segment_expected_end_ms_;
44  std::list<std::shared_ptr<const TextSample>> segment_samples_;
45 };
46 
47 } // namespace media
48 } // namespace shaka
49 
50 #endif // PACKAGER_MEDIA_CHUNKING_TEXT_CHUNKER_H_
All the methods that are virtual are virtual for mocking.