Skip to content

Commit

Permalink
Defined CueEvent struct.
Browse files Browse the repository at this point in the history
Change-Id: If4ba55a7ff403248de9d0411c2ba8553b88c491b
  • Loading branch information
KameshDevarakonda committed Nov 28, 2017
1 parent c4e7d02 commit cc778f6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packager/media/base/media_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum class StreamDataType {
kTextSample,
kSegmentInfo,
kScte35Event,
kCueEvent,
};

// Scte35Event represents cuepoint markers in input streams. It will be used
Expand All @@ -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;
Expand All @@ -60,6 +71,7 @@ struct StreamData {
std::shared_ptr<const TextSample> text_sample;
std::shared_ptr<const SegmentInfo> segment_info;
std::shared_ptr<const Scte35Event> scte35_event;
std::shared_ptr<const CueEvent> cue_event;

static std::unique_ptr<StreamData> FromStreamInfo(
size_t stream_index, std::shared_ptr<const StreamInfo> stream_info) {
Expand Down Expand Up @@ -106,6 +118,16 @@ struct StreamData {
stream_data->scte35_event = std::move(scte35_event);
return stream_data;
}

static std::unique_ptr<StreamData> FromCueEvent(
size_t stream_index,
std::shared_ptr<const CueEvent> cue_event) {
std::unique_ptr<StreamData> 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
Expand Down Expand Up @@ -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<const CueEvent> 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);

Expand Down

0 comments on commit cc778f6

Please sign in to comment.