2015-10-28 17:23:08 +00:00
|
|
|
// Copyright 2015 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
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
|
2015-10-28 17:23:08 +00:00
|
|
|
|
|
|
|
#include "packager/media/formats/webm/segmenter.h"
|
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2015-10-28 17:23:08 +00:00
|
|
|
#include "packager/media/formats/webm/mkv_writer.h"
|
2017-06-29 22:23:53 +00:00
|
|
|
#include "packager/status.h"
|
2015-10-28 17:23:08 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-10-28 17:23:08 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
struct MuxerOptions;
|
|
|
|
|
|
|
|
namespace webm {
|
|
|
|
|
|
|
|
/// An implementation of a Segmenter for a single-segment. This assumes that
|
|
|
|
/// the output file is seekable. For non-seekable files, use
|
|
|
|
/// TwoPassSingleSegmentSegmenter.
|
|
|
|
class SingleSegmentSegmenter : public Segmenter {
|
|
|
|
public:
|
|
|
|
explicit SingleSegmentSegmenter(const MuxerOptions& options);
|
|
|
|
~SingleSegmentSegmenter() override;
|
|
|
|
|
|
|
|
/// @name Segmenter implementation overrides.
|
|
|
|
/// @{
|
2017-05-13 00:02:12 +00:00
|
|
|
Status FinalizeSegment(uint64_t start_timestamp,
|
|
|
|
uint64_t duration_timestamp,
|
2017-02-24 01:17:47 +00:00
|
|
|
bool is_subsegment) override;
|
2016-04-15 23:00:27 +00:00
|
|
|
bool GetInitRangeStartAndEnd(uint64_t* start, uint64_t* end) override;
|
|
|
|
bool GetIndexRangeStartAndEnd(uint64_t* start, uint64_t* end) override;
|
2017-05-01 23:17:09 +00:00
|
|
|
std::vector<Range> GetSegmentRanges() override;
|
2015-10-28 17:23:08 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MkvWriter* writer() { return writer_.get(); }
|
2016-09-29 00:13:15 +00:00
|
|
|
uint64_t init_end() { return init_end_; }
|
2015-10-28 17:23:08 +00:00
|
|
|
void set_init_end(uint64_t end) { init_end_ = end; }
|
|
|
|
void set_index_start(uint64_t start) { index_start_ = start; }
|
2016-04-15 23:00:27 +00:00
|
|
|
void set_index_end(uint64_t end) { index_end_ = end; }
|
2016-08-17 17:41:40 +00:00
|
|
|
void set_writer(std::unique_ptr<MkvWriter> writer) {
|
|
|
|
writer_ = std::move(writer);
|
|
|
|
}
|
2015-10-28 17:23:08 +00:00
|
|
|
|
|
|
|
// Segmenter implementation overrides.
|
2017-03-16 20:56:11 +00:00
|
|
|
Status DoInitialize() override;
|
2015-10-28 17:23:08 +00:00
|
|
|
Status DoFinalize() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Segmenter implementation overrides.
|
2017-05-13 00:02:12 +00:00
|
|
|
Status NewSegment(uint64_t start_timestamp, bool is_subsegment) override;
|
2015-10-28 17:23:08 +00:00
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<MkvWriter> writer_;
|
2016-04-15 23:00:27 +00:00
|
|
|
uint64_t init_end_;
|
|
|
|
uint64_t index_start_;
|
|
|
|
uint64_t index_end_;
|
2015-10-28 17:23:08 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SingleSegmentSegmenter);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace webm
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-10-28 17:23:08 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
|