2017-09-18 15:43:21 +00:00
|
|
|
// Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2018-03-23 22:28:30 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_CHUNKING_TEXT_CHUNKER_H_
|
|
|
|
#define PACKAGER_MEDIA_CHUNKING_TEXT_CHUNKER_H_
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
#include <list>
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
#include "packager/media/base/media_handler.h"
|
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
2018-03-23 22:28:30 +00:00
|
|
|
class TextChunker : public MediaHandler {
|
2017-09-18 15:43:21 +00:00
|
|
|
public:
|
2018-03-23 01:33:01 +00:00
|
|
|
explicit TextChunker(int64_t segment_duration_ms);
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
private:
|
2018-03-23 22:28:30 +00:00
|
|
|
TextChunker(const TextChunker&) = delete;
|
|
|
|
TextChunker& operator=(const TextChunker&) = delete;
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
Status InitializeInternal() override;
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
Status Process(std::unique_ptr<StreamData> stream_data) override;
|
|
|
|
Status OnFlushRequest(size_t input_stream_index) override;
|
|
|
|
|
|
|
|
Status OnStreamInfo(std::shared_ptr<const StreamInfo> info);
|
|
|
|
Status OnCueEvent(std::shared_ptr<const CueEvent> cue);
|
2017-09-18 15:43:21 +00:00
|
|
|
Status OnTextSample(std::shared_ptr<const TextSample> sample);
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
Status EndSegment(int64_t segment_actual_end_ms);
|
|
|
|
void StartNewSegment(int64_t start_ms);
|
2018-01-31 19:10:13 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
int64_t segment_duration_ms_;
|
2018-02-05 17:55:58 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
// The segment that we are currently outputting samples for. The segment
|
|
|
|
// will end once a new sample with start time greater or equal to the
|
|
|
|
// segment's end time arrives.
|
|
|
|
int64_t segment_start_ms_;
|
|
|
|
int64_t segment_expected_end_ms_;
|
|
|
|
std::list<std::shared_ptr<const TextSample>> segment_samples_;
|
2017-09-18 15:43:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|
|
|
|
|
2018-03-23 22:28:30 +00:00
|
|
|
#endif // PACKAGER_MEDIA_CHUNKING_TEXT_CHUNKER_H_
|