From 7dd1574b04a7410f1899981dcef1595e678a30c2 Mon Sep 17 00:00:00 2001 From: Aaron Vaage Date: Thu, 29 Mar 2018 10:32:13 -0700 Subject: [PATCH] Add Cue Alignment For Segmented Text Added the cue alignment handler to the segmented text pipeline. Issue: #362 Change-Id: If105e5310fa82d433c84692b967a93c1cdf148b0 --- packager/packager.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packager/packager.cc b/packager/packager.cc index 674ab50982..ea1ff76a44 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -48,6 +48,7 @@ #include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/mpd_builder.h" #include "packager/mpd/base/simple_mpd_notifier.h" +#include "packager/status_macros.h" #include "packager/version/version.h" namespace shaka { @@ -425,8 +426,6 @@ Status CreateHlsTextJob(const StreamDescriptor& stream, std::unique_ptr muxer_listener, SyncPointQueue* sync_points, JobManager* job_manager) { - // TODO(kqyang): Support Cue Alignment if |sync_points| is not null. - DCHECK(muxer_listener); DCHECK(job_manager); @@ -451,24 +450,25 @@ Status CreateHlsTextJob(const StreamDescriptor& stream, muxer_options, std::move(muxer_listener)); std::unique_ptr reader; - Status open_status = FileReader::Open(stream.input, &reader); - if (!open_status.ok()) { - return open_status; - } + RETURN_IF_ERROR(FileReader::Open(stream.input, &reader)); auto parser = std::make_shared(std::move(reader), stream.language); - auto segmenter = std::make_shared(segment_length_in_ms); + auto chunker = std::make_shared(segment_length_in_ms); // Build in reverse to allow us to move the pointers. - Status status; - status.Update(segmenter->AddHandler(std::move(output))); - status.Update(parser->AddHandler(std::move(segmenter))); - if (!status.ok()) { - return status; + if (sync_points) { + auto cue_aligner = std::make_shared(sync_points); + RETURN_IF_ERROR(chunker->AddHandler(std::move(output))); + RETURN_IF_ERROR(cue_aligner->AddHandler(std::move(chunker))); + RETURN_IF_ERROR(parser->AddHandler(std::move(cue_aligner))); + } else { + RETURN_IF_ERROR(chunker->AddHandler(std::move(output))); + RETURN_IF_ERROR(parser->AddHandler(std::move(chunker))); } job_manager->Add("Segmented Text Job", std::move(parser)); + return Status::OK; }