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