Dispatch Scte35Events.
This patch also fixes a bug which was introduced in https://widevine-internal-review.googlesource.com/c/packager/+/38040 where it was inconsistently assumed that AdCueGenerator would be MIMO while connecting with other handlers and at the same time it was assumed SISO in the AdCueGenerator class. Now we assume SISO everywhere. Change-Id: Icd8c40b5ccfe0d98f47f09a60ea1635f74dceef9
This commit is contained in:
parent
75e1fc3175
commit
e7540bf303
|
@ -23,19 +23,42 @@ AdCueGenerator::AdCueGenerator(
|
||||||
AdCueGenerator::~AdCueGenerator() {}
|
AdCueGenerator::~AdCueGenerator() {}
|
||||||
|
|
||||||
Status AdCueGenerator::InitializeInternal() {
|
Status AdCueGenerator::InitializeInternal() {
|
||||||
|
if (num_input_streams() != 1 || next_output_stream_index() != 1) {
|
||||||
|
return Status(error::INVALID_ARGUMENT,
|
||||||
|
"Expects exactly one input and one output.");
|
||||||
|
}
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status AdCueGenerator::Process(std::unique_ptr<StreamData> stream_data) {
|
Status AdCueGenerator::Process(std::unique_ptr<StreamData> stream_data) {
|
||||||
switch (stream_data->stream_data_type) {
|
switch (stream_data->stream_data_type) {
|
||||||
case StreamDataType::kStreamInfo:
|
case StreamDataType::kStreamInfo: {
|
||||||
// TODO(kdevarakonda): dispatch scte35 events.
|
const uint32_t time_scale = stream_data->stream_info->time_scale();
|
||||||
return DispatchStreamInfo(kStreamIndex,
|
Status status = Dispatch(std::move(stream_data));
|
||||||
std::move(stream_data->stream_info));
|
if (!status.ok()) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
return DispatchScte35Events(kStreamIndex, time_scale);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return Dispatch(std::move(stream_data));
|
return Dispatch(std::move(stream_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status AdCueGenerator::DispatchScte35Events(size_t stream_index,
|
||||||
|
uint32_t time_scale) {
|
||||||
|
Status status;
|
||||||
|
for (const auto& cue_point : ad_cue_generator_params_.cue_points) {
|
||||||
|
std::shared_ptr<Scte35Event> scte35_event = std::make_shared<Scte35Event>();
|
||||||
|
scte35_event->start_time = cue_point.start_time_in_seconds * time_scale;
|
||||||
|
scte35_event->duration = cue_point.duration_in_seconds * time_scale;
|
||||||
|
status.Update(DispatchScte35Event(stream_index, std::move(scte35_event)));
|
||||||
|
if (!status.ok()) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status::OK;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace media
|
} // namespace media
|
||||||
} // namespace shaka
|
} // namespace shaka
|
||||||
|
|
|
@ -26,6 +26,9 @@ class AdCueGenerator : public MediaHandler {
|
||||||
Status InitializeInternal() override;
|
Status InitializeInternal() override;
|
||||||
Status Process(std::unique_ptr<StreamData> stream_data) override;
|
Status Process(std::unique_ptr<StreamData> stream_data) override;
|
||||||
|
|
||||||
|
// Dispatches SCTE35 events that are built from AdCueGenerator params.
|
||||||
|
Status DispatchScte35Events(size_t stream_index, uint32_t time_scale);
|
||||||
|
|
||||||
const AdCueGeneratorParams ad_cue_generator_params_;
|
const AdCueGeneratorParams ad_cue_generator_params_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -496,8 +496,6 @@ Status CreateAudioVideoJobs(
|
||||||
|
|
||||||
// Demuxers are shared among all streams with the same input.
|
// Demuxers are shared among all streams with the same input.
|
||||||
std::shared_ptr<Demuxer> demuxer;
|
std::shared_ptr<Demuxer> demuxer;
|
||||||
// AdCueGenerator is shared among all streams.
|
|
||||||
std::shared_ptr<AdCueGenerator> ad_cue_generator;
|
|
||||||
// Replicators are shared among all streams with the same input and stream
|
// Replicators are shared among all streams with the same input and stream
|
||||||
// selector.
|
// selector.
|
||||||
std::shared_ptr<MediaHandler> replicator;
|
std::shared_ptr<MediaHandler> replicator;
|
||||||
|
@ -509,11 +507,6 @@ Status CreateAudioVideoJobs(
|
||||||
// iteration.
|
// iteration.
|
||||||
int stream_number = first_stream_number - 1;
|
int stream_number = first_stream_number - 1;
|
||||||
|
|
||||||
if (!packaging_params.ad_cue_generator_params.cue_points.empty()) {
|
|
||||||
ad_cue_generator = std::make_shared<AdCueGenerator>(
|
|
||||||
packaging_params.ad_cue_generator_params);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const StreamDescriptor& stream : streams) {
|
for (const StreamDescriptor& stream : streams) {
|
||||||
stream_number += 1;
|
stream_number += 1;
|
||||||
|
|
||||||
|
@ -554,6 +547,12 @@ Status CreateAudioVideoJobs(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_source) {
|
if (new_source) {
|
||||||
|
std::shared_ptr<MediaHandler> ad_cue_generator;
|
||||||
|
if (!packaging_params.ad_cue_generator_params.cue_points.empty()) {
|
||||||
|
ad_cue_generator = std::make_shared<AdCueGenerator>(
|
||||||
|
packaging_params.ad_cue_generator_params);
|
||||||
|
}
|
||||||
|
|
||||||
replicator = std::make_shared<Replicator>();
|
replicator = std::make_shared<Replicator>();
|
||||||
|
|
||||||
std::shared_ptr<MediaHandler> chunker =
|
std::shared_ptr<MediaHandler> chunker =
|
||||||
|
|
Loading…
Reference in New Issue