Shaka Packager SDK
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
shaka::media::MediaHandler Class Referenceabstract

#include <media_handler.h>

Inheritance diagram for shaka::media::MediaHandler:
shaka::media::CachingMediaHandler shaka::media::CcStreamFilter shaka::media::ChunkingHandler shaka::media::CueAlignmentHandler shaka::media::EncryptionHandler shaka::media::FakeInputMediaHandler shaka::media::MockOutputMediaHandler shaka::media::Muxer shaka::media::OriginHandler shaka::media::Replicator shaka::media::TextChunker shaka::media::TextPadder shaka::media::TrickPlayHandler shaka::media::WebVttToMp4Handler shaka::media::ttml::TtmlToMp4Handler

Public Member Functions

Status SetHandler (size_t 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 available output stream index.
 
Status Initialize ()
 
bool IsConnected ()
 Validate if the handler is connected to its upstream handler.
 

Static Public Member Functions

static Status Chain (const std::vector< std::shared_ptr< MediaHandler > > &list)
 

Protected Member Functions

virtual Status InitializeInternal ()=0
 
virtual Status Process (std::unique_ptr< StreamData > stream_data)=0
 
virtual Status OnFlushRequest (size_t input_stream_index)
 Event handler for flush request at the specific input stream index.
 
virtual bool ValidateOutputStreamIndex (size_t stream_index) const
 Validate if the stream at the specified index actually exists.
 
Status Dispatch (std::unique_ptr< StreamData > stream_data) const
 
Status DispatchStreamInfo (size_t stream_index, std::shared_ptr< const StreamInfo > stream_info) const
 Dispatch the stream info to downstream handlers.
 
Status DispatchMediaSample (size_t stream_index, std::shared_ptr< const MediaSample > media_sample) const
 Dispatch the media sample to downstream handlers.
 
Status DispatchTextSample (size_t stream_index, std::shared_ptr< const TextSample > text_sample) const
 Dispatch the text sample to downstream handlers.
 
Status DispatchSegmentInfo (size_t stream_index, std::shared_ptr< const SegmentInfo > segment_info) const
 Dispatch the segment info to downstream handlers.
 
Status DispatchScte35Event (size_t stream_index, std::shared_ptr< const Scte35Event > scte35_event) const
 Dispatch the scte35 event to downstream handlers.
 
Status DispatchCueEvent (size_t stream_index, std::shared_ptr< const CueEvent > cue_event) const
 Dispatch the cue event to downstream handlers.
 
Status FlushDownstream (size_t output_stream_index)
 Flush the downstream connected at the specified output stream index.
 
Status FlushAllDownstreams ()
 Flush all connected downstream handlers.
 
bool initialized ()
 
size_t num_input_streams () const
 
size_t next_output_stream_index () const
 
const std::map< size_t, std::pair< std::shared_ptr< MediaHandler >, size_t > > & output_handlers ()
 

Detailed Description

MediaHandler is the base media processing unit. Media handlers transform the input streams and propagate the outputs to downstream media handlers. There are three different types of media handlers: 1) Single input single output This is the most basic handler. It only supports one input and one output with both index as 0. 2) Multiple inputs multiple outputs The number of outputs must be equal to the number of inputs. The output stream at a specific index comes from the input stream at the same index. Different streams usually share a common resource, although they may be independent. One example of this is encryption handler. 3) Single input multiple outputs The input stream is split into multiple output streams. One example of this is the replicator media handler. Other types of media handlers are disallowed and not supported.

Definition at line 157 of file media_handler.h.

Member Function Documentation

◆ AddHandler()

Status shaka::media::MediaHandler::AddHandler ( std::shared_ptr< MediaHandler handler)
inline

Connect downstream handler to the next available output stream index.

Definition at line 167 of file media_handler.h.

◆ Chain()

Status shaka::media::MediaHandler::Chain ( const std::vector< std::shared_ptr< MediaHandler > > &  list)
static

Definition at line 63 of file media_handler.cc.

◆ Dispatch()

Status shaka::media::MediaHandler::Dispatch ( std::unique_ptr< StreamData stream_data) const
protected

Dispatch the stream data to downstream handlers. Note that stream_data.stream_index should be the output stream index.

Definition at line 94 of file media_handler.cc.

◆ DispatchCueEvent()

Status shaka::media::MediaHandler::DispatchCueEvent ( size_t  stream_index,
std::shared_ptr< const CueEvent cue_event 
) const
inlineprotected

Dispatch the cue event to downstream handlers.

Definition at line 243 of file media_handler.h.

◆ DispatchMediaSample()

