Shaka Packager SDK
webvtt_to_mp4_handler.h
1 // Copyright 2017 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_FORMATS_WEBVTT_WEBVTT_MP4_CUE_HANDLER_H_
8 #define PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_MP4_CUE_HANDLER_H_
9 
10 #include <cstdint>
11 #include <list>
12 #include <queue>
13 
14 #include <packager/media/base/buffer_writer.h>
15 #include <packager/media/base/media_handler.h>
16 
17 namespace shaka {
18 namespace media {
19 
20 // A media handler that should come after the cue aligner and segmenter and
21 // should come before the muxer. This handler is to convert text samples
22 // to media samples so that they can be sent to a mp4 muxer.
24  public:
25  WebVttToMp4Handler() = default;
26  virtual ~WebVttToMp4Handler() override = default;
27 
28  private:
29  WebVttToMp4Handler(const WebVttToMp4Handler&) = delete;
30  WebVttToMp4Handler& operator=(const WebVttToMp4Handler&) = delete;
31 
32  Status InitializeInternal() override;
33  Status Process(std::unique_ptr<StreamData> stream_data) override;
34 
35  Status OnStreamInfo(std::unique_ptr<StreamData> stream_data);
36  Status OnCueEvent(std::unique_ptr<StreamData> stream_data);
37  Status OnSegmentInfo(std::unique_ptr<StreamData> stream_data);
38  Status OnTextSample(std::unique_ptr<StreamData> stream_data);
39 
40  Status DispatchCurrentSegment(int64_t segment_start, int64_t segment_end);
41  Status MergeDispatchSamples(int64_t start_in_seconds,
42  int64_t end_in_seconds,
43  const std::list<const TextSample*>& state);
44 
45  std::list<std::shared_ptr<const TextSample>> current_segment_;
46 
47  // This is the current state of the box we are writing.
48  BufferWriter box_writer_;
49 };
50 
51 } // namespace media
52 } // namespace shaka
53 #endif // PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_MP4_CUE_HANDLER_H_
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66