diff --git a/packager/media/base/media_handler.h b/packager/media/base/media_handler.h index dbcf43dd01..0664c145f7 100644 --- a/packager/media/base/media_handler.h +++ b/packager/media/base/media_handler.h @@ -26,6 +26,7 @@ enum class StreamDataType { kTextSample, kSegmentInfo, kScte35Event, + kCueEvent, }; // Scte35Event represents cuepoint markers in input streams. It will be used @@ -39,6 +40,16 @@ struct Scte35Event { std::string cue_data; }; +enum class CueEventType { kCueIn, kCueOut, kCuePoint }; + +// In server-based model, Chunking Handler consolidates SCTE-35 events and +// generates CueEvent before an ad is about to be inserted. +struct CueEvent { + int64_t timestamp = 0; + CueEventType type = CueEventType::kCuePoint; + std::string cue_data; +}; + struct SegmentInfo { bool is_subsegment = false; bool is_encrypted = false; @@ -60,6 +71,7 @@ struct StreamData { std::shared_ptr text_sample; std::shared_ptr segment_info; std::shared_ptr scte35_event; + std::shared_ptr cue_event; static std::unique_ptr FromStreamInfo( size_t stream_index, std::shared_ptr stream_info) { @@ -106,6 +118,16 @@ struct StreamData { stream_data->scte35_event = std::move(scte35_event); return stream_data; } + + static std::unique_ptr FromCueEvent( + size_t stream_index, + std::shared_ptr cue_event) { + std::unique_ptr stream_data(new StreamData); + stream_data->stream_index = stream_index; + stream_data->stream_data_type = StreamDataType::kCueEvent; + stream_data->cue_event = std::move(cue_event); + return stream_data; + } }; /// MediaHandler is the base media processing unit. Media handlers transform @@ -196,6 +218,12 @@ class MediaHandler { return Dispatch(StreamData::FromScte35Event(stream_index, scte35_event)); } + /// Dispatch the cue event to downstream handlers. + Status DispatchCueEvent(size_t stream_index, + std::shared_ptr cue_event) { + return Dispatch(StreamData::FromCueEvent(stream_index, cue_event)); + } + /// Flush the downstream connected at the specified output stream index. Status FlushDownstream(size_t output_stream_index);