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
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-02-05 17:55:58 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
#include "packager/media/base/media_handler.h"
|
|
|
|
#include "packager/status.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 22:28:30 +00:00
|
|
|
explicit TextChunker(uint64_t segment_duration_ms);
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Status Process(std::unique_ptr<StreamData> stream_data) override;
|
|
|
|
Status OnFlushRequest(size_t input_stream_index) override;
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-03-23 22:28:30 +00:00
|
|
|
using SegmentSamples = std::vector<std::shared_ptr<const TextSample>>;
|
2018-02-05 19:16:00 +00:00
|
|
|
|
2017-09-18 15:43:21 +00:00
|
|
|
Status InitializeInternal() override;
|
|
|
|
|
|
|
|
Status OnTextSample(std::shared_ptr<const TextSample> sample);
|
|
|
|
|
2018-02-05 19:16:00 +00:00
|
|
|
Status DispatchSegmentWithSamples(uint64_t segment,
|
2018-03-23 22:28:30 +00:00
|
|
|
const SegmentSamples& samples);
|
2018-01-31 19:10:13 +00:00
|
|
|
|
2017-09-18 15:43:21 +00:00
|
|
|
uint64_t segment_duration_ms_;
|
2018-02-05 17:55:58 +00:00
|
|
|
|
|
|
|
// Mapping of segment number to segment.
|
2018-03-23 22:28:30 +00:00
|
|
|
std::map<uint64_t, SegmentSamples> segment_map_;
|
2018-02-05 17:55:58 +00:00
|
|
|
uint64_t head_segment_ = 0;
|
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_
|