Connect AdCueGenerator in the pipeline.

Change-Id: Iaae73661bc57ddecd2cc103dbd34d0c3102ffdaa
This commit is contained in:
Kamesh Devarakonda 2017-11-21 16:24:13 -05:00
parent 154e309f3f
commit c4e7d02b80
4 changed files with 42 additions and 6 deletions

View File

@ -9,11 +9,33 @@
namespace shaka { namespace shaka {
namespace media { namespace media {
namespace {
// The AdCuGenerator only supports single input and single output.
const size_t kStreamIndex = 0;
} // namespace
AdCueGenerator::AdCueGenerator( AdCueGenerator::AdCueGenerator(
const AdCueGeneratorParams& ad_cue_generator_params) const AdCueGeneratorParams& ad_cue_generator_params)
: ad_cue_generator_params_(ad_cue_generator_params) {} : ad_cue_generator_params_(ad_cue_generator_params) {}
AdCueGenerator::~AdCueGenerator() {} AdCueGenerator::~AdCueGenerator() {}
Status AdCueGenerator::InitializeInternal() {
return Status::OK;
}
Status AdCueGenerator::Process(std::unique_ptr<StreamData> stream_data) {
switch (stream_data->stream_data_type) {
case StreamDataType::kStreamInfo:
// TODO(kdevarakonda): dispatch scte35 events.
return DispatchStreamInfo(kStreamIndex,
std::move(stream_data->stream_info));
default:
return Dispatch(std::move(stream_data));
}
}
} // namespace media } // namespace media
} // namespace shaka } // namespace shaka

View File

@ -23,6 +23,9 @@ class AdCueGenerator : public MediaHandler {
AdCueGenerator(const AdCueGenerator&) = delete; AdCueGenerator(const AdCueGenerator&) = delete;
AdCueGenerator& operator=(const AdCueGenerator&) = delete; AdCueGenerator& operator=(const AdCueGenerator&) = delete;
Status InitializeInternal() override;
Status Process(std::unique_ptr<StreamData> stream_data) override;
const AdCueGeneratorParams ad_cue_generator_params_; const AdCueGeneratorParams ad_cue_generator_params_;
}; };

View File

@ -21,6 +21,7 @@
#include "packager/file/file.h" #include "packager/file/file.h"
#include "packager/hls/base/hls_notifier.h" #include "packager/hls/base/hls_notifier.h"
#include "packager/hls/base/simple_hls_notifier.h" #include "packager/hls/base/simple_hls_notifier.h"
#include "packager/media/ad_cue_generator/ad_cue_generator.h"
#include "packager/media/base/container_names.h" #include "packager/media/base/container_names.h"
#include "packager/media/base/fourccs.h" #include "packager/media/base/fourccs.h"
#include "packager/media/base/key_source.h" #include "packager/media/base/key_source.h"
@ -495,6 +496,8 @@ 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;
@ -506,6 +509,11 @@ 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;
@ -555,16 +563,17 @@ Status CreateAudioVideoJobs(
packaging_params, stream, encryption_key_source); packaging_params, stream, encryption_key_source);
Status status; Status status;
if (ad_cue_generator) {
// The path is different if there is encryption. Even though there are status.Update(
// common elements, it is easier to understand the path if they are demuxer->SetHandler(stream.stream_selector, ad_cue_generator));
// expressed independently of each other. status.Update(ad_cue_generator->AddHandler(chunker));
if (encryptor) { } else {
status.Update(demuxer->SetHandler(stream.stream_selector, chunker)); status.Update(demuxer->SetHandler(stream.stream_selector, chunker));
}
if (encryptor) {
status.Update(chunker->AddHandler(encryptor)); status.Update(chunker->AddHandler(encryptor));
status.Update(encryptor->AddHandler(replicator)); status.Update(encryptor->AddHandler(replicator));
} else { } else {
status.Update(demuxer->SetHandler(stream.stream_selector, chunker));
status.Update(chunker->AddHandler(replicator)); status.Update(chunker->AddHandler(replicator));
} }

View File

@ -24,8 +24,10 @@
'dependencies': [ 'dependencies': [
'file/file.gyp:file', 'file/file.gyp:file',
'hls/hls.gyp:hls_builder', 'hls/hls.gyp:hls_builder',
'media/ad_cue_generator/ad_cue_generator.gyp:ad_cue_generator',
'media/chunking/chunking.gyp:chunking', 'media/chunking/chunking.gyp:chunking',
'media/codecs/codecs.gyp:codecs', 'media/codecs/codecs.gyp:codecs',
'media/crypto/crypto.gyp:crypto',
'media/demuxer/demuxer.gyp:demuxer', 'media/demuxer/demuxer.gyp:demuxer',
'media/event/media_event.gyp:media_event', 'media/event/media_event.gyp:media_event',
'media/formats/mp2t/mp2t.gyp:mp2t', 'media/formats/mp2t/mp2t.gyp:mp2t',