Shaka Packager SDK
Public Member Functions | Protected Member Functions | List of all members
shaka::media::mp4::Segmenter Class Referenceabstract

#include <segmenter.h>

Inheritance diagram for shaka::media::mp4::Segmenter:
shaka::media::mp4::LowLatencySegmentSegmenter shaka::media::mp4::MultiSegmentSegmenter shaka::media::mp4::SingleSegmentSegmenter

Public Member Functions

 Segmenter (const MuxerOptions &options, std::unique_ptr< FileType > ftyp, std::unique_ptr< Movie > moov)
 
Status Initialize (const std::vector< std::shared_ptr< const StreamInfo >> &streams, MuxerListener *muxer_listener, ProgressListener *progress_listener)
 
Status Finalize ()
 
Status AddSample (size_t stream_id, const MediaSample &sample)
 
Status FinalizeSegment (size_t stream_id, const SegmentInfo &segment_info)
 
virtual bool GetInitRange (size_t *offset, size_t *size)=0
 
virtual bool GetIndexRange (size_t *offset, size_t *size)=0
 
virtual std::vector< RangeGetSegmentRanges ()=0
 
int32_t GetReferenceTimeScale () const
 
double GetDuration () const
 
int64_t sample_duration () const
 

Protected Member Functions

void UpdateProgress (uint64_t progress)
 Update segmentation progress using ProgressListener.
 
void SetComplete ()
 Set progress to 100%.
 
const MuxerOptionsoptions () const
 
FileTypeftyp ()
 
Moviemoov ()
 
BufferWriterfragment_buffer ()
 
SegmentIndexsidx ()
 
MuxerListenermuxer_listener ()
 
uint64_t progress_target ()
 
const std::vector< KeyFrameInfo > & key_frame_infos () const
 
void set_progress_target (uint64_t progress_target)
 

Detailed Description

This class defines the Segmenter which is responsible for organizing fragments into segments/subsegments and package them into a MP4 file. Inherited by MultiSegmentSegmenter and SingleSegmentSegmenter. SingleSegmentSegmenter defines the Segmenter for DASH Video-On-Demand with a single segment for each media presentation while MultiSegmentSegmenter handles all other cases including DASH live profile.

Definition at line 45 of file segmenter.h.

Member Function Documentation

◆ AddSample()

Status shaka::media::mp4::Segmenter::AddSample ( size_t  stream_id,
const MediaSample sample 
)

Add sample to the indicated stream.

Parameters
stream_idis the zero-based stream index.
samplepoints to the sample to be added.
Returns
OK on success, an error status otherwise.

Definition at line 126 of file segmenter.cc.

◆ Finalize()

Status shaka::media::mp4::Segmenter::Finalize ( )

Finalize the segmenter.

Returns
OK on success, an error status otherwise.

Definition at line 110 of file segmenter.cc.

◆ FinalizeSegment()

Status shaka::media::mp4::Segmenter::FinalizeSegment ( size_t  stream_id,
const SegmentInfo segment_info 
)

Finalize the segment / subsegment.

Parameters
stream_idis the zero-based stream index.
is_subsegmentindicates if it is a subsegment (fragment).
Returns
OK on success, an error status otherwise.

Definition at line 154 of file segmenter.cc.

◆ GetDuration()

double shaka::media::mp4::Segmenter::GetDuration ( ) const
Returns
The total length, in seconds, of segmented media files.

Definition at line 258 of file segmenter.cc.

◆ GetIndexRange()

virtual bool shaka::media::mp4::Segmenter::GetIndexRange ( size_t *  offset,
size_t *  size 
)
pure virtual
Returns
true if there is an index byte range, while setting offset and size; or false if index byte range does not apply.

Implemented in shaka::media::mp4::SingleSegmentSegmenter, shaka::media::mp4::MultiSegmentSegmenter, and shaka::media::mp4::LowLatencySegmentSegmenter.

◆ GetInitRange()

virtual bool shaka::media::mp4::Segmenter::GetInitRange ( size_t *  offset,
size_t *  size 
)
pure virtual
Returns
true if there is an initialization range, while setting offset and size; or false if initialization range does not apply.

Implemented in shaka::media::mp4::SingleSegmentSegmenter, shaka::media::mp4::MultiSegmentSegmenter, and shaka::media::mp4::LowLatencySegmentSegmenter.

◆ Initialize()

Status shaka::media::mp4::Segmenter::Initialize ( const std::vector< std::shared_ptr< const StreamInfo >> &  streams,
MuxerListener muxer_listener,
ProgressListener progress_listener 
)

Initialize the segmenter. Calling other public methods of this class without this method returning Status::OK results in an undefined behavior.

Parameters
streamscontains the vector of StreamInfos for initialization.
muxer_listenerreceives muxer events. Can be NULL.
progress_listenerreceives progress updates. Can be NULL.
Returns
OK on success, an error status otherwise.

Definition at line 53 of file segmenter.cc.

◆ sample_duration()

int64_t shaka::media::mp4::Segmenter::sample_duration ( ) const
inline
Returns
The sample duration in the timescale of the media. Returns 0 if no samples are added yet.

Definition at line 102 of file segmenter.h.


The documentation for this class was generated from the following files: