From 8c877379b6dc9583bfe719f8053ac4b3889b20cd Mon Sep 17 00:00:00 2001 From: Kamesh Devarakonda Date: Mon, 13 Nov 2017 13:08:44 -0500 Subject: [PATCH] Defined Scte35Event struct and out of band cue marker flags Change-Id: I5a4db1a691544cbedf2ccfbaf6f71169a8eed6e7 --- packager/app/ad_cue_generator_flags.cc | 19 ++++++++++++ packager/app/ad_cue_generator_flags.h | 14 +++++++++ packager/media/base/media_handler.h | 29 ++++++++++++++++++ .../media/public/ad_cue_generator_params.h | 30 +++++++++++++++++++ packager/packager.gyp | 2 ++ 5 files changed, 94 insertions(+) create mode 100644 packager/app/ad_cue_generator_flags.cc create mode 100644 packager/app/ad_cue_generator_flags.h create mode 100644 packager/media/public/ad_cue_generator_params.h diff --git a/packager/app/ad_cue_generator_flags.cc b/packager/app/ad_cue_generator_flags.cc new file mode 100644 index 0000000000..d86e3eb788 --- /dev/null +++ b/packager/app/ad_cue_generator_flags.cc @@ -0,0 +1,19 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd +// +// Defines cuepoint generator flags. + +#include "packager/app/ad_cue_generator_flags.h" + +DEFINE_string(ad_cues, + "", + "List of cuepoint markers." + "This flag accepts semicolon separated pairs and components in " + "the pair are separated by a comma and the second component " + "duration is optional. For example --ad_cues " + "{start_time}[,{duration}][;{start_time}[,{duration}]]..." + "The start_time represents the start of the cue marker in " + "seconds relative to the start of the program."); diff --git a/packager/app/ad_cue_generator_flags.h b/packager/app/ad_cue_generator_flags.h new file mode 100644 index 0000000000..db3f9f54ed --- /dev/null +++ b/packager/app/ad_cue_generator_flags.h @@ -0,0 +1,14 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef PACKAGER_APP_AD_CUE_GENERATOR_FLAGS_H_ +#define PACKAGER_APP_AD_CUE_GENERATOR_FLAGS_H_ + +#include + +DECLARE_string(ad_cues); + +#endif // PACKAGER_APP_AD_CUE_GENERATOR_FLAGS_H_ diff --git a/packager/media/base/media_handler.h b/packager/media/base/media_handler.h index 0074dbc6b8..dbcf43dd01 100644 --- a/packager/media/base/media_handler.h +++ b/packager/media/base/media_handler.h @@ -25,6 +25,18 @@ enum class StreamDataType { kMediaSample, kTextSample, kSegmentInfo, + kScte35Event, +}; + +// Scte35Event represents cuepoint markers in input streams. It will be used +// to represent out of band cuepoint markers too. +struct Scte35Event { + std::string id; + // Segmentation type id from SCTE35 segmentation descriptor. + int type = 0; + int64_t start_time = 0; + int64_t duration = 0; + std::string cue_data; }; struct SegmentInfo { @@ -47,6 +59,7 @@ struct StreamData { std::shared_ptr media_sample; std::shared_ptr text_sample; std::shared_ptr segment_info; + std::shared_ptr scte35_event; static std::unique_ptr FromStreamInfo( size_t stream_index, std::shared_ptr stream_info) { @@ -83,6 +96,16 @@ struct StreamData { stream_data->segment_info = std::move(segment_info); return stream_data; } + + static std::unique_ptr FromScte35Event( + size_t stream_index, + std::shared_ptr scte35_event) { + std::unique_ptr stream_data(new StreamData); + stream_data->stream_index = stream_index; + stream_data->stream_data_type = StreamDataType::kScte35Event; + stream_data->scte35_event = std::move(scte35_event); + return stream_data; + } }; /// MediaHandler is the base media processing unit. Media handlers transform @@ -167,6 +190,12 @@ class MediaHandler { return Dispatch(StreamData::FromSegmentInfo(stream_index, segment_info)); } + /// Dispatch the scte35 event to downstream handlers. + Status DispatchScte35Event(size_t stream_index, + std::shared_ptr scte35_event) { + return Dispatch(StreamData::FromScte35Event(stream_index, scte35_event)); + } + /// Flush the downstream connected at the specified output stream index. Status FlushDownstream(size_t output_stream_index); diff --git a/packager/media/public/ad_cue_generator_params.h b/packager/media/public/ad_cue_generator_params.h new file mode 100644 index 0000000000..ce5ba66bea --- /dev/null +++ b/packager/media/public/ad_cue_generator_params.h @@ -0,0 +1,30 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_ +#define PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_ + +#include + +namespace shaka { + +struct Cuepoint { + /// Start time of the cuepoint relative to start of the stream. + double start_time_in_seconds = 0; + + /// Duration of the ad. + double duration_in_seconds = 0; +}; + +/// Cuepoint generator related parameters. +struct AdCueGeneratorParams { + /// List of cuepoints. + std::vector cue_points; +}; + +} // namespace shaka + +#endif // PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_ diff --git a/packager/packager.gyp b/packager/packager.gyp index 8e830b7806..ff7ba094fa 100644 --- a/packager/packager.gyp +++ b/packager/packager.gyp @@ -55,6 +55,8 @@ 'target_name': 'packager', 'type': 'executable', 'sources': [ + 'app/ad_cue_generator_flags.cc', + 'app/ad_cue_generator_flags.h', 'app/crypto_flags.cc', 'app/crypto_flags.h', 'app/gflags_hex_bytes.cc',