Shaka Packager SDK
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shaka::media::SegmentCoordinator Class Reference

#include <segment_coordinator.h>

Inheritance diagram for shaka::media::SegmentCoordinator:
shaka::media::MediaHandler

Public Member Functions

void MarkAsTeletextStream (size_t input_stream_index)
 
- Public Member Functions inherited from shaka::media::MediaHandler
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.
 

Protected Member Functions

MediaHandler implementation overrides.
Status InitializeInternal () override
 
Status Process (std::unique_ptr< StreamData > stream_data) override
 
- Protected Member Functions inherited from shaka::media::MediaHandler
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 ()
 

Additional Inherited Members

- Static Public Member Functions inherited from shaka::media::MediaHandler
static Status Chain (const std::vector< std::shared_ptr< MediaHandler > > &list)
 

Detailed Description

SegmentCoordinator is a N-to-N media handler that coordinates segment boundaries across different stream types. All streams (video, audio, text) go through the same coordinator instance, similar to CueAlignmentHandler.

It receives SegmentInfo events from video/audio streams (emitted by ChunkingHandler) and replicates them to registered teletext streams, ensuring that teletext segments align with media segments.

This handler is designed to solve the alignment problem where teletext segments use mathematical calculation (segment_start + segment_duration) while video/audio use actual keyframe timestamps, causing misalignment especially with:

The coordinator only replicates SegmentInfo to teletext streams (cc_index >= 0). Other text formats (WebVTT files, TTML) and video/audio streams pass through unchanged.

Pipeline placement (all streams go through the same coordinator instance): Video/Audio → CueAligner → SegmentCoordinatorChunkingHandler → ... Teletext → CueAligner → SegmentCoordinatorCcStreamFilterTextChunker → ...

When ChunkingHandler emits SegmentInfo, it flows back through the coordinator, which then broadcasts it to all registered teletext stream indices.

Definition at line 46 of file segment_coordinator.h.

Member Function Documentation

◆ InitializeInternal()

Status shaka::media::SegmentCoordinator::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 24 of file segment_coordinator.cc.

◆ MarkAsTeletextStream()

void shaka::media::SegmentCoordinator::MarkAsTeletextStream ( size_t  input_stream_index)

Mark a stream as a teletext stream that should receive segment boundaries. This should be called during pipeline setup before processing begins.

Parameters
input_stream_indexThe input stream index for the teletext stream.

Definition at line 18 of file segment_coordinator.cc.

◆ Process()

Status shaka::media::SegmentCoordinator::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 30 of file segment_coordinator.cc.


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