Shaka Packager SDK
single_segment_segmenter.h
1 // Copyright 2015 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_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
8 #define PACKAGER_MEDIA_FORMATS_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
9 
10 #include <memory>
11 
12 #include <packager/macros/classes.h>
13 #include <packager/media/formats/webm/mkv_writer.h>
14 #include <packager/media/formats/webm/segmenter.h>
15 #include <packager/status.h>
16 
17 namespace shaka {
18 namespace media {
19 
20 struct MuxerOptions;
21 
22 namespace webm {
23 
28  public:
29  explicit SingleSegmentSegmenter(const MuxerOptions& options);
30  ~SingleSegmentSegmenter() override;
31 
34  Status FinalizeSegment(int64_t start_timestamp,
35  int64_t duration_timestamp,
36  bool is_subsegment,
37  int64_t segment_number) override;
38  bool GetInitRangeStartAndEnd(uint64_t* start, uint64_t* end) override;
39  bool GetIndexRangeStartAndEnd(uint64_t* start, uint64_t* end) override;
40  std::vector<Range> GetSegmentRanges() override;
42 
43  protected:
44  MkvWriter* writer() { return writer_.get(); }
45  uint64_t init_end() { return init_end_; }
46  void set_init_end(uint64_t end) { init_end_ = end; }
47  void set_index_start(uint64_t start) { index_start_ = start; }
48  void set_index_end(uint64_t end) { index_end_ = end; }
49  void set_writer(std::unique_ptr<MkvWriter> writer) {
50  writer_ = std::move(writer);
51  }
52 
53  // Segmenter implementation overrides.
54  Status DoInitialize() override;
55  Status DoFinalize() override;
56 
57  private:
58  // Segmenter implementation overrides.
59  Status NewSegment(int64_t start_timestamp, bool is_subsegment) override;
60 
61  std::unique_ptr<MkvWriter> writer_;
62  uint64_t init_end_;
63  uint64_t index_start_;
64  uint64_t index_end_;
65 
66  DISALLOW_COPY_AND_ASSIGN(SingleSegmentSegmenter);
67 };
68 
69 } // namespace webm
70 } // namespace media
71 } // namespace shaka
72 
73 #endif // PACKAGER_MEDIA_FORMATS_WEBM_SINGLE_SEGMENT_SEGMENTER_H_
An implementation of IMkvWriter using our File type.
Definition: mkv_writer.h:23
bool GetIndexRangeStartAndEnd(uint64_t *start, uint64_t *end) override
bool GetInitRangeStartAndEnd(uint64_t *start, uint64_t *end) override
Status FinalizeSegment(int64_t start_timestamp, int64_t duration_timestamp, bool is_subsegment, int64_t segment_number) override
Finalize the (sub)segment.
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:19