2023-12-01 17:32:19 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-02-14 23:21:05 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_MP4_SINGLE_SEGMENT_SEGMENTER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP4_SINGLE_SEGMENT_SEGMENTER_H_
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/file/file_closer.h>
|
|
|
|
#include <packager/macros/classes.h>
|
|
|
|
#include <packager/media/event/muxer_listener.h>
|
|
|
|
#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 {
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Segmenter for MP4 Dash Video-On-Demand profile. A single MP4 file with a
|
|
|
|
/// single segment is created, i.e. with only one SIDX box. The generated media
|
|
|
|
/// file can contain one or many subsegments with subsegment duration
|
|
|
|
/// defined by @b MuxerOptions.segment_duration. A subsegment can contain one
|
|
|
|
/// or many fragments with fragment duration defined by @b
|
|
|
|
/// MuxerOptions.fragment_duration. The actual subsegment or fragment duration
|
|
|
|
/// may not match the requested duration exactly, but will be approximated. That
|
2014-04-08 20:21:07 +00:00
|
|
|
/// is, the Segmenter tries to end subsegment/fragment at the first sample with
|
2014-01-23 22:34:39 +00:00
|
|
|
/// overall subsegment/fragment duration not smaller than defined duration and
|
2020-12-07 08:09:04 +00:00
|
|
|
/// yet meet SAP requirements.
|
2014-04-08 20:21:07 +00:00
|
|
|
class SingleSegmentSegmenter : public Segmenter {
|
2013-11-12 20:37:58 +00:00
|
|
|
public:
|
2014-04-08 20:21:07 +00:00
|
|
|
SingleSegmentSegmenter(const MuxerOptions& options,
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<FileType> ftyp,
|
|
|
|
std::unique_ptr<Movie> moov);
|
2015-07-22 23:40:45 +00:00
|
|
|
~SingleSegmentSegmenter() 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;
|
2017-05-01 23:17:09 +00:00
|
|
|
std::vector<Range> GetSegmentRanges() 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;
|
2024-05-02 20:25:49 +00:00
|
|
|
Status DoFinalizeSegment(int64_t segment_number) override;
|
2014-04-18 22:00:30 +00:00
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<SegmentIndex> vod_sidx_;
|
2014-05-08 21:02:36 +00:00
|
|
|
std::string temp_file_name_;
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<File, FileCloser> temp_file_;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-08 20:21:07 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(SingleSegmentSegmenter);
|
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
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_MP4_SINGLE_SEGMENT_SEGMENTER_H_
|