7#include <packager/media/formats/webvtt/text_readers.h>
15#include <absl/log/check.h>
20LineReader::LineReader() : should_flush_(false) {}
22void LineReader::PushData(
const uint8_t* data,
size_t data_size) {
23 buffer_.Push(data,
static_cast<int>(data_size));
24 should_flush_ =
false;
28bool LineReader::Next(std::string* out) {
35 buffer_.Peek(&data, &data_size);
36 for (i = 0; i < data_size; i++) {
38 if (data[i] ==
'\n') {
44 if (data[i] ==
'\r') {
47 if (i + 1 == data_size) {
52 if (data[i + 1] ==
'\n')
61 if (i == data_size && (!should_flush_ || i == 0)) {
66 out->assign(data, data + i);
67 buffer_.Pop(i + skip);
71void LineReader::Flush() {
75BlockReader::BlockReader() : should_flush_(false) {}
79 should_flush_ =
false;
85 bool end_block =
false;
90 while (source_.
Next(&line)) {
91 if (!temp_.empty() && line.empty()) {
96 temp_.emplace_back(std::move(line));
100 if (!end_block && (!should_flush_ || temp_.empty()))
103 *out = std::move(temp_);
109 should_flush_ =
true;
All the methods that are virtual are virtual for mocking.