Add Cue Alignment For Segmented Text
Added the cue alignment handler to the segmented text pipeline. Issue: #362 Change-Id: If105e5310fa82d433c84692b967a93c1cdf148b0
This commit is contained in:
parent
a11cbf93a7
commit
7dd1574b04
|
@ -48,6 +48,7 @@
|
||||||
#include "packager/mpd/base/media_info.pb.h"
|
#include "packager/mpd/base/media_info.pb.h"
|
||||||
#include "packager/mpd/base/mpd_builder.h"
|
#include "packager/mpd/base/mpd_builder.h"
|
||||||
#include "packager/mpd/base/simple_mpd_notifier.h"
|
#include "packager/mpd/base/simple_mpd_notifier.h"
|
||||||
|
#include "packager/status_macros.h"
|
||||||
#include "packager/version/version.h"
|
#include "packager/version/version.h"
|
||||||
|
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
|
@ -425,8 +426,6 @@ Status CreateHlsTextJob(const StreamDescriptor& stream,
|
||||||
std::unique_ptr<MuxerListener> muxer_listener,
|
std::unique_ptr<MuxerListener> muxer_listener,
|
||||||
SyncPointQueue* sync_points,
|
SyncPointQueue* sync_points,
|
||||||
JobManager* job_manager) {
|
JobManager* job_manager) {
|
||||||
// TODO(kqyang): Support Cue Alignment if |sync_points| is not null.
|
|
||||||
|
|
||||||
DCHECK(muxer_listener);
|
DCHECK(muxer_listener);
|
||||||
DCHECK(job_manager);
|
DCHECK(job_manager);
|
||||||
|
|
||||||
|
@ -451,24 +450,25 @@ Status CreateHlsTextJob(const StreamDescriptor& stream,
|
||||||
muxer_options, std::move(muxer_listener));
|
muxer_options, std::move(muxer_listener));
|
||||||
|
|
||||||
std::unique_ptr<FileReader> reader;
|
std::unique_ptr<FileReader> reader;
|
||||||
Status open_status = FileReader::Open(stream.input, &reader);
|
RETURN_IF_ERROR(FileReader::Open(stream.input, &reader));
|
||||||
if (!open_status.ok()) {
|
|
||||||
return open_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto parser =
|
auto parser =
|
||||||
std::make_shared<WebVttParser>(std::move(reader), stream.language);
|
std::make_shared<WebVttParser>(std::move(reader), stream.language);
|
||||||
auto segmenter = std::make_shared<TextChunker>(segment_length_in_ms);
|
auto chunker = std::make_shared<TextChunker>(segment_length_in_ms);
|
||||||
|
|
||||||
// Build in reverse to allow us to move the pointers.
|
// Build in reverse to allow us to move the pointers.
|
||||||
Status status;
|
if (sync_points) {
|
||||||
status.Update(segmenter->AddHandler(std::move(output)));
|
auto cue_aligner = std::make_shared<CueAlignmentHandler>(sync_points);
|
||||||
status.Update(parser->AddHandler(std::move(segmenter)));
|
RETURN_IF_ERROR(chunker->AddHandler(std::move(output)));
|
||||||
if (!status.ok()) {
|
RETURN_IF_ERROR(cue_aligner->AddHandler(std::move(chunker)));
|
||||||
return status;
|
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));
|
job_manager->Add("Segmented Text Job", std::move(parser));
|
||||||
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue