7 #include "packager/media/formats/webvtt/text_padder.h" 11 #include "packager/status_macros.h" 16 const uint64_t kStreamIndex = 0;
21 Status TextPadder::InitializeInternal() {
25 Status TextPadder::Process(std::unique_ptr<StreamData> data) {
26 DCHECK_EQ(data->stream_index, kStreamIndex);
27 const bool is_text_sample =
28 data->stream_data_type == StreamDataType::kTextSample;
29 return is_text_sample ? OnTextSample(std::move(data))
33 Status TextPadder::OnFlushRequest(
size_t index) {
34 if (duration_ms_ > max_end_time_ms_) {
35 std::shared_ptr<TextSample> filler = std::make_shared<TextSample>();
36 filler->SetTime(max_end_time_ms_, duration_ms_);
44 Status TextPadder::OnTextSample(std::unique_ptr<StreamData> data) {
50 if (sample.start_time() > max_end_time_ms_) {
51 std::shared_ptr<TextSample> filler = std::make_shared<TextSample>();
52 filler->SetTime(max_end_time_ms_, sample.start_time());
57 max_end_time_ms_ = std::max(max_end_time_ms_, sample.EndTime());
All the methods that are virtual are virtual for mocking.
TextPadder(int64_t duration_ms)
Create a new text padder that will ensure the stream's duration is.