Status shaka::media::MediaHandler::DispatchMediaSample ( size_t  stream_index,
std::shared_ptr< const MediaSample media_sample 
) const
inlineprotected

Dispatch the media sample to downstream handlers.

Definition at line 210 of file media_handler.h.

◆ DispatchScte35Event()

Status shaka::media::MediaHandler::DispatchScte35Event ( size_t  stream_index,
std::shared_ptr< const Scte35Event scte35_event 
) const
inlineprotected

Dispatch the scte35 event to downstream handlers.

Definition at line 235 of file media_handler.h.

◆ DispatchSegmentInfo()

Status shaka::media::MediaHandler::DispatchSegmentInfo ( size_t  stream_index,
std::shared_ptr< const SegmentInfo segment_info 
) const
inlineprotected

Dispatch the segment info to downstream handlers.

Definition at line 227 of file media_handler.h.

◆ DispatchStreamInfo()

Status shaka::media::MediaHandler::DispatchStreamInfo ( size_t  stream_index,
std::shared_ptr< const StreamInfo stream_info 
) const
inlineprotected

Dispatch the stream info to downstream handlers.

Definition at line 202 of file media_handler.h.

◆ DispatchTextSample()

Status shaka::media::MediaHandler::DispatchTextSample ( size_t  stream_index,
std::shared_ptr< const TextSample text_sample 
) const
inlineprotected

Dispatch the text sample to downstream handlers.

Definition at line 219 of file media_handler.h.

◆ FlushAllDownstreams()

Status shaka::media::MediaHandler::FlushAllDownstreams ( )
protected

Flush all connected downstream handlers.

Definition at line 114 of file media_handler.cc.

◆ FlushDownstream()

Status shaka::media::MediaHandler::FlushDownstream ( size_t  output_stream_index)
protected

Flush the downstream connected at the specified output stream index.

Definition at line 105 of file media_handler.cc.

◆ Initialize()

Status shaka::media::MediaHandler::Initialize ( )

Initialize the handler and downstream handlers. Note that it should be called after setting up the graph before running the graph.

Definition at line 46 of file media_handler.cc.

◆ initialized()

bool shaka::media::MediaHandler::initialized ( )
inlineprotected

Definition at line 255 of file media_handler.h.

◆ InitializeInternal()

virtual Status shaka::media::MediaHandler::InitializeInternal ( )
protectedpure virtual

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

Implemented in shaka::media::CcStreamFilter, shaka::media::Muxer, shaka::media::ChunkingHandler, shaka::media::EncryptionHandler, and shaka::media::Demuxer.

◆ IsConnected()

bool shaka::media::MediaHandler::IsConnected ( )
inline

Validate if the handler is connected to its upstream handler.

Definition at line 176 of file media_handler.h.

◆ next_output_stream_index()

size_t shaka::media::MediaHandler::next_output_stream_index ( ) const
inlineprotected

Definition at line 257 of file media_handler.h.

◆ num_input_streams()

size_t shaka::media::MediaHandler::num_input_streams ( ) const
inlineprotected

Definition at line 256 of file media_handler.h.

◆ OnFlushRequest()

Status shaka::media::MediaHandler::OnFlushRequest ( size_t  input_stream_index)
protectedvirtual

Event handler for flush request at the specific input stream index.

Reimplemented in shaka::media::Muxer, and shaka::media::ChunkingHandler.

Definition at line 83 of file media_handler.cc.

◆ output_handlers()

const std::map< size_t, std::pair< std::shared_ptr< MediaHandler >, size_t > > & shaka::media::MediaHandler::output_handlers ( )
inlineprotected

Definition at line 259 of file media_handler.h.

◆ Process()

virtual Status shaka::media::MediaHandler::Process ( std::unique_ptr< StreamData stream_data)
protectedpure virtual

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.

Implemented in shaka::media::CcStreamFilter, shaka::media::Muxer, shaka::media::ChunkingHandler, shaka::media::EncryptionHandler, and shaka::media::Demuxer.

◆ SetHandler()

Status shaka::media::MediaHandler::SetHandler ( size_t  output_stream_index,
std::shared_ptr< MediaHandler handler 
)

Connect downstream handler at the specified output stream index.

Definition at line 34 of file media_handler.cc.

◆ ValidateOutputStreamIndex()

bool shaka::media::MediaHandler::ValidateOutputStreamIndex ( size_t  stream_index) const
protectedvirtual

Validate if the stream at the specified index actually exists.

Reimplemented in shaka::media::Demuxer.

Definition at line 90 of file media_handler.cc.


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