DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Friends | List of all members
shaka::media::ChunkingHandler Class Reference

#include <chunking_handler.h>

Inheritance diagram for shaka::media::ChunkingHandler:
shaka::media::MediaHandler

Public Member Functions

 ChunkingHandler (const ChunkingOptions &chunking_options)
 
- Public Member Functions inherited from shaka::media::MediaHandler
Status SetHandler (int output_stream_index, std::shared_ptr< MediaHandler > handler)
 Connect downstream handler at the specified output stream index.
 
Status AddHandler (std::shared_ptr< MediaHandler > handler)
 Connect downstream handler to the next availble output stream index.
 
Status Initialize ()
 

Protected Member Functions

MediaHandler implementation overrides.
Status InitializeInternal () override
 
Status Process (std::unique_ptr< StreamData > stream_data) override
 
Status FlushStream (int input_stream_index) override
 Flush the stream at the specified input stream index.
 
- Protected Member Functions inherited from shaka::media::MediaHandler
virtual bool ValidateOutputStreamIndex (int stream_index) const
 Validate if the stream at the specified index actually exists.
 
bool initialized ()
 
int num_input_streams ()
 
Status Dispatch (std::unique_ptr< StreamData > stream_data)
 
Status DispatchPeriodInfo (int stream_index, std::shared_ptr< PeriodInfo > period_info)
 Dispatch the period info to downstream handlers.
 
Status DispatchStreamInfo (int stream_index, std::shared_ptr< StreamInfo > stream_info)
 Dispatch the stream info to downstream handlers.
 
Status DispatchEncryptionConfig (int stream_index, std::unique_ptr< EncryptionConfig > encryption_config)
 Dispatch the encryption config to downstream handlers.
 
Status DispatchMediaSample (int stream_index, std::shared_ptr< MediaSample > media_sample)
 Dispatch the media sample to downstream handlers.
 
Status DispatchMediaEvent (int stream_index, std::shared_ptr< MediaEvent > media_event)
 Dispatch the media event to downstream handlers.
 
Status DispatchSegmentInfo (int stream_index, std::shared_ptr< SegmentInfo > segment_info)
 Dispatch the segment info to downstream handlers.
 
int num_input_streams () const
 
int next_output_stream_index () const
 

Friends

class ChunkingHandlerTest
 

Detailed Description

ChunkingHandler splits the samples into segments / subsegments based on the specified chunking options. This handler is a multi-in multi-out handler. If more than one input is provided, there should be one and only one video stream; also, all inputs should come from the same thread and are synchronized. There can be multiple chunking handler running in different threads or even different processes, we use the "consistent chunking algorithm" to make sure the chunks in different streams are aligned without explicit communcating with each other - which is not efficient and often difficult.

Consistent Chunking Algorithm:

  1. Find the consistent chunkable boundary Let the timestamps for video frames be (t1, t2, t3, ...). Then a consistent chunkable boundary is simply the first chunkable boundary after (tk / N) != (tk-1 / N), where '/' denotes integer division, and N is the intended chunk duration.
  2. Chunk only at the consistent chunkable boundary

This algorithm will make sure the chunks from different video streams are aligned if they have aligned GoPs. However, this algorithm will only work for video streams. To be able to chunk non video streams at similar positions as video streams, ChunkingHandler is designed to accept one video input and multiple non video inputs, the non video inputs are chunked when the video input is chunked. If the inputs are synchronized - which is true if the inputs come from the same demuxer, the video and non video chunks are aligned.

Definition at line 61 of file chunking_handler.h.

Member Function Documentation

Status shaka::media::ChunkingHandler::InitializeInternal ( )
overrideprotectedvirtual

Internal implementation of initialize. Note that it should only initialize the MediaHandler itself. Downstream handlers are handled in Initialize().

Implements shaka::media::MediaHandler.

Definition at line 28 of file chunking_handler.cc.

Status shaka::media::ChunkingHandler::Process ( std::unique_ptr< StreamData stream_data)
overrideprotectedvirtual

Process the incoming stream data. Note that (1) stream_data.stream_index should be the input stream index; (2) The implementation needs to call DispatchXxx to dispatch the processed stream data to the downstream handlers after finishing processing if needed.

Implements shaka::media::MediaHandler.

Definition at line 36 of file chunking_handler.cc.


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