2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 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
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_MULTI_SEGMENT_SEGMENTER_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_MULTI_SEGMENT_SEGMENTER_H_
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/formats/mp4/segmenter.h"
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-11-12 20:37:58 +00:00
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
struct SegmentType;
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Segmenter for MP4 live, main and simple profiles. The generated media file
|
|
|
|
/// can contain one or many segments with segment duration defined by @b
|
|
|
|
/// MuxerOptions.segment_duration. A segment can contain one or many
|
|
|
|
/// subsegments defined by @b num_subsegments_per_sidx. A subsegment can
|
|
|
|
/// contain one or many fragments with fragment duration defined by @b
|
|
|
|
/// MuxerOptions.fragment_duration. The actual segment or fragment duration
|
|
|
|
/// may not match the requested duration exactly, but will be approximated.
|
2014-04-08 20:21:07 +00:00
|
|
|
/// That is, the Segmenter tries to end segment/fragment at the first sample
|
2014-01-23 22:34:39 +00:00
|
|
|
/// with overall segment/fragment duration not smaller than defined duration
|
|
|
|
/// and yet meet SAP requirements. The generated segments are written to files
|
|
|
|
/// defined by @b MuxerOptions.segment_template if specified; otherwise,
|
|
|
|
/// the segments are appended to the main output file specified by @b
|
|
|
|
/// MuxerOptions.output_file_name.
|
2014-04-08 20:21:07 +00:00
|
|
|
class MultiSegmentSegmenter : public Segmenter {
|
2013-11-12 20:37:58 +00:00
|
|
|
public:
|
2014-04-08 20:21:07 +00:00
|
|
|
MultiSegmentSegmenter(const MuxerOptions& options,
|
|
|
|
scoped_ptr<FileType> ftyp,
|
|
|
|
scoped_ptr<Movie> moov);
|
2015-07-22 23:40:45 +00:00
|
|
|
~MultiSegmentSegmenter() override;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-08 20:21:07 +00:00
|
|
|
/// @name Segmenter implementation overrides.
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
bool GetInitRange(size_t* offset, size_t* size) override;
|
|
|
|
bool GetIndexRange(size_t* offset, size_t* size) override;
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @}
|
2013-12-12 23:49:31 +00:00
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
private:
|
2014-04-18 22:00:30 +00:00
|
|
|
// Segmenter implementation overrides.
|
2015-07-22 23:40:45 +00:00
|
|
|
Status DoInitialize() override;
|
|
|
|
Status DoFinalize() override;
|
|
|
|
Status DoFinalizeSegment() override;
|
2014-04-18 22:00:30 +00:00
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
// Write segment to file.
|
|
|
|
Status WriteSegment();
|
|
|
|
|
|
|
|
scoped_ptr<SegmentType> styp_;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t num_segments_;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-08 20:21:07 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(MultiSegmentSegmenter);
|
2013-11-12 20:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_MULTI_SEGMENT_SEGMENTER_H_
|